Re: Kernel-package, fix version 2 ...
On Mon, October 24, 2005 9:58 am, Sven Luther said:
[...]
> Mattia, could you look over this code :
>
> chomp (my $hostversion = `uname -r`);
> my @ramdisklist =
> grep {
> my $ret = system ("$_ --supported-host-version=$hostversion
> --supported-target-version=$version 1>/dev/null 2>&1");
> -x and (
> $ret == 0 or (
> $ret == 1 and (
> (($ramdisk eq "/usr/sbin/mkinitrd") and
> (system ("dpkg", "--compare-versions", "$version", "lt",
> "2.6.13") == 0)) or
> (($ramdisk eq "/usr/sbin/mkinitramfs") and
> (system ("dpkg", "--compare-versions", "$version", "lt",
> "2.6.12") == 1)) or
> (($ramdisk eq "/usr/sbin/mkinitrd.yaird") and
> (system ("dpkg", "--compare-versions", "$version", "lt",
> "2.6.8") == 1) and
> (system ("dpkg", "--compare-versions", "$hostversion", "lt",
> "2.6.8") == 1))
> )
> )
> )
> }
> (split (/ /, $ramdisk));
you could rewrite the grep this way:
my @ramdisklist =
grep {
-x and (
system ("$_ --supported-host-version=$hostversion
--supported-target-version=$version 1>/dev/null 2>&1") == 0
or (
(($ramdisk eq "/usr/sbin/mkinitrd") and (system ("dpkg",
"--compare-versions", "$version", "lt", "2.6.13") == 0))
or
(($ramdisk eq "/usr/sbin/mkinitramfs") and (system ("dpkg",
"--compare-versions", "$version", "lt", "2.6.12") == 1))
or
(($ramdisk eq "/usr/sbin/mkinitrd.yaird") and (system
("dpkg", "--compare-versions", "$version", "lt", "2.6.8") ==
1) and (system ("dpkg", "--compare-versions",
"$hostversion", "lt", "2.6.8") == 1))
)
)
}
(split (/ /, $ramdisk));
this way you _first_ test for '-x', only then you go ahead with the rest
of the stuff.
> my $ramdiskorig = $ramdisk;
> defined ($ramdisk = shift @ramdisklist)
> or die ("Failed to find suitable ramdisk generation tool for kernel
> version $version on running kernel $hostversion in $ramdiskorig\n");
>
> print STDERR "Using $ramdisk to build the ramdisk.";;
> if (@ramdisklist) { print STDERR "Other suitable ramdisk generating
> tools : @ramdisklist.\n"; }
> print STDERR "Full list of probed ramdisk generating tools :
> $ramdiskorig.\n";
>
> and tell me if there is any glaring error in it.
>
> The code does the following :
>
> 1) tests if the tool exists.
> 2) tests if the tool returns 0 for the given host and target version.
> 3) if the tool returns 1, this means --supported-* is not supported, do an
> explicit check.
> Checks are :
>
> 3.1) mkinitrd is ok if target < 2.6.13.
> 3.2) mkinitramfs is ok if target >= 2.6.12.
> 3.3) mkinitrd.yaird is ok if target >= 2.6.8 and host >= 2.6.8.
other than the grep issue, seems ok to me
--
mattia
:wq!
Reply to: