Avoid releasing intermediate files in the doc bundle
[platform/upstream/nasm.git] / misc / release
1 #!/bin/bash -xe
2 #
3 # Generate a NASM release
4 #
5 # Usage: release {test|real} [branch]
6 #
7
8 if [ -z "$SFUSER" ]; then
9   if [ -f "$HOME/.sfuser" ]; then
10     sfuser=`cat "$HOME/.sfuser"`
11   else
12     sfuser=`whoami`
13   fi
14 fi
15
16 if [ -z "$1" ]; then
17   echo "Usage: $0 {test|real}" 1>&2
18   exit 1
19 fi
20
21 if [ "$1" = "real" ]; then
22   real=true
23 else
24   real=false
25 fi
26
27 rm -rf nasm-release.*
28 work=`pwd`/nasm-release.$$
29 mkdir "$work"
30 cd "$work"
31
32 if $real; then
33   # Need to tag the tree, use real account
34   CVS="cvs -z3 -d ${sfuser}@cvs.nasm.sourceforge.net:/cvsroot/nasm"
35 else
36   # Don't need to tag the tree, can use anonymous
37   echo ':pserver:anonymous@cvs.nasm.sourceforge.net:/cvsroot/nasm A' > "$work"/cvspass
38   export CVS_PASSFILE="$work"/cvspass
39   CVS="cvs -z3 -d :pserver:anonymous@cvs.nasm.sourceforge.net:/cvsroot/nasm"
40 fi
41
42 if [ -n "$2" ]; then
43   branchopt="-r $2"
44 fi
45
46 $CVS co $branchopt nasm
47 version=`cat nasm/version`
48 v1=`echo $version | cut -d. -f1`
49 v2=`echo $version | cut -d. -f2`
50 v3=`echo $version | cut -d. -f3`
51
52 # Tag the tree as a release
53 if $real; then
54   cvstag=nasm-`echo $version | sed -e 's/\./_/g'`
55   # Create the tag for this release
56   ( cd nasm && $CVS tag -F $cvstag )
57   # Update the LATEST tag
58   $CVS rtag -r $cvstag -F -a LATEST nasm
59 fi
60
61 # Extract file names which have the -kb flag set, meaning they
62 # are binary files
63 bins="$work"/binaries
64 rm -f "$bins"
65 cd nasm
66 find . -type d -name CVS -print | (
67     while read dir; do
68        xdir=`echo "$dir" | sed -e 's|^\./||' -e 's|/CVS$||'`
69        egrep '^/[^/]*/[^/]*/[^/]*/[^/]*-kb[^/]*/' < $dir/Entries | \
70            cut -d/ -f2 | sed -e "s|^|$xdir/|" >> "$bins"
71     done
72 )
73 cd ..
74
75 # We did "co" instead of "export" -- remove CVS directories
76 find nasm -type d -name CVS -print | xargs rm -rf
77
78 # Create files which are in the release but automatically generated
79 cd nasm
80 autoconf
81 ./configure --prefix=/usr/local
82 make dist
83 cd ..
84
85 # Clean up any previous attempt
86 rm -f ../nasm-${version}.tar.gz  ../nasm-${version}-xdoc.tar.gz
87 rm -f ../nasm-${version}.tar.bz2 ../nasm-${version}-xdoc.tar.bz2
88 rm -f ../nasm-${version}.zip     ../nasm-${version}-xdoc.zip
89
90 # Create tarfile (Unix convention: file includes prefix)
91 mv nasm nasm-$version
92 tar cvvf  nasm-${version}.tar nasm-${version}
93 bzip2 -9k nasm-${version}.tar
94 gzip -9   nasm-${version}.tar
95 mv nasm-${version}.tar.gz nasm-${version}.tar.bz2 ..
96
97 # Create zipfile (DOS convention: no prefix, convert file endings)
98 cd nasm-$version
99 zip -9Dlr ../../nasm-${version}.zip -x@"$bins" *        # Text files
100 zip -9Dgr ../../nasm-${version}.zip -i@"$bins" *        # Binary files
101 cd ..
102
103 # Record what we have already generated
104 find nasm-$version -not -type d -print > main
105
106 # Create documentation
107 cd nasm-${version}
108 ./configure --prefix=/usr/local
109 make doc
110 # Remove intermediate files.
111 make clean
112 cd ..
113
114 # Remove non-documentation
115 cat main | xargs rm -f
116
117 # Create doc tarfile
118 tar cvvf nasm-${version}-xdoc.tar nasm-${version}/doc
119 bzip2 -9k nasm-${version}-xdoc.tar
120 gzip -9   nasm-${version}-xdoc.tar
121 mv nasm-${version}-xdoc.tar.gz nasm-${version}-xdoc.tar.bz2 ..
122
123 # Create doc zipfile (DOS convention: no prefix, convert file endings)
124 # (Note: generating Win .hlp files requires additional tools)
125 cd nasm-${version}
126 zip -9Dlr ../../nasm-${version}-xdoc.zip doc -x \*.pdf
127 zip -9Dgr ../../nasm-${version}-xdoc.zip doc -i \*.pdf
128
129 # Clean up
130 cd ..
131 rm -rf "$work"