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