summaryrefslogtreecommitdiff
path: root/Master/tlpkg/etc/tlmgr-and-gui-fix-on-mirror.diff
blob: c457ac232b76183f4a8647934544f2e4be49e894 (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
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
Index: tlmgr.pl
===================================================================
--- tlmgr.pl	(revision 10402)
+++ tlmgr.pl	(working copy)
@@ -37,7 +37,7 @@
 use TeXLive::TLUtils;
 use TeXLive::TLWinGoo;
 use TeXLive::TLPostActions;
-TeXLive::TLUtils->import( qw(kpsewhich member win32 merge_into copy log) );
+TeXLive::TLUtils->import( qw(kpsewhich member info give_ctan_mirror win32 merge_into copy log debug) );
 use Cwd qw/abs_path/;
 use Pod::Usage;
 use Getopt::Long qw(:config no_autoabbrev require_order);
@@ -416,8 +416,7 @@
     my $installed = 0;
     if (!$tlp) {
       if (!$tlmediatlpdb) {
-        $tlmediasrc = TeXLive::TLMedia->new($location);
-        die($loadmediasrcerror . $location) unless defined($tlmediasrc);
+        init_tlmedia();
         $tlmediatlpdb = $tlmediasrc->tlpdb;
       }
       $tlp = $tlmediatlpdb->get_package($pkg);
@@ -449,8 +448,7 @@
   my $tlpdb;
   init_local_db();
   if ($opt_global) {
-    $tlmediasrc =  TeXLive::TLMedia->new($location);
-    die($loadmediasrcerror . $location) unless defined($tlmediasrc);
+    init_tlmedia();
     $tlpdb = $tlmediasrc->tlpdb;
   } else {
     $tlpdb = $localtlpdb;
@@ -612,8 +610,7 @@
              "backupdir=s" => \$opt_backupdir,
              "dry-run" => \$opt_dry) or pod2usage(2);
   my %ret;
-  $tlmediasrc = TeXLive::TLMedia->new($location);
-  die($loadmediasrcerror . $location) unless defined($tlmediasrc);
+  init_tlmedia();
   my $mediatlpdb = $tlmediasrc->tlpdb;
   my @todo;
   if ($opt_all || $opt_list) {
@@ -636,7 +633,7 @@
     my $rev = $tlp->revision;
     my $mediatlp = $mediatlpdb->get_package($pkg);
     if (!defined($mediatlp)) {
-      print "$pkg cannot be found in $location\n";
+      debug("$pkg cannot be found in $location\n");
       next;
     }
     my $mediarev = $mediatlp->revision;
@@ -763,8 +760,7 @@
   GetOptions("no-depends" => \$opt_nodepends,
              "dry-run" => \$opt_dry) or pod2usage(2);
   my %ret;
-  $tlmediasrc = TeXLive::TLMedia->new($location);
-  die($loadmediasrcerror . $location) unless defined($tlmediasrc);
+  init_tlmedia();
   foreach my $pkg (@ARGV) {
     if ($opt_dry) {
       print "install: $pkg\n";
@@ -784,8 +780,7 @@
   init_local_db();
   my $what = shift @ARGV;
   $what || ($what = "");
-  $tlmediasrc = TeXLive::TLMedia->new($location);
-  die($loadmediasrcerror . $location) unless defined($tlmediasrc);
+  init_tlmedia();
   my @whattolist;
   if ($what =~ m/^collection/i) {
     @whattolist = $tlmediasrc->tlpdb->collections;
@@ -881,8 +876,7 @@
   if ($what =~ m/^list$/i) {
     # list the available architectures
     # initialize the TLMedia from $location
-    $tlmediasrc = TeXLive::TLMedia->new($location);
-    die($loadmediasrcerror . $location) unless defined($tlmediasrc);
+    init_tlmedia();
     my $mediatlpdb = $tlmediasrc->tlpdb;
     my @already_installed_arch = $localtlpdb->available_architectures;
     print "Available architectures:\n";
@@ -897,8 +891,7 @@
     print "You can add new architectures with tlmgr arch add arch1 arch2\n";
     exit(0);
   } elsif ($what =~ m/^add$/i) {
-    $tlmediasrc = TeXLive::TLMedia->new($location);
-    die($loadmediasrcerror . $location) unless defined($tlmediasrc);
+    init_tlmedia();
     my $mediatlpdb = $tlmediasrc->tlpdb;
     my @already_installed_arch = $localtlpdb->available_architectures;
     my @available_arch = $mediatlpdb->available_architectures;
@@ -1183,7 +1176,24 @@
   system("rmdir", "--ignore-fail-on-non-empty", "$texdir");
 }
 
+#
+# init_tlmedia
+# initialize a tlmedia object and returns it, or dies
+#
+sub init_tlmedia {
+  if (($location =~ m/$TeXLiveServerURL/) ||
+      ($location =~ m/^ctan$/i)) {
+    $location = give_ctan_mirror();
+    info("Using mirror $location\n");
+  }
+  # $tlmediasrc is a global function
+  $tlmediasrc = TeXLive::TLMedia->new($location);
+  die($loadmediasrcerror . $location) unless defined($tlmediasrc);
+}
 
+  
+
+
 #
 # return all the directories from which all content will be removed
 #
Index: tlmgrgui/tlmgrgui-real.pl
===================================================================
--- tlmgrgui/tlmgrgui-real.pl	(revision 10402)
+++ tlmgrgui/tlmgrgui-real.pl	(working copy)
@@ -116,7 +116,7 @@
   loadremotetlpdbwait => "Loading remote TeX Live Database\nThis may take some time, please wait!",
   runupdater    => "Some package cannot be updated using the GUI!\nPlease run TEXROOT/tlpkg/installer/updater.bat once,\notherwise the updates will not be complete!\nNOTE: You have to QUIT this program first!",
   actions       => "Actions",
-  reinitlsr     => "Re-initalise file database",
+  reinitlsr     => "Re-initialize file database",
   recreateformats => "Re-create all formats",
   updatemaps    => "Update font map database",
   warningnonetupdate => "No updates found.\n\nYour installation is set up to look on the disk for updates.\n\nIf you want to install from the Internet for this one time only, click on the \"Change\" button above and select \"Default Net Location\" (or any other network location you know to be working).\n\nIf you want to change it permanently, go to the \"Configuration\" Tab and change the default installation source.",
@@ -263,7 +263,6 @@
 if (defined($opt_location)) {
   $location = $opt_location;
 }
-# our $location = $localtlpdb->option_location;
 
 our $tlmediasrc;
 our $tlmediatlpdb;
@@ -271,6 +270,7 @@
 
 our $balloon = $mw->Balloon();
 
+push @update_function_list, \&check_location_on_ctan;
 push @update_function_list, \&init_install_media;
 push @update_function_list, \&create_update_list;
 
@@ -665,10 +665,11 @@
                     })->pack(-side => "left", -padx => "2m", -pady => "2m");
   $f1->pack;
   my $f = $sw->Frame;
-  my $okbutton = $f->Button(-text => 'Ok',
-    -command => sub { $location = $entry->get;
-                      run_update_functions() ;
-          $sw->destroy })->pack(-side => 'left', -padx => "2m", -pady => "2m");
+  my $okbutton = $f->Button(-text => ___"ok",
+    -command => sub { $location = $entry->get; 
+                      run_update_functions();
+                      $sw->destroy;
+                    })->pack(-side => 'left', -padx => "2m", -pady => "2m");
   my $cancelbutton = $f->Button(-text => 'Cancel',
           -command => sub { $sw->destroy })->pack(-side => 'right', -padx => "2m", -pady => "2m");
   $f->pack(-expand => 'x');
@@ -682,6 +683,13 @@
   }
 }
 
+sub check_location_on_ctan {
+  # we want to check that if mirror.ctan.org 
+  # is used that we select a mirror once
+  if ($location =~ m/$TeXLive::TLConfig::TeXLiveServerURL/) {
+    $location = TeXLive::TLUtils::give_ctan_mirror();
+  }
+}
 
 1;