diff options
author | Dave Reisner <d@falconindy.com> | 2011-06-18 02:01:35 +0200 |
---|---|---|
committer | Thomas Bächler <thomas@archlinux.org> | 2011-06-25 12:25:45 +0200 |
commit | 840893e2b37470749d11e249becdba40b91adc92 (patch) | |
tree | 471e03e8ef170ad7cee9803c108673348a12f629 /mkinitcpio | |
parent | 99c2b87cdbc3f449b68ed6d0bf2fec624d539972 (diff) | |
download | mkinitcpio-840893e2b37470749d11e249becdba40b91adc92.tar.gz mkinitcpio-840893e2b37470749d11e249becdba40b91adc92.tar.xz |
properly support $BASEDIR
This add proper support for a $BASEDIR, wherein as much as possible is
taken from the user specified root, instead of mixing and matching
binaries and modules. This avoids conflicts, particularly with binaries
like udev or module-init-tools which may have newer functionality that
the root in the $BASEDIR requires.
This is somewhat of a large patch, which involves a few key changes:
1) Add a new class of "private" functions: _add_*, which act as a "back
end" for the equivalent non-underscore-prefixed functions.
2) Refactor the add_* family of functions to use these new back end
functions. This generally simplifies the logic as we have a clear
division of labor.
3) Instead of using ldd, which is a glorified wrapper around the RTLD,
create a wrapper around the RTLD and invoke it ourselves. This is
basically just a small performance improvement -- the bulk of the
parsing done by this function's output is done in pure bash.
Signed-off-by: Dave Reisner <d@falconindy.com>
Diffstat (limited to 'mkinitcpio')
-rwxr-xr-x | mkinitcpio | 20 |
1 files changed, 19 insertions, 1 deletions
@@ -14,6 +14,7 @@ shopt -s extglob # Settings KERNELVERSION=$(uname -r) +CARCH=$(uname -m) FUNCTIONS=functions CONFIG=mkinitcpio.conf HOOKDIR=hooks @@ -21,7 +22,7 @@ INSTDIR=install PRESETDIR=mkinitcpio.d COMPRESSION=gzip -declare TMPDIR BASEDIR MODULE_FILE GENIMG PRESET COMPRESSION_OPTIONS BUILDROOT +declare TMPDIR BASEDIR MODULE_FILE GENIMG PRESET COMPRESSION_OPTIONS BUILDROOT LD_SO declare NC= BOLD= BLUE= GREEN= RED= YELLOW= declare -i QUIET=1 SHOW_AUTOMODS=0 SAVELIST=0 COLOR=1 declare -a SKIPHOOKS ADDED_MODULES @@ -285,6 +286,23 @@ trap '[[ $FUNCNAME = parse_hook ]] && (( ++builderrors ))' ERR #parse 'global' hook, as defined in ${CONFIG} parse_hook +# resolve the linker and add it +case $CARCH in + i686) LD_SO=("$BASEDIR"/lib/ld-linux.so.?*) ;; + x86_64) LD_SO=("$BASEDIR"/lib/ld-linux-${CARCH//_/-}.so.?*) ;; + *) die "unknown architecture: $CARCH" ;; +esac + +if (( ${#LD_SO[*]} != 1 )); then # uh oh... + die "failed to resolve the location of /lib/ld.so. Please report this bug." +fi + +resolved=$(readlink -e "$LD_SO") +_add_dir "${resolved%/*}" 755 +_add_symlink "${LD_SO#$BASEDIR}" "${resolved#$BASEDIR}" +_add_file "${resolved#$BASEDIR}" "${resolved#$BASEDIR}" 755 +unset resolved + for hook in ${HOOKS}; do in_array "$hook" "${SKIPHOOKS[@]}" && continue unset MODULES BINARIES FILES SCRIPT |