Add --list support to dib-run-parts.

Our custom dib-run-parts now supports --list for better compatibility
with some OS-provided run-parts tools.

Change-Id: I2feb615b2094d9d6522bfe9b422362223bb8e652
Closes-Bug: #1190521
This commit is contained in:
Chris Jones 2013-09-04 09:43:11 +01:00
parent 9e5bc37265
commit 6311388892

View File

@ -17,13 +17,15 @@
# under the License. # under the License.
allowed_regex=${RUN_PARTS_REGEX:-"^[0-9A-Za-z_-]+$"} allowed_regex=${RUN_PARTS_REGEX:-"^[0-9A-Za-z_-]+$"}
show_list=
set -ue set -ue
name=$(basename $0) name=$(basename $0)
usage() { usage() {
echo "usage: $name scripts_directory" >&2 echo "usage: $name [OPTION] scripts_directory" >&2
echo " --list print names of all valid files" >&2
exit 1 exit 1
} }
@ -35,6 +37,11 @@ if [ $# -lt 1 ] ; then
usage usage
fi fi
if [ "$1" == "--list" ] ; then
show_list="1"
shift
fi
target_dir=$1 target_dir=$1
if ! [ -d $target_dir ] ; then if ! [ -d $target_dir ] ; then
@ -49,6 +56,13 @@ fi
# subdirectories) are run, which is the way run-parts behaves. # subdirectories) are run, which is the way run-parts behaves.
targets=$(find $target_dir -maxdepth 1 -type f -executable -printf '%f\n' | grep -E "$allowed_regex" | LANG=C sort -n) targets=$(find $target_dir -maxdepth 1 -type f -executable -printf '%f\n' | grep -E "$allowed_regex" | LANG=C sort -n)
if [ "$show_list" == "1" ] ; then
for target in $targets ; do
echo "${target_dir}/${target}"
done
exit 0
fi
PROFILE_DIR=$(mktemp -d /tmp/profiledir.XXXXXX) PROFILE_DIR=$(mktemp -d /tmp/profiledir.XXXXXX)
if [ -d /tmp/in_target.d/environment.d ] ; then if [ -d /tmp/in_target.d/environment.d ] ; then