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