| 1 |
#!/bin/sh |
| 2 |
# |
| 3 |
# Build distribution archive |
| 4 |
# |
| 5 |
# Usage: |
| 6 |
# $ sh tools/make-tgz.sh [destdir [snapshot_id]] |
| 7 |
# |
| 8 |
# Output file will save to ../Gauche-${VERSION}[-${SNAPSHOT_ID}.tgz |
| 9 |
# |
| 10 |
# DESTDIR specifies where the tarball is placed. The default is '$pwd/..'. |
| 11 |
# |
| 12 |
# If SNAPSHOT_ID is given, it is set to GAUCHE_SNAPSHOT_ID and shown in |
| 13 |
# the output of 'gosh -V'. It is not included in '(gauche-version)', so |
| 14 |
# it won't affect the installation directory. |
| 15 |
|
| 16 |
set -e |
| 17 |
|
| 18 |
destdir=$1 |
| 19 |
if [ -z "$destdir" ]; then |
| 20 |
destdir=`pwd`/.. |
| 21 |
fi |
| 22 |
|
| 23 |
snapshot_id=$2 |
| 24 |
|
| 25 |
VERSION=$(grep AC_INIT configure.ac | cut --delimiter=, --fields=2 | tr --delete "[]") |
| 26 |
if [ -z "$snapshot_id" ]; then |
| 27 |
name="Gauche-${VERSION}" |
| 28 |
else |
| 29 |
name="Gauche-${VERSION}+${snapshot_id}" |
| 30 |
fi |
| 31 |
|
| 32 |
t=$(mktemp --directory) |
| 33 |
g_dir="${t}/${name}" |
| 34 |
|
| 35 |
# |
| 36 |
# Build distribution source tree |
| 37 |
# |
| 38 |
git archive --prefix="${name}/" HEAD | tar --extract --directory="${t}" |
| 39 |
|
| 40 |
if [ -n "$snapshot_id" ]; then |
| 41 |
sed "s/GAUCHE_SNAPSHOT_ID=/GAUCHE_SNAPSHOT_ID=${snapshot_id}/" \ |
| 42 |
${g_dir}/configure.ac > configure.ac.tmp && \ |
| 43 |
mv configure.ac.tmp ${g_dir}/configure.ac |
| 44 |
fi |
| 45 |
|
| 46 |
# |
| 47 |
# Build generated files |
| 48 |
# |
| 49 |
cd "${g_dir}" |
| 50 |
./DIST gen |
| 51 |
./configure --enable-threads=pthreads --enable-multibyte=utf8 --disable-dependency-tracking |
| 52 |
make GOSH=gosh BUILD_GOSH_FLAGS=${BUILD_GOSH_FLAGS} pre-package |
| 53 |
make distclean |
| 54 |
|
| 55 |
# |
| 56 |
# Make final archive file |
| 57 |
# |
| 58 |
cd "${t}" |
| 59 |
tar --create --exclude-from="${g_dir}/DIST_EXCLUDE" --owner=root --group=root --sort=name --file=- "${name}" | gzip --best > "${destdir}/${name}.tgz" |
| 60 |
|
| 61 |
echo "${destdir}/${name}.tgz is ready." |
| 62 |
|
| 63 |
# |
| 64 |
# Cleanup |
| 65 |
# |
| 66 |
cd "${destdir}" |
| 67 |
rm --recursive --force "${t}" |