diff options
author | Thomas Bächler <thomas@archlinux.org> | 2013-11-27 19:30:04 +0100 |
---|---|---|
committer | Dave Reisner <dreisner@archlinux.org> | 2013-11-27 21:21:13 +0100 |
commit | cf9be93525fb393b0db85a341dfca6fafdd9fab7 (patch) | |
tree | 9ff72cb7963f0fc810db85a76fc6d14d783a430b | |
parent | 9e2c16294bd6281ecbf7ab96e9b14a10154c4f01 (diff) | |
download | mkinitcpio-cf9be93525fb393b0db85a341dfca6fafdd9fab7.tar.gz mkinitcpio-cf9be93525fb393b0db85a341dfca6fafdd9fab7.tar.xz |
mkinitcpio: Allow building an image without modules
The '-k none' switch prevents mkinitcpio from adding modules to the
image and keeps it from bailing out when it cannot find any.
-rw-r--r-- | functions | 6 | ||||
-rw-r--r-- | install/autodetect | 2 | ||||
-rw-r--r-- | man/mkinitcpio.8.txt | 3 | ||||
-rwxr-xr-x | mkinitcpio | 2 |
4 files changed, 10 insertions, 3 deletions
@@ -351,6 +351,8 @@ add_module() { local module= path= deps= field= value= firmware=() local ign_errors=0 + [[ $KERNELVERSION == none ]] && return 0 + if [[ $1 = *\? ]]; then ign_errors=1 set -- "${1%?}" @@ -661,7 +663,7 @@ initialize_buildroot() { printf '%s' "$version" >"$buildroot/VERSION" # kernel module dir - install -dm755 "$buildroot/usr/lib/modules/$kernver/kernel" + [[ $kernver != none ]] && install -dm755 "$buildroot/usr/lib/modules/$kernver/kernel" # mount tables ln -s /proc/self/mounts "$buildroot/etc/mtab" @@ -738,6 +740,8 @@ install_modules() { local m moduledest=$BUILDROOT/lib/modules/$KERNELVERSION local -a xz_comp gz_comp + [[ $KERNELVERSION == none ]] && return 0 + if (( $# == 0 )); then warning "No modules were added to the image. This is probably not what you want." return 0 diff --git a/install/autodetect b/install/autodetect index 37af3be..c98db73 100644 --- a/install/autodetect +++ b/install/autodetect @@ -4,6 +4,8 @@ build() { local m= local -a md_devs mods + [[ $KERNELVERSION == none ]] && return 0 + add_if_avail() { local r= resolved=() diff --git a/man/mkinitcpio.8.txt b/man/mkinitcpio.8.txt index 5edf66c..3b28ee7 100644 --- a/man/mkinitcpio.8.txt +++ b/man/mkinitcpio.8.txt @@ -49,7 +49,8 @@ Options *-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. + path to a kernel image, a specific kernel version or the special keyword + 'none'. In the latter case, no kernel modules are added to the image. *-L, \--listhooks*:: List all available hooks. @@ -417,7 +417,7 @@ fi KERNELVERSION=$(resolve_kernver "$_optkver") || cleanup 1 _d_kmoduledir=$_optmoduleroot/lib/modules/$KERNELVERSION -[[ -d $_d_kmoduledir ]] || die "'$_d_kmoduledir' is not a valid kernel module directory" +[[ $KERNELVERSION == none || -d $_d_kmoduledir ]] || die "'$_d_kmoduledir' is not a valid kernel module directory" _d_workdir=$(initialize_buildroot "$KERNELVERSION" $_opttargetdir) || cleanup 1 BUILDROOT=${_opttargetdir:-$_d_workdir/root} |