On Monday 04 February 2008, Frans Pop wrote: > 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'. [18:27:07] <cjwatson> fjp: personally I'd just allow any postfix; if somebody creates -footbridge-blah that isn't compatible with -footbridge then I think that's their own fault [18:27:19] <cjwatson> seems a much simpler solution with no downsides [18:28:15] <fjp> Yep, was coming to that conclusion too. So, we're going for solution 2). I'll be committing the attached patch unless I hear any objections. The testsuite still runs without errors of course. The only real change is that for arm* and m68k postfixes are now allowed. The change from using expr to grep is because expr does not support ? as meta character. The use of ? allowed to simplify some tests. Cheers, FJP
Index: README =================================================================== --- README (revision 51179) +++ README (working copy) @@ -27,6 +27,16 @@ have subarchitectures that are incompatible at the kernel level. This function should cope with both cases. + Note that by default any postfix (starting with a hyphen) is allowed + after the flavor. This allows for custom kernels and also, for example, + for kernel meta packages for stable kernel updates that have a postfix + to distinguish them from the regular kernel meta packages. + This means that if a specific postfix (such as -smp, or -bigmem) is not + allowed, this should be tested explicitly. + + The same goes for prefixes: any prefix before the flavor is allowed by + default. + Returns zero if the kernel is usable on this flavour, or non-zero otherwise. 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(-.*)?$"; 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(-.*)?$"; 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(-.*)?$"; 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(-.*)?$"; 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(-.*)?$"; 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(-.*)?$"; 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(-.*)?$"; then return 0; fi return 1 } Index: powerpc.sh =================================================================== --- powerpc.sh (revision 51179) +++ powerpc.sh (working copy) @@ -22,12 +22,7 @@ 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 + if echo "$1" | grep -Eq -- "-$2(-.*)?$"; then return 0; fi return 1 } Index: m68k.sh =================================================================== --- m68k.sh (revision 51179) +++ m68k.sh (working copy) @@ -12,8 +12,8 @@ } arch_check_usable_kernel () { - # Subarchitecture must match exactly. - if expr "$1" : ".*-$2\$" >/dev/null; then return 0; fi + # Subarchitecture must match exactly + if echo "$1" | grep -Eq -- "-$2(-.*)?$"; 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(-.*)?$"; 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)?(-.*)?$"; 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?(-.*)?$"; 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(-.*)?$"; 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(-.*)?$"; 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(-.*)?$"; 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(-.*)?$"; 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(-.*)?$"; then return 0 fi return 1 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(-.*)?$"; 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(-.*)?$"; 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(-.*)?$"; 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(-.*)?$"; then return 0; fi # default to usable in case of strangeness warning "Unknown kernel usability: $1 / $2" Index: tests/dotest =================================================================== --- tests/dotest (revision 51179) +++ tests/dotest (working copy) @@ -65,6 +65,16 @@ fi done + # By default any postfix should be allowed + for kernel in $USABLE; do + testname="arch_check_usable_kernel $KERNEL_MAJOR ${kernel}-<postfix> should be usable" + if arch_check_usable_kernel "${kernel}-postfix" "$GOT_FLAVOUR"; 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: tests/powerpc/chrp_ibm.test =================================================================== --- tests/powerpc/chrp_ibm.test (revision 51179) +++ tests/powerpc/chrp_ibm.test (working copy) @@ -9,8 +9,10 @@ linux-image-2.6.18-4-powerpc64 unusable \ linux-image-2.6-powerpc \ + linux-image-2.6-powerpc-miboot \ linux-image-2.6-powerpc-smp \ linux-image-2.6-prep \ linux-image-2.6.18-4-powerpc \ + linux-image-2.6.18-4-powerpc-miboot \ linux-image-2.6.18-4-powerpc-smp \ linux-image-2.6.18-4-prep Index: tests/powerpc/powermac7,3.test =================================================================== --- tests/powerpc/powermac7,3.test (revision 51179) +++ tests/powerpc/powermac7,3.test (working copy) @@ -8,8 +8,10 @@ linux-image-2.6.18-4-powerpc64 unusable \ linux-image-2.6-powerpc \ + linux-image-2.6-powerpc-miboot \ linux-image-2.6-powerpc-smp \ linux-image-2.6-prep \ linux-image-2.6.18-4-powerpc \ + linux-image-2.6.18-4-powerpc-miboot \ linux-image-2.6.18-4-powerpc-smp \ linux-image-2.6.18-4-prep Index: tests/powerpc/g5.test =================================================================== --- tests/powerpc/g5.test (revision 51179) +++ tests/powerpc/g5.test (working copy) @@ -8,8 +8,10 @@ linux-image-2.6.18-4-powerpc64 unusable \ linux-image-2.6-powerpc \ + linux-image-2.6-powerpc-miboot \ linux-image-2.6-powerpc-smp \ linux-image-2.6-prep \ linux-image-2.6.18-4-powerpc \ + linux-image-2.6.18-4-powerpc-miboot \ linux-image-2.6.18-4-powerpc-smp \ linux-image-2.6.18-4-prep Index: tests/powerpc/powermac_newworld.test =================================================================== --- tests/powerpc/powermac_newworld.test (revision 51179) +++ tests/powerpc/powermac_newworld.test (working copy) @@ -5,8 +5,10 @@ kernel-2.6 linux-image-2.6-powerpc usable \ linux-image-2.6-powerpc \ + linux-image-2.6-powerpc-miboot \ linux-image-2.6-powerpc-smp \ linux-image-2.6.18-4-powerpc \ + linux-image-2.6.18-4-powerpc-miboot \ linux-image-2.6.18-4-powerpc-smp unusable \ linux-image-2.6-powerpc64 \
Attachment:
signature.asc
Description: This is a digitally signed message part.