php/docker-php-source
yosifkit 1a4763005a 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
2016-07-12 17:12:43 -07:00

45 lines
887 B
Bash
Executable File

#!/bin/sh
set -e
dir=/usr/src/php
usage() {
echo "usage: $0 COMMAND"
echo
echo "Manage php source tarball lifecycle."
echo
echo "Commands:"
echo " extract extract php source tarball into directory $dir if not already done."
echo " delete delete extracted php source located into $dir if not already done."
echo
}
case "$1" in
extract)
if [ -e "$dir" -a ! -d "$dir" ] ; then
echo >&2 "$dir exists and is not a directory"
exit 1
fi
if [ ! -d "$dir" ]; then
mkdir -p "$dir"
tar -Jxf /usr/src/php.tar.xz -C "$dir" --strip-components=1
if [ ! -f /usr/src/php-available-exts ]; then
find "$dir/ext" \
-mindepth 2 \
-maxdepth 2 \
-type f \
-name 'config.m4' \
| xargs -n1 dirname | xargs -n1 basename | sort \
> /usr/src/php-available-exts
fi
fi
;;
delete)
rm -rf "$dir"
;;
*)
usage
exit 1
;;
esac