Move cleanup before work directory creation
[nasm/avx512.git] / misc / release
blob0df1e5a658963d2dc361ab471357215ec83842ee
1 #!/bin/bash -xe
3 # Generate a NASM release
5 # Usage: release {test|real} [branch]
8 if [ -z "$SFUSER" ]; then
9 if [ -f "$HOME/.sfuser" ]; then
10 sfuser=`cat "$HOME/.sfuser"`
11 else
12 sfuser=`whoami`
16 if [ -z "$1" ]; then
17 echo "Usage: $0 {test|real}" 1>&2
18 exit 1
21 if [ "$1" = "real" ]; then
22 real=true
23 else
24 real=false
27 rm -rf nasm-release.*
28 work=`pwd`/nasm-release.$$
29 mkdir "$work"
30 cd "$work"
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"
42 if [ -n "$2" ]; then
43 branchopt="-r $2"
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`
52 # Tag the tree as a release
53 if $real; then
54 cd nasm && $CVS tag -F nasm-`echo $version | sed -e 's/\./_/g'` && cd ..
57 # Extract file names which have the -kb flag set, meaning they
58 # are binary files
59 bins="$work"/binaries
60 rm -f "$bins"
61 cd nasm
62 find . -type d -name CVS -print | (
63 while read dir; do
64 xdir=`echo "$dir" | sed -e 's|^\./||' -e 's|/CVS$||'`
65 egrep '^/[^/]*/[^/]*/[^/]*/[^/]*-kb[^/]*/' < $dir/Entries | \
66 cut -d/ -f2 | sed -e "s|^|$xdir/|" >> "$bins"
67 done
69 cd ..
71 # We did "co" instead of "export" -- remove CVS directories
72 find nasm -type d -name CVS -print | xargs rm -rf
74 # Create files which are in the release but automatically generated
75 cd nasm
76 autoconf
77 ./configure --prefix=/usr/local
78 make dist
79 cd ..
81 # Clean up any previous attempt
82 rm -f ../nasm-${version}.tar.gz ../nasm-${version}-xdoc.tar.gz
83 rm -f ../nasm-${version}.tar.bz2 ../nasm-${version}-xdoc.tar.bz2
84 rm -f ../nasm-${version}.zip ../nasm-${version}-xdoc.zip
86 # Create tarfile (Unix convention: file includes prefix)
87 mv nasm nasm-$version
88 tar cvvf nasm-${version}.tar nasm-${version}
89 bzip2 -9k nasm-${version}.tar
90 gzip -9 nasm-${version}.tar
91 mv nasm-${version}.tar.gz nasm-${version}.tar.bz2 ..
93 # Create zipfile (DOS convention: no prefix, convert file endings)
94 cd nasm-$version
95 zip -9Dlr ../../nasm-${version}.zip -x@"$bins" * # Text files
96 zip -9Dgr ../../nasm-${version}.zip -i@"$bins" * # Binary files
97 cd ..
99 # Record what we have already generated
100 find nasm-$version -not -type d -print > main
102 # Create documentation
103 cd nasm-${version}
104 ./configure --prefix=/usr/local
105 make doc
106 # The .hpj and .rtf files are used to generate a Windows .hlp file.
107 # That requires Windows tools, so that has to be done separately anyway.
108 rm -f doc/nasmdoc.hpj doc/nasmdoc.rtf
109 cd ..
111 # Remove non-documentation
112 cat main | xargs rm -f
114 # Create doc tarfile
115 tar cvvf nasm-${version}-xdoc.tar nasm-${version}/doc
116 bzip2 -9k nasm-${version}-xdoc.tar
117 gzip -9 nasm-${version}-xdoc.tar
118 mv nasm-${version}-xdoc.tar.gz nasm-${version}-xdoc.tar.bz2 ..
120 # Create doc zipfile (DOS convention: no prefix, convert file endings)
121 # (Note: generating Win .hlp files requires additional tools)
122 cd nasm-${version}
123 zip -9Dlr ../../nasm-${version}-xdoc.zip doc -x \*.pdf
124 zip -9Dgr ../../nasm-${version}-xdoc.zip doc -i \*.pdf
126 # Clean up
127 cd ..
128 rm -rf "$work"