Christopher Faylor wrote: > >* genini (parsedir): Use correct sorting order based on file versions > > It's a lot more complicated than this if you want to get the sorting > right. Maybe the setup.cc code could be of some use.
You're right, it was a simplistic approach. Do you mean version_compare.cc? I don't feel like re-implementing that in perl. Instead I found Sort::Versions (apt-get install libsort-versions-perl). The output looks good given the current release tree. If you don't mind adding the dependency, it would keep the genini code small and simple. See the patch below. > >(get): Fix quotes in sdesc and ldesc values > > It took me a couple of tries but I think I've implemented this in a > slightly cleaner manner than your patch. Ok, great. As I said, I'm not a perl coder: this is in fact the first time I work on a perl script. > >(parse): # in the middle of a line does not start a comment > > Actually, yes it does. It just doesn't start a comment in a quoted > string. I haven't committed this since more work is needed. According to http://sourceware.org/cygwin-apps/setup-head.ini.html: "Any line beginning with # is ignored by setup and can be used to add commentary to the file." All current setup.hint/ini files follow this rule. If you also want to support end-of-line-comments, that's great. Please consider committing my patch as a temporary measure until the final solution is ready. > >Don't output keys with empty values > Committed > > >Fix minor typo in warning > Committed > > >New categories: KDE, Perl, Python > Committed Thank you, Servaas. -- --- genini-1.7 2007-02-25 10:33:14.000000000 +0100 +++ genini 2007-02-25 11:14:23.000000000 +0100 @@ -8,6 +8,7 @@ use File::Basename; use Digest::MD5; use Getopt::Long; +use Sort::Versions; use strict; @@ -108,7 +109,7 @@ open(\*F, '<', $f) or die "$0: couldn't open $f - $!\n"; while (<F>) { chomp; - s/#.*$//o; + s/^#.*$//o; s/^\s+//o; s/(\S)\s+$/$1/o; length or next; @@ -170,17 +171,27 @@ } return if $explicit; - my @files = sort grep{!/-src\.tar.bz2/} glob("$d/*.tar.bz2"); - if ([EMAIL PROTECTED]) { + + # Create list of files and versions + my @versions; + my %files; + foreach my $file (glob("$d/*[0-9].tar.bz2")) { + my $version = getver($file); + push(@versions, $version); + $files{$version} = $file; + } + if (!%files) { myerror "not enough package files in $d"; return; } + @versions = sort { versioncmp($a, $b) } @versions; for my $what ('', "[prev]\n") { - my $f = pop @files or last; + my $version = pop @versions or last; + my $f = $files{$version}; $pkg{$pname}{$what}{-unused} = 1; my $x = $pkg{$pname}{$what}; my $p; - ($p, $x->{'version'}) = getver($f); + ($p, $x->{'version'}) = $version; addfiles($p, $x, $d); } }