summaryrefslogtreecommitdiffstats
path: root/functions
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 /functions
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 'functions')
-rw-r--r--functions26
1 files changed, 26 insertions, 0 deletions
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=