1#! /bin/sh
2
3# This script takes the result of "make dist" and:
4# 1) Unpacks it.
5# 2) Ensures all contents are user-writable.  Some version control systems
6#    keep code read-only until you explicitly ask to edit it, and the normal
7#    "make dist" process does not correct for this, so the result is that
8#    the entire dist is still marked read-only when unpacked, which is
9#    annoying.  So, we fix it.
10# 3) Convert MSVC project files to MSVC 2005, so that anyone who has version
11#    2005 *or* 2008 can open them.  (In version control, we keep things in
12#    MSVC 2008 format since that's what we use in development.)
13# 4) Uses the result to create .tar.gz, .tar.bz2, and .zip versions and
14#    deposites them in the "dist" directory.  In the .zip version, all
15#    non-testdata .txt files are converted to Windows-style line endings.
16# 5) Cleans up after itself.
17
18if [ "$1" == "" ]; then
19  echo "USAGE:  $1 DISTFILE" >&2
20  exit 1
21fi
22
23if [ ! -e $1 ]; then
24  echo $1": File not found." >&2
25  exit 1
26fi
27
28set -ex
29
30BASENAME=`basename $1 .tar.gz`
31
32# Create a directory called "dist", copy the tarball there and unpack it.
33mkdir dist
34cp $1 dist
35cd dist
36tar zxvf $BASENAME.tar.gz
37rm $BASENAME.tar.gz
38
39# Set the entire contents to be user-writable.
40chmod -R u+w $BASENAME
41
42# Convert the MSVC projects to MSVC 2005 format.
43cd $BASENAME/vsprojects
44./convert2008to2005.sh
45cd ..
46
47# Build the dist again in .tar.gz and .tar.bz2 formats.
48./configure
49make dist-gzip
50make dist-bzip2
51
52# Convert all text files to use DOS-style line endings, then build a .zip
53# distribution.
54todos *.txt */*.txt
55make dist-zip
56
57# Clean up.
58mv $BASENAME.tar.gz $BASENAME.tar.bz2 $BASENAME.zip ..
59cd ..
60rm -rf $BASENAME
61