diff options
-rw-r--r-- | functions | 26 | ||||
-rw-r--r-- | install/base | 11 | ||||
-rwxr-xr-x | mkinitcpio | 35 |
3 files changed, 36 insertions, 36 deletions
@@ -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= diff --git a/install/base b/install/base index 30ad3fa..7bb23a8 100644 --- a/install/base +++ b/install/base @@ -1,16 +1,7 @@ #!/bin/bash build() { - local dir applet - - for dir in new_root proc sys dev run tmp usr/bin; do - add_dir "/$dir" - done - - add_symlink /lib usr/lib - add_symlink /sbin usr/bin - add_symlink /bin usr/bin - add_symlink /usr/sbin bin + local applet add_binary /usr/lib/initcpio/busybox /bin/busybox @@ -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 |