diff options
author | Dave Reisner <dreisner@archlinux.org> | 2012-05-03 20:14:42 +0200 |
---|---|---|
committer | Dave Reisner <dreisner@archlinux.org> | 2012-05-12 15:30:32 +0200 |
commit | 41a290ce22844ac6b1d021b04df5f7659547cc56 (patch) | |
tree | fb39185340dec265d0cc7f603718a3fa779f8521 /functions | |
parent | b317b01465d81b2adadd5f8d964e59622a6a7a32 (diff) | |
download | mkinitcpio-41a290ce22844ac6b1d021b04df5f7659547cc56.tar.gz mkinitcpio-41a290ce22844ac6b1d021b04df5f7659547cc56.tar.xz |
mkinitcpio: remove --basedir option
This option is just a bad idea. Initramfs creation is too important to
get wrong, and running it from outside the root FS has too many gotchas,
the worst of them being:
- where do you pull hooks from?
- how do you resolve binary dependencies within the root?
In general, dealing with the extra luggage of the base directory makes the
codebase more complicated than it needs to be (see all the '_' prefixed
functions which are called from add functions). In favor of simplifying the
code, and making it more maintainable, kill this off and force the sane
option of chroot'ing into an install if the need arises.
Signed-off-by: Dave Reisner <dreisner@archlinux.org>
Diffstat (limited to 'functions')
-rw-r--r-- | functions | 48 |
1 files changed, 14 insertions, 34 deletions
@@ -192,26 +192,6 @@ in_array() { return 1 # Not Found } -pathlookup() { - # a basedir aware 'type -P' (or which) for executables - # $1: binary to find - - local path= - local -a paths= - - IFS=: read -r -a paths <<< "$PATH" - - for path in "${paths[@]}"; do - [[ ${path:0:1} = [.~] ]] && continue - if [[ -x $BASEDIR$path/$1 ]]; then - printf '%s' "$BASEDIR$path/$1" - return 0 - fi - done - - return 1 -} - _add_file() { # add a file to $BUILDROOT # $1: pathname on initcpio @@ -266,7 +246,7 @@ auto_modules() { IFS=$'\n' read -rd '' -a mods < \ <(find /sys/devices -name modalias -exec sort -u {} + | # delimit each input by a newline, expanded in place - xargs -d $'\n' modprobe -qd "$BASEDIR" -aRS "$KERNELVERSION" | + xargs -d $'\n' modprobe -qaRS "$KERNELVERSION" | sort -u) printf "%s\n" "${mods[@]//-/_}" @@ -333,12 +313,12 @@ add_module() { done ;; firmware) - if [[ -e "$BASEDIR/usr/lib/firmware/$value" ]]; then - _add_file "/usr/lib/firmware/$value" "$BASEDIR/usr/lib/firmware/$value" 644 + if [[ -e /usr/lib/firmware/$value ]]; then + _add_file "/usr/lib/firmware/$value" "/usr/lib/firmware/$value" 644 fi ;; esac - done < <(modinfo -b "$BASEDIR" -k "$KERNELVERSION" -0 "$module" 2>/dev/null) + done < <(modinfo -k "$KERNELVERSION" -0 "$module" 2>/dev/null) if [[ -z $path ]]; then (( ign_errors )) && return 0 @@ -410,7 +390,7 @@ add_file() { # determine source and destination local src= dest=${2:-$1} mode= - src=$BASEDIR$1 + src=$1 [[ -f "$src" ]] || { error "file not found: \`%s'" "$src"; return 1; } @@ -420,7 +400,7 @@ add_file() { return 1 fi - _add_file "${dest#$BASEDIR}" "$src" "$mode" + _add_file "$dest" "$src" "$mode" } add_binary() { @@ -433,9 +413,9 @@ add_binary() { local line= regex= binary= dest= mode= sodep= resolved= dirname= if [[ ${1:0:1} != '/' ]]; then - binary=$(pathlookup "$1") + binary=$(type -P "$1") else - binary=$BASEDIR$1 + binary=$1 fi [[ -f "$binary" ]] || { error "file not found: \`%s'" "$1"; return 1; } @@ -444,7 +424,7 @@ add_binary() { mode=$(stat -c %a "$binary") # always add the binary itself - _add_file "${dest#$BASEDIR}" "$binary" "$mode" + _add_file "$dest" "$binary" "$mode" lddout=$(ldd "$binary" 2>/dev/null) || return 0 # not a binary! @@ -455,13 +435,13 @@ add_binary() { if [[ -f $sodep && ! -e $BUILDROOT$sodep ]]; then if [[ ! -L $sodep ]]; then - _add_file "$sodep" "$BASEDIR$sodep" "$(stat -c %a "$sodep")" + _add_file "$sodep" "$sodep" "$(stat -c %a "$sodep")" else - resolved=$(readlink -e "$BASEDIR$sodep") + resolved=$(readlink -e "$sodep") dirname=${resolved%/*} - _add_dir "${dirname#$BASEDIR}" 755 - _add_symlink "$sodep" "${resolved#$BASEDIR}" - _add_file "${resolved#$BASEDIR}" "$resolved" 755 + _add_dir "$dirname" 755 + _add_symlink "$sodep" "$resolved" + _add_file "$resolved" "$resolved" 755 fi fi done <<< "$lddout" |