Bug#883547: flash-kernel: please allow flavourless kernels

2018-01-06 Thread Vagrant Cascadian
Control: tags 883547 pending

On 2017-12-19, Adam Borowski wrote:
> On Tue, Dec 19, 2017 at 04:04:34AM +0100, Adam Borowski wrote:
>> On Mon, Dec 18, 2017 at 03:08:08PM -0800, Vagrant Cascadian wrote:
>> > I think the following patch should work for this, by setting:
>> > 
>> > Kernel-Flavor: any
>> 
>> > The patch significantly refactors the use of the check_kflavor function,
>> 
>> > I haven't done extensive testing yet, but I could go ahead any push this
>> > myself once I've done more tests, if nobody objects.
>> 
>> Works for me on Odroid-U2 (armhf).
>> 
>> I'll try on Pine64 once a kernel is built, in the morning (it takes two ages
>> and three aeons).
>
> Also works; I guess you already tested on a Pine64 but the amount of manual
> setup required makes systems different.

Pushed to git, should be in the next upload.


live well,
  vagrant


signature.asc
Description: PGP signature


Bug#883547: flash-kernel: please allow flavourless kernels

2017-12-19 Thread Adam Borowski
On Tue, Dec 19, 2017 at 04:04:34AM +0100, Adam Borowski wrote:
> On Mon, Dec 18, 2017 at 03:08:08PM -0800, Vagrant Cascadian wrote:
> > I think the following patch should work for this, by setting:
> > 
> > Kernel-Flavor: any
> 
> > The patch significantly refactors the use of the check_kflavor function,
> 
> > I haven't done extensive testing yet, but I could go ahead any push this
> > myself once I've done more tests, if nobody objects.
> 
> Works for me on Odroid-U2 (armhf).
> 
> I'll try on Pine64 once a kernel is built, in the morning (it takes two ages
> and three aeons).

Also works; I guess you already tested on a Pine64 but the amount of manual
setup required makes systems different.


Meow!
-- 
// If you believe in so-called "intellectual property", please immediately
// cease using counterfeit alphabets.  Instead, contact the nearest temple
// of Amon, whose priests will provide you with scribal services for all
// your writing needs, for Reasonable And Non-Discriminatory prices.



Bug#883547: flash-kernel: please allow flavourless kernels

2017-12-18 Thread Adam Borowski
On Mon, Dec 18, 2017 at 03:08:08PM -0800, Vagrant Cascadian wrote:
> I think the following patch should work for this, by setting:
> 
> Kernel-Flavor: any

> The patch significantly refactors the use of the check_kflavor function,

> I haven't done extensive testing yet, but I could go ahead any push this
> myself once I've done more tests, if nobody objects.

Works for me on Odroid-U2 (armhf).

I'll try on Pine64 once a kernel is built, in the morning (it takes two ages
and three aeons).


Meow!
-- 
// If you believe in so-called "intellectual property", please immediately
// cease using counterfeit alphabets.  Instead, contact the nearest temple
// of Amon, whose priests will provide you with scribal services for all
// your writing needs, for Reasonable And Non-Discriminatory prices.



Bug#883547: flash-kernel: please allow flavourless kernels

2017-12-18 Thread Vagrant Cascadian
Control: tag 883547 +patch
On 2017-12-04, Adam Borowski wrote:
> If for whatever reason you want or need to build your own kernels, the
> preferred way these days is "make bindeb-pkg".  It is also a good idea
> to use CONFIG_LOCALVERSION_AUTO=y, which marks the exact tree used to
> build the kernel.
>
> However, with this option, the version is _appended_ after local version,
> thus making it hard to add that "-armmp" string.
...
> Just allowing an empty string flavour doesn't work, as it'll still want a -
> after the version.

I think the following patch should work for this, by setting:

Kernel-Flavor: any

or even an empty value:

Kernel-Flavor:

(though, if that device has existing value in all.db, it will not be
overridden by the empty value).

The patch significantly refactors the use of the check_kflavor function,
and the one place it is called. Essentially, rather than trying to
derive the suffix from file, comparing that against a known list of good
suffixes, it merely checks if the targeted kernel version ends with one
of the good suffixes.

I haven't done extensive testing yet, but I could go ahead any push this
myself once I've done more tests, if nobody objects.


live well,
  vagrant


diff --git a/functions b/functions
index b2ae5be..8dc542d 100644
--- a/functions
+++ b/functions
@@ -86,17 +86,17 @@ mtdsize() {
 }
 
 check_kflavors() {
-   local kfile_suffix="$1"
-   shift
-
-   if [ -z "$kfile_suffix" ]; then
+   local kvers="$1"
+   local kflavor="$2"
+   if [ "$kflavor" = "any" ]; then
+   return 0
+   fi
+   # count flavor+ as valid
+   kvers=${kvers%%+}
+   if [ "${kvers}" != "${kvers%%$kflavor}" ]; then
+   # kernel version ended with flavor
return 0
fi
-   for kflavor; do
-   if [ "$kfile_suffix" = "$kflavor" ] || [ "$kfile_suffix" = 
"$kflavor+" ]; then
-   return 0
-   fi
-   done
return 1
 }
 
@@ -764,18 +764,16 @@ if ! check_supported "$machine"; then
error "Unsupported platform."
 fi
 
