summaryrefslogtreecommitdiff
path: root/new-infra/use_tldb.pl
diff options
context:
space:
mode:
authorNorbert Preining <preining@logic.at>2007-05-05 13:27:04 +0000
committerNorbert Preining <preining@logic.at>2007-05-05 13:27:04 +0000
commitd50c2f933a09df08e19fb6c6277ff7c0caf0d6bf (patch)
tree680d20d84bf23e2bac3f20b25cc14db80975742d /new-infra/use_tldb.pl
parent6da8fddd44b407d977a0ed6afc948b2c8bc67983 (diff)
test implementation of new infrastructure
git-svn-id: svn://tug.org/texlive/trunk@4243 c570f23f-e606-0410-a88d-b1316a301751
Diffstat (limited to 'new-infra/use_tldb.pl')
-rw-r--r--new-infra/use_tldb.pl241
1 files changed, 241 insertions, 0 deletions
diff --git a/new-infra/use_tldb.pl b/new-infra/use_tldb.pl
new file mode 100644
index 00000000000..d9342a0267b
--- /dev/null
+++ b/new-infra/use_tldb.pl
@@ -0,0 +1,241 @@
+#!/usr/bin/perl -w
+#
+# use_tldb.pl
+# use the tldb file which is nothing else then a concatenation of
+# single tlp files
+# (c) 2007 Norbert Preining
+#
+# This file is licensed under the GNU General Public Licence version 2
+# (not later)
+
+use strict;
+
+my %tldb;
+my $opt_debug = 0;
+
+my $tlpline;
+
+&main(@ARGV);
+
+1;
+
+
+
+
+sub main {
+ my ($tldb) = @_;
+ read_tldb_file($tldb);
+ foreach my $f (keys %tldb) {
+ write_tlp_file($f);
+ }
+}
+
+sub read_tldb_file {
+ my ($tldb) = @_;
+ open(TMP,"<$tldb") || die("Cannot open $tldb: $!");
+ my @lines = <TMP>;
+ close(TMP);
+ my $name = "";
+ my $shortdesc = "";
+ my $longdesc= "";
+ my $catalogue = "";
+ my (@executes, @depends);
+ my (@runfiles, @docfiles, @binfiles, @srcfiles);
+ my $started = 0;
+ my $lastcmd =
+
+ logit("Working on $tldb\n");
+ foreach my $line (@lines) {
+ logit("line=>>>$line<<<\n");
+ $line =~ /^\s*#/ && next; # skip comment lines
+ if ($line =~ /^\s*$/) {
+ if ($started) {
+ # one entry is finished, we have to fill the hash and
+ # clean the tmp variables
+ # clear the tmp variables
+ @runfiles = @docfiles = @srcfiles = @binfiles = ();
+ @executes = @depends = ();
+ $shortdesc = $longdesc = $catalogue = "";
+ $started = 0;
+ next;
+ } else {
+ # ignore empty lines between tlps
+ next;
+ }
+ }
+ if ($line =~ /^ /) {
+ if ( ($lastcmd eq "longdesc") ||
+ ($lastcmd eq "runfiles") ||
+ ($lastcmd eq "binfiles") ||
+ ($lastcmd eq "docfiles") ||
+ ($lastcmd eq "srcfiles") ||
+ ($lastcmd eq "execute") ||
+ ($lastcmd eq "depend") ) {
+ $line =~ s/^ /$lastcmd /;
+ } else {
+ die("Continuation of $lastcmd not allowed, please fix tlsrc!\n");
+ }
+ }
+ if ($line =~ /^name\s*(\w+)$/) {
+ logit("found name: $1\n");
+ $name = "$1";
+ $lastcmd = "name";
+ $started && die("Cannot have two name directives!");
+ $started = 1;
+ } else {
+ $started || die("First directive needs to be 'name'");
+ if ($line =~ /^shortdesc\s*(.*)$/) {
+ logit("found shortdesc: $1\n");
+ $tldb{$name}{'shortdesc'} .= "$1 ";
+ $lastcmd = "shortdesc";
+ next;
+ } elsif ($line =~ /^longdesc\s*(.*)$/) {
+ logit("found longdesc: $1\n");
+ $tldb{$name}{'longdesc'} .= "$1 ";
+ $lastcmd = "longdesc";
+ next;
+ } elsif ($line =~ /^catalogue\s*(.*)$/) {
+ logit("found catalogue: $1\n");
+ $tldb{$name}{'catalogue'} = "$1";
+ $lastcmd = "catalogue";
+ next;
+ } elsif ($line =~ /^runfiles\s*(.*)$/) {
+ logit("found runfiles: $1\n");
+ push @{$tldb{$name}{'runfiles'}}, "$1" unless "$1" eq "";
+ $lastcmd = "runfiles";
+ next;
+ } elsif ($line =~ /^srcfiles\s*(.*)$/) {
+ logit("found srcfiles: $1\n");
+ push @{$tldb{$name}{'srcfiles'}}, "$1" unless "$1" eq "";
+ $lastcmd = "srcfiles";
+ next;
+ } elsif ($line =~ /^docfiles\s*(.*)$/) {
+ logit("found docfiles: $1\n");
+ push @{$tldb{$name}{'docfiles'}}, "$1" unless "$1" eq "";
+ $lastcmd = "docfiles";
+ next;
+ } elsif ($line =~ /^binfiles\s*(.*)$/) {
+ logit("found binfiles: $1\n");
+ push @{$tldb{$name}{'binfiles'}}, "$1" unless "$1" eq "";
+ $lastcmd = "binfiles";
+ next;
+ } elsif ($line =~ /^execute\s*(.*)$/) {
+ logit("found execute: $1\n");
+ push @{$tldb{$name}{'executes'}}, "$1" unless "$1" eq "";
+ $lastcmd = "execute";
+ next;
+ } elsif ($line =~ /^depend\s*(.*)$/) {
+ logit("found depend: $1\n");
+ push @{$tldb{$name}{'depends'}}, "$1" unless "$1" eq "";
+ $lastcmd = "depend";
+ next;
+ } else {
+ die("Unknown directive ...$line... in $tldb, please fix it!");
+ }
+ }
+ }
+ logit("Done reading the tldb file, filling the data structure!\n");
+ if ($catalogue ne "") {
+ $tldb{$name}{'catalogue'} = "$catalogue";
+ } else {
+ $tldb{$name}{'catalogue'} = "$name";
+ }
+ if ($shortdesc ne "") {
+ $tldb{$name}{'shortdesc'} = "$shortdesc";
+ }
+ if ($longdesc ne "") {
+ $tldb{$name}{'longdesc'} = "$longdesc";
+ }
+ if ($#srcfiles >= 0) {
+ $tldb{$name}{'srcfiles'} = [ @srcfiles ];
+ }
+ if ($#runfiles >= 0) {
+ $tldb{$name}{'runfiles'} = [ @runfiles ];
+ }
+ if ($#binfiles >= 0) {
+ $tldb{$name}{'binfiles'} = [ @binfiles ];
+ }
+ if ($#docfiles >= 0) {
+ $tldb{$name}{'docfiles'} = [ @docfiles ];
+ }
+ if ($#executes >= 0) {
+ $tldb{$name}{'executes'} = [ @executes ];
+ }
+ if ($#depends>= 0) {
+ $tldb{$name}{'depends'} = [ @depends ];
+ }
+}
+
+sub write_tlp_file {
+ my ($tlp) = @_;
+ open(TLP,">tlp/$tlp.tlp") || die("Cannot open tlp/$tlp.tlp for writing: $!");
+ print TLP "name $tlp\n";
+ if (defined($tldb{$tlp}{'shortdesc'})) {
+ $tlpline = "shortdesc $tldb{$tlp}{'shortdesc'}";
+ write TLP;
+ }
+ if (defined($tldb{$tlp}{'longdesc'})) {
+ $tlpline = "longdesc $tldb{$tlp}{'longdesc'}";
+ write TLP;
+ }
+ if (defined($tldb{$tlp}{'catalogue'})) {
+ print TLP "catalogue $tldb{$tlp}{'catalogue'}\n";
+ }
+ my @tmp;
+ if (defined($tldb{$tlp}{'executes'})) {
+ foreach (@{$tldb{$tlp}{'executes'}}) {
+ print TLP "execute $_\n";
+ }
+ }
+ if (defined($tldb{$tlp}{'depends'})) {
+ foreach (@{$tldb{$tlp}{'depends'}}) {
+ print TLP "depend $_\n";
+ }
+ }
+ if (defined($tldb{$tlp}{'docfiles'})) {
+ print TLP "docfiles\n";
+ foreach (@{$tldb{$tlp}{'docfiles'}}) {
+ print TLP " $_\n";
+ }
+ }
+ if (defined($tldb{$tlp}{'srcfiles'})) {
+ print TLP "srcfiles\n";
+ foreach (@{$tldb{$tlp}{'srcfiles'}}) {
+ print TLP " $_\n";
+ }
+ }
+ if (defined($tldb{$tlp}{'binfiles'})) {
+ print TLP "binfiles\n";
+ foreach (@{$tldb{$tlp}{'binfiles'}}) {
+ print TLP " $_\n";
+ }
+ }
+ if (defined($tldb{$tlp}{'runfiles'})) {
+ print TLP "runfiles\n";
+ foreach (@{$tldb{$tlp}{'runfiles'}}) {
+ print TLP " $_\n";
+ }
+ }
+ close(TLP);
+}
+
+sub logit {
+ $opt_debug && print STDERR @_;
+}
+
+
+###### Formats
+format TLP =
+^<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
+$tlpline
+ ^<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<~~
+$tlpline
+.
+
+
+### Local Variables:
+### perl-indent-level: 4
+### tab-width: 4
+### indent-tabs-mode: t
+### End:
+# vim:set tabstop=4: #