diff --git a/functions b/functions index 0c407e9..2325a86 100644 --- a/functions +++ b/functions @@ -423,8 +423,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" @@ -432,13 +433,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 diff --git a/man/mkinitcpio.8.txt b/man/mkinitcpio.8.txt index 5c3118e..931a167 100644 --- a/man/mkinitcpio.8.txt +++ b/man/mkinitcpio.8.txt @@ -139,7 +139,7 @@ functions exist to facilitate this. Adds a directory and its parents to the image. -*add_full_dir* 'directory' [ 'glob' ]:: +*add_full_dir* 'directory' [ 'glob' ] [ 'strip_prefix' ]:: Recursively adds a directory to the image by walking the given path and calling *add_file*, *add_dir*, and *add_symlink* accordingly. This function @@ -148,6 +148,11 @@ functions exist to facilitate this. If the 'glob' argument is passed, only files and symlinks matching this glob will be added. + If the 'strip_prefix' argument is passed, it will be used to strip the + destination path (path in the initramfs image) from the prefix specified by + the 'strip_prefix' argument. This can be useful when writing rootfs-overlay + hooks. + *add_symlink* 'path' [ 'link-target' ]:: Adds a symlink to the image at the specified `path`, optionally pointing to