| 1 | #!/bin/sh |
|---|
| 2 | |
|---|
| 3 | isTest() { # {{{1 |
|---|
| 4 | [[ ! -z "$isTest" ]] |
|---|
| 5 | } |
|---|
| 6 | |
|---|
| 7 | cd() { # {{{1 |
|---|
| 8 | builtin cd "$@" |
|---|
| 9 | if isTest ; then |
|---|
| 10 | if [[ $OLDPWD != $PWD ]]; then |
|---|
| 11 | echo cd "$PWD" |
|---|
| 12 | fi |
|---|
| 13 | fi |
|---|
| 14 | } |
|---|
| 15 | |
|---|
| 16 | getOutputDir() { # {{{1 |
|---|
| 17 | valueof "$1"OutputDir |
|---|
| 18 | } |
|---|
| 19 | |
|---|
| 20 | getSubdirs() { # {{{1 |
|---|
| 21 | pushd "$1" >/dev/null 2>&1 |
|---|
| 22 | local dir |
|---|
| 23 | for dir in *; do |
|---|
| 24 | [[ -d $dir ]] && echo "$dir" |
|---|
| 25 | done |
|---|
| 26 | popd >/dev/null 2>&1 |
|---|
| 27 | } |
|---|
| 28 | # }}} |
|---|
| 29 | |
|---|
| 30 | getExtVersions() { # {{{1 |
|---|
| 31 | local ext=$1 |
|---|
| 32 | local len=${#ext} |
|---|
| 33 | local dir |
|---|
| 34 | ((len=len+1)) |
|---|
| 35 | getSubdirs "$topdir/$1" | while read dir; do |
|---|
| 36 | echo ${dir:$len} |
|---|
| 37 | done |
|---|
| 38 | } |
|---|
| 39 | |
|---|
| 40 | loadExt() { # {{{1 |
|---|
| 41 | ext="$1" |
|---|
| 42 | extDir="$topdir/$ext" |
|---|
| 43 | |
|---|
| 44 | extVersions=($(getExtVersions "$ext")) |
|---|
| 45 | |
|---|
| 46 | configFile="$extDir/.config" |
|---|
| 47 | if [[ ! -f $configFile ]]; then |
|---|
| 48 | die "$configFile not found" |
|---|
| 49 | fi |
|---|
| 50 | . "$configFile" |
|---|
| 51 | unset configFile |
|---|
| 52 | } |
|---|
| 53 | |
|---|
| 54 | foreachExt() { # {{{1 |
|---|
| 55 | local ext |
|---|
| 56 | for ext in "${exts[@]}"; do ( |
|---|
| 57 | loadExt "$ext" |
|---|
| 58 | "$@" |
|---|
| 59 | ); done |
|---|
| 60 | } |
|---|
| 61 | |
|---|
| 62 | loadExtVersion() { # {{{1 |
|---|
| 63 | extVersion="$1" |
|---|
| 64 | extDirVersioned="$topdir/$ext/$ext-$extVersion" |
|---|
| 65 | configFile="$extDirVersioned/.config" |
|---|
| 66 | if [[ -f $configFile ]]; then |
|---|
| 67 | . "$configFile" |
|---|
| 68 | fi |
|---|
| 69 | unset configFile |
|---|
| 70 | } |
|---|
| 71 | |
|---|
| 72 | foreachExtVersion() { # {{{1 |
|---|
| 73 | local extVersion |
|---|
| 74 | for extVersion in "${extVersions[@]}"; do ( |
|---|
| 75 | loadExtVersion "$extVersion" |
|---|
| 76 | "$@" |
|---|
| 77 | ); done |
|---|
| 78 | } |
|---|
| 79 | |
|---|
| 80 | loadPhpVersion() { # {{{1 |
|---|
| 81 | phpVersion="$1" |
|---|
| 82 | phpSourcePackage="$sourceDir/php-$phpVersion.tar.bz2" |
|---|
| 83 | develDirVersioned="$develDir/php-$phpVersion" |
|---|
| 84 | } |
|---|
| 85 | |
|---|
| 86 | foreachPhpVersion() { # {{{1 |
|---|
| 87 | local phpVersion |
|---|
| 88 | local badVersion |
|---|
| 89 | local ok |
|---|
| 90 | for phpVersion in "${phpVersions[@]}"; do ( |
|---|
| 91 | ok=1 |
|---|
| 92 | for badVersion in "${extBadPhpVersions[@]}"; do |
|---|
| 93 | case "$extVersion-$phpVersion" in |
|---|
| 94 | $badVersion) |
|---|
| 95 | ok=0 |
|---|
| 96 | ;; |
|---|
| 97 | esac |
|---|
| 98 | done |
|---|
| 99 | case "$ok" in |
|---|
| 100 | 1) |
|---|
| 101 | loadPhpVersion "$phpVersion" |
|---|
| 102 | "$@" |
|---|
| 103 | ;; |
|---|
| 104 | esac |
|---|
| 105 | ); done |
|---|
| 106 | } |
|---|
| 107 | foreachPhpReleaseVersion() { # {{{1 |
|---|
| 108 | local arch |
|---|
| 109 | local compiler |
|---|
| 110 | local nts |
|---|
| 111 | local phpReleaseVersion |
|---|
| 112 | local phpReleaseDir |
|---|
| 113 | |
|---|
| 114 | for nts in '' '-nts'; do |
|---|
| 115 | case "$phpVersion" in |
|---|
| 116 | 4.*|5.0.*|5.1.*) |
|---|
| 117 | phpReleaseVersion="php-$phpVersion-Win32" |
|---|
| 118 | phpReleaseDir="$develDir/$phpReleaseVersion" |
|---|
| 119 | arch=x86 |
|---|
| 120 | compiler=VC6 |
|---|
| 121 | nts= |
|---|
| 122 | "$@" |
|---|
| 123 | break |
|---|
| 124 | ;; |
|---|
| 125 | *) |
|---|
| 126 | for compiler in "${compilers[@]}"; do |
|---|
| 127 | for arch in "${arches[@]}"; do |
|---|
| 128 | phpReleaseVersion=php-$phpVersion$nts-Win32-$compiler-$arch$snapVersion |
|---|
| 129 | phpReleaseDir="$develDir/$phpReleaseVersion" |
|---|
| 130 | phpReleaseFile="$sourceDir/$phpReleaseVersion" |
|---|
| 131 | if [[ -d $phpReleaseDir || -f $phpReleaseFile ]]; then |
|---|
| 132 | "$@" |
|---|
| 133 | fi |
|---|
| 134 | done |
|---|
| 135 | done |
|---|
| 136 | esac |
|---|
| 137 | done |
|---|
| 138 | } |
|---|
| 139 | # }}} |
|---|