source: autobuild/scripts/unpackphpbinary @ 905

Last change on this file since 905 was 905, checked in by moo, 2 years ago

import auto build scripts

  • Property svn:executable set to *
File size: 1.8 KB
Line 
1#!/bin/bash
2. scripts/common
3
4[[ $# != 3 ]] && "Usage: $0 <phpVersion> <binaryPackage> <directory>"
5phpVersion="$1"
6binaryPackage="$2"
7[[ -s $binaryPackage ]] || die "$binaryPackage not found as a file"
8binaryPackageDir="$3"
9[[ -d $binaryPackageDir ]] || die "$binaryPackageDir not found as a directory"
10
11
12begin "Cleaning $binaryPackageDir"; {
13    rm -rf "$binaryPackageDir"
14    mkdir "$binaryPackageDir/"
15}; end
16
17phpVersionMajor=$(getVersionPart 0 $phpVersion)
18phpVersionMinor=$(getVersionPart 1 $phpVersion)
19
20case "$(basename "$binaryPackage")" in
21*-nts-*)
22    ts=
23    ;;
24*)
25    ts=ts
26    ;;
27esac
28
29if [[ $phpVersionMajor -lt 5 ]]; then
30    binaryFiles=($(printf " php-$phpVersion/%s" "${binaryFiles[@]}"))
31fi
32
33echo "Unpacking $binaryFiles ..."; {
34    rm -rf "$binaryPackageDir.tmp"
35    mkdir "$binaryPackageDir.tmp" || die "failed chdir $binaryPackageDir"
36    cd "$binaryPackageDir.tmp" || die "failed chdir $binaryPackageDir"
37    unzip -o "$binaryPackage" || die "failed unpacking"
38
39    if [[ -d $binaryPackageDir.tmp/php-$phpVersion ]]; then
40        mv "$binaryPackageDir.tmp/php-$phpVersion"/* "$binaryPackageDir.tmp/"
41        rmdir "$binaryPackageDir.tmp/php-$phpVersion"
42    fi
43
44    for subdir in sapi dev; do
45        if [[ -d $binaryPackageDir.tmp/$subdir/ ]]; then
46            mv -v "$binaryPackageDir.tmp/$subdir"/* "$binaryPackageDir.tmp/"
47        fi
48    done
49
50    if [[ ! -f $binaryPackageDir.tmp/php-cgi.exe ]]; then
51        mv "$binaryPackageDir.tmp/php.exe" "$binaryPackageDir.tmp/php-cgi.exe"
52    fi
53
54    if [[ -f $binaryPackageDir.tmp/cli/php.exe ]]; then
55        mv "$binaryPackageDir.tmp/cli/php.exe" "$binaryPackageDir.tmp/php.exe"
56    fi
57
58    for filename in "php${phpVersionMajor}${ts}.dll" "php${phpVersionMajor}${ts}.lib" php-cgi.exe php.exe; do
59        mv -v "$binaryPackageDir.tmp/$filename" "$binaryPackageDir/" || die
60    done
61    mv -v "$binaryPackageDir.tmp/"php${phpVersionMajor}apache*.dll "$binaryPackageDir/"
62
63    cd ..
64    rm -rf "$binaryPackageDir.tmp"
65}
Note: See TracBrowser for help on using the repository browser.