From 02d387b2370215d51d1aa8958fce42cd099bee29 Mon Sep 17 00:00:00 2001 From: Dave Reisner Date: Sat, 21 Jun 2014 12:38:04 -0400 Subject: add second param to add_full_dir to allow filtering files Use this to only add files matching *.conf in the modconf hook. Fixes FS#39994. --- functions | 7 ++++--- install/modconf | 4 ++-- man/mkinitcpio.8.txt | 5 ++++- 3 files changed, 10 insertions(+), 6 deletions(-) diff --git a/functions b/functions index b4f51a8..20bbffe 100644 --- a/functions +++ b/functions @@ -414,19 +414,20 @@ add_full_dir() { # Add a directory and all its contents, recursively, to the initcpio image. # 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) - local f= + local f= filter=${2:-*} if [[ -n $1 && -d $1 ]]; then add_dir "$1" for f in "$1"/*; do if [[ -L $f ]]; then - add_symlink "$f" "$(readlink "$f")" + [[ $f = $filter ]] && add_symlink "$f" "$(readlink "$f")" elif [[ -d $f ]]; then add_full_dir "$f" elif [[ -f $f ]]; then - add_file "$f" + [[ $f = $filter ]] && add_file "$f" fi done fi diff --git a/install/modconf b/install/modconf index b06b51a..06cb997 100644 --- a/install/modconf +++ b/install/modconf @@ -1,8 +1,8 @@ #!/bin/bash build() { - add_full_dir /etc/modprobe.d - add_full_dir /usr/lib/modprobe.d + add_full_dir /etc/modprobe.d '*.conf' + add_full_dir /usr/lib/modprobe.d '*.conf' } help() { diff --git a/man/mkinitcpio.8.txt b/man/mkinitcpio.8.txt index cd06576..05d71c4 100644 --- a/man/mkinitcpio.8.txt +++ b/man/mkinitcpio.8.txt @@ -138,12 +138,15 @@ functions exist to facilitate this. Adds a directory and its parents to the image. -*add_full_dir* 'directory':: +*add_full_dir* 'directory' [ 'glob' ]:: Recursively adds a directory to the image by walking the given path and calling *add_file*, *add_dir*, and *add_symlink* accordingly. This function will not follow symlinks, nor will it add the targets of symlinks. + If the 'glob' argument is passed, only files and symlinks matching this glob + will be added. + *add_symlink* 'path' [ 'link-target' ]:: Adds a symlink to the image at the specified `path`, optionally pointing to -- cgit v1.2.3-24-g4f1b