#!/bin/bash -xe here=/home/nasmbuild/work patchdir=/home/nasmbuild/patches snapdir=/pub/nasm/snapshots reldir=/pub/nasm/releasebuilds excludedir=/home/nasmbuild/exclude repo=/pub/git/nasm/nasm.git tagrepo=/pub/git/nasm/nasm-daily.git web=/home/www/nasm DOS4GW=/usr/share/openwatcom/binw/dos4gw.exe CWSDPMI=/home/nasmbuild/cwsdpmi READMES=/home/nasmbuild/readmes export PATH=/home/nasmbuild/bin:/bin:/usr/bin:/usr/local/bin:/opt/watcom/bin cd $here if [ `whoami` != nasmbuild ]; then echo "$0: run me as nasmbuild, please" 1>&2 exit 1 fi build () { version="$1" outdir="$2" gitdir="$3" rev="$4" cpus=$(grep '^processor' < /proc/cpuinfo | wc -l) jobs=$((cpus+2)) makej="make -j$jobs" rm -rf nasm-* win32 dos macosx os2 rpmbuild doc html mkdir -p rpmbuild/{BUILD,RPMS,SRPMS,SPECS,SOURCES} # --- Generate tarballs --- ( cd "$gitdir" if [ -d "$patchdir"/"$version" ]; then for p in "$patchdir"/"$version"/*; do git am "$p" done fi ./misc/release $version $here ) # --- Generate Linux RPMs --- do32 rpmbuild --target i386 -ta nasm-$version.tar.bz2 rpmbuild --target x86_64 -ta nasm-$version.tar.bz2 # --- Expand tarballs (generate combined src+doc working tree) --- tar xfj nasm-$version-xdoc.tar.bz2 cp -a nasm-$version/doc . tar xfj nasm-$version.tar.bz2 # --- Generate Win32 binaries --- mkdir -p win32 cp -a nasm-$version win32 cd win32/nasm-$version LDFLAGS='-s' ./configure --host=i686-pc-mingw32 $makej cd .. zip -9Dl ../nasm-$version-win32.zip nasm-$version/LICENSE zip -9Drg ../nasm-$version-win32.zip nasm-$version -i \*.exe cd nasm-$version makensis nasm.nsi mv nasm-$version-installer.exe ../.. cd ../.. # --- Generate DOS binaries --- mkdir -p dos cp -a nasm-$version dos cd dos/nasm-$version LDFLAGS='-s' ./configure --host=i586-pc-msdosdjgpp $makej mv doc/nasmdoc.txt . cp $READMES/dos README cp $CWSDPMI/bin/cwsdpmi.{exe,doc} . cd .. zip -9Dl ../nasm-$version-dos.zip nasm-$version/{LICENSE,README,nasmdoc.txt,cwsdpmi.doc} zip -9Drg ../nasm-$version-dos.zip nasm-$version -i \*.exe find nasm-$version -name \*.exe -a -not -name cwsdpmi.exe -type f -print0 | \ xargs -0r time upx -q --lzma --best --all-filters zip -9Dl ../nasm-$version-dos-upx.zip nasm-$version/{LICENSE,README,nasmdoc.txt,cwsdpmi.doc} zip -9Drg ../nasm-$version-dos-upx.zip nasm-$version -i \*.exe cd .. # --- Generate MacOS X binaries --- mkdir -p macosx/nasm-$version cp -a nasm-$version macosx/nasm-$version.work cd macosx/nasm-$version.work CC='darwinx-gcc' LDFLAGS='-s' ./configure --host=i686-apple-darwin9 $makej CC='darwinx-gcc -arch i386 -arch ppc' mv LICENSE README doc/nasmdoc.pdf ../nasm-$version/ make install INSTALLROOT=`pwd`/../nasm-$version bindir= mandir= make install_rdf INSTALLROOT=`pwd`/../nasm-$version bindir= mandir= cd .. zip -9Dr ../nasm-$version-macosx.zip nasm-$version cd .. # --- Generate OS/2 binaries --- mkdir -p os2 cp -a nasm-$version os2 cd os2/nasm-$version make -f Mkfiles/owlinux.mak os2 cd .. zip -9Dl ../nasm-$version-os2.zip nasm-$version/LICENSE zip -9Drg ../nasm-$version-os2.zip nasm-$version -i \*.exe cd .. # --- Clean up --- rm -rf "$gitdir" nasm-$version # --- Publish resulting output files --- mkdir -p "$outdir" echo "$rev" > "$outdir"/git.id for os in linux win32 dos macosx os2; do mkdir -p "$outdir"/"$os" done # Sources mv -f nasm-${version}.tar.* nasm-${version}.zip "$outdir" mv -f nasm-${version}-xdoc.tar.* nasm-${version}-xdoc.zip "$outdir" # Win32 mv -f nasm-${version}-win32.zip "$outdir"/win32/ mv -f nasm-${version}-installer.exe "$outdir"/win32/ # DOS mv -f nasm-${version}-dos.zip nasm-${version}-dos-upx.zip "$outdir"/dos/ # MacOS X mv -f nasm-${version}-macosx.zip "$outdir"/macosx/ # OS/2 mv -f nasm-${version}-os2.zip "$outdir"/os2/ # Linux (RPMS) find rpmbuild -name \*.rpm -exec mv -f '{}' "$outdir"/linux/ \; # Expanded docs cp -a doc "$outdir"/doc echo "$version" "$rev" >> build-ids } # This gets run for real (tagged) releases process_release () { rm -rf $web/docs/"$1" $web/xdoc/"$1" cp -al "$outdir"/doc/html $web/docs/"$1" cp -al "$outdir"/doc $web/xdoc/"$1" case "$1" in *rc*) # -rc release update_version "$1" $web/version.inc ;; *) if update_version "$1" $web/version.inc; then ( cd $web && rm -f doc && ln -s docs/"$1" doc ) fi ;; esac } rm -rf git git-rel today=$(date +%Y%m%d) git clone -s -l $repo git (cd $tagrepo && git fetch -f) > /dev/null 2>&1 HEAD=$(cd git && git rev-parse HEAD) # # Test run? # if [ x"$1" = xtest ]; then rm -rf /var/tmp/nasmtest build $(cat git/version)-test /var/tmp/nasmtest git "$HEAD" exit 0 fi # # Tagged releases... # (cd git && git tag) | while read tag; do : $tag tagref=$(cd git && git rev-parse "$tag") if [ x$(cat "$excludedir"/"$tag" 2>/dev/null) != x"$tagref" ]; then case "$tag" in nasm-0.99.0[5-9]|nasm-0.99.[1-9]*|nasm-[1-9]*) rel_version=$(echo "$tag" | sed -e 's/^nasm-//') if [ ! -d "$reldir"/"$rel_version" ]; then git clone -s -l -n git git-rel ( cd git-rel && git checkout "$tag" ) tagref=$(cd git-rel && git rev-parse "$tag") # Note: "if ( shellfunc ... ); then" breaks -e... thus this workaround. set +e ( set -e; build "$rel_version" "$reldir"/"$rel_version" git-rel "$tagref" ) err=$? set -e if [ $err -eq 0 ]; then process_release "$rel_version" else # Build failed, we don't want to build this exact tag again echo "$tagref" > "$excludedir"/"$tag" fi fi ;; esac fi done # # Daily snapshot... # if [ x$HEAD = x$(cat LAST_HEAD) ]; then exit 0 fi if [ -d "$snapdir"/$today ]; then # We already did a build today... exit 0 fi snap_version=$(cat git/version)-$today set +e ( set -e; build "$snap_version" "$snapdir"/$today git "$HEAD" ) err=$? set -e if [ $err -eq 0 ]; then env GIT_DIR="$tagrepo" git tag -a -f -m "Daily snapshot $today" nasm-"$snap_version" env GIT_DIR="$tagrepo" git update-server-info ( cd $snapdir && rm -f latest && ln -s $today latest ) fi echo "$HEAD" > LAST_HEAD