[arch-projects] [mkinitcpio] 0.12.0 feature release review
arch-projects has been fairly quietly recently, so here's a patch dump for interested parties to amuse themselves with. This is what I'm looking at merging for the next release. Most of it is fairly innocuous and there's the usual occurences of cleanup and bugfixing, but there's a few things worth explicitly calling out: * I'm merging all of the block device build hooks into a single "block" hook. So previously, if your array had "pata sata scsi" in it, you now can replace all that with "block". Since this will also include things like "usb" and "virtio", there's some nice surprises for people who previously had to add these things explicitly. * Addition of a modconf hook, which will be added by default. Rather than have people explicitly add their modprobe.conf (which is no longer the "right thing" as per upstream, this hook will just add the entirety of /{etc,lib}/modprobe.d to the image. I think this is generally the right thing to do as it would be rare that you want an option in early userspace and not later, and vice versa. * Dropping support for /etc/rc.conf. This means that the keymap and consolefont hooks will no longer read from /etc/rc.conf, but only from /etc/vconsole.conf and /etc/locale.conf. We've been slowly dropping this support in other places, and I think it makes sense to do this here as well. * Dropping support for old hook API. No one should really notice this. I personally did the work to update the hooks in the repos when I introduced the new API several months ago, and I prodded some of the hook authors in the AUR to update. Full shortlog below. Latest patches can always be found at: git://code.falconindy.com/mkinitcpio But I don't expect much to change at this point. Cheers, Dave Dave Reisner (18): shutdown: share dm teardown with lvm shutdown: avoid talking to udev via dmsetup shutdown: copy kexec from host if requested and not available usbinput: use autodetection on newer kernels init: condense early module loading init: use exponential backoff in poll_device init: remove needless workaround for empty rootdelay init: declare defaults earlier init: remove unneeded variable expansion drop support for reading /etc/rc.conf obsolete old-style install hook API build: move manpages to subdir functions: only show the basename of a deprecated hook Makefile: copy directories, not individual files on install merge most storage hooks into a single 'block' hook modconf: add new hook to simply inclusion of modprobe config unique _modpaths arrays in during build selectively decompress modules on install Makefile | 19 ++- functions | 73 ++++-------- init | 14 +-- init_functions | 24 ++-- install/block | 45 +++++++ install/consolefont | 9 +- install/fw | 22 +--- install/keymap | 5 +- install/mmc | 19 +-- install/modconf | 15 +++ install/pata | 22 +--- install/sata | 23 +--- install/scsi | 22 +--- install/usb | 21 +--- install/usbinput | 15 ++- install/virtio | 16 +-- lsinitcpio.1.txt | 68 ----------- man/lsinitcpio.1.txt | 68 +++++++++++ man/mkinitcpio.8.txt | 297 +++++++++++++++++++++++++++++++++++++++++++++ man/mkinitcpio.conf.5.txt | 82 +++++++++++++ mkinitcpio | 38 ++++-- mkinitcpio.8.txt | 298 ---------------------------------------------- mkinitcpio.conf | 17 +-- mkinitcpio.conf.5.txt | 82 ------------- shutdown | 30 +++-- 25 files changed, 637 insertions(+), 707 deletions(-) create mode 100644 install/block mode change 100644 => 120000 install/fw mode change 100644 => 120000 install/mmc create mode 100644 install/modconf mode change 100644 => 120000 install/pata mode change 100644 => 120000 install/sata mode change 100644 => 120000 install/scsi mode change 100644 => 120000 install/usb mode change 100644 => 120000 install/virtio delete mode 100644 lsinitcpio.1.txt create mode 100644 man/lsinitcpio.1.txt create mode 100644 man/mkinitcpio.8.txt create mode 100644 man/mkinitcpio.conf.5.txt delete mode 100644 mkinitcpio.8.txt delete mode 100644 mkinitcpio.conf.5.txt -- 1.8.0
lvm is a chatty bitch and wants to tell all its friends about what it's doing. Mostly this just goes poorly with udev, but now its lvmetad as well. Use dmsetup as a shortcut and just tear down the volumes without worrying about the needless accounting. Guys? GUYS?!?! GUYS IM TEARING STUFF DOWN NOW!!!11!!!111 Fixes FS#32680. Signed-off-by: Dave Reisner <dreisner@archlinux.org> --- shutdown | 10 +--------- 1 file changed, 1 insertion(+), 9 deletions(-) diff --git a/shutdown b/shutdown index e13e6fb..88ec9ca 100644 --- a/shutdown +++ b/shutdown @@ -16,18 +16,10 @@ stop_device() { read devname <"$1/dm/name" cryptsetup remove "$devname" ;; - dm) + lvm|dm) read devname <"$1/dm/name" dmsetup remove "$devname" ;; - lvm) - # disassemble the parent VG - read devname <"$1/dm/name" - lvm lvdisplay -c "/dev/mapper/$devname" | { - IFS=: read _ vgname _ - lvm vgchange --noudevsync -an "$vgname" - } - ;; raid*) # wait for arrays with external metadata to be marked as # clean. unfortunately, there isn't a whole lot we can do -- 1.8.0
Similar to c257b0d7b4dd. Signed-off-by: Dave Reisner <dreisner@archlinux.org> --- shutdown | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/shutdown b/shutdown index 88ec9ca..c705541 100644 --- a/shutdown +++ b/shutdown @@ -18,7 +18,7 @@ stop_device() { ;; lvm|dm) read devname <"$1/dm/name" - dmsetup remove "$devname" + dmsetup --noudevsync remove "$devname" ;; raid*) # wait for arrays with external metadata to be marked as -- 1.8.0
Signed-off-by: Dave Reisner <dreisner@archlinux.org> --- shutdown | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/shutdown b/shutdown index c705541..dc293d4 100644 --- a/shutdown +++ b/shutdown @@ -50,10 +50,28 @@ disassemble() { done } +copy_binary_from_host() { + local bin=$1 + + # hardcode a sane PATH + for p in '/usr/sbin' '/usr/bin' '/sbin' '/bin'; do + if [ -e "/oldroot/$p/$bin" ]; then + cp "/oldroot/$p/$bin" "/usr/bin/$1" + return 0 + fi + done + + return 1 +} + # XXX: Discourage libdevmapper from thinking that udev # might be in a useful state. FS#30995. rm -rf /run/udev +if [ "$1" = kexec ] && ! command -v kexec >/dev/null; then + copy_binary_from_host kexec +fi + # chdir, so that we can avoid a lot of path chopping cd /sys/class/block -- 1.8.0
This is a partial "revert" of 822a88700e since kernels as of 3.5 add module aliases for hid devices. Fixes FS#32575. Signed-off-by: Dave Reisner <dreisner@archlinux.org> --- install/usbinput | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/install/usbinput b/install/usbinput index f427600..a292345 100644 --- a/install/usbinput +++ b/install/usbinput @@ -1,9 +1,20 @@ #!/bin/bash build() { + local major minor + add_checked_modules -f '(_cs|sl811_hcd|isp116x_hcd)' '/usb/host' - add_all_modules '/hid/hid-' - add_module 'usbhid?' + + # As of 3.5, modaliases seem to be exported for HID + # devices, so we can leverage autodetection. + IFS=.- read major minor _ <<<"$KERNELVERSION" + if (( major > 3 || (major == 3 && minor >= 5) )); then + add_checked_modules '/hid/hid' + else + add_all_modules '/hid/hid' + fi + + add_module 'usbhid' } help() { -- 1.8.0
Since mkinitcpio rewrites its runtime config, we can guarantee that these variable are sanitized of extraneous whitespace. Meld the two calls together, ensuring that we retain the ordering, but only call modprobe once. Signed-off-by: Dave Reisner <dreisner@archlinux.org> --- init | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/init b/init index b95565d..3351cfc 100644 --- a/init +++ b/init @@ -24,8 +24,9 @@ done run_hookfunctions 'run_earlyhook' 'early hook' $EARLYHOOKS -[ -n "${earlymodules//[[:space:]]}" ] && modprobe -qab ${earlymodules//,/ } -[ -n "${MODULES//[[:space:]]}" ] && modprobe -qab $MODULES +if [ -n "$earlymodules$MODULES" ]; then + modprobe -qab ${earlymodules//,/ } $MODULES +fi # If rootdelay is empty or not a non-negative integer, set it to 10 if [ -z "${rootdelay}" ] || ! [ "${rootdelay}" -ge 0 ]; then -- 1.8.0
Start at .1 second and double the interval, capping at 1s. Signed-off-by: Dave Reisner <dreisner@archlinux.org> --- init_functions | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-) diff --git a/init_functions b/init_functions index 3ac0588..2bd07bd 100644 --- a/init_functions +++ b/init_functions @@ -11,14 +11,24 @@ poll_device() { local device=$1 seconds=${2//[!0-9]} [ -z "$seconds" ] && seconds=10 + deciseconds=$(( seconds * 10 )) + + # tenths of a second + sleepinterval=1 [ -b "$device" ] && return 0 if [ "$udevd_running" -eq 1 ]; then msg "Waiting $seconds seconds for device $device ..." >&2 - while [ ! -b "$device" -a "$seconds" -gt 0 ]; do - sleep 1 - seconds=$(( $seconds - 1 )) + while [ ! -b "$device" -a "$deciseconds" -gt 0 ]; do + if [ "$sleepinterval" -ge 10 ]; then + sleep 1 + deciseconds=$(( deciseconds - 10 )) + else + sleep .$sleepinterval + deciseconds=$(( deciseconds - sleepinterval )) + sleepinterval=$(( sleepinterval * 2 )) + fi done fi -- 1.8.0
Adjust the test in poll_device to look for either an unset OR an empty 2nd parameter. Signed-off-by: Dave Reisner <dreisner@archlinux.org> --- init | 6 +----- init_functions | 2 +- 2 files changed, 2 insertions(+), 6 deletions(-) diff --git a/init b/init index 3351cfc..b375e72 100644 --- a/init +++ b/init @@ -1,4 +1,5 @@ #!/usr/bin/ash + udevd_running=0 if [ -x /usr/bin/systemd-timestamp ]; then @@ -28,11 +29,6 @@ if [ -n "$earlymodules$MODULES" ]; then modprobe -qab ${earlymodules//,/ } $MODULES fi -# If rootdelay is empty or not a non-negative integer, set it to 10 -if [ -z "${rootdelay}" ] || ! [ "${rootdelay}" -ge 0 ]; then - rootdelay=10 -fi - run_hookfunctions 'run_hook' 'hook' $HOOKS # honor the old behavior of break=y as a synonym for break=premount diff --git a/init_functions b/init_functions index 2bd07bd..bdc6cc9 100644 --- a/init_functions +++ b/init_functions @@ -10,7 +10,7 @@ err () { poll_device() { local device=$1 seconds=${2//[!0-9]} - [ -z "$seconds" ] && seconds=10 + [ "${seconds:-x}" = x ] && seconds=10 deciseconds=$(( seconds * 10 )) # tenths of a second -- 1.8.0
Signed-off-by: Dave Reisner <dreisner@archlinux.org> --- init | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/init b/init index b375e72..f3f9253 100644 --- a/init +++ b/init @@ -1,6 +1,8 @@ #!/usr/bin/ash udevd_running=0 +mount_handler=default_mount_handler +init=/sbin/init if [ -x /usr/bin/systemd-timestamp ]; then RD_TIMESTAMP=$(systemd-timestamp) @@ -43,12 +45,11 @@ unset rootdev fsck_root # Mount root at /new_root -${mount_handler:-default_mount_handler} /new_root +"$mount_handler" /new_root run_hookfunctions 'run_latehook' 'late hook' $LATEHOOKS run_hookfunctions 'run_cleanuphook' 'cleanup hook' $CLEANUPHOOKS -init=${init:-/sbin/init} if [ "$(stat -c %D /)" = "$(stat -c %D /new_root)" ]; then # Nothing got mounted on /new_root. This is the end, we don't know what to do anymore # We fall back into a shell, but the shell has now PID 1 -- 1.8.0
Signed-off-by: Dave Reisner <dreisner@archlinux.org> --- init_functions | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/init_functions b/init_functions index bdc6cc9..761f7a2 100644 --- a/init_functions +++ b/init_functions @@ -143,7 +143,7 @@ fsck_root() { fsck_ret() { [ -z "$fsckret" ] && return 1 [ "$fsckret" -eq "$1" ] && return 0 - [ "$(( $fsckret & $1 ))" -eq "$1" ] + [ "$(( fsckret & $1 ))" -eq "$1" ] } if [ "$fsckret" -ne 255 ]; then @@ -218,8 +218,8 @@ resolve_device() { minor=$(( 0x0$device & 0xff )) ;; 0x[0-9a-fA-F][0-9a-fA-F]*) - major=$(( $device >> 8 )) - minor=$(( $device & 0xff )) + major=$(( device >> 8 )) + minor=$(( device & 0xff )) ;; esac -- 1.8.0
Signed-off-by: Dave Reisner <dreisner@archlinux.org> --- install/consolefont | 9 ++------- install/keymap | 5 ++--- 2 files changed, 4 insertions(+), 10 deletions(-) diff --git a/install/consolefont b/install/consolefont index 0bb1af6..bbcd7ec 100644 --- a/install/consolefont +++ b/install/consolefont @@ -3,11 +3,7 @@ build() { # subshell to avoid namespace pollution ( - for cfg in /etc/{rc,vconsole}.conf; do - [[ -s $cfg ]] && . "$cfg" - done - - [[ $FONT ]] && CONSOLEFONT=$FONT + [[ -s /etc/vconsole.conf ]] && . /etc/vconsole.conf if [[ $CONSOLEFONT ]]; then for file in "/usr/share/kbd/consolefonts/$CONSOLEFONT".@(fnt|psf?(u))?(.gz); do @@ -32,8 +28,7 @@ build() { help() { cat <<HELPEOF -This hook loads consolefont specified in locale.conf or rc.conf during early -userspace. +This hook loads consolefont specified in locale.conf during early userspace. HELPEOF } diff --git a/install/keymap b/install/keymap index 99b816a..c1948b1 100644 --- a/install/keymap +++ b/install/keymap @@ -7,7 +7,7 @@ build() { l=$LANG unset LANG - for cfg in /etc/{rc,vconsole,locale}.conf; do + for cfg in /etc/{vconsole,locale}.conf; do [[ -s $cfg ]] && . "$cfg" done @@ -29,8 +29,7 @@ build() { help() { cat <<HELPEOF -This hook loads keymap(s) specified in vconsole.conf or rc.conf during early -userspace. +This hook loads keymap(s) specified in vconsole.conf during early userspace. HELPEOF } -- 1.8.0
This removes any meaning from the definitions of MODULES, BINARIES, FILES, and SCRIPT within install hooks. It also removed the deprecated checked_modules() function, which is replaced by add_checked_modules(). Signed-off-by: Dave Reisner <dreisner@archlinux.org> --- functions | 68 +++++++++++++++++--------------------------------------- mkinitcpio | 3 +-- mkinitcpio.8.txt | 3 +-- 3 files changed, 22 insertions(+), 52 deletions(-) diff --git a/functions b/functions index 8c44e43..e370190 100644 --- a/functions +++ b/functions @@ -288,21 +288,6 @@ add_checked_modules() { return $(( !${#mods[*]} )) } -checked_modules() { - # Returns a list of modules filtered by the list of autodetected modules. - # $@: arguments to all_modules - # - # DEPRECATED: Use add_checked_modules instead - # - - if (( ${#_autodetect_cache[*]} )); then - all_modules "$@" | grep -xFf <(printf '%s\n' "${!_autodetect_cache[@]}") - return 1 - else - all_modules "$@" - fi -} - add_module() { # Add a kernel module to the initcpio image. Dependencies will be # discovered and added. @@ -466,12 +451,9 @@ add_file() { add_runscript() { # Adds a runtime script to the initcpio image. The name is derived from the - # script which calls it, though it can be overriden by passing the name of - # the runtime hook as the first argument to the function. This shouldn't be - # needed and is only left for legacy compatability reasons. It may not work - # in future versions of mkinitcpio. + # script which calls it as the basename of the caller. - local funcs fn script hookname=${SCRIPT:-${BASH_SOURCE[1]##*/}} + local funcs fn script hookname=${BASH_SOURCE[1]##*/} if ! script=$(find_in_dirs "$hookname" "${_d_hooks[@]}"); then error "runtime script for \`%s' not found" "$hookname" @@ -554,38 +536,16 @@ add_binary() { return 0 } -parse_hook() { - # parse key global variables set by install hooks. This function is called - # prior to the start of hook processing, and after each hook's build - # function is run. +parse_config() { + # parse key global variables set by the config file. + set -f map add_module $MODULES map add_binary $BINARIES map add_file $FILES + set +f - if [[ $SCRIPT ]]; then - add_runscript "$SCRIPT" - fi -} - -find_in_dirs() { - local dir - - for dir in "${@:2}"; do - if [[ -e $dir/$1 ]]; then - printf '%s' "$dir/$1" - return 0 - fi - done - - return 1 -} - -write_image_config() { - # write the config as runtime config and as a pristine build config - # (for audting purposes) to the image. - - tee "$BUILDROOT/buildconfig" < "$_f_config" | { + tee "$BUILDROOT/buildconfig" < "$1" | { . /dev/stdin # sanitize of any extra whitespace @@ -604,6 +564,19 @@ write_image_config() { } >"$BUILDROOT/config" } +find_in_dirs() { + local dir + + for dir in "${@:2}"; do + if [[ -e $dir/$1 ]]; then + printf '%s' "$dir/$1" + return 0 + fi + done + + return 1 +} + initialize_buildroot() { # creates a temporary directory for the buildroot and initialize it with a # basic set of necessary directories and symlinks @@ -673,7 +646,6 @@ run_build_hook() { # run msg2 "Running build hook: [%s]" "${script##*/}" build - parse_hook } # vim: set ft=sh ts=4 sw=4 et: diff --git a/mkinitcpio b/mkinitcpio index 27902f1..beb5022 100755 --- a/mkinitcpio +++ b/mkinitcpio @@ -428,8 +428,7 @@ fi map run_build_hook "${_hooks[@]}" || (( ++_builderrors )) # process config file -parse_hook -write_image_config +parse_config "$_f_config" # switch out the error handler to catch all errors trap -- RETURN diff --git a/mkinitcpio.8.txt b/mkinitcpio.8.txt index 0c415a6..f19250f 100644 --- a/mkinitcpio.8.txt +++ b/mkinitcpio.8.txt @@ -160,8 +160,7 @@ functions exist to facilitate this. Adds a runtime hook to the image, which is a busybox ash compatible shell script. The name of the script is guaranteed to match the name of the hook the - script is called from. It *can* be overriden, but this is not recommended, as - this only exists for legacy compatibility. + script is called from. About Runtime Hooks ------------------- -- 1.8.0
Signed-off-by: Dave Reisner <dreisner@archlinux.org> --- Makefile | 14 +-- lsinitcpio.1.txt | 68 ----------- man/lsinitcpio.1.txt | 68 +++++++++++ man/mkinitcpio.8.txt | 297 ++++++++++++++++++++++++++++++++++++++++++++++ man/mkinitcpio.conf.5.txt | 82 +++++++++++++ mkinitcpio.8.txt | 297 ---------------------------------------------- mkinitcpio.conf.5.txt | 82 ------------- 7 files changed, 454 insertions(+), 454 deletions(-) delete mode 100644 lsinitcpio.1.txt create mode 100644 man/lsinitcpio.1.txt create mode 100644 man/mkinitcpio.8.txt create mode 100644 man/mkinitcpio.conf.5.txt delete mode 100644 mkinitcpio.8.txt delete mode 100644 mkinitcpio.conf.5.txt diff --git a/Makefile b/Makefile index 88f82db..756d42f 100644 --- a/Makefile +++ b/Makefile @@ -16,9 +16,9 @@ DIRS = \ all: doc MANPAGES = \ - mkinitcpio.8 \ - mkinitcpio.conf.5 \ - lsinitcpio.1 + man/mkinitcpio.8 \ + man/mkinitcpio.conf.5 \ + man/lsinitcpio.1 install: all mkdir -p $(DESTDIR) @@ -47,14 +47,14 @@ install: all cp -at $(DESTDIR)/usr/lib/initcpio/install install/* cp -at $(DESTDIR)/etc/mkinitcpio.d mkinitcpio.d/* - install -m644 mkinitcpio.8 $(DESTDIR)/usr/share/man/man8/mkinitcpio.8 - install -m644 mkinitcpio.conf.5 $(DESTDIR)/usr/share/man/man5/mkinitcpio.conf.5 - install -m644 lsinitcpio.1 $(DESTDIR)/usr/share/man/man1/lsinitcpio.1 + install -m644 man/mkinitcpio.8 $(DESTDIR)/usr/share/man/man8/mkinitcpio.8 + install -m644 man/mkinitcpio.conf.5 $(DESTDIR)/usr/share/man/man5/mkinitcpio.conf.5 + install -m644 man/lsinitcpio.1 $(DESTDIR)/usr/share/man/man1/lsinitcpio.1 install -m644 bash-completion $(DESTDIR)/usr/share/bash-completion/completions/mkinitcpio ln -s mkinitcpio $(DESTDIR)/usr/share/bash-completion/completions/lsinitcpio doc: $(MANPAGES) -%: %.txt Makefile +man/%: man/%.txt Makefile a2x -d manpage \ -f manpage \ -a manversion=$(VERSION) \ diff --git a/lsinitcpio.1.txt b/lsinitcpio.1.txt deleted file mode 100644 index 98bd756..0000000 --- a/lsinitcpio.1.txt +++ /dev/null @@ -1,68 +0,0 @@ -///// -vim:set ts=4 sw=4 syntax=asciidoc noet: -///// -lsinitcpio(1) -============= - -Name ----- -lsinitcpio - Examine an initramfs - -Synopsis --------- -'lsinitcpio' [action] [options] 'image' - -Description ------------ -Examines the contents of an initcpio image. Without any options, 'lsinitcpio' -simply lists the contents of an image. - -Actions -------- -*-a, \--analyze*:: - Analyze the contents of the specified image and print output in human - readable form. - -*-c, \--config*:: - Show the configuration file the given image was built with. - -*-l, \--list*:: - List the contents of the archive. This is the default action. Pass the *-v* - flag for more detailed results. - -*-x, \--extract*:: - Extract the given image to the current working directory. - -Options -------- - -*-h, \--help*:: - Output a short overview of available command-line switches. - -*-n, \--nocolor*:: - Disable color output. - -*-V, \--version*:: - Display version information. - -*-v, \--verbose*:: - Be more verbose. In particular, show long style output when listing - the contents of an image, and show files as they are extracted when - the *-x* option is given. - -Bugs ----- -Upon writing this manpage, there were no noticeable bugs present. Please visit -<http://bugs.archlinux.org/> for an up to date list. - -See Also --------- -*mkinitcpio*(8) - -Authors -------- -lsinitcpio was created by Dave Reisner <dreisner@archlinux.org> - -Copyright ---------- -Copyright (c) Arch Linux 2011-2012 diff --git a/man/lsinitcpio.1.txt b/man/lsinitcpio.1.txt new file mode 100644 index 0000000..98bd756 --- /dev/null +++ b/man/lsinitcpio.1.txt @@ -0,0 +1,68 @@ +///// +vim:set ts=4 sw=4 syntax=asciidoc noet: +///// +lsinitcpio(1) +============= + +Name +---- +lsinitcpio - Examine an initramfs + +Synopsis +-------- +'lsinitcpio' [action] [options] 'image' + +Description +----------- +Examines the contents of an initcpio image. Without any options, 'lsinitcpio' +simply lists the contents of an image. + +Actions +------- +*-a, \--analyze*:: + Analyze the contents of the specified image and print output in human + readable form. + +*-c, \--config*:: + Show the configuration file the given image was built with. + +*-l, \--list*:: + List the contents of the archive. This is the default action. Pass the *-v* + flag for more detailed results. + +*-x, \--extract*:: + Extract the given image to the current working directory. + +Options +------- + +*-h, \--help*:: + Output a short overview of available command-line switches. + +*-n, \--nocolor*:: + Disable color output. + +*-V, \--version*:: + Display version information. + +*-v, \--verbose*:: + Be more verbose. In particular, show long style output when listing + the contents of an image, and show files as they are extracted when + the *-x* option is given. + +Bugs +---- +Upon writing this manpage, there were no noticeable bugs present. Please visit +<http://bugs.archlinux.org/> for an up to date list. + +See Also +-------- +*mkinitcpio*(8) + +Authors +------- +lsinitcpio was created by Dave Reisner <dreisner@archlinux.org> + +Copyright +--------- +Copyright (c) Arch Linux 2011-2012 diff --git a/man/mkinitcpio.8.txt b/man/mkinitcpio.8.txt new file mode 100644 index 0000000..f19250f --- /dev/null +++ b/man/mkinitcpio.8.txt @@ -0,0 +1,297 @@ +///// +vim:set ts=4 sw=4 syntax=asciidoc noet: +///// +mkinitcpio(8) +============= + +Name +---- +mkinitcpio - Create an initial ramdisk environment + +Synopsis +-------- +'mkinitcpio' [options] + +Description +----------- +Creates an initial ramdisk environment for booting the linux kernel. The +initial ramdisk is in essence a very small environment (early userspace) which +loads various kernel modules and sets up necessary things before handing over +control to init. This makes it possible to have, for example, encrypted root +filesystems and root filesystems on a software RAID array. mkinitcpio allows +for easy extension with custom hooks, has autodetection at runtime, and many +other features. + +Options +------- +*-A, \--addhooks* 'hooks':: + Add the additional 'hooks' to the image. These will be processed in order + after all other hooks from the config file. Multiple hooks should be + comma-separated. This option can be specified multiple times. + +*-c, \--config* 'config':: + Use 'config' file to generate the ramdisk. Default: /etc/mkinitcpio.conf + +*-g, \--generate* 'filename':: + Generate a CPIO image as 'filename'. Default: no; this means nothing will be + written to the filesystem unless this option is specified. + +*-H, \--hookhelp* 'hookname':: + Output help for hookname 'hookname'. + +*-h, \--help*:: + Output a short overview of available command-line switches. + +*-k, \--kernel* 'kernelversion':: + Use 'kernelversion', instead of the current running kernel. This may be a + path to a kernel image or a specific kernel version. + +*-L, \--listhooks*:: + List all available hooks. + +*-M, \--automods*:: + Display modules found via autodetection. mkinitcpio will automatically try to + determine which kernel modules are needed to start your computer. This option + lists which modules were detected. + +*-n, \--nocolor*:: + Disable color output. + +*-p, \--preset* 'preset':: + Build initramfs image(s) according to specified 'preset'. This may be a file in + /etc/mkinitcpio.d (without the .preset extension) or a full, absolute path to a + file. + +*-r, \--moduleroot* 'root':: + Specifies the root directory to find modules in, defaulting to '/'. + +*-S, \--skiphooks* 'hooks':: + Skip 'hooks' when generating the image. Multiple hooks should be comma-separated. + This option can be specified multiple times. + +*-s, \--save*:: + Saves the build directory for the initial ramdisk. Default: no; This means + the directory will not be retained if this option isn't specified. Useful for + debugging purposes. + +*-t, \--builddir* 'tmpdir':: + Use 'tmpdir' as the temporary build directory instead of /tmp. 'tmpdir' + must exist. The 'TMPDIR' environment variable is also honored to set this + location, but the command line option will take precedence. + +*-V, \--version*:: + Display version information. + +*-v, \--verbose*:: + Verbose output. Outputs more information about what's happening during + creation of the ramdisk. + +*-z, \--compress* 'compress':: + Override the compression method with the 'compress' program. + +About Presets +------------- +A preset is a pre-defined definition on how to create an initial ramdisk. +Instead of specifying the configuration file and which output file, every time +you generate a new initial ramdisk, you define a preset and use the -p switch +to generate an initial ramdisk according to your preset. Presets are located in +/etc/mkinitcpio.d + +About Install Hooks +------------------- +Install hooks are bash scripts which are sourced during mkinitcpio runtime in +order to add modules, binaries, and other files to the image. A variety of +functions exist to facilitate this. + +*add_module* 'modname':: + + Adds the module specified by 'modname' to the image. Dependencies are derived + and added automatically. + +*add_binary* 'binary' [ 'destination' ] [ 'mode' ]:: + + Adds a binary to the image. The argument 'binary' need not be an absolute + path and, if needed, a lookup will be performed. If the binary is a dynamically + linked ELF binary, dependencies will be automatically added. Optionally, a + destination within the initramfs image as well as a file mode can be specified. + By default, the destintation and mode be taken from the source derived from + 'binary'. + +*add_file* 'path' [ 'destination' ] [ 'mode' ]:: + + Adds a file and any needed parent directories to the image. Optionally, a + destination within the initramfs image as well as a file mode can be specified. + By default, the destination and mode will be taken from the source and mode of + the file specified by the 'path'. + +*add_dir* 'path':: + + Adds a directory and its parents to the image. + +*add_full_dir* 'directory':: + + Recursively adds a directory to the image by walking the given path and + calling *add_file*, *add_dir*, and *add_symlink* accordingly. This function + will not follow symlinks, nor will it add the targets of symlinks. + +*add_symlink* 'path' [ 'link-target' ]:: + + Adds a symlink to the image at the specified `path`, optionally pointing to + the specified `link-target`. If the `link-target` is not provided, it is assumed + that this symlink exists in the real filesystem, and the target will be read + using readlink. There is no checking done to ensure that the target of the + symlink exists, and symlinks will not be followed recursively. + +*add_all_modules* [ '-f filter' ] *pattern*:: + + Adds modules to the image, without regard for the autodetect whitelist. *pattern* + should be a subdirectory within the kernel tree describing a subset of modules to + be included. Further refinement can be provided via the -f flag with an extended + regular expression. + +*add_checked_modules* [ '-f filter' ] *pattern*:: + + Similar to *add_all_modules* with the constraint that only modules matching the + whitelist generated by the autodetect hook will be added to the image. If the + autodetect hook is not present in the image, this function is identical to + *add_all_modules*. + +*add_runscript* [ 'scriptname' ]:: + + Adds a runtime hook to the image, which is a busybox ash compatible shell + script. The name of the script is guaranteed to match the name of the hook the + script is called from. + +About Runtime Hooks +------------------- +Runtime hooks added to the image via the *add_runscript* function from an +install hook are able to provide extra functionality during early userspace. +Specific functions in these files will run at different times. A hook can +define one or more of these. At each hook point, hooks are run in the order +that they are defined in the HOOKS variable, except for cleanup hooks which are +run in reverse. + +*run_earlyhook*:: + + Functions of this name will be run once the API mounts have been setup and the + kernel command line has been parsed. Daemons needed for early userspace should + be started from this hook point. + +*run_hook*:: + + Functions of this name will be run after any early hooks, and after user + defined modules have been installed. This is the most common hook point, and + functionality such as scanning for LVM volumes and mapping encrypted volumes + should be performed here. + +*run_latehook*:: + + Functions of this name will be run after root has been mounted. This is generally + used for further necessary setup in the real root, such as mounting other system + partitions. + +*run_cleanuphook*:: + + Functions of this name are run as late as possible. Any daemons started + from a run_earlyhook function should be shut down here in preparation for + switching to the real root. + +Early Init Environment +---------------------- +mkinitcpio gives special treatment to certain environment variables passed on +the kernel command line: + +*break*['=<premount|postmount>']:: + If specified, mkinitcpio will start a shell during early init. The optional + parameter controls when this occurs: when 'premount' or no parameter are + specified, the shell will be launched prior to mounting root. If 'postmount' + is specified, the shell will be launched after mounting root. + +*disablehooks=*'hooklist':: + This is a comma separated list of hooks which will be skipped during early + init. + +*earlymodules=*'modulelist':: + This is a comma separated list of modules which will be loaded prior to any + others. This is generally not needed, and usually points to a configuration + or kernel problem. + +*quiet*:: + Causes mkinitcpio to output fewer messages during boot. Errors will not be + suppressed. + +*ro*:: + Specifies that root should be mounted with readonly permissions. This is the + default behavior. + +*rw*:: + Specifies that root should be mounted with readwrite permissions. This is + generally only useful if your initramfs uses the 'fsck' hook. + +*root=*'rootdevice':: + This variable describes the root partition which early init will mount + before passing control to the real init. mkinitcpio understands a variety of + formats, the most basic of which is the path to the block device, either + directly such as '/dev/sda2', or using a udev symlink such as + '/dev/disk/by-label/CorsairF80-root'. Support for identification by LABEL or + UUID tags are also supported, such as, 'LABEL=CorsairF80-root'. As of + util-linux 2.22, PARTUUID is also supported. Identification via hex encoded + major/minor device ID is supported for legacy reasons, but should not be used. + +*rootdelay=*'seconds':: + Sets the delay, in seconds, that mkinitcpio is willing to wait for the root + device to show up, if it is not available immediately. This defaults to 5 + seconds. If an invalid integer is passed, this variable will have no effect. + +These are only the variables that the core of mkinitcpio honor. Additional +hooks may look for other environment variables and should be documented by the +help output for the hook. + +Files +----- +'/etc/mkinitcpio.conf':: + Default configuration file for mkinitcpio. + +'/etc/mkinitcpio.d':: + Folder containing mkinitcpio presets. + +'/usr/lib/initcpio/install':: +'/lib/initcpio/install':: + Search path for build time hooks. + +'/usr/lib/initcpio/hooks':: +'/lib/initcpio/hooks':: + Search path for early userspace runtime hooks. + +Examples +-------- +*mkinitcpio*:: + Perform a 'dry-run'. This will generate an initial ramdisk but will not + write anything. Use -g to create the real image. + +*mkinitcpio -p linux*:: + Create an initial ramdisk based on the 'linux' preset. + +*mkinitcpio -g /boot/initramfs-linux.img -k /boot/vmlinuz-linux*:: + Create an initial ramdisk for the kernel at /boot/vmlinuz-linux. The + resulting image will be written to /boot/initramfs-linux.img. + +See also +-------- +A more thorough article on configuring mkinitcpio: +<http://wiki.archlinux.org/index.php/Mkinitcpio> + +*initrd*(4), *lsinitcpio*(1), *mkinitcpio.conf*(5) + +Bugs +---- +Upon writing this manpage, there were no noticeable bugs present. Please visit +<http://bugs.archlinux.org/> for an up to date list. + +Authors +------- +mkinitcpio is created and maintained by the Arch Linux Developer community. + +Copyright +--------- +Copyright (c) Arch Linux 2006-2012 diff --git a/man/mkinitcpio.conf.5.txt b/man/mkinitcpio.conf.5.txt new file mode 100644 index 0000000..c2519c9 --- /dev/null +++ b/man/mkinitcpio.conf.5.txt @@ -0,0 +1,82 @@ +///// +vim:set ts=4 sw=4 syntax=asciidoc noet: +///// +mkinitcpio.conf(5) +================== + +Name +---- +mkinitcpio.conf - mkinitcpio configuration file + +Synopsis +-------- +/etc/mkinitcpio.conf + +Description +----------- +mkinitcpio will attempt to read from a config file each time it is invoked, +`/etc/mkinitcpio.conf' by default. This file defines several variables which +describe the contents of the image to be generated. + +Variables +--------- +*MODULES*:: + + Defines additional modules, space delimited, which should be added to the + image. Dependencies (including other modules and necessary firmware), will + also be added to the image. At runtime, the modules in this array which + were successfully added to the image will be explicitly loaded. + +*FILES*:: + + Defines additional files, space delimited, which should be added to the image. + Files are added as is, and parent directories will be added if needed. Files + specified in this variable will override previously added files of the same + path. + +*BINARIES*:: + + Defines additional binaries, space delimited, which should be added to the + image. These are assumed to be dynamic ELF binaries, and necessary shared + library dependencies will automatically be added. However, it is not + considered an error to specify a non-ELF binary in this variable. Parent + directories will be added if needed. Files specified in this variable will + override previously added files of the same path. + +*HOOKS*:: + + This variable defines the hooks which will be run during the build process. + Order is important, as it defines the order in which hooks will be run + during bootup. Use mkinitcpio's '-L' flag to list all available hooks, + and the '-H' flag to display the help text for a specific hook. + +*COMPRESSION*:: + + Defines a program to filter the generated image through. As of linux 2.6.38, + the kernel understands the compression formats yielded by the *gzip*, *bzip2*, + *lzop*, *lzma*, and *xz* compressors. If unspecified, this setting defaults to + *gzip* compression. In order to create an uncompressed image, define this + variable as *cat*. ++ +It's not hard to realize that a filter such as a *tac* or *rev* will cause +*mkinitcpio* to report success but generate a useless image. Similarly, using a +compression program not listed above may generate an equally useless image, +despite being "valid". + +*COMPRESSION_OPTIONS*:: + + Defines additional options to be passed to the compression program. This option + is generally not used. It can be potentially dangerous and may cause + invalid images to be generated without any sign of an error. + +See Also +-------- +*mkinitcpio*(8) + +Authors +------- +mkinitcpio is created and maintained by the Arch Linux Developer community. + +Copyright +--------- +Copyright (c) Arch Linux 2006-2012 diff --git a/mkinitcpio.8.txt b/mkinitcpio.8.txt deleted file mode 100644 index f19250f..0000000 --- a/mkinitcpio.8.txt +++ /dev/null @@ -1,297 +0,0 @@ -///// -vim:set ts=4 sw=4 syntax=asciidoc noet: -///// -mkinitcpio(8) -============= - -Name ----- -mkinitcpio - Create an initial ramdisk environment - -Synopsis --------- -'mkinitcpio' [options] - -Description ------------ -Creates an initial ramdisk environment for booting the linux kernel. The -initial ramdisk is in essence a very small environment (early userspace) which -loads various kernel modules and sets up necessary things before handing over -control to init. This makes it possible to have, for example, encrypted root -filesystems and root filesystems on a software RAID array. mkinitcpio allows -for easy extension with custom hooks, has autodetection at runtime, and many -other features. - -Options -------- -*-A, \--addhooks* 'hooks':: - Add the additional 'hooks' to the image. These will be processed in order - after all other hooks from the config file. Multiple hooks should be - comma-separated. This option can be specified multiple times. - -*-c, \--config* 'config':: - Use 'config' file to generate the ramdisk. Default: /etc/mkinitcpio.conf - -*-g, \--generate* 'filename':: - Generate a CPIO image as 'filename'. Default: no; this means nothing will be - written to the filesystem unless this option is specified. - -*-H, \--hookhelp* 'hookname':: - Output help for hookname 'hookname'. - -*-h, \--help*:: - Output a short overview of available command-line switches. - -*-k, \--kernel* 'kernelversion':: - Use 'kernelversion', instead of the current running kernel. This may be a - path to a kernel image or a specific kernel version. - -*-L, \--listhooks*:: - List all available hooks. - -*-M, \--automods*:: - Display modules found via autodetection. mkinitcpio will automatically try to - determine which kernel modules are needed to start your computer. This option - lists which modules were detected. - -*-n, \--nocolor*:: - Disable color output. - -*-p, \--preset* 'preset':: - Build initramfs image(s) according to specified 'preset'. This may be a file in - /etc/mkinitcpio.d (without the .preset extension) or a full, absolute path to a - file. - -*-r, \--moduleroot* 'root':: - Specifies the root directory to find modules in, defaulting to '/'. - -*-S, \--skiphooks* 'hooks':: - Skip 'hooks' when generating the image. Multiple hooks should be comma-separated. - This option can be specified multiple times. - -*-s, \--save*:: - Saves the build directory for the initial ramdisk. Default: no; This means - the directory will not be retained if this option isn't specified. Useful for - debugging purposes. - -*-t, \--builddir* 'tmpdir':: - Use 'tmpdir' as the temporary build directory instead of /tmp. 'tmpdir' - must exist. The 'TMPDIR' environment variable is also honored to set this - location, but the command line option will take precedence. - -*-V, \--version*:: - Display version information. - -*-v, \--verbose*:: - Verbose output. Outputs more information about what's happening during - creation of the ramdisk. - -*-z, \--compress* 'compress':: - Override the compression method with the 'compress' program. - -About Presets -------------- -A preset is a pre-defined definition on how to create an initial ramdisk. -Instead of specifying the configuration file and which output file, every time -you generate a new initial ramdisk, you define a preset and use the -p switch -to generate an initial ramdisk according to your preset. Presets are located in -/etc/mkinitcpio.d - -About Install Hooks -------------------- -Install hooks are bash scripts which are sourced during mkinitcpio runtime in -order to add modules, binaries, and other files to the image. A variety of -functions exist to facilitate this. - -*add_module* 'modname':: - - Adds the module specified by 'modname' to the image. Dependencies are derived - and added automatically. - -*add_binary* 'binary' [ 'destination' ] [ 'mode' ]:: - - Adds a binary to the image. The argument 'binary' need not be an absolute - path and, if needed, a lookup will be performed. If the binary is a dynamically - linked ELF binary, dependencies will be automatically added. Optionally, a - destination within the initramfs image as well as a file mode can be specified. - By default, the destintation and mode be taken from the source derived from - 'binary'. - -*add_file* 'path' [ 'destination' ] [ 'mode' ]:: - - Adds a file and any needed parent directories to the image. Optionally, a - destination within the initramfs image as well as a file mode can be specified. - By default, the destination and mode will be taken from the source and mode of - the file specified by the 'path'. - -*add_dir* 'path':: - - Adds a directory and its parents to the image. - -*add_full_dir* 'directory':: - - Recursively adds a directory to the image by walking the given path and - calling *add_file*, *add_dir*, and *add_symlink* accordingly. This function - will not follow symlinks, nor will it add the targets of symlinks. - -*add_symlink* 'path' [ 'link-target' ]:: - - Adds a symlink to the image at the specified `path`, optionally pointing to - the specified `link-target`. If the `link-target` is not provided, it is assumed - that this symlink exists in the real filesystem, and the target will be read - using readlink. There is no checking done to ensure that the target of the - symlink exists, and symlinks will not be followed recursively. - -*add_all_modules* [ '-f filter' ] *pattern*:: - - Adds modules to the image, without regard for the autodetect whitelist. *pattern* - should be a subdirectory within the kernel tree describing a subset of modules to - be included. Further refinement can be provided via the -f flag with an extended - regular expression. - -*add_checked_modules* [ '-f filter' ] *pattern*:: - - Similar to *add_all_modules* with the constraint that only modules matching the - whitelist generated by the autodetect hook will be added to the image. If the - autodetect hook is not present in the image, this function is identical to - *add_all_modules*. - -*add_runscript* [ 'scriptname' ]:: - - Adds a runtime hook to the image, which is a busybox ash compatible shell - script. The name of the script is guaranteed to match the name of the hook the - script is called from. - -About Runtime Hooks -------------------- -Runtime hooks added to the image via the *add_runscript* function from an -install hook are able to provide extra functionality during early userspace. -Specific functions in these files will run at different times. A hook can -define one or more of these. At each hook point, hooks are run in the order -that they are defined in the HOOKS variable, except for cleanup hooks which are -run in reverse. - -*run_earlyhook*:: - - Functions of this name will be run once the API mounts have been setup and the - kernel command line has been parsed. Daemons needed for early userspace should - be started from this hook point. - -*run_hook*:: - - Functions of this name will be run after any early hooks, and after user - defined modules have been installed. This is the most common hook point, and - functionality such as scanning for LVM volumes and mapping encrypted volumes - should be performed here. - -*run_latehook*:: - - Functions of this name will be run after root has been mounted. This is generally - used for further necessary setup in the real root, such as mounting other system - partitions. - -*run_cleanuphook*:: - - Functions of this name are run as late as possible. Any daemons started - from a run_earlyhook function should be shut down here in preparation for - switching to the real root. - -Early Init Environment ----------------------- -mkinitcpio gives special treatment to certain environment variables passed on -the kernel command line: - -*break*['=<premount|postmount>']:: - If specified, mkinitcpio will start a shell during early init. The optional - parameter controls when this occurs: when 'premount' or no parameter are - specified, the shell will be launched prior to mounting root. If 'postmount' - is specified, the shell will be launched after mounting root. - -*disablehooks=*'hooklist':: - This is a comma separated list of hooks which will be skipped during early - init. - -*earlymodules=*'modulelist':: - This is a comma separated list of modules which will be loaded prior to any - others. This is generally not needed, and usually points to a configuration - or kernel problem. - -*quiet*:: - Causes mkinitcpio to output fewer messages during boot. Errors will not be - suppressed. - -*ro*:: - Specifies that root should be mounted with readonly permissions. This is the - default behavior. - -*rw*:: - Specifies that root should be mounted with readwrite permissions. This is - generally only useful if your initramfs uses the 'fsck' hook. - -*root=*'rootdevice':: - This variable describes the root partition which early init will mount - before passing control to the real init. mkinitcpio understands a variety of - formats, the most basic of which is the path to the block device, either - directly such as '/dev/sda2', or using a udev symlink such as - '/dev/disk/by-label/CorsairF80-root'. Support for identification by LABEL or - UUID tags are also supported, such as, 'LABEL=CorsairF80-root'. As of - util-linux 2.22, PARTUUID is also supported. Identification via hex encoded - major/minor device ID is supported for legacy reasons, but should not be used. - -*rootdelay=*'seconds':: - Sets the delay, in seconds, that mkinitcpio is willing to wait for the root - device to show up, if it is not available immediately. This defaults to 5 - seconds. If an invalid integer is passed, this variable will have no effect. - -These are only the variables that the core of mkinitcpio honor. Additional -hooks may look for other environment variables and should be documented by the -help output for the hook. - -Files ------ -'/etc/mkinitcpio.conf':: - Default configuration file for mkinitcpio. - -'/etc/mkinitcpio.d':: - Folder containing mkinitcpio presets. - -'/usr/lib/initcpio/install':: -'/lib/initcpio/install':: - Search path for build time hooks. - -'/usr/lib/initcpio/hooks':: -'/lib/initcpio/hooks':: - Search path for early userspace runtime hooks. - -Examples --------- -*mkinitcpio*:: - Perform a 'dry-run'. This will generate an initial ramdisk but will not - write anything. Use -g to create the real image. - -*mkinitcpio -p linux*:: - Create an initial ramdisk based on the 'linux' preset. - -*mkinitcpio -g /boot/initramfs-linux.img -k /boot/vmlinuz-linux*:: - Create an initial ramdisk for the kernel at /boot/vmlinuz-linux. The - resulting image will be written to /boot/initramfs-linux.img. - -See also --------- -A more thorough article on configuring mkinitcpio: -<http://wiki.archlinux.org/index.php/Mkinitcpio> - -*initrd*(4), *lsinitcpio*(1), *mkinitcpio.conf*(5) - -Bugs ----- -Upon writing this manpage, there were no noticeable bugs present. Please visit -<http://bugs.archlinux.org/> for an up to date list. - -Authors -------- -mkinitcpio is created and maintained by the Arch Linux Developer community. - -Copyright ---------- -Copyright (c) Arch Linux 2006-2012 diff --git a/mkinitcpio.conf.5.txt b/mkinitcpio.conf.5.txt deleted file mode 100644 index c2519c9..0000000 --- a/mkinitcpio.conf.5.txt +++ /dev/null @@ -1,82 +0,0 @@ -///// -vim:set ts=4 sw=4 syntax=asciidoc noet: -///// -mkinitcpio.conf(5) -================== - -Name ----- -mkinitcpio.conf - mkinitcpio configuration file - -Synopsis --------- -/etc/mkinitcpio.conf - -Description ------------ -mkinitcpio will attempt to read from a config file each time it is invoked, -`/etc/mkinitcpio.conf' by default. This file defines several variables which -describe the contents of the image to be generated. - -Variables ---------- -*MODULES*:: - - Defines additional modules, space delimited, which should be added to the - image. Dependencies (including other modules and necessary firmware), will - also be added to the image. At runtime, the modules in this array which - were successfully added to the image will be explicitly loaded. - -*FILES*:: - - Defines additional files, space delimited, which should be added to the image. - Files are added as is, and parent directories will be added if needed. Files - specified in this variable will override previously added files of the same - path. - -*BINARIES*:: - - Defines additional binaries, space delimited, which should be added to the - image. These are assumed to be dynamic ELF binaries, and necessary shared - library dependencies will automatically be added. However, it is not - considered an error to specify a non-ELF binary in this variable. Parent - directories will be added if needed. Files specified in this variable will - override previously added files of the same path. - -*HOOKS*:: - - This variable defines the hooks which will be run during the build process. - Order is important, as it defines the order in which hooks will be run - during bootup. Use mkinitcpio's '-L' flag to list all available hooks, - and the '-H' flag to display the help text for a specific hook. - -*COMPRESSION*:: - - Defines a program to filter the generated image through. As of linux 2.6.38, - the kernel understands the compression formats yielded by the *gzip*, *bzip2*, - *lzop*, *lzma*, and *xz* compressors. If unspecified, this setting defaults to - *gzip* compression. In order to create an uncompressed image, define this - variable as *cat*. -+ -It's not hard to realize that a filter such as a *tac* or *rev* will cause -*mkinitcpio* to report success but generate a useless image. Similarly, using a -compression program not listed above may generate an equally useless image, -despite being "valid". - -*COMPRESSION_OPTIONS*:: - - Defines additional options to be passed to the compression program. This option - is generally not used. It can be potentially dangerous and may cause - invalid images to be generated without any sign of an error. - -See Also --------- -*mkinitcpio*(8) - -Authors -------- -mkinitcpio is created and maintained by the Arch Linux Developer community. - -Copyright ---------- -Copyright (c) Arch Linux 2006-2012 -- 1.8.0
Signed-off-by: Dave Reisner <dreisner@archlinux.org> --- functions | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/functions b/functions index e370190..491fc6c 100644 --- a/functions +++ b/functions @@ -627,7 +627,8 @@ run_build_hook() { error "$script is a broken symlink to $(readlink "$script")" return 1 fi - warning "Hook '%s' is deprecated. Replace it with '%s' in your config" "$script" "${realscript##*/}" + warning "Hook '%s' is deprecated. Replace it with '%s' in your config" \ + "${script##*/}" "${realscript##*/}" script=$realscript fi -- 1.8.0
This allow preservation of symlinks. Signed-off-by: Dave Reisner <dreisner@archlinux.org> --- Makefile | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/Makefile b/Makefile index 756d42f..7bf70cf 100644 --- a/Makefile +++ b/Makefile @@ -43,9 +43,8 @@ install: all install -m644 -t $(DESTDIR)/usr/lib/initcpio init_functions functions install -m644 01-memdisk.rules $(DESTDIR)/usr/lib/initcpio/udev/01-memdisk.rules - cp -at $(DESTDIR)/usr/lib/initcpio/hooks hooks/* - cp -at $(DESTDIR)/usr/lib/initcpio/install install/* - cp -at $(DESTDIR)/etc/mkinitcpio.d mkinitcpio.d/* + cp -at $(DESTDIR)/usr/lib/initcpio hooks install + cp -at $(DESTDIR)/etc mkinitcpio.d install -m644 man/mkinitcpio.8 $(DESTDIR)/usr/share/man/man8/mkinitcpio.8 install -m644 man/mkinitcpio.conf.5 $(DESTDIR)/usr/share/man/man5/mkinitcpio.conf.5 -- 1.8.0
As the autodetect hook gets better with every kernel release, we can "afford" to remove the needless segregation of block device driver hooks and simply merge all the "vanilla" or "unstacked" block device drivers. This should make a lot of setups, like usb or virtio, easier as you won't need to remember to add the hook. Signed-off-by: Dave Reisner <dreisner@archlinux.org> --- install/block | 45 +++++++++++++++++++++++++++++++++++++++++++++ install/fw | 22 +--------------------- install/mmc | 19 +------------------ install/pata | 22 +--------------------- install/sata | 23 +---------------------- install/scsi | 22 +--------------------- install/usb | 21 +-------------------- install/virtio | 16 +--------------- mkinitcpio.conf | 14 +++++--------- 9 files changed, 57 insertions(+), 147 deletions(-) create mode 100644 install/block mode change 100644 => 120000 install/fw mode change 100644 => 120000 install/mmc mode change 100644 => 120000 install/pata mode change 100644 => 120000 install/sata mode change 100644 => 120000 install/scsi mode change 100644 => 120000 install/usb mode change 100644 => 120000 install/virtio diff --git a/install/block b/install/block new file mode 100644 index 0000000..44f2c27 --- /dev/null +++ b/install/block @@ -0,0 +1,45 @@ +#!/bin/bash + +build() { + local filter + local -A blockdevs + + # pata, sata, scsi + for filter in 'scsi/.*ata' '/(block|scsi|fusion)/' 'ata/[ps]ata_' \ + 'ata/(ahci|pdc_adma|ata_piix|ata_generic)'; do + add_checked_modules "$filter" && blockdevs['sd_mod']=1 + done + + # usb + if add_checked_modules -f '(_cs|sl811_hcd|isp116x_hcd)' '/usb/host'; then + blockdevs+=(['usb_storage']=1 ['sd_mod']=1 ['sr_mod']=1) + add_checked_modules 'drivers/usb/storage/ums-*' + fi + + # firewire + if add_checked_modules '/drivers/firewire/'; then + blockdevs+=(['firewire-sbp2']=1 ['sd_mod']=1 ['sr_mod']=1) + fi + + # mmc + if add_checked_modules '/mmc'; then + blockdevs+=(['tifm_7xx1']=1 ['mmc_block']=1) + fi + + # virtio + if add_checked_modules 'virtio'; then + blockdevs['virtio_blk']=1 + fi + + map add_module "${!blockdevs[@]}" +} + +help() { + cat <<HELPEOF +This hook loads the necessary modules for most block devices using pata, sata, +scsi, firewire, usb, or mmc. Detection will take place at runtime. To minimize +the modules in the image, add the autodetect hook too. +HELPEOF +} + +# vim: set ft=sh ts=4 sw=4 et: diff --git a/install/fw b/install/fw deleted file mode 100644 index 98c05ab..0000000 --- a/install/fw +++ /dev/null @@ -1,21 +0,0 @@ -#!/bin/bash - -build() { - local mod - - if add_checked_modules '/drivers/firewire/'; then - for mod in firewire-sbp2 sd_mod sr_mod; do - add_module "$mod?" - done - fi -} - -help() { - cat <<HELPEOF -This hook loads the necessary modules for a firewire root device. Detection -will take place at runtime. To minimize the modules in the image, add the -autodetect hook too. -HELPEOF -} - -# vim: set ft=sh ts=4 sw=4 et: diff --git a/install/fw b/install/fw new file mode 120000 index 0000000..ad926c8 --- /dev/null +++ b/install/fw @@ -0,0 +1 @@ +block \ No newline at end of file diff --git a/install/mmc b/install/mmc deleted file mode 100644 index 60068df..0000000 --- a/install/mmc +++ /dev/null @@ -1,18 +0,0 @@ -#!/bin/bash - -build() { - if add_checked_modules '/mmc'; then - add_module 'tifm_7xx1' - add_module 'mmc_block' - fi -} - -help() { - cat <<HELPEOF -This hook loads the necessary modules for a mmc root device. Detection will -take place at runtime. To minimize the modules in the image, add the autodetect -hook too. -HELPEOF -} - -# vim: set ft=sh ts=4 sw=4 et: diff --git a/install/mmc b/install/mmc new file mode 120000 index 0000000..ad926c8 --- /dev/null +++ b/install/mmc @@ -0,0 +1 @@ +block \ No newline at end of file diff --git a/install/pata b/install/pata deleted file mode 100644 index bcf3809..0000000 --- a/install/pata +++ /dev/null @@ -1,21 +0,0 @@ -#!/bin/bash - -build() { - local filter added - - for filter in 'ata/pata_*' 'ata/ata_generic' 'ata/ata_piix'; do - add_checked_modules "$filter" && (( ++added )) - done - - (( added )) && add_module "sd_mod?" -} - -help() { - cat <<HELPEOF -This hook loads the necessary modules for a pata (ide) root device, using the -new libata subsystem. Detection will take place at runtime. To minimize the -modules in the image, add the autodetect hook too. -HELPEOF -} - -# vim: set ft=sh ts=4 sw=4 et: diff --git a/install/pata b/install/pata new file mode 120000 index 0000000..ad926c8 --- /dev/null +++ b/install/pata @@ -0,0 +1 @@ +block \ No newline at end of file diff --git a/install/sata b/install/sata deleted file mode 100644 index c6a2ade..0000000 --- a/install/sata +++ /dev/null @@ -1,22 +0,0 @@ -#!/bin/bash - -build() { - local filter added - - for filter in 'scsi/.*ata' 'block/sx8' 'ata/sata_*' \ - 'ata/ahci' 'ata/pdc_adma' 'ata/ata_piix'; do - add_checked_modules "$filter" && (( ++added )) - done - - (( added )) && add_module "sd_mod?" -} - -help() { - cat <<HELPEOF -This hook loads the necessary modules for an sata root device. Detection will -take place at runtime. To minimize the modules in the image, add the autodetect -hook too. -HELPEOF -} - -# vim: set ft=sh ts=4 sw=4 et: diff --git a/install/sata b/install/sata new file mode 120000 index 0000000..ad926c8 --- /dev/null +++ b/install/sata @@ -0,0 +1 @@ +block \ No newline at end of file diff --git a/install/scsi b/install/scsi deleted file mode 100644 index 7c5a771..0000000 --- a/install/scsi +++ /dev/null @@ -1,21 +0,0 @@ -#!/bin/bash - -build(){ - local filter added - - add_checked_modules -f '(imm|ata|pcmcia)' '/scsi/' && (( ++added )) - add_checked_modules -f '(cciss|cpqarray|DAC960)' '/block/' && (( ++added )) - add_checked_modules '/fusion/' && (( ++added )) - - (( added )) && add_module 'sd_mod?' -} - -help() { - cat <<HELPEOF -This hook loads the necessary modules for an scsi root device. Detection will -take place at runtime. To minimize the modules in the image, add the autodetect -hook too. -HELPEOF -} - -# vim: set ft=sh ts=4 sw=4 et: diff --git a/install/scsi b/install/scsi new file mode 120000 index 0000000..ad926c8 --- /dev/null +++ b/install/scsi @@ -0,0 +1 @@ +block \ No newline at end of file diff --git a/install/usb b/install/usb deleted file mode 100644 index 2b36c35..0000000 --- a/install/usb +++ /dev/null @@ -1,20 +0,0 @@ -#!/bin/bash - -build() { - if add_checked_modules -f '(_cs|sl811_hcd|isp116x_hcd)' '/usb/host'; then - add_module 'usb_storage?' - add_module 'sd_mod?' - add_module 'sr_mod?' - add_checked_modules 'drivers/usb/storage/ums-*' - fi -} - -help() { - cat <<HELPEOF -This hook loads the necessary modules for an usb root device. Detection will -take place at runtime. To minimize the modules in the image, add the autodetect -hook too. -HELPEOF -} - -# vim: set ft=sh ts=4 sw=4 et: diff --git a/install/usb b/install/usb new file mode 120000 index 0000000..ad926c8 --- /dev/null +++ b/install/usb @@ -0,0 +1 @@ +block \ No newline at end of file diff --git a/install/virtio b/install/virtio deleted file mode 100644 index 10037ab..0000000 --- a/install/virtio +++ /dev/null @@ -1,15 +0,0 @@ -#!/bin/bash - -build() { - add_checked_modules 'virtio_(blk|pci)' -} - -help() { - cat <<HELPEOF -This hook loads the necessary modules for a virtio root device. Detection will -take place at runtime. To minimize the modules in the image, add the autodetect -hook too. -HELPEOF -} - -# vim: set ft=sh ts=4 sw=4 et: diff --git a/install/virtio b/install/virtio new file mode 120000 index 0000000..ad926c8 --- /dev/null +++ b/install/virtio @@ -0,0 +1 @@ +block \ No newline at end of file diff --git a/mkinitcpio.conf b/mkinitcpio.conf index 229fa05..c4380af 100644 --- a/mkinitcpio.conf +++ b/mkinitcpio.conf @@ -37,26 +37,22 @@ FILES="" # ## This setup will autodetect all modules for your system and should ## work as a sane default -# HOOKS="base udev autodetect pata scsi sata filesystems" -# -## This is identical to the above, except the old ide subsystem is -## used for IDE devices instead of the new pata subsystem. -# HOOKS="base udev autodetect ide scsi sata filesystems" +# HOOKS="base udev autodetect block filesystems" # ## This setup will generate a 'full' image which supports most systems. ## No autodetection is done. -# HOOKS="base udev pata scsi sata usb filesystems" +# HOOKS="base udev block filesystems" # ## This setup assembles a pata mdadm array with an encrypted root FS. ## Note: See 'mkinitcpio -H mdadm' for more information on raid devices. -# HOOKS="base udev pata mdadm encrypt filesystems" +# HOOKS="base udev block mdadm encrypt filesystems" # ## This setup loads an lvm2 volume group on a usb device. -# HOOKS="base udev usb lvm2 filesystems" +# HOOKS="base udev block lvm2 filesystems" # ## NOTE: If you have /usr on a separate partition, you MUST include the # usr, fsck and shutdown hooks. -HOOKS="base udev autodetect pata scsi sata filesystems usbinput fsck" +HOOKS="base udev autodetect block filesystems usbinput fsck" # COMPRESSION # Use this to compress the initramfs image. By default, gzip compression -- 1.8.0
Add this as a default in the config file. Signed-off-by: Dave Reisner <dreisner@archlinux.org> --- install/modconf | 15 +++++++++++++++ mkinitcpio.conf | 5 +---- 2 files changed, 16 insertions(+), 4 deletions(-) create mode 100644 install/modconf diff --git a/install/modconf b/install/modconf new file mode 100644 index 0000000..b06b51a --- /dev/null +++ b/install/modconf @@ -0,0 +1,15 @@ +#!/bin/bash + +build() { + add_full_dir /etc/modprobe.d + add_full_dir /usr/lib/modprobe.d +} + +help() { + cat <<HELPEOF +This hook installs modprobe configuration files from /etc/modprobe.d and +/usr/lib/modprobe.d. +HELPEOF +} + +# vim: set ft=sh ts=4 sw=4 et: diff --git a/mkinitcpio.conf b/mkinitcpio.conf index c4380af..1047011 100644 --- a/mkinitcpio.conf +++ b/mkinitcpio.conf @@ -16,9 +16,6 @@ BINARIES="" # FILES # This setting is similar to BINARIES above, however, files are added # as-is and are not parsed in any way. This is useful for config files. -# Some users may wish to include modprobe.conf for custom module options -# like so: -# FILES="/etc/modprobe.d/modprobe.conf" FILES="" # HOOKS @@ -52,7 +49,7 @@ FILES="" # ## NOTE: If you have /usr on a separate partition, you MUST include the # usr, fsck and shutdown hooks. -HOOKS="base udev autodetect block filesystems usbinput fsck" +HOOKS="base udev autodetect modconf block filesystems usbinput fsck" # COMPRESSION # Use this to compress the initramfs image. By default, gzip compression -- 1.8.0
Declaring _modpaths as an associative array allows us to forego the printf|sort -u|xargs cp pipeline as we can guarantee that the array is already prepared. Signed-off-by: Dave Reisner <dreisner@archlinux.org> --- functions | 2 +- mkinitcpio | 21 +++++++++++---------- 2 files changed, 12 insertions(+), 11 deletions(-) diff --git a/functions b/functions index 491fc6c..e79d057 100644 --- a/functions +++ b/functions @@ -331,7 +331,7 @@ add_module() { # aggregate modules and add them all at once to save some forks quiet "adding module: %s" "$1" - _modpaths+=("$path") + _modpaths["$path"]=1 _addedmodules["${module//-/_}"]=1 # handle module quirks diff --git a/mkinitcpio b/mkinitcpio index beb5022..5303f2d 100755 --- a/mkinitcpio +++ b/mkinitcpio @@ -21,8 +21,8 @@ _optmoduleroot= _optkver= _optgenimg= _optpreset= _optcompress= _optshowautomods=0 _optsavetree=0 _optshowmods=0 _optquiet=1 _optcolor=1 -_optskiphooks=() _optaddhooks=() _modpaths=() _hooks=() -declare -A _runhooks=() _addedmodules=() _autodetect_cache=() +_optskiphooks=() _optaddhooks=() _hooks=() +declare -A _runhooks _addedmodules _modpaths _autodetect_cache # export a sane PATH export PATH='/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin' @@ -224,25 +224,26 @@ install_modules() { return 0 fi - printf '%s\0' "$@" | sort -zu | - xargs -0 cp -t "$BUILDROOT/usr/lib/modules/$KERNELVERSION/kernel" + cp "$@" "$BUILDROOT/lib/modules/$KERNELVERSION/kernel" # unzip modules prior to recompression - gzip -dr "$BUILDROOT/usr/lib/modules/$KERNELVERSION/kernel" + gzip -dr "$BUILDROOT/lib/modules/$KERNELVERSION/kernel" msg "Generating module dependencies" - install -m644 -t "$BUILDROOT/usr/lib/modules/$KERNELVERSION" \ + install -m644 -t "$BUILDROOT/lib/modules/$KERNELVERSION" \ "$_d_kmoduledir"/modules.builtin - # we install all modules into kernel/, making the .order file incorrect - # for the module tree. munge it, so that we have an accurate index. + # we install all modules into kernel/, making the .order file incorrect for + # the module tree. munge it, so that we have an accurate index. This avoids + # some rare and subtle issues with module loading choices when an alias + # resolves to multiple modules, only one of which can claim a device. awk -F'/' '{ print "kernel/" $NF }' \ "$_d_kmoduledir"/modules.order >"$BUILDROOT/lib/modules/$KERNELVERSION/modules.order" depmod -b "$BUILDROOT" "$KERNELVERSION" # remove all non-binary module.* files (except devname for on-demand module loading) - rm "$BUILDROOT/usr/lib/modules/$KERNELVERSION"/modules.!(*.bin|devname) + rm "$BUILDROOT/lib/modules/$KERNELVERSION"/modules.!(*.bin|devname) } . "$_f_functions" @@ -434,7 +435,7 @@ parse_config "$_f_config" trap -- RETURN trap '(( ++_builderrors ))' ERR -install_modules "${_modpaths[@]}" +install_modules "${!_modpaths[@]}" # unset errtrace and trap set +o functrace -- 1.8.0
Don't make any assumptions about the compression on modules and scan the passed in module list for telltale extensions. This has the benefit of doing nothing when modules are uncompressed, and adds support for decompression of XZ modules. Signed-off-by: Dave Reisner <dreisner@archlinux.org> --- mkinitcpio | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) diff --git a/mkinitcpio b/mkinitcpio index 5303f2d..e8ec413 100755 --- a/mkinitcpio +++ b/mkinitcpio @@ -219,6 +219,9 @@ process_preset() { } install_modules() { + local m + local -a xz_comp gz_comp + if (( $# == 0 )); then warning "No modules were added to the image. This is probably not what you want." return 0 @@ -227,7 +230,18 @@ install_modules() { cp "$@" "$BUILDROOT/lib/modules/$KERNELVERSION/kernel" # unzip modules prior to recompression - gzip -dr "$BUILDROOT/lib/modules/$KERNELVERSION/kernel" + for m in "$@"; do + case ${m##*.} in + xz) + xz_comp+=("$BUILDROOT/lib/modules/$KERNELVERSION/kernel/${m##*/}") + ;; + gz) + gz_comp+=("$BUILDROOT/lib/modules/$KERNELVERSION/kernel/${m##*/}") + ;; + esac + done + (( ${#xz_comp[*]} )) && xz -dr "${xz_comp[@]}" + (( ${#gz_comp[*]} )) && gzip -dr "${gz_comp[@]}" msg "Generating module dependencies" install -m644 -t "$BUILDROOT/lib/modules/$KERNELVERSION" \ -- 1.8.0
Dave Reisner <dreisner@archlinux.org> on Fri, 2012/11/23 18:48:
* Dropping support for /etc/rc.conf. This means that the keymap and consolefont hooks will no longer read from /etc/rc.conf, but only from /etc/vconsole.conf and /etc/locale.conf. We've been slowly dropping this support in other places, and I think it makes sense to do this here as well.
This is from 'man vconsole.conf':
FONT=, FONT_MAP=, FONT_UNIMAP= Configures the console font, the console map and the unicode font map.
The hook looks for variable CONSOLEFONT, though. This should be just 'FONT', no? -- main(a){char*c=/* Schoene Gruesse */"B?IJj;MEH" "CX:;",b;for(a/* Chris get my mail address: */=0;b=c[a++];) putchar(b-1/(/* gcc -o sig sig.c && ./sig */b/42*2-3)*42);}
On Mon, Dec 03, 2012 at 08:44:45PM +0100, Christian Hesse wrote:
Dave Reisner <dreisner@archlinux.org> on Fri, 2012/11/23 18:48:
* Dropping support for /etc/rc.conf. This means that the keymap and consolefont hooks will no longer read from /etc/rc.conf, but only from /etc/vconsole.conf and /etc/locale.conf. We've been slowly dropping this support in other places, and I think it makes sense to do this here as well.
This is from 'man vconsole.conf':
FONT=, FONT_MAP=, FONT_UNIMAP= Configures the console font, the console map and the unicode font map.
The hook looks for variable CONSOLEFONT, though. This should be just 'FONT', no?
Reported on the bug tracker and the bbs already. It's already fixed in git: https://projects.archlinux.org/mkinitcpio.git/commit/?id=6be469d5f d
participants (3)
-
Christian Hesse
-
Dave Reisner
-
Dave Reisner