newer, nicer
[platform/upstream/curl.git] / maketgz
1 #! /bin/sh
2 # Script to build release-archives with
3 #
4
5 version=$1
6
7 if [ -z "$version" ]; then
8   echo "Specify a version number!"
9   exit
10 fi
11
12 libversion="$version"
13
14 #
15 # Now we have a section to get the major, minor and patch number from the
16 # full version string. We create a single hexadecimal number from it '0xMMmmpp'
17 #
18 perl='$a=<STDIN>;@p=split("[\\.-]",$a);for(0..2){printf STDOUT ("%02x",$p[0+$_]);}';
19
20 numeric=`echo $libversion | perl -e "$perl"`
21
22 # we make curl the same version as libcurl
23 curlversion=$libversion
24
25 HEADER=include/curl/curl.h
26 CHEADER=src/version.h
27
28 # Replace version number in header file:
29 sed -e 's/^#define LIBCURL_VERSION .*/#define LIBCURL_VERSION "'$libversion'"/g' \
30     -e 's/^#define LIBCURL_VERSION_NUM .*/#define LIBCURL_VERSION_NUM 0x'$numeric'/g' \
31  $HEADER >$HEADER.dist
32
33 # Replace version number in header file:
34 sed 's/#define CURL_VERSION.*/#define CURL_VERSION "'$curlversion'"/g' $CHEADER >$CHEADER.dist
35
36 echo "curl version $curlversion"
37 echo "libcurl version $libversion"
38 echo "libcurl numerical $numeric"
39
40 findprog()
41 {
42   file="$1"
43   for part in `echo $PATH| tr ':' ' '`; do
44     path="$part/$file"
45     if [ -x "$path" ]; then
46       # there it is!
47       return 1
48     fi
49   done
50
51   # no such executable
52   return 0
53 }
54
55 ############################################################################
56 #
57 # Enforce a rerun of configure (updates the VERSION)
58 #
59
60 echo "Re-running config.status"
61 ./config.status --recheck >/dev/null
62
63 ############################################################################
64 #
65 # automake is needed to run to make a non-GNU Makefile.in if Makefile.am has
66 # been modified.
67 #
68
69 if { findprog automake >/dev/null 2>/dev/null; } then
70   echo "- Could not find or run automake, I hope you know what you're doing!"
71 else
72   echo "Runs automake --include-deps"
73   automake --include-deps Makefile >/dev/null
74 fi
75
76 ############################################################################
77 #
78 # Make sure we have updated HTML versions of all man pages:
79 #
80 make -s html
81
82 # And the PDF versions
83 make -s pdf
84
85 ############################################################################
86 #
87 # Now run make dist to generate a tar.gz archive
88 #
89
90 targz="curl-$version.tar.gz"
91 make -s dist VERSION=$version
92
93 ############################################################################
94 #
95 # Now make a bz2 archive from the tar.gz original
96 #
97
98 bzip2="curl-$version.tar.bz2"
99 echo "Generating $bzip2"
100 gzip -dc $targz | bzip2 - > $bzip2
101
102 ############################################################################
103 #
104 # Now make a zip archive from the tar.gz original
105 #
106 makezip ()
107 {
108   rm -rf $tempdir
109   mkdir $tempdir
110   cd $tempdir
111   gzip -dc ../$targz | tar -xf -
112   find . | zip $zip -@ >/dev/null
113   mv $zip ../
114   cd ..
115   rm -rf $tempdir
116 }
117
118 zip="curl-$version.zip"
119 echo "Generating $zip"
120 tempdir=".builddir"
121 makezip
122
123 echo "------------------"
124 echo "maketgz report:"
125 echo ""
126 ls -l $targz $bzip2 $zip
127
128 md5sum $targz $bzip2 $zip
129
130 echo "Run these commands:"
131 echo "gpg -b -a $targz"
132 echo "gpg -b -a $bzip2"
133 echo "gpg -b -a $zip"