Skip to content

Commit

Permalink
mkinitcpio: Allow building an image without modules
Browse files Browse the repository at this point in the history
The '-k none' switch prevents mkinitcpio from adding modules to the
image and keeps it from bailing out when it cannot find any.
  • Loading branch information
brain0 authored and falconindy committed Nov 27, 2013
1 parent 9e2c162 commit cf9be93
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 3 deletions.
6 changes: 5 additions & 1 deletion functions
Original file line number Diff line number Diff line change
Expand Up @@ -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%?}"
Expand Down Expand Up @@ -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"
Expand Down Expand Up @@ -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
Expand Down
2 changes: 2 additions & 0 deletions install/autodetect
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@ build() {
local m=
local -a md_devs mods

[[ $KERNELVERSION == none ]] && return 0

add_if_avail() {
local r= resolved=()

Expand Down
3 changes: 2 additions & 1 deletion man/mkinitcpio.8.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
2 changes: 1 addition & 1 deletion mkinitcpio
Original file line number Diff line number Diff line change
Expand Up @@ -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}
Expand Down

0 comments on commit cf9be93

Please sign in to comment.