summaryrefslogtreecommitdiff
path: root/Master
diff options
context:
space:
mode:
authorNorbert Preining <preining@logic.at>2008-05-14 06:18:14 +0000
committerNorbert Preining <preining@logic.at>2008-05-14 06:18:14 +0000
commit69ac138e19b13261722c9949774c3aedd21097f3 (patch)
tree91e3f5b92622ff03fffcc29d94199bfb2d66cd8b /Master
parente26ac07d955b55d4c983b1775a68b3bbdfaeab08 (diff)
tlmgr.pl: * implement independent backup action
* use "." before the revision instead of "_" * add a switch --list to update so that you can see what would be updated git-svn-id: svn://tug.org/texlive/trunk@8124 c570f23f-e606-0410-a88d-b1316a301751
Diffstat (limited to 'Master')
-rwxr-xr-xMaster/texmf/scripts/texlive/tlmgr.pl77
1 files changed, 73 insertions, 4 deletions
diff --git a/Master/texmf/scripts/texlive/tlmgr.pl b/Master/texmf/scripts/texlive/tlmgr.pl
index 250d09bc6b1..72a0ad6acf9 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/^backup$/i) {
+ merge_into(\%ret, action_backup());
} elsif ($action =~ m/^restore$/i) {
merge_into(\%ret, action_restore());
} elsif ($action =~ m/^search$/i) {
@@ -448,7 +450,7 @@ sub action_restore {
closedir (DIR) || warn "closedir($opt_backupdir) failed: $!";
for my $dirent (@dirents) {
next if (-d $dirent);
- next if ($dirent !~ m/^(.*)_r([0-9]+).tar.lzma$/);
+ next if ($dirent !~ m/^(.*)\.r([0-9]+)\.tar\.lzma$/);
$backups{$1}->{$2} = 1;
}
my $ret;
@@ -504,6 +506,41 @@ sub action_restore {
return $ret;
}
+sub action_backup {
+ init_local_db();
+ my $opt_dry = 0;
+ my $opt_all = 0;
+ my $opt_backupdir;
+ Getopt::Long::Configure(qw(no_pass_through));
+ GetOptions("all" => \$opt_all,
+ "backupdir=s" => \$opt_backupdir,
+ ) or pod2usage(2);
+ my %ret;
+ my @todo;
+ die ("tlmgr backup needs an obligatory argument --backupdir")
+ unless (defined($opt_backupdir));
+ if ($opt_all) {
+ @todo = $localtlpdb->list_packages;
+ } else {
+ @todo = @ARGV;
+ }
+ if (!@todo) {
+ printf "tlmgr backup takes either a list of packages or --all\n";
+ }
+ foreach my $pkg (@todo) {
+ $opt_backupdir = abs_path($opt_backupdir);
+ if (! -d $opt_backupdir) {
+ printf STDERR "backupdir argument must be an existing directory!\n";
+ } else {
+ my $tlp = $localtlpdb->get_package($pkg);
+ $tlp->make_container("lzma", $localtlpdb->root,
+ $opt_backupdir, "${pkg}.r" . $tlp->revision);
+ }
+ }
+ return(\%ret);
+}
+
+
sub action_update {
if ($opt_gui) {
action_gui("update");
@@ -513,10 +550,12 @@ sub action_update {
my $opt_nodepends = 0;
my $opt_dry = 0;
my $opt_all = 0;
+ my $opt_list = 0;
my $opt_backupdir;
Getopt::Long::Configure(qw(no_pass_through));
GetOptions("no-depends" => \$opt_nodepends,
"all" => \$opt_all,
+ "list" => \$opt_list,
"backupdir=s" => \$opt_backupdir,
"dry-run" => \$opt_dry) or pod2usage(2);
my %ret;
@@ -524,7 +563,7 @@ sub action_update {
die($loadmediasrcerror . $location) unless defined($tlmediasrc);
my $mediatlpdb = $tlmediasrc->tlpdb;
my @todo;
- if ($opt_all) {
+ if ($opt_all || $opt_list) {
@todo = $localtlpdb->list_packages;
} else {
@todo = @ARGV;
@@ -547,7 +586,9 @@ sub action_update {
}
my $mediarev = $mediatlp->revision;
if ($rev < $mediarev) {
- if ($opt_dry) {
+ if ($opt_list) {
+ print "$pkg: local: $rev, source: $mediarev\n";
+ } elsif ($opt_dry) {
print "Installing $pkg\n";
} else {
# first remove the package, then reinstall it
@@ -560,7 +601,7 @@ sub action_update {
} else {
my $tlp = $localtlpdb->get_package($pkg);
$tlp->make_container("lzma", $localtlpdb->root,
- $opt_backupdir, "${pkg}_r" . $tlp->revision);
+ $opt_backupdir, "${pkg}.r" . $tlp->revision);
}
}
merge_into(\%ret, &remove_package($pkg, $localtlpdb, 1));
@@ -1129,6 +1170,10 @@ at the installation source. Options:
=over 8
+=item B<--list>
+
+List only which packages could be updated.
+
=item B<--all>
Update all package.
@@ -1147,6 +1192,30 @@ turned out as not working. See the action B<restore> for details.
=back
+=item B<backup --backupdir dir [--all] [pkg [pkg]]>
+
+Makes a backup of the given packages (or all packages with B<--all>) to
+the directory specified with B<--backupdir> (must exist and be a writable).
+
+Warning: Making a backup of I<all> packages will need quite some space and
+time.
+
+Options:
+
+=over 8
+
+=item B<--backupdir directory>
+
+This is an obligatory argument and has to specify a directory where
+backups are to be found.
+
+=item B<--all>
+
+Make a backup of all packages in the texlive.tlpdb
+
+=back
+
+
=item B<restore --backupdir dir [pkg [rev]]>
If no B<pkg> and B[rev] is given list all packages the available