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 patch

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 code could be of some use.

You're right, it was a simplistic approach. Do you mean 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 

	"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,

--- 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>) {
-	s/#.*$//o;
+	s/^#.*$//o;
 	length or next;
@@ -170,17 +171,27 @@
     return if $explicit;
-    my @files = sort grep{!/-src\.tar.bz2/} glob("$d/*.tar.bz2");
-    if (!@files) {
+    # 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";
+    @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);

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