Remove extracted php src (#256)

* Remove php src the right way for lightweight containers.

* Adapt docker-php-ext-* scripts to check exts against /available-exts generated file.

* Improve docker-php-source script

 - swap spaces to tabs to match
 - use gnu tar for `--strip-components`
 - cache known extension list in `/usr/src/`
 - remove extra output

* Changes per tianon's comments
This commit is contained in:
yosifkit
2016-07-12 17:12:43 -07:00
committed by Tianon Gravi
parent 8f978dd1f2
commit 1a4763005a
6 changed files with 103 additions and 41 deletions

View File

@ -1,8 +1,6 @@
#!/bin/sh
set -e
cd /usr/src/php/ext
usage() {
echo "usage: $0 [-jN] ext-name [ext-name ...]"
echo " ie: $0 gd mysqli"
@ -12,7 +10,7 @@ usage() {
echo 'if custom ./configure arguments are necessary, see docker-php-ext-configure'
echo
echo 'Possible values for ext-name:'
echo $(find /usr/src/php/ext -mindepth 2 -maxdepth 2 -type f -name 'config.m4' | cut -d/ -f6 | sort)
echo $(cat /usr/src/php-available-exts)
}
opts="$(getopt -o 'h?j:' --long 'help,jobs:' -- "$@" || { usage >&2 && false; })"
@ -41,8 +39,8 @@ for ext; do
if [ -z "$ext" ]; then
continue
fi
if [ ! -d "$ext" ]; then
echo >&2 "error: $(pwd -P)/$ext does not exist"
if ! grep -qE "^$ext$" /usr/src/php-available-exts; then
echo >&2 "error: /usr/src/php/ext/$ext does not exist"
echo >&2
usage >&2
exit 1
@ -72,6 +70,9 @@ if [ "$pm" = 'apk' ]; then
fi
fi
docker-php-source extract
cd /usr/src/php/ext
for ext in $exts; do
(
cd "$ext"
@ -90,3 +91,4 @@ done
if [ "$pm" = 'apk' ] && [ -n "$apkDel" ]; then
apk del $apkDel
fi
docker-php-source delete