<p>I guess the only sane usecase is to create the ramfs from the instal medium. Currently, this functionality would let you generate a ramfs without installing mkinitcpio on the target machine. In the same way that you don't have to instal pacman. I don't know how useful this is...</p>

<div class="gmail_quote">On May 3, 2012 8:22 PM, "Dave Reisner" <<a href="mailto:dreisner@archlinux.org">dreisner@archlinux.org</a>> wrote:<br type="attribution"><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
This option is just a bad idea. Initramfs creation is too important to<br>
get wrong, and running it from outside the root FS has too many gotchas,<br>
the worst of them being:<br>
<br>
- where do you pull hooks from?<br>
- how do you resolve binary dependencies within the root?<br>
<br>
In general, dealing with the extra luggage of the base directory makes the<br>
codebase more complicated than it needs to be (see all the '_' prefixed<br>
functions which are called from add functions). In favor of simplifying the<br>
code, and making it more maintainable, kill this off and force the sane<br>
option of chroot'ing into an install if the need arises.<br>
<br>
Signed-off-by: Dave Reisner <<a href="mailto:dreisner@archlinux.org">dreisner@archlinux.org</a>><br>
---<br>
I suspect that no one will miss this option. I certainly won't. However,<br>
please speak up if you really do think you'll miss this option, and make<br>
your case for keeping it around.<br>
<br>
If no one objects, I'll be removing this with next proper release.<br>
<br>
 functions           |   48 ++++++++++++++----------------------------------<br>
 install/autodetect  |    4 ++--<br>
 install/consolefont |    6 +++---<br>
 install/fsck        |    4 ++--<br>
 install/keymap      |    2 +-<br>
 mkinitcpio          |   41 +++++++++++++----------------------------<br>
 mkinitcpio.8.txt    |    4 ----<br>
 7 files changed, 35 insertions(+), 74 deletions(-)<br>
<br>
diff --git a/functions b/functions<br>
index 0fec85b..2576180 100644<br>
--- a/functions<br>
+++ b/functions<br>
@@ -192,26 +192,6 @@ in_array() {<br>
     return 1 # Not Found<br>
 }<br>
