summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorNorbert Preining <preining@logic.at>2008-12-10 11:33:58 +0000
committerNorbert Preining <preining@logic.at>2008-12-10 11:33:58 +0000
commit2d30dd9f1fd7f30b44410f94a55333105a4c3fd8 (patch)
tree02bb8573097d7287d8d97992f48ba5bf493ac519
parente65e41c28a585181c8f3b353b04a7253dfe923fb (diff)
tlmgr2 update --machinereadablelist, Karl please give a better name !!!
git-svn-id: svn://tug.org/texlive/trunk@11579 c570f23f-e606-0410-a88d-b1316a301751
-rwxr-xr-xMaster/texmf/scripts/texlive/tlmgr2.pl68
-rw-r--r--Master/tlpkg/TeXLive/TLUtils.pm3
2 files changed, 57 insertions, 14 deletions
diff --git a/Master/texmf/scripts/texlive/tlmgr2.pl b/Master/texmf/scripts/texlive/tlmgr2.pl
index a0ee8c565f1..b5871e56688 100755
--- a/Master/texmf/scripts/texlive/tlmgr2.pl
+++ b/Master/texmf/scripts/texlive/tlmgr2.pl
@@ -102,6 +102,12 @@ our %papersetting_subs;
# each action uses this.
my @getopt_configure_subopts = qw(no_pass_through permute);
+# flags for machine readable form
+our $FLAG_REMOVE = "d";
+our $FLAG_FORCIBLE_REMOVED = "f";
+our $FLAG_UPDATE = "u";
+our $FLAG_REVERSED_UPDATE = "r";
+our $FLAG_AUTOINSTALL = "a";
# option variables
my $opt_location;
@@ -1160,6 +1166,14 @@ sub close_w32_updater {
# TLMedia->install_package does ONLY INSTALL ONE PACKAGE, no deps whatsoever
# anymore. That has all to be done by hand.
#
+sub machine_line {
+ my ($pkg, $flag, $lrev, $rrev) = @_;
+ $lrev || ($lrev = "-");
+ $rrev || ($rrev = "-");
+ $flag || ($flag = "?");
+ print "$pkg\t$flag\t$lrev\t$rrev\n";
+}
+
sub action_update {
if ($opt_gui) {
action_gui("update");
@@ -1171,6 +1185,7 @@ sub action_update {
my $opt_dry = 0;
my $opt_all = 0;
my $opt_list = 0;
+ my $opt_machinereadablelist = 0;
my $opt_noremove = 0;
my $opt_backupdir;
my $opt_backup = 0;
@@ -1180,6 +1195,7 @@ sub action_update {
"no-depends-at-all" => \$opt_reallynodepends,
"all" => \$opt_all,
"list" => \$opt_list,
+ "machinereadablelist" => \$opt_machinereadablelist,
"no-remove" => \$opt_noremove,
"force" => \$opt_force,
"backupdir=s" => \$opt_backupdir,
@@ -1189,6 +1205,12 @@ sub action_update {
my $nrupdated = 0;
my %ret;
+ if ($opt_machinereadablelist) {
+ # this global setting makes info lines go to STDERR so that on STDOUT
+ # there is only material we actually want to see
+ $::machinereadable = 1;
+ }
+
init_tlmedia();
my $mediatlpdb = $tlmediasrc->tlpdb;
info("update: dry run, no changes will be made\n") if $opt_dry;
@@ -1354,7 +1376,7 @@ sub action_update {
debug ("tlmgr: deleted : " . join("\n\t",keys %removals) . "\n");
debug ("tlmgr: forced : " . join("\n\t",keys %forcermpkgs) . "\n");
- if ($opt_all || $opt_list) {
+ if ($opt_all || $opt_list || $opt_machinereadablelist) {
@todo = $localtlpdb->list_packages;
} else {
@todo = @ARGV;
@@ -1365,14 +1387,19 @@ sub action_update {
# to support moving of files from one package to another.
# remove the packages that have disappeared:
for my $p (keys %removals) {
- if ($opt_noremove) {
- info("not removing $p due to -no-remove (removed on server)\n");
+ if ($opt_machinereadablelist) {
+ # TODO version numbers
+ machine_line($p, $FLAG_REMOVE, "-", "-");
} else {
- info("remove $p (removed on server)\n");
- }
- if (!($opt_dry or $opt_list or $opt_noremove)) {
- merge_into(\%ret, &remove_package($p, $localtlpdb));
- logpackage("remove: $p");
+ if ($opt_noremove) {
+ info("not removing $p due to -no-remove (removed on server)\n");
+ } else {
+ info("remove $p (removed on server)\n");
+ }
+ if (!($opt_dry or $opt_list or $opt_noremove)) {
+ merge_into(\%ret, &remove_package($p, $localtlpdb));
+ logpackage("remove: $p");
+ }
}
}
@@ -1403,7 +1430,12 @@ sub action_update {
# will be in the dependency expansion, and we want it.
my $newpkg_coll = $newpkgs{$pkg} || $newpkgs{$pkg_noarch};
if ($forcerm_coll) {
- info("skipping forcibly removed package $pkg\n");
+ if ($opt_machinereadablelist) {
+ # TODO should we add a revision number
+ machine_line($pkg, $FLAG_FORCIBLE_REMOVED, "-", "-");
+ } else {
+ info("skipping forcibly removed package $pkg\n");
+ }
next;
} elsif ($newpkg_coll) {
# do nothing here, it will be reported below.
@@ -1421,8 +1453,12 @@ sub action_update {
next;
}
my $mediarev = $mediatlp->revision;
- info("auto-install: $pkg\n");
- next if ($opt_dry || $opt_list);
+ if ($opt_machinereadablelist) {
+ machine_line($pkg, $FLAG_AUTOINSTALL, "-", $mediatlp->revision);
+ } else {
+ info("auto-install: $pkg\n");
+ }
+ next if ($opt_dry || $opt_list || $opt_machinereadablelist);
my $foo = $tlmediasrc->install_package($pkg, $localtlpdb);
if (ref $foo) {
# installation succeeded because we got a reference
@@ -1448,6 +1484,8 @@ sub action_update {
$nrupdated++;
if ($opt_list) {
info("$pkg: local: $rev, source: $mediarev\n");
+ } elsif ($opt_machinereadablelist) {
+ machine_line($pkg, $FLAG_UPDATE, $rev, $mediarev);
} else {
if ($opt_backup && !$opt_dry) {
$tlp->make_container("lzma", $root,
@@ -1540,8 +1578,12 @@ sub action_update {
}
}
} elsif ($rev > $mediarev) {
- print "$pkg: local revision ($rev) is newer than revision in $location"
- . " ($mediarev), not updating.\n";
+ if ($opt_machinereadablelist) {
+ machine_line($pkg, $FLAG_REVERSED_UPDATE, $rev, $mediarev);
+ } else {
+ info("$pkg: local revision ($rev) is newer than revision in $location"
+ . " ($mediarev), not updating.\n");
+ }
next;
}
}
diff --git a/Master/tlpkg/TeXLive/TLUtils.pm b/Master/tlpkg/TeXLive/TLUtils.pm
index 55deb9c50dd..d9d36ec038f 100644
--- a/Master/tlpkg/TeXLive/TLUtils.pm
+++ b/Master/tlpkg/TeXLive/TLUtils.pm
@@ -1621,7 +1621,8 @@ operations.
sub info {
my $str = shift;
- logit(\*STDOUT, 0, $str);
+ my $fh = ($::machinereadable ? \*STDERR : \*STDOUT);
+ logit($fh, 0, $str);
chomp($str);
for my $i (@::info_hook) {
&{$i}($str);