[arch-projects] [mkinitcpio] [PATCH 1/3] 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. --- functions | 6 +++++- install/autodetect | 2 ++ man/mkinitcpio.8.txt | 3 ++- mkinitcpio | 2 +- 4 files changed, 10 insertions(+), 3 deletions(-) diff --git a/functions b/functions index 9a29a17..2b89c88 100644 --- a/functions +++ b/functions @@ -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. diff --git a/mkinitcpio b/mkinitcpio index e927884..2ec44ed 100755 --- a/mkinitcpio +++ b/mkinitcpio @@ -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} -- 1.8.4.2
When the module directory matching $(uname -r) cannot be found, generation of the shutdown ramfs aborted: systemd[1]: Starting Generate shutdown-ramfs... mkinitcpio[1944]: ==> ERROR: '/lib/modules/3.12.1-1-ARCH' is not a valid kernel module directory systemd[1]: mkinitcpio-generate-shutdown-ramfs.service: main process exited, code=exited, status=1/FAILURE systemd[1]: Failed to start Generate shutdown-ramfs. systemd[1]: Unit mkinitcpio-generate-shutdown-ramfs.service entered failed state. Tell mkinitcpio that we do not wish to add any kernel modules. --- mkinitcpio-generate-shutdown-ramfs.service | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/mkinitcpio-generate-shutdown-ramfs.service b/mkinitcpio-generate-shutdown-ramfs.service index 36c2508..d5876df 100644 --- a/mkinitcpio-generate-shutdown-ramfs.service +++ b/mkinitcpio-generate-shutdown-ramfs.service @@ -9,7 +9,7 @@ Type=oneshot # /tmp could be umounted at this point # use /run as temporary directory Environment=TMPDIR=/run -ExecStart=/usr/bin/mkinitcpio -A sd-shutdown -c /dev/null -d /run/initramfs +ExecStart=/usr/bin/mkinitcpio -A sd-shutdown -k none -c /dev/null -d /run/initramfs [Install] WantedBy=shutdown.target -- 1.8.4.2
Commit caf145fd4 causes mkinitcpio to bail out when the build directory does not exist. However, we use '-d /run/initramfs' but noone creates /run/initramfs for us. --- functions | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/functions b/functions index 2b89c88..35e450a 100644 --- a/functions +++ b/functions @@ -637,7 +637,7 @@ initialize_buildroot() { fi buildroot=${2:-$workdir/root} - if [[ ! -w ${2:-$workdir} ]]; then + if ! install -dm755 "${buildroot}" && [[ ! -w $buildroot ]]; then error 'Unable to write to build root: %s' "$buildroot" return 1 fi -- 1.8.4.2
Hi Dave, these patches have been sitting here for 2 weeks. I'd love to have this stuff fixed in the repository and preferably have a release. My sd-vconsole patches have also been sitting here dormant for quite longer and should at some point be available in Arch.
On Wed, Dec 11, 2013 at 02:05:27PM +0100, Thomas Bächler wrote:
Hi Dave, these patches have been sitting here for 2 weeks. I'd love to have this stuff fixed in the repository and preferably have a release.
My sd-vconsole patches have also been sitting here dormant for quite longer and should at some point be available in Arch.
Sorry about this, I don't mean to be an absentee maintainer. My life is forfeit through EOY thanks to $dayjob. I've pushed what I have locally (with some minimal amount of testing). Feel free to rebase your sd-vconsole hook against master and push it. You still have commit rights, yes? d
Am 11.12.2013 19:58, schrieb Dave Reisner:
On Wed, Dec 11, 2013 at 02:05:27PM +0100, Thomas Bächler wrote:
Hi Dave, these patches have been sitting here for 2 weeks. I'd love to have this stuff fixed in the repository and preferably have a release.
My sd-vconsole patches have also been sitting here dormant for quite longer and should at some point be available in Arch.
Sorry about this, I don't mean to be an absentee maintainer. My life is forfeit through EOY thanks to $dayjob. I've pushed what I have locally (with some minimal amount of testing). Feel free to rebase your sd-vconsole hook against master and push it. You still have commit rights, yes?
I do. But since you didn't comment on it at all, I'm unsure. It could be a problem that the add_systemd_unit function is not in mkinitcpio, but in the systemd hook.
participants (2)
-
Dave Reisner
-
Thomas Bächler