1#!/bin/bash -xe 2# 3# Generate a NASM release 4# 5# Usage: release version [destination] 6# 7 8version="$1" 9if [ -z "$1" ]; then 10 echo "Usage: $0 version [destination]" 1>&2 11 exit 1 12fi 13 14WHERE="$2" 15if [ -z "$WHERE" ]; then 16 WHERE=/var/tmp 17fi 18 19if [ -n "$GIT_DIR" ]; then 20 HERE="$GIT_DIR" 21else 22 HERE=`pwd` 23fi 24 25if [ x`cat version` != x"${version}" ]; then 26 echo "${version}" > version 27 git update-index version 28 git commit -m "Version ${version}" -- version 29fi 30git tag -m "NASM version ${version}" -f "nasm-${version}" 31 32cd "$WHERE" 33rm -rf nasm-release.* 34work=nasm-release.$$ 35mkdir $work 36cd $work 37unset GIT_DIR 38git clone -s -l "$HERE" nasm 39rm -rf nasm/.git nasm/.gitignore 40 41# How to invoke make if makej is not set 42makej="${makej:-make}" 43 44# Create files which are in the release but automatically generated 45cd nasm 46./autogen.sh 47./configure --prefix=/usr/local 48$makej perlreq spec manpages 49$makej alldeps 50$makej distclean 51cd .. 52 53# Clean up any previous attempt 54rm -f ../nasm-"$version".tar.gz ../nasm-"$version"-xdoc.tar.gz 55rm -f ../nasm-"$version".tar.bz2 ../nasm-"$version"-xdoc.tar.bz2 56rm -f ../nasm-"$version".tar.xz ../nasm-"$version"-xdoc.tar.xz 57rm -f ../nasm-"$version".zip ../nasm-"$version"-xdoc.zip 58 59# Create tarfile (Unix convention: file includes prefix) 60mv nasm nasm-"$version" 61tar cvvf nasm-"$version".tar nasm-"$version" 62xz -9ek nasm-"$version".tar 63bzip2 -9k nasm-"$version".tar 64gzip -9 nasm-"$version".tar 65mv nasm-"$version".tar.gz nasm-"$version".tar.bz2 nasm-"$version".tar.xz .. 66 67# Create zipfile (DOS convention: no prefix, convert file endings) 68cd nasm-"$version" 69# Text files 70zip -9Dlr ../../nasm-"$version".zip * -x \*.jpg -x \*.zip -x \*.ico -x \*.png 71# Binary files 72zip -9Dgr ../../nasm-"$version".zip * -i \*.jpg -i \*.zip -i \*.ico -i \*.png 73cd .. 74 75# Record what we have already generated 76find nasm-"$version" -not -type d -print > main 77 78# Create documentation 79cd nasm-"$version" 80./configure --prefix=/usr/local 81$makej doc 82# Remove intermediate files. 83$makej cleaner 84cd .. 85 86# Remove non-documentation 87cat main | xargs rm -f 88# Delete empty subdirectories 89find nasm-"$version"/doc -type d -exec rmdir '{}' \; 2>/dev/null || true 90 91# Create doc tarfile 92tar cvvf nasm-"$version"-xdoc.tar nasm-"$version"/doc 93xz -9ek nasm-"$version"-xdoc.tar 94bzip2 -9k nasm-"$version"-xdoc.tar 95gzip -9 nasm-"$version"-xdoc.tar 96mv nasm-"$version"-xdoc.tar.gz nasm-"$version"-xdoc.tar.bz2 nasm-"$version"-xdoc.tar.xz .. 97 98# Create doc zipfile (DOS convention: no prefix, convert file endings) 99cd nasm-"$version" 100zip -9Dlr ../../nasm-"$version"-xdoc.zip doc -x \*.pdf -x \*.png 101zip -9Dgr ../../nasm-"$version"-xdoc.zip doc -i \*.pdf -i \*.png 102 103# Clean up 104cd ../.. 105rm -rf "$work" 106