[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Bug#807708: Implicitly overrides version number without --force



Package: flash-kernel
Version: 3.52
Tags: patch

When you run flash-kernel with a specific version number, it will
simply ignore the version number if there's a higher version unless
you use --force.  I think flash-kernel should at least print a warning
in this case.

tbm@debian:~$ sudo flash-kernel 4.2.0-1-kirkwood
[sudo] password for tbm:
kirkwood-qnap: machine: QNAP TS219 family
DTB: kirkwood-ts219-6281.dtb
Installing kirkwood-ts219-6281.dtb into /boot/dtbs/4.2.0-1-kirkwood/kirkwood-ts219-6281.dtb
Taking backup of kirkwood-ts219-6281.dtb.
Installing new kirkwood-ts219-6281.dtb.
Installing kirkwood-ts219-6281.dtb into /boot/dtbs/4.4.0-rc4-kirkwood/kirkwood-ts219-6281.dtb
Taking backup of kirkwood-ts219-6281.dtb.
Installing new kirkwood-ts219-6281.dtb.
flash-kernel: installing version 4.4.0-rc4-kirkwood
flash-kernel: appending
/usr/lib/linux-image-4.4.0-rc4-kirkwood/kirkwood-ts219-6281.dtb to kernel

When I tried to add a warning, I noticed that there's some similar
code, so I combined it into one block.  (Note that I dropped the -n
"$kvers" check since there's a comparison between $kvers and
$latest_version anyway, but maybe that's wrong).

The only remaining problem is that it installs the .dtb of the old
kernel before changing the kernel version and installing the new .dtb.
I'm not familiar with the code so I'm not sure if we can move the
first handle_dtb call down or the version change up.

Anyway, with this patch you get:

root@debian:/home/tbm# flash-kernel 4.2.0-1-kirkwood
kirkwood-qnap: machine: QNAP TS219 family
DTB: kirkwood-ts219-6281.dtb
Installing kirkwood-ts219-6281.dtb into /boot/dtbs/4.2.0-1-kirkwood/kirkwood-ts219-6281.dtb
Taking backup of kirkwood-ts219-6281.dtb.
Installing new kirkwood-ts219-6281.dtb.
Ignoring old or unknown version 4.2.0-1-kirkwood (latest is 4.4.0-rc4-kirkwood)
Use --force if you want version 4.2.0-1-kirkwood.
Installing kirkwood-ts219-6281.dtb into /boot/dtbs/4.4.0-rc4-kirkwood/kirkwood-ts219-6281.dtb
Taking backup of kirkwood-ts219-6281.dtb.
Installing new kirkwood-ts219-6281.dtb.

-- 
Martin Michlmayr
http://www.cyrius.com/
diff --git a/functions b/functions
index 5829d51..b6713b5 100644
--- a/functions
+++ b/functions
@@ -637,10 +637,6 @@ if [ -n "$kvers" ] ; then
 fi
 
 latest_version=$(linux-version list | linux-version sort | tail -1)
-if [ -n "$kvers" ] && [ "x$force" != "xyes" ] && [ "$kvers" != "$latest_version" ] && [ "$FK_KERNEL_HOOK_SCRIPT" = "postinst.d" ]; then
-	echo "Ignoring old or unknown version $kvers (latest is $latest_version)" >&2
-	exit 0
-fi
 
 if [ -n "$kvers" ] && [ "$FK_KERNEL_HOOK_SCRIPT" = "postrm.d" ]; then
 	echo "flash-kernel: Kernel ${kvers} has been removed." >&2
@@ -663,6 +659,11 @@ if [ "$kvers" != "$latest_version" ] && [ "x$force" = "xyes" ]; then
 	echo "flash-kernel: forcing install of ${kvers} instead of ${latest_version}." >&2
 	echo "flash-kernel: WARNING: Installing any new kernel package might override this." >&2
 else
+	echo "Ignoring old or unknown version $kvers (latest is $latest_version)" >&2
+	if [ "$FK_KERNEL_HOOK_SCRIPT" = "postinst.d" ]; then
+		exit 0
+	fi
+	echo "Use --force if you want version $kvers." >&2
 	kvers="$latest_version"
 	# Make sure we install the DTB for $latest_version
 	handle_dtb

Reply to: