Skip to content

Commit 74b7aae

Browse files
committed
make-initrd: Add option to build initramfs for latest kernel
Signed-off-by: Alexey Gladkov <gladkov.alexey@gmail.com>
1 parent 78fb926 commit 74b7aae

File tree

3 files changed

+22
-1
lines changed

3 files changed

+22
-1
lines changed

Documentation/manpages/make-initrd.1.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,10 @@ Without options, the program generates images for all the configuration files.
5252
Creates an UEFI executable with the kernel, cmdline and initramfs combined.
5353

5454
# OPTIONS
55+
*--latest-kernel*
56+
create an initramfs image for the highest kernel version that can be found,
57+
cnot the currently running kernel.
58+
5559
*-D, --no-depmod*
5660
don’t recreate a list of module dependencies.
5761

contrib/bash-completion/make-initrd

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ _make_initrd()
55

66
local subcommands="guess-modules guess-config bug-report feature-info uki"
77
local opts="
8+
--latest-kernel
89
-D --no-depmod
910
-N --no-checks
1011
-c --config=

utils/make-initrd/make-initrd.in

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,9 @@ show_help() {
6464
initramfs combined;
6565
6666
Options:
67+
--latest-kernel create an initramfs image for the highest kernel
68+
version that can be found, not the currently
69+
running kernel;
6770
-D, --no-depmod don't recreate a list of module dependencies;
6871
-N, --no-checks don't check /dev, /proc and the kernel
6972
modules directory;
@@ -110,12 +113,25 @@ check_noexec() {
110113
return $rc
111114
}
112115

113-
TEMP=`getopt -n "$PROG" -o 'b:,c:,k:,D,N,h,v,V' -l 'bootdir:,config:,kernel:,no-depmod,no-checks,help,verbose,version' -- "$@"` ||
116+
latest_kernel()
117+
{
118+
find /lib/modules/ -mindepth 2 -maxdepth 2 -type d -name kernel -printf '%h\n' |
119+
xargs -r basename |
120+
sort --version-sort |
121+
tail -1
122+
}
123+
124+
TEMP=`getopt -n "$PROG" -o 'b:,c:,k:,D,N,h,v,V' -l 'bootdir:,config:,kernel:,latest-kernel,no-depmod,no-checks,help,verbose,version' -- "$@"` ||
114125
show_usage
115126
eval set -- "$TEMP"
116127

117128
while :; do
118129
case "$1" in
130+
--latest-kernel)
131+
KERNEL="$(latest_kernel)"
132+
[ -n "$KERNEL" ] ||
133+
fatal "Unable to find latest kernel"
134+
;;
119135
-b|--bootdir) shift
120136
BOOTDIR="$(opt_check_dir --bootdir "$1")"
121137
;;

0 commit comments

Comments
 (0)