This is the mail archive of the cygwin-apps mailing list for the Cygwin project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: genini: support multiple compression formats


Christopher Faylor wrote:
> On Wed, Mar 10, 2010 at 09:41:34PM -0500, Charles Wilson wrote:
>> I'm working on adding .xz support to setup via mingw-liblzma. It's
>> code-complete, but I still have a lot of testing to do.  To that end, I
>> found that genini needs to be taught about tarballs whose name ends in
>> something other than ".bz2".
>>
>> upset will need something similar, I guess.
>>
>> 2010-03-10  Charles Wilson  <...>
>>
>> 	* genini (parsedir): Support tarballs whose name ends in gz,
>> 	lzma, and xz in addition to bz2.
>> 	(filer): Test for existence of tarballs to determine which
>> 	compression format/extension is used. If not found, default
>> 	to .bz2.
>> 	(addfiles): Ripple from changes to filer().
>>
>> --
>> Chuck
> 
>> Index: genini
>> ===================================================================
>> RCS file: /cvs/cygwin-apps/genini/genini,v
>> retrieving revision 1.9
>> diff -u -p -r1.9 genini
>> --- genini	2 Mar 2010 00:23:04 -0000	1.9
>> +++ genini	11 Mar 2010 02:37:41 -0000
>> @@ -173,7 +173,7 @@ sub parsedir {
>>     }
>>
>>     return if $explicit;
>> -    my @files = sort grep{!/-src\.tar.bz2/} glob("$d/*.tar.bz2");
>> +    my @files = sort grep{!/-src\.tar\.(gz|bz2|lzma|xz)/} glob("$d/*.tar.{gz,bz2,lzma,xz}");
> 
> This is ok, but maybe it would be worth exploring putting all of the
> extensions at the top of the file somewhere.

Something like this, at the top of the file (untested)?

my @cmp_fmts = qw(gz bz2 lzma xz);
my $cmp_fmts_grep = join('|', @cmp_fmts);
my $cmp_fmts_glob = join(',', @cmp_fmts);

Then:

my @files = sort grep{!/-src\.tar\.($cmp_fmts_grep)/}
glob("$d/*.tar.{$cmp_fmts_glob}");

Dunno if that would work -- obviously you can interpolate $vars inside
glob(), since $d works, but also inside grep{}?

> Why not just pass the extensions as the final N arguments?  Then there's
> no need to pass a reference to an array...

I don't think that would work, given the way -src is handled:

>> -    my $install = "$d/" . tarball($pname, $x->{'version'});
>> -    my $source  = "$d/" . tarball($pname, $x->{'version'}, 'src');

+my $install = tarball($d, $pname, $x->{'version'}, @cmp_fmts);
+my $source  = tarball($d, $pname, $x->{'version'}, 'src', @cmp_fmts);

???

Actually, if @cmp_fmts is set up at the top of the file, then we
wouldn't have to pass it in via the argument list at all.

>>
>> sub tarball {
>> -    return join('-', @_) . '.tar.bz2';
>> +    my $d = shift;
>> +    my @c = @{(shift)};
>> +    my $b = join('-', @_) . '.tar.';
>> +    my $f;
>> +    for my $e (@c) {
> 
> ...then you just iterate over @_ here.

See above.  Is there are real problem with array references? I'm no perl
guru (obviously)...

--
Chuck


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]