This is the mail archive of the cygwin 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]

Additions to genini


I've added a few things to the genini.pl script, as I downloaded it from
the CVS archive.  Mostly this was to make it not choke on the setup.hint
files that come with CygWin.

I've added an --append switch, so that one can build a setup.ini file
incrementally, because (at least on my system) I was unable to find a
way to pass the entire huge list of directories to it all at once without
it returning an error that I couldn't figure out the source of.

The two main changes I made were:
1) Check for and fix "internal" quote marks in the "value" fields (this
   particularly shows up in the ldescs in certain packages).  A warning
   will be issued.
2) Check for and fix keys that do not have a space between the colon
   and the value.  A warning will be issued here as well.
3) Check for keys without values, and simply skip them.

Let me know what you think...


--- genini.pl.orig      2006-07-19 13:17:18.000000000 -0600
+++ genini.pl     2006-07-19 15:28:42.000000000 -0600
@@ -15,13 +15,19 @@

 my @okmissing;
 my ($outfile, $help);
-GetOptions('okmissing=s'=>\@okmissing, 'output=s'=>\$outfile,
'help'=>\$help) or usage;
+GetOptions('okmissing=s'=>\@okmissing, 'output=s'=>\$outfile,
'append'=>\$appendfile, 'help'=>\$help) or usage;
 $help and usage;

 @main::okmissing{@okmissing} = @okmissing;

 if (defined($outfile)) {
-    open(STDOUT, '>', $outfile) or die "$0: can't open $outfile - $!\n";
+    my $fmode;
+    if (defined($appendfile)) {
+        $fmode = '>>';
+    } else {
+        $fmode = '>';
+    }
+    open(STDOUT, $fmode, $outfile) or die "$0: can't open $outfile -
$!\n";
 }

 local %pkg;
@@ -34,15 +40,17 @@
     }
 }

-print <<'EOF';
+if (!defined($appendfile)) {
+    print <<'EOF';
 # This file is automatically generated.  If you edit it, your
 # edits will be discarded next time the file is generated.
 # See http://cygwin.com/setup.html for details.
 #
 EOF

-print "$main::setup_timestamp\n" if $main::setup_timestamp;
-print "$main::setup_version\n" if $main::setup_version;
+    print "$main::setup_timestamp\n" if $main::setup_timestamp;
+    print "$main::setup_version\n" if $main::setup_version;
+}

 undef $main::curfile;
 for my $p (sort keys %pkg) {
@@ -88,6 +96,11 @@
          length or last;
          chomp;
          s/(\S)\s+$//;
+            # eliminate internal quote marks, replace with single quotes
+            if ($ ~= /."./) {
+                mywarn "internal quotes in '$key'";
+                s/(.)"(.)/\1'\2/g;
+            }
          $val .= "\n" . $_;
      }
     }
@@ -139,6 +152,16 @@
          $what = $_ . "\n";
          next;
      };
+        # Check for key without a value
+        /^([^:]+):$/ and do {
+            next;
+        };
+     # Check for missing space after the colon
+     /^([^:]+):(.*)$/ and do {
+            mywarn "missing space after colon in '$1'";
+            s/^([^:]+):(.*)$/\1: \2/;
+            redo;
+        };
      die "$0: unrecognized input at line file $ARGV[0], line $.\n";
     }
 }
@@ -241,6 +264,7 @@

     --okmissing=key    don't warn if key is missing from setup.ini or
setup.hint
     --output=file      output setup.ini info to file
+    --append           append to existing file (don't overwrite)
     --help             display this message

 Report bugs to cygwin mailing list.
@@ -251,8 +275,8 @@
 BEGIN {
     my @cats = qw'
      Admin Archive Audio Base Comm Database Devel Doc Editors Games
-     Gnome Graphics Interpreters Libs Mail Math Mingw Net Publishing
-     Science Shells Sound System Text Utils Web X11
+     Gnome Graphics Interpreters KDE Libs Mail Math Mingw Net Perl
+     Publishing Python Science Shells System Text Utils Web X11
      _obsolete _PostInstallLast
      ';
     @main::categories{map {lc $_} @cats} = @cats;


--
Unsubscribe info:      http://cygwin.com/ml/#unsubscribe-simple
Problem reports:       http://cygwin.com/problems.html
Documentation:         http://cygwin.com/docs.html
FAQ:                   http://cygwin.com/faq/


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