makedist 4.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157
  1. #!/bin/sh
  2. #
  3. # Distribution generator for git
  4. #
  5. # Usage: makedist version
  6. # Example: makedist 5.4.1
  7. # Example: makedist 5.3.5RC1
  8. #
  9. # To work, this script needs a consistent tagging of all releases.
  10. # 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. if test "$#" != "1"; then
  21. echo "Usage: makedist <version>" >&2
  22. exit 1
  23. fi
  24. VER=$1 ; shift
  25. old_IFS="$IFS"
  26. IFS=.
  27. eval set `bison --version| grep 'GNU Bison' | cut -d ' ' -f 4 | sed -e 's/\./ /g'`
  28. if test "${1}" -lt "3" -o "${1}" = "3" -a "${2}" -eq "0" -a "${3}" -lt "2"; then
  29. echo "You will need bison >= 3.0.2 if you want to regenerate the Zend parser (found ${1}.${2}.${3})."
  30. exit 2
  31. fi
  32. eval set `re2c --version| grep 're2c' | cut -d ' ' -f 2 | sed -e 's/\./ /g'`
  33. if test "${2}" -lt "13" -o "${2}" -eq "13" -a "${3}" -lt "5"; then
  34. echo "You will need re2c >= 0.13.5 if you want to regenerate the Zend scanner (found ${1}.${2}.${3})."
  35. exit 2
  36. fi
  37. IFS="$old_IFS"
  38. if test "x$PHPROOT" != "x"; then
  39. remote_option=--remote=$PHPROOT
  40. else
  41. remote_option=
  42. fi
  43. LT_TARGETS='ltconfig ltmain.sh config.guess config.sub'
  44. if echo '\c' | grep -s c >/dev/null 2>&1
  45. then
  46. ECHO_N="echo -n"
  47. ECHO_C=""
  48. else
  49. ECHO_N="echo"
  50. ECHO_C='\c'
  51. fi
  52. MY_OLDPWD=`pwd`
  53. # the destination .tar.gz file
  54. ARCHIVE=$MY_OLDPWD/php-$VER.tar
  55. # temporary directory used to check out files from SVN
  56. DIR=php-$VER
  57. DIRPATH=$MY_OLDPWD/$DIR
  58. if test -d "$DIRPATH"; then
  59. echo "The directory $DIR" >&2
  60. echo "already exists, rename or remove it and run makedist again." >&2
  61. exit 1
  62. fi
  63. # Export PHP
  64. $ECHO_N "makedist: exporting tag 'php-$VER' from '$PHPROOT'...$ECHO_C"
  65. git archive --format=tar $remote_option refs/tags/php-$VER --prefix=php-$VER/ | (cd $MY_OLDPWD; tar xvf -) || exit 4
  66. echo ""
  67. cd $DIR || exit 5
  68. # hide away our own versions of libtool-generated files
  69. for i in $LT_TARGETS; do
  70. if test -f "$i"; then
  71. mv $i $i.bak
  72. cp $i.bak $i
  73. fi
  74. done
  75. # generate some files so people don't need bison, re2c and autoconf
  76. # to install
  77. set -x
  78. ./buildconf --copy --force
  79. # remove buildmk.stamp. Otherwise, buildcheck.sh might not be run,
  80. # when a user runs buildconf in the distribution.
  81. rm -f buildmk.stamp
  82. ./genfiles
  83. # now restore our versions of libtool-generated files
  84. for i in $LT_TARGETS; do
  85. test -f "$i" && mv $i.bak $i
  86. done
  87. # removing junk files
  88. find . -name \*.orig -print0 | xargs -0 rm
  89. rm -fr autom4te.cache/
  90. # touching everything to be packaged
  91. find $MY_OLDPWD/php-$VER -exec touch -c {} \;
  92. # tweak zendparse to be exported through ZEND_API
  93. # NOTE this has to be revisited once bison supports foreign skeletons
  94. # and that bison version is used. Read /usr/share/bison/README for more
  95. sed -i 's,^int zendparse\(.*\),ZEND_API int zendparse\1,g' $MY_OLDPWD/php-$VER/Zend/zend_language_parser.c
  96. sed -i 's,^int zendparse\(.*\),ZEND_API int zendparse\1,g' $MY_OLDPWD/php-$VER/Zend/zend_language_parser.h
  97. sed -i 's,^#ifndef YYTOKENTYPE,#include "zend.h"\n#ifndef YYTOKENTYPE,g' $MY_OLDPWD/php-$VER/Zend/zend_language_parser.h
  98. # download pear
  99. $ECHO_N "makedist: Attempting to download PEAR's phar archive"
  100. if test ! -x wget; then
  101. wget https://pear.php.net/install-pear-nozlib.phar -nd -P pear/
  102. if [ "x$?" != "x0" ]
  103. then
  104. $ECHO_N "Pear download failed";
  105. exit 7
  106. fi
  107. else
  108. $ECHO_N "Missing wget binary needed for pear download";
  109. exit 7
  110. fi
  111. cd $MY_OLDPWD
  112. $ECHO_N "makedist: making gzipped tar archive...$ECHO_C"
  113. rm -f $ARCHIVE.gz
  114. tar cf $ARCHIVE php-$VER || exit 8
  115. gzip -9 $ARCHIVE || exit 9
  116. echo ""
  117. $ECHO_N "makedist: making bz2zipped tar archive...$ECHO_C"
  118. rm -f $ARCHIVE.bz2
  119. tar cf $ARCHIVE php-$VER || exit 10
  120. bzip2 -9 $ARCHIVE || exit 11
  121. echo ""
  122. $ECHO_N "makedist: making xz2zipped tar archive...$ECHO_C"
  123. rm -f $ARCHIVE.xz
  124. tar cf $ARCHIVE php-$VER || exit 10
  125. xz -9 $ARCHIVE || exit 12
  126. echo ""
  127. $ECHO_N "makedist: cleaning up...$ECHO_C"
  128. rm -rf $DIRPATH || exit 13
  129. echo ""
  130. exit 0