diff options
-rwxr-xr-x | Master/texmf/scripts/texlive/tlmgr.pl | 93 | ||||
-rw-r--r-- | Master/tlpkg/TeXLive/TLMedia.pm | 17 | ||||
-rw-r--r-- | Master/tlpkg/TeXLive/TLPDB.pm | 2 | ||||
-rw-r--r-- | Master/tlpkg/TeXLive/TLPOBJ.pm | 30 |
4 files changed, 108 insertions, 34 deletions
diff --git a/Master/texmf/scripts/texlive/tlmgr.pl b/Master/texmf/scripts/texlive/tlmgr.pl index 6670f1205a7..fae6380ca8c 100755 --- a/Master/texmf/scripts/texlive/tlmgr.pl +++ b/Master/texmf/scripts/texlive/tlmgr.pl @@ -103,6 +103,8 @@ if ($action =~ m/^generate$/i) { merge_into(\%ret, action_install()); } elsif ($action =~ m/^update$/i) { merge_into(\%ret, action_update()); +} elsif ($action =~ m/^restore$/i) { + merge_into(\%ret, action_restore()); } elsif ($action =~ m/^search$/i) { merge_into(\%ret, action_search()); exit(0); @@ -221,22 +223,7 @@ sub remove_package { rmdir $entry; } $localtlpdb->remove_package($pkg); - my (@maps, @formats, @dats); - $ret{'mktexlsr'} = 1; - foreach my $e ($tlp->executes) { - if ($e =~ m/^add((Mixed)?Map)\s+([^\s]+)\s*$/) { - push @maps, "disable $3"; - } elsif ($e =~ m/^BuildFormat\s+([^\s]+)\s*$/) { - push @formats, $1; - } elsif ($e =~ m/^BuildLanguageDat\s+([^\s]+)\s*$/) { - push @dats, $1; - } else { - warn("Unknown execute $e in $pkg"); - } - } - $ret{'map'} = [ @maps ] if (@maps); - $ret{'format'} = [ @formats ] if (@formats); - $ret{'language'} = [ @dats ] if (@dats); + merge_into(\%ret, $tlp->make_return_hash_from_executes); # remove those bin dependencies .ARCH foreach my $d ($tlp->depends) { if ($d eq "$pkg.ARCH") { @@ -437,6 +424,78 @@ sub action_search { return; } +sub action_restore { + # tlmgr restore --backupdir dir + # lists all packages with all revisions + # tlmgr restore --backupdir dir pkg + # lists all revisions of pkg + # tlmgr restore --backupdir dir pkg rev + # restores pkg to revision rev + my $opt_backupdir; + my $opt_force; + Getopt::Long::Configure(qw(no_pass_through)); + GetOptions("backupdir=s" => \$opt_backupdir, + "force" => \$opt_force) or pod2usage(2); + if (!defined($opt_backupdir)) { + die "restore needs --backupdir\n"; + } + # initialize the hash(packages) of hash(revisions) + my %backups; + opendir (DIR, $opt_backupdir) || die "opendir($opt_backupdir) failed: $!"; + my @dirents = readdir (DIR); + closedir (DIR) || warn "closedir($opt_backupdir) failed: $!"; + for my $dirent (@dirents) { + next if (-d $dirent); + next if ($dirent !~ m/^(.*)_r([0-9]+).tar.lzma$/; + $backups{$1}->{$2} = 1; + } + my $ret; + my ($pkg, $rev) = @ARGV; + if (!defined($pkg)) { + if (keys %backup) { + print "Available backups:\n"; + foreach my $p (sort keys %backups) { + print "$p: "; + my @rs = sort (keys %{$backups{$p}}); + print "@rs\n"; + } + } else { + print "No backups available in $opt_backupdir\n"; + } + exit 0; + } + if (!defined($rev)) { + print "Available backups for $pkg: "; + my @rs = sort (keys %{$backups{$p}}); + print "@rs\n"; + exit 0; + } + # we did arrive here, so we try to restore ... + if (defined($backup{$pkg}->{$rev})) { + if (!$opt_force) { + print "Do you really want to restore $pkg to revision $rev (y/N): "; + my $yesno = <STDIN>; + if ($yesno !~ m/^y(es)?$/i) { + print "Ok, cancelling the restore!\n"; + exit(0); + } + } + if ($opt_dry) { + print "Installing $pkg\n"; + } else { + # first remove the package, then reinstall it + # this way we get rid of useless files + # force the deinstallation since we will reinstall it + merge_into(\%ret, &remove_package($pkg, $localtlpdb, 1)); + $tlmediasrc->_install_package("$opt_backupdir/${pkg}_r${rev}.tar.lzma" , [] ,$localtlpdb); + $ret = $localtlpdb->get_package($pkg)->make_return_hash_from_executes; + } + } else { + print "revision $rev for $pkg is not present in $opt_backupdir\n"; + } + return $ret; +} + sub action_update { if ($opt_gui) { action_gui("update"); @@ -493,7 +552,7 @@ sub action_update { } else { my $tlp = $localtlpdb->get_package($pkg); $tlp->make_container("lzma", $localtlpdb->root, - $opt_backupdir, "${pkg}_rev" . $tlp->revision); + $opt_backupdir, "${pkg}_r" . $tlp->revision); } } merge_into(\%ret, &remove_package($pkg, $localtlpdb, 1)); diff --git a/Master/tlpkg/TeXLive/TLMedia.pm b/Master/tlpkg/TeXLive/TLMedia.pm index 15908aa3ef8..b9babeaed1d 100644 --- a/Master/tlpkg/TeXLive/TLMedia.pm +++ b/Master/tlpkg/TeXLive/TLMedia.pm @@ -191,22 +191,7 @@ sub install_package { $totlpdb->save; # compute the return value my %ret; - my (@maps, @formats, @dats); - $ret{'mktexlsr'} = 1; - foreach my $e ($tlpobj->executes) { - if ($e =~ m/^add((Mixed)?Map)\s+([^\s]+)\s*$/) { - push @maps, "enable $1=$3"; - } elsif ($e =~ m/^BuildFormat\s+([^\s]+)\s*$/) { - push @formats, $1; - } elsif ($e =~ m/^BuildLanguageDat\s+([^\s]+)\s*$/) { - push @dats, $1; - } else { - warn("Unknown execute $e in $pkg"); - } - } - $ret{'map'} = [ @maps ] if (@maps); - $ret{'format'} = [ @formats ] if (@formats); - $ret{'language'} = [ @dats ] if (@dats); + merge_into(\%ret, $tlpobj->make_return_hash_from_executes); # now install all the depends if they are not already present if (!$nodepends) { foreach my $d ($tlpobj->depends) { diff --git a/Master/tlpkg/TeXLive/TLPDB.pm b/Master/tlpkg/TeXLive/TLPDB.pm index 0c073e86cf7..54105de6777 100644 --- a/Master/tlpkg/TeXLive/TLPDB.pm +++ b/Master/tlpkg/TeXLive/TLPDB.pm @@ -952,7 +952,7 @@ sub language_dat_lines { die "No TeX Live package named $p, too strange" if ! $obj; foreach my $e ($obj->executes) { if ($e =~ m/BuildLanguageDat (.*)$/) { - $langfiles{$1} = 1; + $langfiles{$1} = 1; } # others are ignored here } diff --git a/Master/tlpkg/TeXLive/TLPOBJ.pm b/Master/tlpkg/TeXLive/TLPOBJ.pm index 67800fe959c..e5927f358ac 100644 --- a/Master/tlpkg/TeXLive/TLPOBJ.pm +++ b/Master/tlpkg/TeXLive/TLPOBJ.pm @@ -787,6 +787,36 @@ sub allbinfiles { return @ret; } +sub make_return_hash_from_executes { + my $self = shift; + my %ret; + my (@maps, @formats, @dats); + if ($self->runfiles) { + $ret{'mktexlsr'} = 1; + } + if ($self->srcfiles) { + $ret{'mktexlsr'} = 1; + } + if ($self->docfiles) { + $ret{'mktexlsr'} = 1; + } + foreach my $e ($self->executes) { + if ($e =~ m/^add((Mixed)?Map)\s+([^\s]+)\s*$/) { + push @maps, "enable $1=$3"; + } elsif ($e =~ m/^BuildFormat\s+([^\s]+)\s*$/) { + push @formats, $1; + } elsif ($e =~ m/^BuildLanguageDat\s+([^\s]+)\s*$/) { + push @dats, $1; + } else { + warn("Unknown execute $e in ", $self->name); + } + } + $ret{'map'} = [ @maps ] if (@maps); + $ret{'format'} = [ @formats ] if (@formats); + $ret{'language'} = [ @dats ] if (@dats); + return(\%ret); +} + # member access functions # |