makedist 3.02 KB
Newer Older
1 2
#!/bin/sh
#
3
# Distribution generator for git
4
#
5 6
# Usage: makedist version
# Example: makedist 5.4.1
7
# Example: makedist 5.3.5RC1
8
#
9 10
# To work, this script needs a consistent tagging of all releases.
# Each release of a package should have a tag of the form
11
#
12
#  php-X.Y.Z[sub]
13 14
#
# The distribution ends up in a .tar.gz file that contains the distribution
15
# in a directory called php-<version>.  
16
# A .tar.bz2 file is also created.
17
# 
18
# Written by Stig Bakken <ssb@guardian.no> 1997-05-28.
19
# Adapted to git by Stanislav Malyshev <stas@php.net>
20

21 22 23

if test "$#" != "1"; then
    echo "Usage: makedist <version>" >&2
24 25 26 27 28 29 30 31 32 33
    exit 1
fi

VER=$1 ; shift

old_IFS="$IFS"
IFS=.
eval set `bison --version| grep 'GNU Bison' | cut -d ' ' -f 4 | sed -e 's/\./ /'`
if test "${1}" = "1" -a "${2}" -lt "28"; then
  echo "You will need bison 1.28 if you want to regenerate the Zend parser (found ${1}.${2}).)"
34
  exit 2
35 36 37
fi
IFS="$old_IFS"

38
PHPROOT=git@git.php.net:php-src.git
39 40 41 42 43 44 45 46 47 48 49 50 51 52
LT_TARGETS='ltconfig ltmain.sh config.guess config.sub'

if echo '\c' | grep -s c >/dev/null 2>&1
then
    ECHO_N="echo -n"
    ECHO_C=""
else
    ECHO_N="echo"
    ECHO_C='\c'
fi

MY_OLDPWD=`pwd`

# the destination .tar.gz file
53
ARCHIVE=$MY_OLDPWD/php-$VER.tar
54

55
# temporary directory used to check out files from SVN
56
DIR=php-$VER
57 58 59 60 61 62 63 64 65
DIRPATH=$MY_OLDPWD/$DIR

if test -d "$DIRPATH"; then
    echo "The directory $DIR"
    echo "already exists, rename or remove it and run makedist again."
    exit 1
fi

# Export PHP
66 67
$ECHO_N "makedist: exporting tag 'php-$VER' from '$PHPROOT'...$ECHO_C"
git archive --format=tar --remote=$PHPROOT refs/tags/php-$VER --prefix=php-$VER/ | (cd $MY_OLDPWD; tar xvf -) || exit 4
68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95
echo ""

cd $DIR || exit 5

# hide away our own versions of libtool-generated files
for i in $LT_TARGETS; do
  if test -f "$i"; then
    mv $i $i.bak
    cp $i.bak $i
  fi
done

# generate some files so people don't need bison, flex and autoconf
# to install
set -x
./buildconf --copy --force

# remove buildmk.stamp. Otherwise, buildcheck.sh might not be run,
# when a user runs buildconf in the distribution.
rm -f buildmk.stamp

./genfiles

# now restore our versions of libtool-generated files
for i in $LT_TARGETS; do
  test -f "$i" && mv $i.bak $i
done

96 97 98 99
# removing junk files
find . -name \*.orig -print0 | xargs -0 rm
rm -fr autom4te.cache/

100 101 102 103 104 105
# download pear 
$ECHO_N "makedist: Attempting to download PEAR's phar archive"
if test ! -x wget; then
	wget http://pear.php.net/install-pear-nozlib.phar -nd -P pear/
else
	$ECHO_N "Missing wget binary needed for pear download";
106
	exit 7
107 108
fi

109 110 111
cd $MY_OLDPWD
$ECHO_N "makedist: making gzipped tar archive...$ECHO_C"
rm -f $ARCHIVE.gz
112
tar cf $ARCHIVE php-$VER || exit 8
113 114 115 116 117
gzip -9 $ARCHIVE || exit 9
echo ""

$ECHO_N "makedist: making bz2zipped tar archive...$ECHO_C"
rm -f $ARCHIVE.bz2
118
tar cf $ARCHIVE php-$VER || exit 10
119 120 121
bzip2 -9 $ARCHIVE || exit 11
echo ""

122 123 124 125 126 127
$ECHO_N "makedist: making xz2zipped tar archive...$ECHO_C"
rm -f $ARCHIVE.xz
tar cf $ARCHIVE php-$VER || exit 10
xz -9 $ARCHIVE || exit 12
echo ""

128
$ECHO_N "makedist: cleaning up...$ECHO_C"
129
rm -rf $DIRPATH || exit 13
130 131 132
echo ""

exit 0