summaryrefslogtreecommitdiff
path: root/Master/tlpkg/etc/remove-removed-packages.diff
blob: 7853851057cfbc297b7ef077704094ec9a099fb0 (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
Index: tlmgr.pl
===================================================================
--- tlmgr.pl	(revision 10729)
+++ tlmgr.pl	(working copy)
@@ -650,8 +650,40 @@
     unlink($f) unless $opt_dry;
   }
   my @todo;
+  my @removal = ();
   if ($opt_all || $opt_list) {
     @todo = $localtlpdb->list_packages;
+    # we check for deleted packages by checking:
+    # . the package is referenced by collection of the local tlpdb
+    # . the package is present in the local tlpdb
+    # . the collection is present in the remote tlpdb
+    # . the package is not referenced any more in the remote tlpdb
+    for my $c ($localtlpdb->collections) {
+      my $tlcremote = $mediatlpdb->get_package($c);
+      # continue with next package if the local connection is not
+      # present on the server side
+      next if !defined($tlcremote);
+      my $tlc = $localtlpdb->get_package($c);
+      die ("That should not happen, listed but not found!") if !defined($tlc);
+      # take all the dependencies of the installed collection 
+      # *as*found* in the network tlpdb
+      for my $d ($tlc->depends) {
+        my $tlp = $localtlpdb->get_package($d);
+        if (!defined($tlp)) {
+          info("forcibly removed $d, mentioned in $c\n");
+        } else {
+          # now check the remote tlpdb for reference of that package
+          if (!defined($mediatlpdb->get_package($d))) {
+            # it seems that the package is present in the local tlpdb
+            # is referenced in $c in the local tlpdb
+            # $c is present in the remote tlpdb
+            # the package is NOT present in the remote tlpdb
+            info("$d ($c): removed package\n");
+            push @removal, $d;
+          }
+        }
+      }
+    }
   } else {
     @todo = @ARGV;
   }
@@ -838,6 +870,12 @@
       next;
     }
   }
+  # remove the packages that have disappeared
+  for my $p (@removal) {
+    info("remove $p (removed on server)\n");
+    merge_into(\%ret, &remove_package($p, $localtlpdb, 1)) unless 
+      ($opt_dry or $opt_list);
+  }
   if ($updater_started) {
     print UPDATER "del tlpkg\\installer\\tarsave.exe\n";
     print UPDATER "rem del /s /q temp\n";