summaryrefslogtreecommitdiffstats
path: root/mkinitcpio
diff options
context:
space:
mode:
authorDave Reisner <dreisner@archlinux.org>2012-05-29 16:12:40 +0200
committerDave Reisner <dreisner@archlinux.org>2012-07-15 16:29:08 +0200
commit5f81d06e8b879e1778649405b314d60234934dfc (patch)
tree94a207718e239cde141b31c311fcceee625ca608 /mkinitcpio
parentc4fcc20e9446ed0715681c0d664feb7cb3af2bbb (diff)
downloadmkinitcpio-5f81d06e8b879e1778649405b314d60234934dfc.tar.gz
mkinitcpio-5f81d06e8b879e1778649405b314d60234934dfc.tar.xz
initalize buildroot later, and out outside of hooks
mkinitcpio needs to be able to more tightly control the layout of the image. By moving this outside the control of the base hook, it's more reasonable to believe that a drop-in replacement for the base hook could be written, as it now only contains the utilities required for the /init that it provides. Being that initialize_buildroot is outside of a hook, we can make "raw" calls to coreutils that create the directories and symlinks, saving some overhead and forking. This also symlinks /usr/local/{lib,bin} into the common /usr/lib and /usr/bin, respectively, so that there's always a way to override libs and bins, and they're automatically pulled into our strict early init path of /usr/bin. Finally, we lump all this generally a little "later" in the early setup. This addresses an unseen "bug" wherein an extra temp directory that never gets used is created when leveraging a preset. Signed-off-by: Dave Reisner <dreisner@archlinux.org>
Diffstat (limited to 'mkinitcpio')
-rwxr-xr-xmkinitcpio35
1 files changed, 9 insertions, 26 deletions
diff --git a/mkinitcpio b/mkinitcpio
index 0834dc0..5202e7f 100755
--- a/mkinitcpio
+++ b/mkinitcpio
@@ -195,7 +195,7 @@ while :; do
SHOW_AUTOMODS=1 ;;
-t|--builddir)
shift
- TMPDIR=$1 ;;
+ export TMPDIR=$1 ;;
-z|--compress)
shift
optcompress=$1 ;;
@@ -232,24 +232,6 @@ readonly NC BOLD BLUE GREEN RED YELLOW
[[ -e /proc/self/mountinfo ]] || die "/proc must be mounted!"
[[ -e /dev/fd ]] || die "/dev must be mounted!"
-KERNELVERSION=$(resolve_kernver "$optkver") || cleanup 1
-
-if [[ $TMPDIR ]]; then
- if [[ ! -d $TMPDIR ]]; then
- error "Temporary directory does not exist or is not a directory: \`%s'" "$TMPDIR"
- cleanup 1
- fi
- if [[ ! -w $TMPDIR ]]; then
- error "Temporary directory is not writeable: \`%s'" "$TMPDIR"
- cleanup 1
- fi
-fi
-workdir=$(TMPDIR=$TMPDIR mktemp -d --tmpdir mkinitcpio.XXXXXX)
-BUILDROOT=$workdir/root
-
-# explicitly create the buildroot
-mkdir -p "$BUILDROOT/usr/lib/modules/$KERNELVERSION/kernel"
-
# use preset $PRESET
if [[ $PRESET ]]; then
# allow absolute path to preset file, else resolve it
@@ -304,10 +286,14 @@ if [[ $PRESET ]]; then
fi
fi
-if [[ ! -f $CONFIG ]]; then
- die "Config file does not exist: \`%s'" "$CONFIG"
-fi
-. "$CONFIG"
+KERNELVERSION=$(resolve_kernver "$optkver") || cleanup 1
+MODULEDIR=$(find_moduledir "$KERNELVERSION") || cleanup 1
+
+# initialize the working directory and buildroot
+workdir=$(initialize_buildroot "$KERNELVERSION") || cleanup 1
+BUILDROOT=$workdir/root
+
+. "$CONFIG" || die "Failed to read configuration \`%s'" "$CONFIG"
# after returning, hooks are populated into the array 'hooks'
# HOOKS should not be referenced from here on
@@ -317,8 +303,6 @@ if (( ${#hooks[*]} == 0 )); then
die "Invalid config: No hooks found"
fi
-MODULEDIR=$(find_moduledir "$KERNELVERSION") || cleanup 1
-
if [[ ! -d $MODULEDIR ]]; then
die "'$MODULEDIR' is not a valid kernel module directory"
fi
@@ -332,7 +316,6 @@ if (( SHOW_AUTOMODS )); then
cleanup 0
fi
-
if [[ -z $GENIMG ]]; then
msg "Starting dry run: %s" "$KERNELVERSION"
else