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

Re: Perl help needed for kernel-package mod ... (Was: Bringing the 2.6.13 (and beyond) kernel to sid, solving ramdisk generations issues and stuff.)



On Sat, Oct 15, 2005 at 10:16:48PM +0200, Mattia Dongili wrote:
> On Sat, Oct 15, 2005 at 08:36:11PM +0200, Sven Luther wrote:
> > I would be extremely grateful if someone could take the time and implement
> > this ASAP, as we need this to upload 2.6.13-2 and finish the support.
> 
> It's not entirely clear to me but the following might help. I'm missing
> some bits but if you can give me more insight I'll fix the wrong stuff
> (sorry I never played seriously with initrd :) )

Thanks Mattia, i am extremely thankful for your help. Let's me go over this
proposed code with you to see if i understood well, and add places where it
did not work out.

> #!/usr/bin/perl
> use strict;
> 
> chomp (my $unamedashr = `uname -r`);

We get the kernel version.

> #
> # is lexical comparison enough ?? <---------
> # 2.6.13-rc1 will result in being greater than 2.6.13

We need to use dpkg --compare-versions here, so probably :

> #
> my $ramdisk	= '/usr/sbin/initramfs' if ($unamedashr lt "2.6.13");

my $ramdisk	= '/usr/sbin/mkinitramfs' if (system ("dpkg --compare-versions $unamedashr lt 2.6.13 1>/dev/null 2>&1") == 0)

or something such, but i suppose that this line is precedded by a more generic :
my $ramdisk = '/usr/sbin/mkinitrd', right ? 

> $ramdisk	= "$1"  if /ramdisk\s*=\s*(\S+)/ig;

Does this one not cut at the first space ? I was told to use split instead, or
something such.

> 
> # points 2) 3) of your list
> my @ramdisklist = 
> 	grep { 
> 		-x and 
> 		system ("$_ --supported-host-version=$unamedashr 1>/dev/null 2>&1") == 0 
> 	}
> 	(split (/ /, $ramdisk));

Ok, so we try -x and the call, over the space separadet ramdisk list.
> 
> # point 4) and 5)
> defined ($ramdisk = shift @ramdisklist) 
> 	|| die "Dear user I failed to find an usable tool to create initial ram fs";

We redefine ramdisk to the first element of the list, and die if it is empty.

> my $ret = system("$ramdisk " .
> 		($mkimage ? "-m '$mkimage' " : "") .
> 		"-o $initrd_path.new $modules_base/$version");

And we do the ramdisk call, as normal.

This sounds very nice and very near what i wanted to do, so again, i express
my extreme thanks for you jumping in. So if the first line change is ok, and
the ramdisk = "$1" ... thingy indeed pulls in space also, we have something
which can be uploaded.

Friendly,

Sven Luther



Reply to: