summaryrefslogtreecommitdiff
path: root/Master/texmf
diff options
context:
space:
mode:
authorNorbert Preining <preining@logic.at>2010-05-28 11:55:26 +0000
committerNorbert Preining <preining@logic.at>2010-05-28 11:55:26 +0000
commit6a603a72de517acee6c82d4d1334a4fc45041091 (patch)
treef88969144774008b2a5b956757eb50cd456febba /Master/texmf
parenta0cb3ae37b51b9af9b271a199f241fc0a2f92c6e (diff)
- make TLConfFile behave like kpathsea in the way that continuations of
comment lines are not supported - make tlmgr use TLConfFile for reading and writing the configuration file, this way we can now have arbitrary comments in it - TLConfFile: If a line cannot be parsed it is saved as comment and written out as is, but a big fat warning is issued git-svn-id: svn://tug.org/texlive/trunk@18550 c570f23f-e606-0410-a88d-b1316a301751
Diffstat (limited to 'Master/texmf')
-rwxr-xr-xMaster/texmf/scripts/texlive/tlmgr.pl77
1 files changed, 31 insertions, 46 deletions
diff --git a/Master/texmf/scripts/texlive/tlmgr.pl b/Master/texmf/scripts/texlive/tlmgr.pl
index d6dd8f77d69..b85677d825d 100755
--- a/Master/texmf/scripts/texlive/tlmgr.pl
+++ b/Master/texmf/scripts/texlive/tlmgr.pl
@@ -22,6 +22,7 @@ our $ismain;
our $loadmediasrcerror;
our $packagelogfile;
our $packagelogged;
+our $tlmgr_config_file;
BEGIN {
$^W = 1;
@@ -4417,62 +4418,46 @@ sub load_config_file
chomp (my $TEXMFCONFIG = `kpsewhich -var-value=TEXMFCONFIG`);
my $fn = "$TEXMFCONFIG/tlmgr/config";
- if (-r $fn) {
- if (!open(TLC, "<$fn")) {
- tlwarn("Cannot open $fn: $!");
- return;
- }
- while (<TLC>) {
- if (m/^\s*$/) { next; }
- if (m/^\s*#/) { next; }
- if (m/^\s*([\w-]+)\s*=\s*(.*)\s*$/) {
- my $key = $1;
- my $val = $2;
- if ($key eq "gui_expertmode") {
- if ($val eq "0") {
- $config{"gui_expertmode"} = 0;
- } elsif ($val eq "1") {
- $config{"gui_expertmode"} = 1;
- } else {
- tlwarn("Unknown value $val for gui_expertmode in $fn\n");
- }
- } elsif ($key eq "persistent-downloads") {
- if (($val eq "0") || ($val eq "1")) {
- $config{'persistent-downloads'} = $val;
- } else {
- tlwarn("Unknown value $val for persistent-downloads in $fn\n");
- }
- } else {
- tlwarn("Unknown key $key in $fn\n");
- }
- next;
+ $tlmgr_config_file = TeXLive::TLConfFile->new($fn, "#", "=");
+ for my $key ($tlmgr_config_file->keys) {
+ my $val = $tlmgr_config_file->value($key);
+ if ($key eq "gui_expertmode") {
+ if ($val eq "0") {
+ $config{"gui_expertmode"} = 0;
+ } elsif ($val eq "1") {
+ $config{"gui_expertmode"} = 1;
+ } else {
+ tlwarn("Unknown value >$val< for gui_expertmode in $fn\n");
}
- tlwarn("I cannot understand the following line in $fn:\n$_\n");
- next;
+ } elsif ($key eq "persistent-downloads") {
+ if (($val eq "0") || ($val eq "1")) {
+ $config{'persistent-downloads'} = $val;
+ } else {
+ tlwarn("Unknown value $val for persistent-downloads in $fn\n");
+ }
+ } else {
+ tlwarn("Unknown key $key in $fn\n");
}
- close(TLC);
}
}
sub write_config_file
{
- chomp (my $TEXMFCONFIG = `kpsewhich -var-value=TEXMFCONFIG`);
- my $dn = "$TEXMFCONFIG/tlmgr";
- my $fn = "$dn/config";
- if (! -d $dn) {
- TeXLive::TLUtils::mkdirhier($dn);
- }
- if (!open(TLC, ">$fn")) {
- tlwarn("Cannot open $fn for writing: $!");
- return;
+ if (!defined($tlmgr_config_file)) {
+ chomp (my $TEXMFCONFIG = `kpsewhich -var-value=TEXMFCONFIG`);
+ my $dn = "$TEXMFCONFIG/tlmgr";
+ my $fn = "$dn/config";
+ # create a new one
+ $tlmgr_config_file = TeXLive::TLConfFile->new($fn, "#", "=");
}
- print TLC "# tlmgr/config file\n";
- print TLC "# written by tlmgr\n";
- print TLC "# all comments will be deleted\n";
for my $k (keys %config) {
- print TLC "$k = $config{$k}\n";
+ # it doesn't hurt to save all config settings as we check in TLConfFile
+ # if the value has actually changed
+ $tlmgr_config_file->value($k, $config{$k});
+ }
+ if ($tlmgr_config_file->is_changed) {
+ $tlmgr_config_file->save;
}
- close(TLC);
}
# if the packagelog variable is set then write to PACKAGELOG filehandle