Use dib-run-parts for running scripts in target

Also modified dib-run-parts to apply a more workable solution for
filtering out unwanted files such as editor backups and VCS.

The script is installed in its own element, depended on by the OS
specific ubuntu element. This is  because the ubuntu element (and
later other OS's) are responsible for populating the root filesystem.
If we try to install this in base, the root filesystem will look to
be populated already and we will skip automatically choosing ubuntu.

Change-Id: I017646748c1a8360299106289b57d976d45875a8
This commit is contained in:
Clint Byrum 2013-02-14 10:20:30 -08:00
parent 3ce071c894
commit 91c30f6ab2
4 changed files with 12 additions and 3 deletions

View File

@ -0,0 +1,5 @@
#!/bin/bash
home=$(dirname $0)
exec sudo install -m 0755 -o root -g root -D \
$home/dib-run-parts \
$TARGET_ROOT/usr/local/bin/dib-run-parts

View File

@ -16,6 +16,8 @@
# License for the specific language governing permissions and limitations
# under the License.
allowed_regex=${RUN_PARTS_REGEX:-"^[0-9A-Za-z_-]+$"}
set -ue
name=$(basename $0)
@ -41,8 +43,9 @@ if ! [ -d $target_dir ] ; then
fi
# We specifically only want to sort *by the numbers*.
# Lexical sorting is not guaranteed.
targets=$(find $target_dir -type f -executable \! -name '.*' -printf '%f\n' | sort -n)
# Lexical sorting is not guaranteed, and identical numbers may be
# parallelized later
targets=$(find $target_dir -type f -executable -printf '%f\n' | grep -E "$allowed_regex" | LANG=C sort -n)
for target in $targets ; do
output "Running $target_dir/$target"

View File

@ -1 +1,2 @@
dpkg
dib-run-parts

View File

@ -116,7 +116,7 @@ function run_d_in_target() {
sudo mount --bind ${TMP_HOOKS_PATH} $TMP_MOUNT_PATH/tmp/in_target.d
sudo mount -o remount,ro,bind ${TMP_HOOKS_PATH} $TMP_MOUNT_PATH/tmp/in_target.d
check_break before-$1 run_in_target bash
run_in_target run-parts /tmp/in_target.d/$1.d
run_in_target dib-run-parts /tmp/in_target.d/$1.d
check_break after-$1 run_in_target bash
sudo umount -f $TMP_MOUNT_PATH/tmp/in_target.d
sudo rmdir $TMP_MOUNT_PATH/tmp/in_target.d