Re: genini patch to support the new message field

2010-03-01 Thread Brendan Conoboy

On 02/28/2010 04:51 PM, Christopher Faylor wrote:

I think it makes more sense to test for message initially and, if found skip
over the keyword and parse the rest of the line as normal:

Does this work?


Yes- genini produces the same output with either of our two patches.

Are there any other new fields being contemplated in setup.hint?

--
Brendan Conoboy / Red Hat, Inc. / b...@redhat.com


Re: genini patch to support the new message field

2010-02-28 Thread Christopher Faylor
On Fri, Feb 26, 2010 at 09:03:46PM -0700, Brendan Conoboy wrote:
2010-02-26  Brendan Conoboy  b...@redhat.com

 * genini (get): Handle special 'message' format case.

***
*** 84,92 
  my $key = shift;
  my $val = shift;
  
! if (substr($val, 0, 1) ne '') {
!  $val = ''. $val . '' if $key eq 'ldesc' || $key eq 'sdesc';
! } else {
   while (length($val) == 1 || $val !~ /$/os) {
   $_ = $FH;
   length or last;
--- 84,90 
  my $key = shift;
  my $val = shift;
  
! if ( (substr($val, 0, 1) eq '') or ($key eq message and $val =~ 
/\w\s+/) ) {

(Please adhere to the rest of the file and use '||' and '' in if
expressions.)

I think it makes more sense to test for message initially and, if found skip
over the keyword and parse the rest of the line as normal:

Does this work?

cgf

Index: genini
===
RCS file: /cvs/cygwin-apps/genini/genini,v
retrieving revision 1.7
diff -d -u -r1.7 genini
--- genini  23 Feb 2007 16:24:17 -  1.7
+++ genini  28 Feb 2010 23:50:08 -
@@ -49,7 +49,7 @@
 undef $main::curfile;
 for my $p (sort keys %pkg) {
 print \n@ $p\n;
-for my $key ('sdesc', 'ldesc', 'category', 'requires') {
+for my $key ('sdesc', 'ldesc', 'category', 'requires', 'message') {
my $val = $pkg{$p}{''}{$key};
if (!defined($val)  $pkg{$p}{''}{'install'} !~ /_obsolete/o) {
mywarn package $p is missing a $key field
@@ -81,11 +81,14 @@
 
 sub get {
 my $FH = shift;
-my $key = shift;
+my $keyhint = shift;
 my $val = shift;
 
-if (substr($val, 0, 1) ne '') {
-   $val = ''. $val . '' if $key eq 'ldesc' || $key eq 'sdesc';
+if ($keyhint eq 'message') {
+   my ($kw, $rest) = /^(\S+)\s+(.*)$/;
+   return $kw . ' ' . get($FH, 'ldesc', $rest);
+} elsif (substr($val, 0, 1) ne '') {
+   $val = ''. $val . '' if $keyhint eq 'ldesc' || $keyhint eq 'sdesc';
 } else {
while (length($val) == 1 || $val !~ /$/os) {
$_ = $FH;


RE: genini patch

2007-02-27 Thread Servaas Goossens
Christopher Faylor wrote:
 Again, sorry but I am not really supporting genini.  I 
 provided it as a
 proof of concept when people thought they had a right to have 
 some sort
 of way to handle the awful complexity of setup.hint files.  
 Since there
 is nothing important relying on it, I'm comfortable leaving it as is
 until somebody does it the right way.  

Ok. (I just wonder how the setup.ini for the official release 
is created.)

Anyway, I now have a genini that works for me, and I'm happy that
some of my patches were useful to you. 

Greetings,
Servaas.


Re: genini patch

2007-02-27 Thread Christopher Faylor
On Tue, Feb 27, 2007 at 01:31:18PM +0100, Servaas Goossens wrote:
Christopher Faylor wrote:
Again, sorry but I am not really supporting genini.  I provided it as a
proof of concept when people thought they had a right to have some sort
of way to handle the awful complexity of setup.hint files.  Since there
is nothing important relying on it, I'm comfortable leaving it as is
until somebody does it the right way.

Ok.  (I just wonder how the setup.ini for the official release is
created.)

Not with genini.

cgf


RE: genini patch

2007-02-25 Thread Servaas Goossens
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.0 +0100
+++ genini  2007-02-25 11:14:23.0 +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);
 }
 }


Re: genini patch

2007-02-23 Thread Christopher Faylor
On Fri, Feb 23, 2007 at 09:59:25AM +0100, Servaas Goossens wrote:
Thanks for submitting my previous patches. I have further modified 
genini so that it generates output that is parsed without errors by 
setup.exe. I also fixed the sorting problem for file versions (ref: 
http://sourceware.org/ml/cygwin-apps/2006-09/msg00020.html).

A few issues remain, but setup.exe seems to accept them:
* genini generates one line for the non-existing db package (@ db)
* genini doesn't include some -src files that do exist in the official
  setup.ini. This seems to be related to external-source values in 
  setup.hint. Maybe the error is in the .hint file? (e.g. gcc)
* for postgresql genini includes a [prev] version with no files (install
  or source). These files don't exist: the error is in the setup.hint.

Here's the changelog:

* 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.

(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.


(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.

Don't output keys with empty values

Committed

Fix minor typo in warning

Committed

New categories: KDE, Perl, Python

Committed

cgf