From 52c664adcaba5d606cd23141c7ed58faee2fb74e Mon Sep 17 00:00:00 2001 From: Norbert Preining Date: Mon, 15 Dec 2008 21:55:37 +0000 Subject: add two patches in development, one for permutable arguments, one for using podselect for selecting the right part of the doc when warning git-svn-id: svn://tug.org/texlive/trunk@11625 c570f23f-e606-0410-a88d-b1316a301751 --- Master/tlpkg/etc/dev.permutable-arguments.patch | 394 ++++++++++++++++++++++++ Master/tlpkg/etc/dev.usage-via-podselect.patch | 197 ++++++++++++ 2 files changed, 591 insertions(+) create mode 100644 Master/tlpkg/etc/dev.permutable-arguments.patch create mode 100644 Master/tlpkg/etc/dev.usage-via-podselect.patch (limited to 'Master/tlpkg/etc') diff --git a/Master/tlpkg/etc/dev.permutable-arguments.patch b/Master/tlpkg/etc/dev.permutable-arguments.patch new file mode 100644 index 00000000000..d5e1d156c90 --- /dev/null +++ b/Master/tlpkg/etc/dev.permutable-arguments.patch @@ -0,0 +1,394 @@ +--- /src/TeX/texlive-svn/Master/texmf/scripts/texlive/tlmgr2.pl 2008-12-15 15:19:14.000000000 +0100 ++++ tlmgr2.pl 2008-12-15 15:22:44.000000000 +0100 +@@ -71,7 +71,7 @@ + mkdirhier merge_into copy log debug)); + use Cwd qw/abs_path/; + use Pod::Usage; +-use Getopt::Long qw(:config no_autoabbrev require_order); ++use Getopt::Long qw(:config no_autoabbrev permute); + use strict; + + require("papersize-setting.pl"); +@@ -99,9 +99,6 @@ + # stubs for setting paper sizes + 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"; +@@ -119,17 +116,90 @@ + my $opt_pause = 0; + $::machinereadable = 0; + ++my %globaloptions = ( ++ "location" => "=s", ++ "gui" => 1, ++ "gui-lang" => "=s", ++ "package-logfiles" => "=s", ++ "machine-readable" => 1, ++ "version" => 1, ++ "pause" => 1, ++ "help|h|?" => 1); ++ ++my %actionoptions = ( ++ "remove" => { "no-depends" => 1, ++ "no-depends-at-all" => 1, ++ "force" => 1, ++ "dry-run|n" => 1 }, ++ "show" => { "list" => 1 }, ++ "search" => { "global" => 1, ++ "file" => 1 }, ++ "restore" => { "backupdir" => "=s", ++ "dry-run|n" => 1, ++ "force" => 1 }, ++ "backup" => { "backupdir" => "=s", ++ "clean" => ":s", ++ "all" => 1, ++ "dry-run|n" => 1 }, ++ "update" => { "no-depends" => 1, ++ "no-depends-at-all" => 1, ++ "all" => 1, ++ "list" => 1, ++ "no-remove" => 1, ++ "force" => 1, ++ "backupdir" => "=s", ++ "backup" => 1, ++ "dry-run|n" => 1 }, ++ "install" => { "no-depends" => 1, ++ "no-depends-at-all" => 1, ++ "reinstall" => 1, ++ "force" => 1, ++ "dry-run|n" => 1 }, ++ "arch" => { "dry-run|n" => 1 }, ++ "generate" => { "localcfg" => "=s", ++ "dest" => "=s" }, ++ "uninstall"=> { "force" => 1 }, ++ "check" => { "use-svn" => 1 } ++ ); ++ ++my %optarg; ++for my $k (keys %globaloptions) { ++ if ($globaloptions{$k} eq "1") { ++ $optarg{$k} = 1; ++ } else { ++ $optarg{"$k" . $globaloptions{$k}} = 1; ++ } ++} ++for my $v (values %actionoptions) { ++ for my $k (keys %$v) { ++ if ($v->{$k} eq "1") { ++ $optarg{$k} = 1; ++ } else { ++ $optarg{"$k" . $v->{$k}} = 1; ++ } ++ } ++} + TeXLive::TLUtils::process_logging_options(); +-GetOptions("location=s" => \$opt_location, +- "gui" => \$opt_gui, +- "gui-lang=s" => \$opt_gui_lang, +- "package-logfile=s" => \$opt_packagelogfile, +- # for machine readable we use a global variable so that +- # the perl modules can check for that, too, more easily +- "machine-readable" => \$::machinereadable, +- "version" => \$opt_version, +- "pause" => \$opt_pause, +- "h|help|?" => \$opt_help) or pod2usage(2); ++ ++my %cmdopts; ++ ++GetOptions(\%cmdopts, keys(%optarg)) or pod2usage(2); ++ ++ ++$opt_location = $cmdopts{"location"} ++ if (defined($cmdopts{"location"})); ++$opt_gui = $cmdopts{"gui"} ++ if (defined($cmdopts{"gui"})); ++$opt_gui_lang = $cmdopts{"gui-lang"} ++ if (defined($cmdopts{"gui-lang"})); ++$opt_packagelogfile = $cmdopts{"package-logfile"} ++ if (defined($cmdopts{"package-logfile"})); ++$::machinereadable = $cmdopts{"machine-readable"} ++ if (defined($cmdopts{"machine-readable"})); ++$opt_version = $cmdopts{"version"} ++ if (defined($cmdopts{"version"})); ++$opt_help = $cmdopts{"help"} ++ if (defined($cmdopts{"help"})); + + my $action = shift; + +@@ -137,6 +207,14 @@ + $action = "gui"; + } + ++ddebug("action = $action\n"); ++for my $k (keys %cmdopts) { ++ ddebug("$k => $cmdopts{$k}\n"); ++} ++if (@ARGV) { ++ ddebug("arguments: @ARGV\n"); ++} ++ + sub give_version { + if (!defined($::version_string)) { + $::version_string = ""; +@@ -178,6 +256,40 @@ + } + } + ++# ++# check on supported arguments ++# ++my %suppargs; ++%suppargs = %{$actionoptions{$action}} ++ if defined($actionoptions{$action}); ++my @notvalidargs; ++for my $k (keys %cmdopts) { ++ my $kk = $k; ++ if ($k eq "n" || $k eq "dry-run") { ++ $kk = "dry-run|n"; ++ } ++ if (!defined($suppargs{$kk})) { ++ push @notvalidargs, $k; ++ } ++} ++if (@notvalidargs) { ++ my $msg = ++ "The following arguments are not supported for the action $action:\n"; ++ for my $c (@notvalidargs) { ++ $msg .= " $c"; ++ } ++ $msg .= "\n"; ++ # here we should call pod2usage actually with the argument ++ # -verbose => 99 ++ # -sections => "ACTIONS/$action.*" ++ # to show the correct invocation of the action ++ if (TeXLive::TLUtils::which("perldoc")) { ++ pod2usage(-msg => $msg, -exitstatus => 1, -verbose => 1); ++ } else { ++ pod2usage(-msg => $msg, -exitstatus => 1, -verbose => 1, -noperldoc => 1); ++ } ++} ++ + # besides doing normal logging if -logfile is specified, we try to log + # package related actions (install, remove, update) to + # the package-log file TEXMFSYSVAR/web2c/tlmgr.log +@@ -495,15 +607,14 @@ + # . remove the package + # + my %ret; +- my $opt_nodepends = 0; +- my $opt_reallynodepends = 0; +- my $opt_force = 0; +- my $opt_dry = 0; +- Getopt::Long::Configure(@getopt_configure_subopts); +- GetOptions("no-depends" => \$opt_nodepends, +- "no-depends-at-all" => \$opt_reallynodepends, +- "force" => \$opt_force, +- "n|dry-run" => \$opt_dry) or pod2usage(2); ++ my $opt_nodepends = ++ defined($cmdopts{"no-depends"}) ? $cmdopts{"no-depends"} : 0; ++ my $opt_reallynodepends = ++ defined($cmdopts{"no-depends-at-all"}) ? $cmdopts{"no-depends-at-all"} : 0; ++ my $opt_force = ++ defined($cmdopts{"force"}) ? $cmdopts{"force"} : 0; ++ my $opt_dry = ++ defined($cmdopts{"dry-run"}) ? $cmdopts{"dry-run"} : 0; + $opt_nodepends = 1 if $opt_reallynodepends; + my %already_removed; + my @more_removal; +@@ -684,9 +795,7 @@ + } + tlwarn("machine-readable output not supported for show\n") + if $::machinereadble; +- my $opt_list = 0; +- Getopt::Long::Configure(@getopt_configure_subopts); +- GetOptions("list" => \$opt_list) or pod2usage(2); ++ my $opt_list = defined($cmdopts{"list"}) ? $cmdopts{"list"} : 0; + init_local_db(); + my $tlmediatlpdb; + foreach my $pkg (@ARGV) { +@@ -765,14 +874,11 @@ + } + + sub action_search { +- my $opt_global = 0; +- my $opt_file = 0; ++ my $opt_global = defined($cmdopts{"global"}) ? $cmdopts{"global"} : 0; ++ my $opt_file = defined($cmdopts{"file"}) ? $cmdopts{"file"} : 0; + my %ret; + tlwarn("machine-readable output not supported for search\n") + if $::machinereadble; +- Getopt::Long::Configure(@getopt_configure_subopts); +- GetOptions("global" => \$opt_global, +- "file" => \$opt_file) or pod2usage(2); + my $r = shift @ARGV; + my $ret = ""; + my $tlpdb; +@@ -819,12 +925,9 @@ + tlwarn("machine-readable output not supported for restore\n") + if $::machinereadble; + my $opt_backupdir; +- my $opt_force; +- my $opt_dry = 0; +- Getopt::Long::Configure(@getopt_configure_subopts); +- GetOptions("backupdir=s" => \$opt_backupdir, +- "n|dry-run" => \$opt_dry, +- "force" => \$opt_force) or pod2usage(2); ++ defined($cmdopts{"backupdir"}) && ( $opt_backupdir = $cmdopts{"backupdir"} ); ++ my $opt_force = defined($cmdopts{"force"}) ? $cmdopts{"force"} : 0; ++ my $opt_dry = defined($cmdopts{"dry"}) ? $cmdopts{"dry"} : 0; + my %ret; + # check the backup dir argument + if ($opt_backupdir) { +@@ -920,9 +1023,10 @@ + tlwarn("machine-readable output not supported for backup\n") + if $::machinereadble; + init_local_db(1); +- my $opt_dry = 0; +- my $opt_all = 0; ++ my $opt_dry = defined($cmdopts{"dry-run"}) ? $cmdopts{"dry-run"} : 0; ++ my $opt_all = defined($cmdopts{"all"}) ? $cmdopts{"all"} : 0; + my $opt_backupdir; ++ defined($cmdopts{"backupdir"}) && ( $opt_backupdir = $cmdopts{"backupdir"} ); + # --clean argument + # can be either -1 ... don't clean + # 0 ... remove all backups +@@ -937,12 +1041,7 @@ + # $opt_clean = -1, 0, N -> --clean=N given, check argument + # + my $opt_clean; +- Getopt::Long::Configure(@getopt_configure_subopts); +- GetOptions("all" => \$opt_all, +- "backupdir=s" => \$opt_backupdir, +- "clean:s" => \$opt_clean, +- "n|dry-run" => \$opt_dry, +- ) or pod2usage(2); ++ defined($cmdopts{"clean"}) && ( $opt_clean = $cmdopts{"clean"} ); + my $clean_mode = 0; + $clean_mode = 1 if defined($opt_clean); + if ($clean_mode) { +@@ -1200,25 +1299,18 @@ + } + init_local_db(1); + # initialize the TLMedia from $location +- my $opt_nodepends = 0; +- my $opt_reallynodepends = 0; +- my $opt_dry = 0; +- my $opt_all = 0; +- my $opt_list = 0; +- my $opt_noremove = 0; ++ my $opt_nodepends = ++ defined($cmdopts{"no-depends"}) ? $cmdopts{"no-depends"} : 0; ++ my $opt_reallynodepends = ++ defined($cmdopts{"no-depends-at-all"}) ? $cmdopts{"no-depends-at-all"} : 0; ++ my $opt_dry = defined($cmdopts{"dry-run"}) ? $cmdopts{"dry-run"} : 0; ++ my $opt_all = defined($cmdopts{"all"}) ? $cmdopts{"all"} : 0; ++ my $opt_list = defined($cmdopts{"list"}) ? $cmdopts{"list"} : 0; ++ my $opt_noremove = defined($cmdopts{"no-remove"}) ? $cmdopts{"no-remove"} : 0; + my $opt_backupdir; +- my $opt_backup = 0; +- my $opt_force = 0; +- Getopt::Long::Configure(@getopt_configure_subopts); +- GetOptions("no-depends" => \$opt_nodepends, +- "no-depends-at-all" => \$opt_reallynodepends, +- "all" => \$opt_all, +- "list" => \$opt_list, +- "no-remove" => \$opt_noremove, +- "force" => \$opt_force, +- "backupdir=s" => \$opt_backupdir, +- "backup" => \$opt_backup, +- "n|dry-run" => \$opt_dry) or pod2usage(2); ++ defined($cmdopts{"backupdir"}) && ( $opt_backupdir = $cmdopts{"backupdir"} ); ++ my $opt_backup = defined($cmdopts{"backup"}) ? $cmdopts{"backup"} : 0; ++ my $opt_force = defined($cmdopts{"force"}) ? $cmdopts{"force"} : 0; + $opt_nodepends = 1 if $opt_reallynodepends; + my $nrupdated = 0; + my %ret; +@@ -1652,17 +1744,16 @@ + if $::machinereadble; + init_local_db(1); + # initialize the TLMedia from $location +- my $opt_nodepends = 0; +- my $opt_reallynodepends = 0; +- my $opt_dry = 0; +- my $opt_reinstall = 0; +- my $opt_force = 0; +- Getopt::Long::Configure(@getopt_configure_subopts); +- GetOptions("no-depends" => \$opt_nodepends, +- "no-depends-at-all" => \$opt_reallynodepends, +- "reinstall" => \$opt_reinstall, +- "force" => \$opt_force, +- "n|dry-run" => \$opt_dry) or pod2usage(2); ++ my $opt_nodepends = ++ defined($cmdopts{"no-depends"}) ? $cmdopts{"no-depends"} : 0; ++ my $opt_reallynodepends = ++ defined($cmdopts{"no-depends-at-all"}) ? $cmdopts{"no-depends-at-all"} : 0; ++ my $opt_dry = ++ defined($cmdopts{"dry-run"}) ? $cmdopts{"dry-run"} : 0; ++ my $opt_reinstall = ++ defined($cmdopts{"reinstall"}) ? $cmdopts{"reinstall"} : 0; ++ my $opt_force = defined($cmdopts{"force"}) ? $cmdopts{"force"} : 0; ++ $opt_nodepends = 1 if $opt_reallynodepends; + my %ret; + init_tlmedia(); + my $tlmediatlpdb = $tlmediasrc->tlpdb; +@@ -1869,9 +1960,8 @@ + tlwarn("machine-readable output not supported for arch\n") + if $::machinereadble; + my %ret; +- my $opt_dry = 0; +- Getopt::Long::Configure(@getopt_configure_subopts); +- GetOptions("n|dry-run" => \$opt_dry) or pod2usage(2); ++ my $opt_dry = ++ defined($cmdopts{"dry-run"}) ? $cmdopts{"dry-run"} : 0; + my $what = shift @ARGV; + init_local_db(1); + info("arch: dry run, no changes will be made\n") if $opt_dry; +@@ -1948,10 +2038,8 @@ + } + + sub action_generate { +- my $localconf = ""; +- my $dest = ""; +- Getopt::Long::Configure(@getopt_configure_subopts); +- GetOptions("localcfg=s" => \$localconf, "dest=s" => \$dest,) or pod2usage(2); ++ my $dest = defined($cmdopts{"dest"}) ? $cmdopts{"dest"} : ""; ++ my $localconf = defined($cmdopts{"localcfg"}) ? $cmdopts{"localcfg"} : ""; + my $what = shift @ARGV; + tlwarn("machine-readable output not supported for generate\n") + if $::machinereadble; +@@ -2114,9 +2202,7 @@ + if ($opt_gui) { + action_gui("uninstall"); + } +- my $force = 0; +- Getopt::Long::Configure(@getopt_configure_subopts); +- GetOptions("force" => \$force) or pod2usage(2); ++ my $force = defined($cmdopts{"force"}) ? $cmdopts{"force"} : 0; + if (!$force) { + print("If you answer yes here the whole TeX Live installation will be removed!\n"); + print "Remove TeX Live (y/N): "; +@@ -2238,9 +2324,7 @@ + + + sub action_check { +- my $svn = 0; +- Getopt::Long::Configure(@getopt_configure_subopts); +- GetOptions("use-svn" => \$svn) or pod2usage(2); ++ my $svn = defined($cmdopts{"use-svn"}) ? $cmdopts{"use-svn"} : 0; + my $what = shift @ARGV; + $what || ($what = "all"); + init_local_db(); +@@ -2952,7 +3036,7 @@ + option value is used (if set). + + The C option (de)activates the automatic generation of +-backups. Its value is an integer. If C is C<-1<, backups ++backups. Its value is an integer. If C is C<-1>, backups + will not be removed by default. If C is 0 or positive, it + specifies the number of backups to be kept. Thus, backups are disabled + with 0 as the values. diff --git a/Master/tlpkg/etc/dev.usage-via-podselect.patch b/Master/tlpkg/etc/dev.usage-via-podselect.patch new file mode 100644 index 00000000000..c51e6157ddc --- /dev/null +++ b/Master/tlpkg/etc/dev.usage-via-podselect.patch @@ -0,0 +1,197 @@ +--- /src/TeX/texlive-svn/Master/texmf/scripts/texlive/tlmgr2.pl 2008-12-15 08:27:24.000000000 +0100 ++++ tlmgr2.pl 2008-12-15 08:57:06.000000000 +0100 +@@ -71,6 +71,7 @@ + mkdirhier merge_into copy log debug)); + use Cwd qw/abs_path/; + use Pod::Usage; ++use Pod::Select; + use Getopt::Long qw(:config no_autoabbrev require_order); + use strict; + +@@ -245,6 +246,22 @@ + $localtlpdb->save; + } + finish(0); ++ } elsif ($action =~ m/^pod-test$/i) { ++ # piping the output of that to pod2text (-t) works very nicely ++ #podselect( {-output => \*STDOUT, -sections => ['ACTIONS/update.*']}, ++ # qw:/home/norbert/tlfoo/2008/texmf/scripts/texlive/tlmgr2.pl:); ++ #exit(0); ++ # ++ # that would be the perfect solution, but somehow it always creates ++ # a very strange output, I guess due to automatic resetting of ++ # verbose to 1 in Pod/Usage.pm code after selecting the sections ++ # I have no idea how to debug that ... maybe copy Pod/Usage.pm to ++ # tlpkg/TeXLive and use that instead? ++ pod2usage( { ++ -exitval => 0, ++ -verbose => 99, ++ -sections => 'ACTIONS/update.*' ++ }); + } elsif ($action =~ m/^get-mirror$/i) { + my $loc = give_ctan_mirror(); + print("$loc\n"); +@@ -2669,21 +2686,19 @@ + + =head1 ACTIONS + +-=over 4 +- +-=item B ++=head2 help + + Gives this help information (same as C<--help>). + +-=item B ++=head2 version + + Gives version information (same as C<--version>). + +-=item B ++=head2 gui + + Start the graphical user interface. + +-=item B [I