[subversion-commit] SVN tetex commit + diffs: r365 - tex-common/branches/for-0.13/scripts

Norbert Preining preining-guest at costa.debian.org
Fri Dec 2 19:17:26 UTC 2005


Author: preining-guest
Date: 2005-12-02 19:17:26 +0000 (Fri, 02 Dec 2005)
New Revision: 365

Modified:
   tex-common/branches/for-0.13/scripts/dh_installtexfonts
Log:
implementation on --flavor=with(all)config


Modified: tex-common/branches/for-0.13/scripts/dh_installtexfonts
===================================================================
--- tex-common/branches/for-0.13/scripts/dh_installtexfonts	2005-12-02 18:01:20 UTC (rev 364)
+++ tex-common/branches/for-0.13/scripts/dh_installtexfonts	2005-12-02 19:17:26 UTC (rev 365)
@@ -11,7 +11,8 @@
 
 =head1 SYNOPSIS
 
-B<dh_installtexfonts> [S<I<debhelper options>>] [B<-n>] [B<--priority=>I<n>] [S<I<maptype=mapfile ...>>] [S<I<cfg-file[=I<n>] ...>>] 
+B<dh_installtexfonts> [S<I<debhelper options>>] [B<-n>] [B<--priority=>I<n>] 
+    [B<--flavor=>I<flavor>] [S<I<maptype=mapfile ...>>] [S<I<cfg-file[=I<n>] ...>>] 
 
 =head1 DESCRIPTION
 
@@ -96,6 +97,19 @@
 
 Set the default priority to I<n> instead of 10.
 
+=item B<--flavor=>I<flavor>
+
+This option will be used to switch additional options on. At the moment
+you can select for I<flavor> either B<withconfig> or B<withallconfig>.
+In the first case for each activate map I<foo.map> in this call of 
+L<dh_installtexfonts> (i.e. either I<foo.map> is occuring on the command
+line (way 2), or is active in one of the cfg files (way 1 and 3)) a file
+I<config.foo> is generated in /usr/share/texmf/dvips/config/.
+
+If you select B<withallconfig> then the script tries to generate config
+files also for those map files which are present in cfg files, but
+are deactivated by a comment.
+
 =head1 NOTES
 
 Note that this command is not idempotent. "dh_clean -k" should be called
@@ -110,13 +124,26 @@
 
 init();
 
+sub extract_map {
+	my ($line,$doconfig) = @_;
+	if ($doconfig == 0) { return ""; }
+	if ($_ =~ m/^[[:space:]]*([#[:space:]]*)[[:space:]]*(Mixed)?Map[[:space:]]*(.*\.map)[[:space:]]*(#.*)?$/) {
+		my $comment = $1;
+		my $map = $3;
+		if (($comment eq "") || ($doconfig == 2)) {
+			return $map;
+		}
+	}
+	return "";
+}
+
 sub magic_comment_present {
 	my ($fname) = @_;
 	my @args = ( "grep", "-q", "^# -_- DebPkgProvidedMaps -_-", $fname );
 	if (system(@args) == 0) { return 1; }
 	return 0;
 }
-		
+
 my $magicheader = "# You can change/add entries to this file and changes will be preserved
 # over upgrades, even if you have removed the main package prior
 # (not if you purged it). You should leave the following pseudo comment
@@ -135,10 +162,21 @@
 	my @cmdlinecfgs;
 	my $pkgfileoncmdline = 0;
 	my @listlines;
+	my @mapfiles;
+	my $doconfig = 0;
 
 	if (defined($dh{PRIORITY}) && $dh{PRIORITY} ne '') {
 		$priority=$dh{PRIORITY};
 	}
+	if (defined($dh{FLAVOR})) {
+		if ($dh{FLAVOR} eq "withconfig") {
+			$doconfig = 1;
+		} elsif ($dh{FLAVOR} eq "withallconfig") {
+			$doconfig = 2;
+		} else {
+			error("Specified flavor $dh{FLAVOR} not supported.\nPlease see man page for supported flavors!\n");
+		}
+	}
 	if ($file) {
 		open(FOO, "<$file") || error("$file cannot be opened.");
 		@pkgcfg = <FOO>;
@@ -148,6 +186,7 @@
 		foreach my $entry (@ARGV) {
 			if ($entry =~ m/^(Map|MixedMap)=(.*)$/) {
 				push @cmdlinemaps, "$1 $2";
+				if ($doconfig > 0) { push @mapfiles, $2; }
 			} elsif ($entry =~ m/^(.*\.cfg)(=([[:digit:]]+))?$/) {
 				my $fn=$1;
 				my $pr=$priority;
@@ -193,7 +232,11 @@
 			print CFGFILE $magicheader;
 		}
 		open(FOO,"<$fn") || error("Cannot open $fn for reading!");
-		while (<FOO>) { print CFGFILE $_; }
+		while (<FOO>) { 
+			my $m;
+			print CFGFILE $_; 
+			if ($m = extract_map($_, $doconfig)) { push @mapfiles, $m; }
+		}
 		close(FOO);
 		close(CFGFILE);
 		$bn =~ s/\.cfg$//;
@@ -214,7 +257,9 @@
 			print CFGFILE $magicheader;
 		}
 		foreach (@pkgcfg) {
+			my $m;
 			print CFGFILE "$_";
+			if ($m = extract_map($_, $doconfig)) { push @mapfiles, $m; }
 		}
 		foreach (@cmdlinemaps) {
 			print CFGFILE "$_\n";
@@ -233,6 +278,19 @@
 	}
 	close(LISTFILE);
 
+	if ($#mapfiles >= 0) {
+		doit("install","-d","$tmp/usr/share/texmf/dvips/config/");
+	}
+	foreach my $m (@mapfiles) {
+		my $f = $m;
+		$f =~ s/\.map$//;
+		-r "$tmp/usr/share/texmf/dvips/config/config.$f" &&
+			error("The dvips config file $tmp/usr/share/texmf/dvips/config/config.$f already exists!\nYou may have to call dh_clean -k!\n");
+		open(CNFFILE, ">$tmp/usr/share/texmf/dvips/config/config.$f") ||
+			error("Cannot open $tmp/usr/share/texmf/dvips/config/config.$f for writing!");
+		print CNFFILE "Map +$m\n";
+		close(CNFFILE);
+	}
 	if (! $dh{NOSCRIPTS}) {
 		autoscript($package, "postinst", "postinst-texfonts", "");
 		autoscript($package, "postrm",   "postrm-texfonts",   "");




More information about the Pkg-tetex-commits mailing list