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

Re: Kernel-package, fix version 2 ...



On Mon, Oct 24, 2005 at 12:53:22PM +0200, Mattia Dongili wrote:
> [sorry again for line wrapping]
> 
> On Mon, October 24, 2005 10:58 am, Sven Luther said:
> > On Mon, Oct 24, 2005 at 11:01:53AM +0200, Mattia Dongili wrote:
> [...]
> >> 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));
> >
> > Oh, right, altough your code disregard the fact that i need to check for
> > two return values of the --supported* case.
> 
> oh, I'm just not considering the fact that '$_ --supported-*' can return
> other values than just 0 or 1. Is this the case? AFAIR you were talking of
> some tool returning 2 in some case, if so please discard my suggestion?

hehe, indeed and system returns values shifted by 8 even. Current code is :

my @ramdisklist =
  grep {
    if (-x) {
      my $ret = system ("$_ --supported-host-version=$hostversion --supported-target-version=$version 1>/dev/null 2>&1") >> 8;
      $ret == 0 or (
        $ret == 1 and (
          (("$_" eq "/usr/sbin/mkinitrd") and
           (system ("dpkg", "--compare-versions", "$version", "lt", "2.6.13") == 0)) or
          (("$_" eq "/usr/sbin/mkinitramfs") and
           (system ("dpkg", "--compare-versions", "$version", "lt", "2.6.12") == 1)) or
          (("$_" 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));

As you suggested below, does this sound reasonable ? Seems to work fine.

Friendly,

Sven Luther



Reply to: