summaryrefslogtreecommitdiffstats
path: root/functions
diff options
context:
space:
mode:
authorErik Stromdahl <erik.stromdahl@gmail.com>2017-06-01 19:29:18 +0200
committerDave Reisner <dreisner@archlinux.org>2017-08-20 22:40:27 +0200
commit172ca644527cfaf3bba1dbeab9e7139cca2b249a (patch)
tree043ff751d3e1d01abbceabcaff4f6b3b2d10a24d /functions
parentcee0499489e97384b72d47473606272d12ac96c0 (diff)
downloadmkinitcpio-172ca644527cfaf3bba1dbeab9e7139cca2b249a.tar.gz
mkinitcpio-172ca644527cfaf3bba1dbeab9e7139cca2b249a.tar.xz
functions: add_full_dir: path prefix strip-off
Add third argument to add_full_dir: strip_prefix. The strip_prefix will be stripped off from the destination path (path in the initramfs image) when adding files. Rationale: Make it easier to add rootfs overlay hooks when generating images. add_full_dir can be invoked in this way: add_full_dir /path/on/parent/rootfs-overlay * /path/on/parent/rootfs-overlay The above invocation will add all content of */path/on/parent/rootfs-overlay* into */* in the initramfs image. Signed-off-by: Erik Stromdahl <erik.stromdahl@gmail.com>
Diffstat (limited to 'functions')
-rw-r--r--functions9
1 files changed, 5 insertions, 4 deletions
diff --git a/functions b/functions
index 6cc74a4..0e1fe0f 100644
--- a/functions
+++ b/functions
@@ -433,8 +433,9 @@ add_full_dir() {
# No parsing is performed and the contents of the directory is added as is.
# $1: path to directory
# $2: glob pattern to filter file additions (optional)
+ # $3: path prefix that will be stripped off from the image path (optional)
- local f= filter=${2:-*}
+ local f= filter=${2:-*} strip_prefix=$3
if [[ -n $1 && -d $1 ]]; then
add_dir "$1"
@@ -442,13 +443,13 @@ add_full_dir() {
for f in "$1"/*; do
if [[ -L $f ]]; then
if [[ $f = $filter ]]; then
- add_symlink "$f" "$(readlink "$f")"
+ add_symlink "${f#$strip_prefix}" "$(readlink "$f")"
fi
elif [[ -d $f ]]; then
- add_full_dir "$f" "$filter"
+ add_full_dir "$f" "$filter" "$strip_prefix"
elif [[ -f $f ]]; then
if [[ $f = $filter ]]; then
- add_file "$f"
+ add_file "$f" "${f#$strip_prefix}"
fi
fi
done