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:
parent
3ce071c894
commit
91c30f6ab2
5
elements/dib-run-parts/root.d/90-base-dib-run-parts
Executable file
5
elements/dib-run-parts/root.d/90-base-dib-run-parts
Executable 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
|
7
elements/base/bin/dib-run-parts → elements/dib-run-parts/root.d/dib-run-parts
Executable file → Normal file
7
elements/base/bin/dib-run-parts → elements/dib-run-parts/root.d/dib-run-parts
Executable file → Normal file
@ -16,6 +16,8 @@
|
|||||||
# License for the specific language governing permissions and limitations
|
# License for the specific language governing permissions and limitations
|
||||||
# under the License.
|
# under the License.
|
||||||
|
|
||||||
|
allowed_regex=${RUN_PARTS_REGEX:-"^[0-9A-Za-z_-]+$"}
|
||||||
|
|
||||||
set -ue
|
set -ue
|
||||||
|
|
||||||
name=$(basename $0)
|
name=$(basename $0)
|
||||||
@ -41,8 +43,9 @@ if ! [ -d $target_dir ] ; then
|
|||||||
fi
|
fi
|
||||||
|
|
||||||
# We specifically only want to sort *by the numbers*.
|
# We specifically only want to sort *by the numbers*.
|
||||||
# Lexical sorting is not guaranteed.
|
# Lexical sorting is not guaranteed, and identical numbers may be
|
||||||
targets=$(find $target_dir -type f -executable \! -name '.*' -printf '%f\n' | sort -n)
|
# 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
|
for target in $targets ; do
|
||||||
output "Running $target_dir/$target"
|
output "Running $target_dir/$target"
|
@ -1 +1,2 @@
|
|||||||
dpkg
|
dpkg
|
||||||
|
dib-run-parts
|
||||||
|
@ -116,7 +116,7 @@ function run_d_in_target() {
|
|||||||
sudo mount --bind ${TMP_HOOKS_PATH} $TMP_MOUNT_PATH/tmp/in_target.d
|
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
|
sudo mount -o remount,ro,bind ${TMP_HOOKS_PATH} $TMP_MOUNT_PATH/tmp/in_target.d
|
||||||
check_break before-$1 run_in_target bash
|
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
|
check_break after-$1 run_in_target bash
|
||||||
sudo umount -f $TMP_MOUNT_PATH/tmp/in_target.d
|
sudo umount -f $TMP_MOUNT_PATH/tmp/in_target.d
|
||||||
sudo rmdir $TMP_MOUNT_PATH/tmp/in_target.d
|
sudo rmdir $TMP_MOUNT_PATH/tmp/in_target.d
|
||||||
|
Loading…
Reference in New Issue
Block a user