[arch-projects] [mkinitcpio][PATCH 0/5] basedir fixes
Had some amazing help from Gerardo to polish up $BASEDIR. He made a couple of images from outside of a root and was able to boot off them. I've verified on my end that after these changes we're still able make a useable image for the simple testcase. Yay teamwork! Dave Reisner (5): functions: add missing 'command' before install functions: s/basedir/BASEDIR/ functions: fix pathing issue with $BASEDIR install/base: use private API call to add config mkinitcpio: fix resolution issues with RTLD functions | 12 ++++++------ install/base | 4 +++- mkinitcpio | 7 +++---- 3 files changed, 12 insertions(+), 11 deletions(-) -- 1.7.5.4
Without this, we hit an infinte loop and crash when a legacy 'install' function in a hook is encountered. Thanks-to: Gerardo Exequiel Pozzi <vmlinuz386@yahoo.com.ar> Signed-off-by: Dave Reisner <dreisner@archlinux.org> --- functions | 2 +- 1 files changed, 1 insertions(+), 1 deletions(-) diff --git a/functions b/functions index ee6921c..8e3588a 100644 --- a/functions +++ b/functions @@ -221,7 +221,7 @@ _add_file() { [[ -e "$BUILDROOT$1" ]] && return $EEXIST (( QUIET )) || plain "adding file: %s" "$1" - install -Dm$3 "$2" "$BUILDROOT$1" + command install -Dm$3 "$2" "$BUILDROOT$1" } _add_dir() { -- 1.7.5.4
Thanks-to: Gerardo Exequiel Pozzi <vmlinuz386@yahoo.com.ar> Signed-off-by: Dave Reisner <dreisner@archlinux.org> --- functions | 4 ++-- 1 files changed, 2 insertions(+), 2 deletions(-) diff --git a/functions b/functions index 8e3588a..54442c8 100644 --- a/functions +++ b/functions @@ -278,9 +278,9 @@ add_binary() { if [[ ! -L $sodep ]]; then _add_file "$sodep" "$BASEDIR$sodep" "$(stat -c %a "$sodep")" else - resolved=$(readlink -e "$basedir$sodep") + resolved=$(readlink -e "$BASEDIR$sodep") dirname=${resolved%/*} - _add_dir "${dirname#$basedir}" 755 + _add_dir "${dirname#$BASEDIR}" 755 _add_symlink "$sodep" "${resolved#$BASEDIR}" _add_file "${resolved#$BASEDIR}" "$resolved" 755 fi -- 1.7.5.4
Thanks-to: Gerardo Exequiel Pozzi <vmlinuz386@yahoo.com.ar> Signed-off-by: Dave Reisner <dreisner@archlinux.org> --- functions | 6 +++--- 1 files changed, 3 insertions(+), 3 deletions(-) diff --git a/functions b/functions index 54442c8..9c095bc 100644 --- a/functions +++ b/functions @@ -182,7 +182,7 @@ add_module() { # get module firmware while read -r -d '' fw; do if [[ -e "$BASEDIR/lib/firmware/$fw" ]]; then - add_file "$BASEDIR/lib/firmware/$fw" + add_file "/lib/firmware/$fw" fi done < <(kmodinfo -0F firmware "$module") @@ -193,7 +193,7 @@ add_module() { done ADDED_MODULES+=("${module//-/_}") - add_file "$path" || return + add_file "${path#$BASEDIR}" || return else error "module '$module' not found" return 1 @@ -265,7 +265,7 @@ add_binary() { mode=$(stat -c %a "$binary") # always add the binary itself - _add_file "${dest#$BASEDIR}" "${binary#$BASEDIR}" "$mode" + _add_file "${dest#$BASEDIR}" "$binary" "$mode" $LD_SO --verify "$binary" &>/dev/null || return # not a binary! -- 1.7.5.4
We can't let add_file get its hands on the config file, because we need to be sure that an absolute path is honored. As a side effect, ensure that $BASEDIR is appended to the config file during preset processing. Thanks-to: Gerardo Exequiel Pozzi <vmlinuz386@yahoo.com.ar> Signed-off-by: Dave Reisner <dreisner@archlinux.org> --- install/base | 4 +++- mkinitcpio | 2 +- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/install/base b/install/base index d5fcef7..446167c 100644 --- a/install/base +++ b/install/base @@ -11,8 +11,10 @@ build() { add_file "/lib/initcpio/init_functions" "/init_functions" add_file "/lib/initcpio/init" "/init" - add_file "$CONFIG" "/config" add_file "/etc/modprobe.d/usb-load-ehci-first.conf" + + # private API call is required here + _add_file "/config" "$CONFIG" 644 } help() { diff --git a/mkinitcpio b/mkinitcpio index 7a30be0..5389aca 100755 --- a/mkinitcpio +++ b/mkinitcpio @@ -209,7 +209,7 @@ if [[ $PRESET ]]; then preset_config=${p}_config if [[ ${!preset_config:-$ALL_config} ]]; then - preset_cmd+=(-c "${!preset_config:-$ALL_config}") + preset_cmd+=(-c "$BASEDIR${!preset_config:-$ALL_config}") else warning "No configuration file specified. Skipping image '%s'" "$p" continue -- 1.7.5.4
The _add_dir call is all wrong. The necessary paths are created by reversing the order of the _add_symlink and _add_file calls, as _add_file will take care of creating parent directories. Thanks-to: Gerardo Exequiel Pozzi <vmlinuz386@yahoo.com.ar> Signed-off-by: Dave Reisner <dreisner@archlinux.org> --- mkinitcpio | 5 ++--- 1 files changed, 2 insertions(+), 3 deletions(-) diff --git a/mkinitcpio b/mkinitcpio index 5389aca..459c828 100755 --- a/mkinitcpio +++ b/mkinitcpio @@ -306,9 +306,8 @@ if (( ${#LD_SO[*]} != 1 )); then # uh oh... fi resolved=$(readlink -e "$LD_SO") -_add_dir "${resolved%/*}" 755 -_add_symlink "${LD_SO#$BASEDIR}" "${resolved#$BASEDIR}" -_add_file "${resolved#$BASEDIR}" "${resolved#$BASEDIR}" 755 +_add_file "${resolved#$BASEDIR}" "$resolved" 755 +_add_symlink "${LD_SO#$BASEDIR}" "$resolved" unset resolved for hook in ${HOOKS}; do -- 1.7.5.4
Am 27.06.2011 02:32, schrieb Dave Reisner:
Had some amazing help from Gerardo to polish up $BASEDIR. He made a couple of images from outside of a root and was able to boot off them. I've verified on my end that after these changes we're still able make a useable image for the simple testcase.
Yay teamwork!
Pulled. Thanks Dave and Gerardo.
participants (2)
-
Dave Reisner
-
Thomas Bächler