<br>
-pathlookup() {<br>
-    # a basedir aware 'type -P' (or which) for executables<br>
-    #   $1: binary to find<br>
-<br>
-    local path=<br>
-    local -a paths=<br>
-<br>
-    IFS=: read -r -a paths <<< "$PATH"<br>
-<br>
-    for path in "${paths[@]}"; do<br>
-        [[ ${path:0:1} = [.~] ]] && continue<br>
-        if [[ -x $BASEDIR$path/$1 ]]; then<br>
-            printf '%s' "$BASEDIR$path/$1"<br>
-            return 0<br>
-        fi<br>
-    done<br>
-<br>
-    return 1<br>
-}<br>
-<br>
 _add_file() {<br>
     # add a file to $BUILDROOT<br>
     #   $1: pathname on initcpio<br>
@@ -266,7 +246,7 @@ auto_modules() {<br>
     IFS=$'\n' read -rd '' -a mods < \<br>
         <(find /sys/devices -name modalias -exec sort -u {} + |<br>
         # delimit each input by a newline, expanded in place<br>
-        xargs -d $'\n' modprobe -qd "$BASEDIR" -aRS "$KERNELVERSION" |<br>
+        xargs -d $'\n' modprobe -qaRS "$KERNELVERSION" |<br>
         sort -u)<br>
<br>
     printf "%s\n" "${mods[@]//-/_}"<br>
@@ -333,12 +313,12 @@ add_module() {<br>
                 done<br>
                 ;;<br>
             firmware)<br>
-                if [[ -e "$BASEDIR/usr/lib/firmware/$value" ]]; then<br>
-                    _add_file "/usr/lib/firmware/$value" "$BASEDIR/usr/lib/firmware/$value" 644<br>
+                if [[ -e /usr/lib/firmware/$value ]]; then<br>
+                    _add_file "/usr/lib/firmware/$value" "/usr/lib/firmware/$value" 644<br>
                 fi<br>
                 ;;<br>
         esac<br>
-    done < <(modinfo -b "$BASEDIR" -k "$KERNELVERSION" -0 "$module" 2>/dev/null)<br>
+    done < <(modinfo -k "$KERNELVERSION" -0 "$module" 2>/dev/null)<br>
<br>
     if [[ -z $path ]]; then<br>
         (( ign_errors )) && return 0<br>
@@ -410,7 +390,7 @@ add_file() {<br>
     # determine source and destination<br>
     local src= dest=${2:-$1} mode=<br>
<br>
-    src=$BASEDIR$1<br>
+    src=$1<br>
<br>
     [[ -f "$src" ]] || { error "file not found: \`%s'" "$src"; return 1; }<br>
<br>
@@ -420,7 +400,7 @@ add_file() {<br>
         return 1<br>
     fi<br>
<br>
-    _add_file "${dest#$BASEDIR}" "$src" "$mode"<br>
+    _add_file "$dest" "$src" "$mode"<br>
 }<br>
<br>
 add_binary() {<br>
@@ -433,9 +413,9 @@ add_binary() {<br>
     local line= regex= binary= dest= mode= sodep= resolved= dirname=<br>
<br>
     if [[ ${1:0:1} != '/' ]]; then<br>
-        binary=$(pathlookup "$1")<br>
+        binary=$(type -P "$1")<br>
     else<br>
-        binary=$BASEDIR$1<br>
+        binary=$1<br>
     fi<br>
<br>
     [[ -f "$binary" ]] || { error "file not found: \`%s'" "$1"; return 1; }<br>
@@ -444,7 +424,7 @@ add_binary() {<br>
     mode=$(stat -c %a "$binary")<br>
<br>
     # always add the binary itself<br>
-    _add_file "${dest#$BASEDIR}" "$binary" "$mode"<br>
+    _add_file "$dest" "$binary" "$mode"<br>
<br>
     lddout=$(ldd "$binary" 2>/dev/null) || return 0 # not a binary!<br>
<br>
@@ -455,13 +435,13 @@ add_binary() {<br>
<br>
         if [[ -f $sodep && ! -e $BUILDROOT$sodep ]]; then<br>
             if [[ ! -L $sodep ]]; then<br>
-                _add_file "$sodep" "$BASEDIR$sodep" "$(stat -c %a "$sodep")"<br>
+                _add_file "$sodep" "$sodep" "$(stat -c %a "$sodep")"<br>
             else<br>
-                resolved=$(readlink -e "$BASEDIR$sodep")<br>
+                resolved=$(readlink -e "$sodep")<br>
                 dirname=${resolved%/*}<br>
-                _add_dir "${dirname#$BASEDIR}" 755<br>
-                _add_symlink "$sodep" "${resolved#$BASEDIR}"<br>
-                _add_file "${resolved#$BASEDIR}" "$resolved" 755<br>
+                _add_dir "$dirname" 755<br>
+                _add_symlink "$sodep" "$resolved"<br>
+                _add_file "$resolved" "$resolved" 755<br>
             fi<br>
         fi<br>
     done <<< "$lddout"<br>
diff --git a/install/autodetect b/install/autodetect<br>
index 4ed7ccf..1daa429 100644<br>
--- a/install/autodetect<br>
+++ b/install/autodetect<br>
@@ -25,7 +25,7 @@ build() {<br>
     auto_modules >"$MODULE_FILE"<br>
<br>
     # detect filesystem for root<br>
-    if rootfstype=$(findmnt -uno fstype "${BASEDIR:-/}"); then<br>
+    if rootfstype=$(findmnt -uno fstype '/'); then<br>
         add_if_avail "$rootfstype"<br>
     else<br>
         error "failed to detect root filesystem"<br>
@@ -33,7 +33,7 @@ build() {<br>
     fi<br>
<br>
     # detect filesystem for separate /usr<br>
-    if usrfstype=$(findmnt -snero fstype --tab-file "$BASEDIR/etc/fstab" /usr); then<br>
+    if usrfstype=$(findmnt -snero fstype --tab-file '/etc/fstab' /usr); then<br>
         add_if_avail "$usrfstype"<br>
     fi<br>
<br>
diff --git a/install/consolefont b/install/consolefont<br>
index 2d2d8ea..5be9344 100644<br>
--- a/install/consolefont<br>
+++ b/install/consolefont<br>
@@ -6,19 +6,19 @@ build() {<br>
     # subshell to avoid namespace pollution<br>
     (<br>
         for cfg in etc/{rc,vconsole}.conf; do<br>
-            [[ -s $BASEDIR/$cfg ]] && . "$BASEDIR/$cfg"<br>
+            [[ -s $cfg ]] && . "$cfg"<br>
         done<br>
<br>
         [[ $FONT ]] && CONSOLEFONT=$FONT<br>
<br>
         if [[ $CONSOLEFONT ]]; then<br>
-            for file in "$BASEDIR/usr/share/kbd/consolefonts/$CONSOLEFONT".psf?(u)?(.gz); do<br>
+            for file in "/usr/share/kbd/consolefonts/$CONSOLEFONT".psf?(u)?(.gz); do<br>
                 if [[ -e $file ]]; then<br>
                     [[ $file =~ \.(psfu?)(\.gz)?$ ]] && ext=${BASH_REMATCH[1]}<br>
                     if [[ $file = *.gz ]]; then<br>
                         gzip -cd "$file" > "$BUILDROOT/consolefont.$ext"<br>
                     else<br>
-                        add_file "${file#$BASEDIR}" "/consolefont.$ext"<br>
+                        add_file "$file" "/consolefont.$ext"<br>
                     fi<br>
                     exit 0<br>
                 fi<br>
diff --git a/install/fsck b/install/fsck<br>
index baf1c3d..e8b5ea3 100644<br>
--- a/install/fsck<br>
+++ b/install/fsck<br>
@@ -21,9 +21,9 @@ build() {<br>
             add_fsck $usrfstype && (( ++added ))<br>
         fi<br>
     else<br>
-        for fsck in "$BASEDIR"/{usr/,}{s,}bin/fsck.*; do<br>
+        for fsck in /{usr/,}{s,}bin/fsck.*; do<br>
             [[ -f $fsck ]] || continue<br>
-            add_binary "${fsck#$BASEDIR}" && (( ++added ))<br>
+            add_binary "$fsck" && (( ++added ))<br>
         done<br>
     fi<br>
<br>
diff --git a/install/keymap b/install/keymap<br>
index fe5e459..1cbf75e 100644<br>
--- a/install/keymap<br>
+++ b/install/keymap<br>
@@ -8,7 +8,7 @@ build() {<br>
         unset LANG<br>
<br>
         for cfg in etc/{rc,vconsole,locale}.conf; do<br>
-            [[ -s $BASEDIR/$cfg ]] && . "$BASEDIR/$cfg"<br>
+            [[ -s $cfg ]] && . "$cfg"<br>
         done<br>
<br>
         [[ $LANG ]] && LOCALE=$LANG<br>
diff --git a/mkinitcpio b/mkinitcpio<br>
index 084dff7..f7fc571 100755<br>
--- a/mkinitcpio<br>
+++ b/mkinitcpio<br>
@@ -22,7 +22,7 @@ INSTDIR=(install /usr/lib/initcpio/install /lib/initcpio/install)<br>
 PRESETDIR=mkinitcpio.d<br>
 COMPRESSION=gzip<br>
<br>
-declare BASEDIR= MODULE_FILE= GENIMG= PRESET= COMPRESSION_OPTIONS= BUILDROOT=<br>
+declare MODULE_FILE= GENIMG= PRESET= COMPRESSION_OPTIONS= BUILDROOT=<br>
 declare NC= BOLD= BLUE= GREEN= RED= YELLOW=<br>
 declare -i QUIET=1 SHOW_AUTOMODS=0 SAVELIST=0 COLOR=1<br>
 declare -a SKIPHOOKS ADDED_MODULES MODPATHS<br>
@@ -42,7 +42,6 @@ usage: ${0##*/} [options]<br>
<br>
   Options:<br>
    -A, --add <hooks>            Add specified hooks, comma separated, to image<br>
-   -b, --basedir <dir>          Use alternate base directory. (default: /)<br>
    -c, --config <config>        Use alternate config file. (default: /etc/mkinitcpio.conf)<br>
    -g, --generate <path>        Generate cpio image and write to specified path<br>
    -H, --hookhelp <hookname>    Display help for given hook and exit<br>
@@ -87,18 +86,18 @@ get_kernver() {<br>
         return 0<br>
     fi<br>
<br>
-    if [[ ! -e $BASEDIR$kernel ]]; then<br>
-        error "Specified kernel image does not exist: \`%s'" "$BASEDIR$kernel"<br>
+    if [[ ! -e $kernel ]]; then<br>
+        error "Specified kernel image does not exist: \`%s'" "$kernel"<br>
         return 1<br>
     fi<br>
<br>
-    read _ kernver < <(file -Lb "$BASEDIR$kernel" | grep -o 'version [^ ]\+')<br>
-    if [[ $kernver && -e $BASEDIR/lib/modules/$kernver ]]; then<br>
+    read _ kernver < <(file -Lb "$kernel" | grep -o 'version [^ ]\+')<br>
+    if [[ $kernver && -e /lib/modules/$kernver ]]; then<br>
         echo "$kernver"<br>
         return 0<br>
     fi<br>
<br>
-    [[ ${optkver:0:1} == / ]] && optkver=$BASEDIR$optkver<br>
+    [[ ${optkver:0:1} == / ]] && optkver=$optkver<br>
     error "invalid kernel specifier: \`%s'" "$optkver"<br>
<br>
     return 1<br>
@@ -116,9 +115,9 @@ compute_hookset() {<br>
 trap 'cleanup 130' INT<br>
 trap 'cleanup 143' TERM<br>
<br>
-OPT_SHORT='A:b:c:g:H:hk:mnLMp:S:st:vz:'<br>
-OPT_LONG=('add:' 'basedir:' 'config:' 'generate:' 'hookhelp:' 'help' 'kernel:' 'listhooks'<br>
-          'automods' 'nocolor' 'preset:' 'skiphooks:' 'save' 'builddir:' 'verbose' 'compress:')<br>
+OPT_SHORT='A:c:g:H:hk:mnLMp:S:st:vz:'<br>
+OPT_LONG=('add:' 'config:' 'generate:' 'hookhelp:' 'help' 'kernel:' 'listhooks' 'automods'<br>
+          'nocolor' 'preset:' 'skiphooks:' 'save' 'builddir:' 'verbose' 'compress:')<br>
<br>
 if ! parseopts "$OPT_SHORT" "${OPT_LONG[@]}" -- "$@"; then<br>
     exit 1<br>
@@ -141,9 +140,6 @@ while :; do<br>
             optkver=$1 ;;<br>
         -s|--save)<br>
             SAVELIST=1 ;;<br>
-        -b|--basedir)<br>
-            shift<br>
-            BASEDIR=$1 ;;<br>
         -g|--generate)<br>
             shift<br>
             GENIMG=$1 ;;<br>
@@ -224,16 +220,6 @@ readonly NC BOLD BLUE GREEN RED YELLOW<br>
 [[ -e /proc/self/mountinfo ]] || die "/proc must be mounted!"<br>
 [[ -e /dev/fd ]] || die "/dev must be mounted!"<br>
<br>
-if [[ $BASEDIR ]]; then<br>
-    # resolve the path. it might be a relative path and/or contain symlinks<br>
-    if ! pushd "$BASEDIR" &>/dev/null; then<br>
-        die "base directory does not exist or is not a directory: \`%s'" "$BASEDIR"<br>
-    fi<br>
-    BASEDIR=$(pwd -P)<br>
-    BASEDIR=${BASEDIR%/}<br>
-    popd &>/dev/null<br>
-fi<br>
-<br>
 KERNELVERSION=$(get_kernver "$optkver") || cleanup 1<br>
<br>
 if [[ $TMPDIR ]]; then<br>
@@ -261,7 +247,6 @@ if [[ $PRESET ]]; then<br>
     if [[ -f "$PRESET" ]]; then<br>
         # Use -b, -m and -v options specified earlier<br>
         declare -a preset_mkopts preset_cmd<br>
-        [[ $BASEDIR ]] && preset_mkopts+=(-b "$BASEDIR")<br>
         (( QUIET )) || preset_mkopts+=(-v)<br>
         # Build all images<br>
         . "$PRESET"<br>
@@ -279,7 +264,7 @@ if [[ $PRESET ]]; then<br>
<br>
             preset_config=${p}_config<br>
             if [[ ${!preset_config:-$ALL_config} ]]; then<br>
-              preset_cmd+=(-c "$BASEDIR${!preset_config:-$ALL_config}")<br>
+              preset_cmd+=(-c "${!preset_config:-$ALL_config}")<br>
             else<br>
                 warning "No configuration file specified. Skipping image \`%s'" "$p"<br>
                 continue<br>
@@ -287,7 +272,7 @@ if [[ $PRESET ]]; then<br>
<br>
             preset_image=${p}_image<br>
             if [[ ${!preset_image} ]]; then<br>
-                preset_cmd+=(-g "$BASEDIR${!preset_image}")<br>
+                preset_cmd+=(-g "${!preset_image}")<br>
             else<br>
                 warning "No image file specified. Skipping image \`%s'" "$p"<br>
                 continue<br>
@@ -327,7 +312,7 @@ if (( ${#hooks[*]} == 0 )); then<br>
     die "Invalid config: No hooks found"<br>
 fi<br>
<br>
-MODULEDIR=$BASEDIR/lib/modules/$KERNELVERSION/<br>
+MODULEDIR=/lib/modules/$KERNELVERSION/<br>
 if [[ ! -d $MODULEDIR ]]; then<br>
     die "'$MODULEDIR' is not a valid kernel module directory"<br>
 fi<br>
@@ -416,7 +401,7 @@ if (( ${#ADDED_MODULES[*]} )); then<br>
<br>
     msg "Generating module dependencies"<br>
     install -m644 -t "$BUILDROOT/usr/lib/modules/$KERNELVERSION" \<br>
-        "$BASEDIR/lib/modules/$KERNELVERSION"/modules.{builtin,order}<br>
+        "/lib/modules/$KERNELVERSION"/modules.{builtin,order}<br>
     depmod -b "$BUILDROOT" "$KERNELVERSION"<br>
<br>
     # remove all non-binary module.* files (except devname for on-demand module loading)<br>
diff --git a/mkinitcpio.8.txt b/mkinitcpio.8.txt<br>
index 4b0d770..14a349b 100644<br>
--- a/mkinitcpio.8.txt<br>
+++ b/mkinitcpio.8.txt<br>
@@ -29,10 +29,6 @@ Options<br>
        after all other hooks from the config file. Multiple hooks should be<br>
        comma-separated. This option can be specified multiple times.<br>
<br>
-*-b, \--basedir* 'basedir'::<br>
-       Use 'basedir' as a starting point for gathering information about the<br>
-       currently running system. Default: /.<br>
-<br>
 *-c, \--config* 'config'::<br>
        Use 'config' file to generate the ramdisk. Default: /etc/mkinitcpio.conf<br>
<br>
--<br>
1.7.10.1<br>
<br>
</blockquote></div>