From 5f81d06e8b879e1778649405b314d60234934dfc Mon Sep 17 00:00:00 2001 From: Dave Reisner Date: Tue, 29 May 2012 10:12:40 -0400 Subject: 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 --- functions | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) (limited to 'functions') diff --git a/functions b/functions index e9fb81a..e17e46e 100644 --- a/functions +++ b/functions @@ -606,6 +606,32 @@ write_image_config() { ) >"$BUILDROOT/config" } +initialize_buildroot() { + # creates a temporary directory for the buildroot and initialize it with a + # basic set of necessary directories and symlinks + + local workdir= kernver=$1 + + if ! workdir=$(mktemp -d --tmpdir mkinitcpio.XXXXXX); then + error 'Failed to create temporary working directory in %s' "${TMPDIR:-/tmp}" + return 1 + fi + + # base directory structure + install -dm755 "$workdir/root"/{new_root,proc,sys,dev,run,tmp,usr/{local,lib,bin}} + ln -s "usr/lib" "$workdir/root/lib" + ln -s "../lib" "$workdir/root/usr/local/lib" + ln -s "bin" "$workdir/root/usr/sbin" + ln -s "usr/bin" "$workdir/root/bin" + ln -s "usr/bin" "$workdir/root/sbin" + ln -s "../bin" "$workdir/root/usr/local/bin" + + # kernel module dir + install -dm755 "$workdir/root/usr/lib/modules/$kernver/kernel" + + printf '%s' "$workdir" +} + run_build_hook() { local hook=$1 script= realscript= local MODULES= BINARIES= FILES= SCRIPT= -- cgit v1.2.3-24-g4f1b