Skip to content

Commit 299906f

Browse files
committed
make-initrd: Add option to build initramfs for latest kernel
Signed-off-by: Alexey Gladkov <[email protected]>
1 parent 78fb926 commit 299906f

File tree

2 files changed

+15
-1
lines changed

2 files changed

+15
-1
lines changed

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: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -110,12 +110,25 @@ check_noexec() {
110110
return $rc
111111
}
112112

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' -- "$@"` ||
113+
latest_kernel()
114+
{
115+
find /lib/modules/ -mindepth 2 -maxdepth 2 -type d -name kernel -printf '%h\n' |
116+
xargs -r basename |
117+
sort --version-sort |
118+
tail -1
119+
}
120+
121+
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' -- "$@"` ||
114122
show_usage
115123
eval set -- "$TEMP"
116124

117125
while :; do
118126
case "$1" in
127+
--latest-kernel)
128+
KERNEL="$(latest_kernel)"
129+
[ -n "$KERNEL" ] ||
130+
fatal "Unable to find latest kernel"
131+
;;
119132
-b|--bootdir) shift
120133
BOOTDIR="$(opt_check_dir --bootdir "$1")"
121134
;;

0 commit comments

Comments
 (0)