summaryrefslogtreecommitdiff
path: root/Master/tlpkg/dev/dev.update-tlpdb-option-on-the-fly.patch
blob: f6d5d9cb926355276eae0f3257a5b81abe997398 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
--- ./texmf/scripts/texlive/tlmgr.pl.pre	2010-09-14 01:36:15.000000000 +0900
+++ ./texmf/scripts/texlive/tlmgr.pl	2010-09-14 02:11:51.000000000 +0900
@@ -1811,6 +1811,10 @@
 }
 
 sub action_update {
+  # the following var is only use to update options in 
+  # the local tlpdb in case we updated texlive.infra
+  my $texlive_infra_was_updated = 0;
+
   init_local_db(1);
   $opts{"no-depends"} = 1 if $opts{"no-depends-at-all"};
 
@@ -2446,6 +2450,9 @@
             }
           }
         }
+        # special case if texlive.infra was changed so that before shutting
+        # down we can update the options
+        $texlive_infra_was_updated = 1 if ($pkg eq "texlive.infra");
       } else {
         # install_package returned a scalar, so error.
         # now in fact we should do some cleanup, removing files and
@@ -2614,6 +2621,32 @@
     }
   }
 
+  # update of tlpdb options
+  # if texlive.infra has been updated (actually, not --list or --dry-run)
+  # we check the old against the new TLConfig::TLPDBOptions and add
+  # new ones
+  if ($texlive_infra_was_updated) {
+    my $changed = 0;
+    # save he old %TLConfig:
+    my %oldTLPDBOptions = %TeXLive::TLConfig::TLPDBOptions;
+    # make sure that a require reloads the TLConfig.pm
+    delete $INC{'TeXLive/TLConfig.pm'};
+    # reload TLConfig.pm, but disable warnings about redefining stuff
+    no warnings qw(redefine);
+    require 'TeXLive/TLConfig.pm';
+    use warnings 'all';
+    for my $opt (keys %TeXLive::TLConfig::TLPDBOptions) {
+      next if (defined($oldTLPDBOptions{$opt}));
+      $changed = 1;
+      info("Updating local tlpdb:\n");
+      info("* new option $opt\n");
+      info("  description: " . $TeXLive::TLConfig::TLPDBOptions{$opt}->[3] . "\n");
+      info("  default value: " . $TeXLive::TLConfig::TLPDBOptions{$opt}->[1] . "\n");
+      $localtlpdb->option($opt, $TeXLive::TLConfig::TLPDBOptions{$opt}->[1]);
+    }
+    $localtlpdb->save if $changed;
+  }
+
   my $restart_tlmgr = 0;
   if ($opts{"self"} && @critical &&
       $infra_update_done && $other_updates_asked_for) {