| 1 | #!/bin/bash |
|---|
| 2 | . scripts/common |
|---|
| 3 | . scripts/svn |
|---|
| 4 | |
|---|
| 5 | packSource() { |
|---|
| 6 | local args="$1" |
|---|
| 7 | local suffix="$2" |
|---|
| 8 | local file="$outputDir/$ext-$extVersion$rev$suffix" |
|---|
| 9 | |
|---|
| 10 | if [[ ! -f $file ]]; then |
|---|
| 11 | pushd "$extDir" >/dev/null || die |
|---|
| 12 | tar $VERBOSE --exclude tags --exclude .svn "$args" "$file.tmp" $ext-$extVersion || die |
|---|
| 13 | popd >/dev/null |
|---|
| 14 | mv "$file.tmp" "$file" |
|---|
| 15 | md5sum "$file" | sed 's#/.*/##' > "$file.md5.txt" |
|---|
| 16 | fi |
|---|
| 17 | } |
|---|
| 18 | |
|---|
| 19 | packBinary() { |
|---|
| 20 | local buildDirVersioned="$buildDir/$extNiceName-$extVersion-$phpReleaseVersion" |
|---|
| 21 | [[ ! -d "$buildDirVersioned" ]] && return |
|---|
| 22 | local output="$outputDir$rev/" |
|---|
| 23 | local _TS= |
|---|
| 24 | [[ ! -z $nts ]] && _TS= |
|---|
| 25 | [[ -z $nts ]] && _TS=_TS |
|---|
| 26 | local distDir="$buildDirVersioned/php/Release${_TS}" |
|---|
| 27 | |
|---|
| 28 | local -a files |
|---|
| 29 | local outputFile="$outputDir/$extNiceName-$extVersion$rev-$phpReleaseVersion" |
|---|
| 30 | if [[ ! -f $outputFile.zip || ! -f $outputFile-pdb.zip ]]; then |
|---|
| 31 | pushd "$buildDirVersioned/php" >/dev/null || die |
|---|
| 32 | pushv file "Release${_TS}/php_$ext.dll" |
|---|
| 33 | local i |
|---|
| 34 | for i in "${packageFiles[@]}" ; do |
|---|
| 35 | local f="$buildDirVersioned/$ext/$i" |
|---|
| 36 | if [[ -e $f ]]; then |
|---|
| 37 | dstdir="$distDir/"$(dirname "$i") |
|---|
| 38 | if [[ ! -d $dstdir ]]; then |
|---|
| 39 | mkdir -p "$dstdir" |
|---|
| 40 | fi |
|---|
| 41 | rm -rf "$distDir/$i" |
|---|
| 42 | cp -a "$f" "$distDir/$i" |
|---|
| 43 | pushv file "Release${_TS}/$i" |
|---|
| 44 | fi |
|---|
| 45 | done |
|---|
| 46 | |
|---|
| 47 | zip tmp.zip $(find "${files[@]}") || die |
|---|
| 48 | mv tmp.zip "$outputFile.zip" |
|---|
| 49 | md5sum "$outputFile.zip" > "$outputFile.zip.md5.txt" |
|---|
| 50 | |
|---|
| 51 | zip tmp.zip "Release${_TS}/php_$ext.pdb" |
|---|
| 52 | mv tmp.zip "$outputFile-pdb.zip" |
|---|
| 53 | md5sum "$outputFile-pdb.zip" > "$outputFile-pdb.zip.md5.txt" |
|---|
| 54 | popd >/dev/null |
|---|
| 55 | fi |
|---|
| 56 | } |
|---|
| 57 | |
|---|
| 58 | pack() { |
|---|
| 59 | local prefix= |
|---|
| 60 | if [[ -z $release ]]; then |
|---|
| 61 | rev=-r$(svnRevOf $extDirVersioned) |
|---|
| 62 | prefix="$snapshotOutputDir/$extVersion" |
|---|
| 63 | else |
|---|
| 64 | prefix="$releaseOutputDir/$extVersion" |
|---|
| 65 | fi |
|---|
| 66 | local outputDir="$prefix$rev" |
|---|
| 67 | mkdir -p "$outputDir" |
|---|
| 68 | |
|---|
| 69 | packSource -jcf .tar.bz2 |
|---|
| 70 | packSource -zcf .tar.gz |
|---|
| 71 | foreachPhpVersion foreachPhpReleaseVersion packBinary |
|---|
| 72 | |
|---|
| 73 | local files=$(shopt -s nullglob; echo "$prefix"*) |
|---|
| 74 | if [[ ! -z $files ]]; then |
|---|
| 75 | rm $VERBOSE -rf `ls -td $files | sed -n ${snapshotCount:-8}',$p'` |
|---|
| 76 | fi |
|---|
| 77 | } |
|---|
| 78 | |
|---|
| 79 | if [ `find build -iname php_xcache.dll -size 0 | wc -l` -gt 0 ] ; then |
|---|
| 80 | echo "corrupt file built" |
|---|
| 81 | find build -iname php_xcache.dll -size 0 |
|---|
| 82 | exit 1 |
|---|
| 83 | fi |
|---|
| 84 | |
|---|
| 85 | case $# in |
|---|
| 86 | 0) |
|---|
| 87 | foreachExt foreachExtVersion pack |
|---|
| 88 | ;; |
|---|
| 89 | 1) |
|---|
| 90 | loadExt "$1" |
|---|
| 91 | foreachExtVersion pack |
|---|
| 92 | ;; |
|---|
| 93 | 2) |
|---|
| 94 | loadExt "$1" |
|---|
| 95 | loadExtVersion "$2" |
|---|
| 96 | pack |
|---|
| 97 | ;; |
|---|
| 98 | *) |
|---|
| 99 | die "Usage: $0 [ext [extVersion]]" |
|---|
| 100 | ;; |
|---|
| 101 | esac |
|---|