-if kflavors="$(get_machine_field "$machine" "Kernel-Flavors")"; then
-   kfile_suffix=""
-   while [ "$kfile_suffix" != "$kfile" ] ; do
-   kfile_suffix=$(get_kfile_suffix "$kfile" "$kfile_suffix")
-
-   if check_kflavors "$kfile_suffix" $kflavors; then
-   break
-   fi
-   done
-fi
+kfile_suffix=""
+kflavors=$(get_machine_field "$machine" "Kernel-Flavors")
+for kflavor in ${kflavors:-"any"} ; do
+   if check_kflavors "$kvers" "$kflavor" ; then
+   kfile_suffix="$kflavor"
+   break
+   fi
+done
 
-if [ "$kfile_suffix" = "$kfile" ]; then
+if [ -z "$kfile_suffix" ]; then
echo "Kernel $kfile does not match any of the expected flavors 
($kflavors), therefore not writing it to flash." >&2
exit 0
 fi
diff --git a/test_functions b/test_functions
index e75b089..eeea52f 100755
--- a/test_functions
+++ b/test_functions
@@ -116,34 +116,26 @@ add_test test_mtdsize
 test_check_kflavors() {
 (
 . "$functions"
-if check_kflavors "ksuffix" "kflavor1" "kflavor2"; then
+if check_kflavors "4.14.0-1-armmp" "armmp-lpae"; then
 echo "Expected check_kflavors to fail with kernel suffix not in 
expected flavors, but it succeeded" >&2
 exit 1
 fi
-if ! check_kflavors "foo" "kflavor1" "foo" "kflavor3"; then
+if ! check_kflavors "4.14.0-1-armmp-lpae" "armmp-lpae"; then
 echo "Expected check_kflavors to succeed with kernel suffix in 
expected flavors, but it failed" >&2
 exit 1
 fi
-if ! check_kflavors "kflavor1-suffix" "klavor1" "kflavor1-suffix" 
"kflavor2"; then
-echo "Expected check_kflavours to succeed with double-barrelled 
kernel suffix in expected flavours, but it failed" >&2
-exit 1
-fi
-if check_kflavors "kflavor1-suffix" "klavor1" "kflavor2"; then
-echo "Expected check_kflavours to fail with double-barrelled 
kernel suffix not in expected flavours, but it succeeded" >&2
-exit 1
-fi
-if ! check_kflavors "" "kflavor1" "kflavor2" "kflavor3"; then
-echo "Expected check_kflavors to succeed with empty kernel suffix, 
but it failed" >&2
-exit 1
-fi
-if check_kflavors "ksuffix+" "kflavor1" "kflavor2"; then
+if check_kflavors "4.14.0-1-armp-lpae+" "armmp"; then
 echo "Expected check_kflavors to fail with kernel suffix (with 
additional +) not in expected flavors, but it succeeded" >&2
 exit 1
 fi
-if ! check_kflavors "foo+" "kflavor1" "foo" "kflavor2"; then
+if ! check_kflavors "4.14.0-1-armmp-lpae+" "armmp-lpae"; then
 echo "Expected check_kflavours to succeed with kernel suffix (with 
additional +) in expected flavors, but it failed" >&2
 exit 

Bug#883547: flash-kernel: please allow flavourless kernels

2017-12-04 Thread Adam Borowski
Package: flash-kernel
Version: 3.88
Severity: wishlist

Hi!
If for whatever reason you want or need to build your own kernels, the
preferred way these days is "make bindeb-pkg".  It is also a good idea
to use CONFIG_LOCALVERSION_AUTO=y, which marks the exact tree used to
build the kernel.

However, with this option, the version is _appended_ after local version,
thus making it hard to add that "-armmp" string.

I found no way to override this, other than manually editing
--- functions~  2017-08-03 05:01:54.0 +0200
+++ functions   2017-12-05 02:39:54.113903579 +0100
@@ -775,11 +775,6 @@
done
 fi
 
-if [ "$kfile_suffix" = "$kfile" ]; then
-   echo "Kernel $kfile does not match any of the expected flavors 
($kflavors), therefore not writing it to flash." >&2
-   exit 0
-fi
-
 echo "flash-kernel: installing version $kvers" >&2
 
 mkarch="$(get_mkimage_architecture $kvers)"


Just allowing an empty string flavour doesn't work, as it'll still want a -
after the version.

Thus, it would nice if there was an override -- or, perhaps, I'm holding it
wrong?


Meow!
-- System Information:
Debian Release: buster/sid
  APT prefers unstable-debug
  APT policy: (500, 'unstable-debug'), (500, 'unstable'), (500, 'testing'), (1, 
'experimental')
Architecture: armhf (armv7l)

Kernel: Linux 4.14.0-00115-g3d7c587c4c1b (SMP w/4 CPU cores; PREEMPT)
Locale: LANG=C.UTF-8, LC_CTYPE=C.UTF-8 (charmap=UTF-8), LANGUAGE=C.UTF-8 
(charmap=UTF-8)
Shell: /bin/sh linked to /bin/dash
Init: sysvinit (via /sbin/init)

Versions of packages flash-kernel depends on:
ii  debconf [debconf-2.0]  1.5.65
ii  devio  1.2-1.2+b1
ii  initramfs-tools0.130
ii  linux-base 4.5
ii  mtd-utils  1:2.0.1-1
ii  ucf3.0036

Versions of packages flash-kernel recommends:
ii  u-boot-tools  2017.09+dfsg1-3

flash-kernel suggests no packages.

-- debconf information excluded