On Monday 04 February 2008, Frans Pop wrote: > On Monday 04 February 2008, Frans Pop wrote: > > There is one issue, which I will detail in a follow-up mail to > > debian-boot only. The short summary is that for arm the etchnhalf > > kernel meta packages are currently not considered "installable", so as > > things stand now the above would not work for arm. > > The problem is also valid for armeb, armel and m68k, but those arches are > not really relevant for Etch+1/2. > > Right, so this is what happens. Current kernel selection scripts use one > of these formats to test whether a kernel is usable (note quoting): > 1) expr "$1" : '.*-<flavor>.*' > 2) expr "$1" : '.*-<flavor>' > 3) expr "$1" : '.*-<flavor>$' OR expr "$1" : ".*-<flavor>\$" > > Tests for a lot of arches look like 1), some like 2). But effectively > those are identical, which is confusing. The "problem" arches use 3). > > With tests 1) and 2), basically _any_ postfix after the flavor is > allowed, which could possibly be considered a bug but I do now make use > of that fact in the etchnhalf patches.
I'd like to propose the attached patch, which both tightens the kernel selection for most arches and solves the issue for Etch+1/2 for arm. A trivial change in library.sh is needed as well. The one downside to this patch is that (if I read library.sh correctly) we would now disallow custom kernels that follow the Debian naming scheme but have an added postfix. Unless of course the user specifies his postfix in base-installer/kernel/altmeta. There could be two other solutions to that: 1) Instead of allowing only a specific postfix, allow _any_ postfix starting with a hyphen. 2) For preseeded kernels, don't test against the "filtered" kernel list, but only test if the kernel exists by grepping '$KERNEL_LIST.unfiltered'. Cheers, FJP
Index: mips.sh =================================================================== --- mips.sh (revision 51179) +++ mips.sh (working copy) @@ -14,15 +14,15 @@ arch_check_usable_kernel () { # Subarchitecture must match exactly - if expr "$1" : ".*-$2.*" >/dev/null; then return 0; fi + if echo "$1" | grep -Eq -- "-$2($3)?$"; then return 0; fi # For 2.6, the r4k-ip22 kernel will do for r5k-ip22 as well - if expr "$1" : ".*-2\.6.*-r4k-ip22.*" >/dev/null && \ - [ "$2" = r5k-ip22 ]; then + if [ "$2" = r5k-ip22 ] && \ + echo "$1" | grep -Eq -- "-r4k-ip22($3)?$"; then return 0 fi # The 4kc-malta kernel will do for 5kc-malta as well - if expr "$1" : ".*-4kc-malta.*" >/dev/null && \ - [ "$2" = 5kc-malta ]; then + if [ "$2" = 5kc-malta ] && \ + echo "$1" | grep -Eq -- "-4kc-malta($3)?$"; then return 0 fi return 1 Index: sparc.sh =================================================================== --- sparc.sh (revision 51179) +++ sparc.sh (working copy) @@ -4,7 +4,7 @@ } arch_check_usable_kernel () { - if expr "$1" : '.*-sparc64.*' >/dev/null; then return 0; fi + if echo "$1" | grep -Eq -- "-sparc64(-smp)?($3)?$"; then return 0; fi return 1 } Index: amd64.sh =================================================================== --- amd64.sh (revision 51179) +++ amd64.sh (working copy) @@ -12,8 +12,7 @@ } arch_check_usable_kernel () { - # Generic kernels can be run on any machine - if expr "$1" : '.*-amd64' >/dev/null; then return 0; fi + if echo "$1" | grep -Eq -- "-amd64($3)?$"; then return 0; fi return 1 } Index: arm.sh =================================================================== --- arm.sh (revision 51179) +++ arm.sh (working copy) @@ -17,10 +17,10 @@ arch_check_usable_kernel () { # Netwinder subarch uses footbridge kernel flavor if [ "$2" = "netwinder" ]; then - if expr "$1" : ".*-footbridge\$" >/dev/null; then return 0; fi + if echo "$1" | grep -Eq -- "-footbridge($3)?$"; then return 0; fi fi # Subarchitecture must match exactly - if expr "$1" : ".*-$2\$" >/dev/null; then return 0; fi + if echo "$1" | grep -Eq -- "-$2($3)?$"; then return 0; fi return 1 } Index: powerpc.sh =================================================================== --- powerpc.sh (revision 51179) +++ powerpc.sh (working copy) @@ -21,13 +21,21 @@ } arch_check_usable_kernel () { - # CPU family must match exactly - if [ "$2" = powerpc ]; then - # powerpc is a substring of powerpc64, so we have to check - # this separately - if expr "$1" : ".*-powerpc64.*" >/dev/null; then return 1; fi - fi - if expr "$1" : ".*-$2.*" >/dev/null; then return 0; fi + case $2 in + powerpc64) + # Allow both powerpc and powerpc64 + if echo "$1" | grep -Eq -- "-$2(64)?(-smp)?($3)?$"; then + return 0 + fi ;; + powerpc) + # Also allow miboot kernels + if echo "$1" | grep -Eq -- "-$2(-smp|-miboot)?($3)?$"; then + return 0 + fi ;; + *) + # CPU family must match exactly + if echo "$1" | grep -Eq -- "-$2(-smp)?($3)?$"; then return 0; fi + esac return 1 } Index: README =================================================================== --- README (revision 51179) +++ README (working copy) @@ -19,7 +19,7 @@ Returns zero if successful, or non-zero otherwise. If non-zero, it should print some kind of warning to syslog explaining why. - arch_check_usable_kernel (kernel, flavour) + arch_check_usable_kernel (kernel, flavour, postfix) Test whether a kernel is usable at all. For the purposes of this test, we assume that SMP is usable on UP and vice versa (is this safe?). Some @@ -27,6 +27,10 @@ have subarchitectures that are incompatible at the kernel level. This function should cope with both cases. + The parameter "postfix" is optional. If it has a value, then a kernel + which has the postfix appended to its name is considered usable + _in addition_ to the kernel without the postfix. + Returns zero if the kernel is usable on this flavour, or non-zero otherwise. Index: m68k.sh =================================================================== --- m68k.sh (revision 51179) +++ m68k.sh (working copy) @@ -13,7 +13,7 @@ arch_check_usable_kernel () { # Subarchitecture must match exactly. - if expr "$1" : ".*-$2\$" >/dev/null; then return 0; fi + if echo "$1" | grep -Eq -- "-$2($3)?$"; then return 0; fi return 1 } Index: armeb.sh =================================================================== --- armeb.sh (revision 51179) +++ armeb.sh (working copy) @@ -11,7 +11,7 @@ arch_check_usable_kernel () { # Subarchitecture must match exactly - if expr "$1" : ".*-$2\$" >/dev/null; then return 0; fi + if echo "$1" | grep -Eq -- "-$2($3)?$"; then return 0; fi return 1 } Index: hppa.sh =================================================================== --- hppa.sh (revision 51179) +++ hppa.sh (working copy) @@ -4,12 +4,9 @@ } arch_check_usable_kernel () { - if expr "$1" : '.*-parisc-' >/dev/null; then return 0; fi - if expr "$1" : '.*-parisc$' >/dev/null; then return 0; fi - if expr "$1" : '.*-32.*' >/dev/null; then return 0; fi + if echo "$1" | grep -Eq -- "-parisc(32)?(-smp)?($3)?$"; then return 0; fi if [ "$2" = parisc ]; then return 1; fi - if expr "$1" : '.*-parisc64.*' >/dev/null; then return 0; fi - if expr "$1" : '.*-64.*' >/dev/null; then return 0; fi + if echo "$1" | grep -Eq -- "-parisc64(-smp)?($3)?$"; then return 0; fi # default to usable in case of strangeness warning "Unknown kernel usability: $1 / $2" Index: i386.sh =================================================================== --- i386.sh (revision 51179) +++ i386.sh (working copy) @@ -36,12 +36,12 @@ # Note: the -k7 flavor has been dropped with linux-2.6 (2.6.23-1) arch_check_usable_kernel () { - if expr "$1" : '.*-486.*' >/dev/null; then return 0; fi + if echo "$1" | grep -Eq -- "-486($3)?$"; then return 0; fi if [ "$2" = 486 ]; then return 1; fi - if expr "$1" : '.*-686.*' >/dev/null; then return 0; fi + if echo "$1" | grep -Eq -- "-686(-bigmem)?($3)?$"; then return 0; fi if [ "$2" = 686 ]; then return 1; fi if [ "$2" = k7 ]; then - if expr "$1" : '.*-k7.*' >/dev/null; then return 0; fi + if echo "$1" | grep -Eq -- "-k7($3)?$"; then return 0; fi return 1 fi Index: mipsel.sh =================================================================== --- mipsel.sh (revision 51179) +++ mipsel.sh (working copy) @@ -17,10 +17,10 @@ arch_check_usable_kernel () { # Subarchitecture must match exactly - if expr "$1" : ".*-$2.*" >/dev/null; then return 0; fi + if echo "$1" | grep -Eq -- "-$2($3)?$"; then return 0; fi # The 4kc-malta kernel will do for 5kc-malta as well - if expr "$1" : ".*-4kc-malta.*" >/dev/null && \ - [ "$2" = 5kc-malta ]; then + if [ "$2" = 5kc-malta ] && \ + echo "$1" | grep -Eq -- "-4kc-malta($3)?$"; then return 0 fi return 1 Index: tests/dotest =================================================================== --- tests/dotest (revision 51179) +++ tests/dotest (working copy) @@ -65,6 +65,16 @@ fi done + # An optional postfix should be allowed + for kernel in $USABLE; do + testname="arch_check_usable_kernel $KERNEL_MAJOR $kernel-test should be usable (with postfix set)" + if arch_check_usable_kernel "$kernel-test" "$GOT_FLAVOUR" "-test"; then + ok + else + notok + fi + done + for kernel in $UNUSABLE; do testname="arch_check_usable_kernel $KERNEL_MAJOR $kernel should be unusable" if arch_check_usable_kernel "$kernel" "$GOT_FLAVOUR"; then Index: ppc64.sh =================================================================== --- ppc64.sh (revision 51179) +++ ppc64.sh (working copy) @@ -3,7 +3,7 @@ } arch_check_usable_kernel () { - if expr "$1" : ".*-$2.*" >/dev/null; then return 0; fi + if echo "$1" | grep -Eq -- "-$2(-smp)?($3)?$"; then return 0; fi return 1 } Index: armel.sh =================================================================== --- armel.sh (revision 51179) +++ armel.sh (working copy) @@ -16,7 +16,7 @@ arch_check_usable_kernel () { # Subarchitecture must match exactly - if expr "$1" : ".*-$2\$" >/dev/null; then return 0; fi + if echo "$1" | grep -Eq -- "-$2($3)?$"; then return 0; fi return 1 } Index: ia64.sh =================================================================== --- ia64.sh (revision 51179) +++ ia64.sh (working copy) @@ -8,9 +8,9 @@ } arch_check_usable_kernel () { - if expr "$1" : '.*-itanium.*' >/dev/null; then return 0; fi + if echo "$1" | grep -Eq -- "-itanium($3)?$"; then return 0; fi if [ "$2" = itanium ]; then return 1; fi - if expr "$1" : '.*-mckinley.*' >/dev/null; then return 0; fi + if echo "$1" | grep -Eq -- "-mckinley($3)?$"; then return 0; fi # default to usable in case of strangeness warning "Unknown kernel usability: $1 / $2"
signature.asc
Description: This is a digitally signed message part.