From 272f667ff1987bad105a0f13f0337e9813671862 Mon Sep 17 00:00:00 2001 From: Norbert Preining Date: Wed, 5 Aug 2009 15:17:49 +0000 Subject: merge the bunch of TLPDBOptionsXXXX and TLPDBSettingXXXX into one hash each git-svn-id: svn://tug.org/texlive/trunk@14541 c570f23f-e606-0410-a88d-b1316a301751 --- Master/texmf/scripts/texlive/tlmgr.pl | 36 +++--- .../texmf/scripts/texlive/tlmgrgui/gui-config.pl | 4 +- Master/tlpkg/TeXLive/TLConfig.pm | 141 ++++++++++----------- Master/tlpkg/TeXLive/TLPDB.pm | 14 +- 4 files changed, 91 insertions(+), 104 deletions(-) diff --git a/Master/texmf/scripts/texlive/tlmgr.pl b/Master/texmf/scripts/texlive/tlmgr.pl index e138e649496..5a18cab7203 100755 --- a/Master/texmf/scripts/texlive/tlmgr.pl +++ b/Master/texmf/scripts/texlive/tlmgr.pl @@ -2113,8 +2113,8 @@ sub action_option { if (win32()) { next if ($o =~ m/^sys_/); } - if (defined $TLPDBOptionDesc{$o}) { - info("$TLPDBOptionDesc{$o} ($TLPDBOptionTlmgrName{$o}): " . + if (defined $TLPDBOptions{$o}) { + info("$TLPDBOptions{$o}->[2] ($TLPDBOptions{$o}->[1]): " . $localtlpdb->option($o) . "\n"); } else { tlwarn ("option $o not supported\n"); @@ -2122,21 +2122,21 @@ sub action_option { } } elsif ($what =~ m/^showall$/i) { my %loc = %{$localtlpdb->options}; - for my $o (keys %TLPDBOptionDesc) { - info("$TLPDBOptionDesc{$o} ($TLPDBOptionTlmgrName{$o}): " . + for my $o (keys %TLPDBOptions) { + info("$TLPDBOptions{$o}->[2] ($TLPDBOptions{$o}->[1]): " . (defined($loc{$o}) ? $loc{$o} : "(not set)") . "\n"); } } else { my $found = 0; - for my $opt (keys %TLPDBOptionTlmgrName) { - if ($what eq $TLPDBOptionTlmgrName{$opt}) { + for my $opt (keys %TLPDBOptions) { + if ($what eq $TLPDBOptions{$opt}->[1]) { $found = 1; # the option argument matches the name my $val = shift @ARGV; if (defined($val)) { # set new value # here we have to care for some special cases - if ($what eq $TLPDBOptionTlmgrName{"location"}) { + if ($what eq $TLPDBOptions{"location"}->[1]) { # support "ctan" on the cmd line, and don't abs_path it! if ($val =~ m/^ctan$/i) { $val = "$TeXLive::TLConfig::TeXLiveURL"; @@ -2151,18 +2151,18 @@ sub action_option { } info("tlmgr: setting default installation location to $val\n"); $localtlpdb->option($opt, $val); - } elsif ($what eq $TLPDBOptionTlmgrName{"backupdir"}) { + } elsif ($what eq $TLPDBOptions{"backupdir"}->[1]) { info("tlmgr: setting option $what to $val.\n"); if (! -d $val) { info("tlmgr: the directory $val does not exists, it has to be created\n"); info("tlmgr: before backups can be done automatically.\n"); } $localtlpdb->option($opt, $val); - } elsif ($what eq $TLPDBOptionTlmgrName{"w32_multi_user"}) { + } elsif ($what eq $TLPDBOptions{"w32_multi_user"}->[1]) { # when running w32 do not allow that a non-admin users sets # this from false to true if (win32() && !admin() && !$val) { - tlwarn("tlmgr: non-admin user cannot set $TLPDBOptionTlmgrName{'w32_multi_user'} option to true\n"); + tlwarn("tlmgr: non-admin user cannot set $TLPDBOptions{'w32_multi_user'}->[1] option to true\n"); } else { if ($val) { info("tlmgr: setting option $what to 1.\n"); @@ -2174,7 +2174,7 @@ sub action_option { } } else { # default case, switch for different types - if ($TLPDBOptionType{$opt} eq "b") { + if ($TLPDBOptions{$opt}->[0] eq "b") { if ($val) { info("tlmgr: setting option $what to 1.\n"); $localtlpdb->option($opt, 1); @@ -2182,13 +2182,13 @@ sub action_option { info("tlmgr: setting option $what to 0.\n"); $localtlpdb->option($opt, 0); } - } elsif ($TLPDBOptionType{$opt} eq "p") { + } elsif ($TLPDBOptions{$opt}->[0] eq "p") { info("tlmgr: setting option $what to $val.\n"); $localtlpdb->option($opt, $val); - } elsif ($TLPDBOptionType{$opt} eq "u") { + } elsif ($TLPDBOptions{$opt}->[0] eq "u") { info("tlmgr: setting option $what to $val.\n"); $localtlpdb->option($opt, $val); - } elsif ($TLPDBOptionType{$opt} =~ m/^n(:((-)?\d+)?..((-)?\d+)?)?$/) { + } elsif ($TLPDBOptions{$opt}->[0] =~ m/^n(:((-)?\d+)?..((-)?\d+)?)?$/) { my $isgood = 1; my $n = int($val); my $low; @@ -2198,14 +2198,14 @@ sub action_option { if (defined($2)) { # lower border if ($2 > $n) { - tlwarn("value $n for $what out of range ($TLPDBOptionType{$opt})\n"); + tlwarn("value $n for $what out of range ($TLPDBOptions{$opt}->[0])\n"); $isgood = 0; } } if (defined($4)) { # upper border if ($4 < $n) { - tlwarn("value $n for $what out of range ($TLPDBOptionType{$opt})\n"); + tlwarn("value $n for $what out of range ($TLPDBOptions{$opt}->[0])\n"); $isgood = 0; } } @@ -2215,13 +2215,13 @@ sub action_option { $localtlpdb->option($opt, $n); } } else { - tlwarn ("Unknown type of option $opt: $TLPDBOptionType{$opt}\n"); + tlwarn ("Unknown type of option $opt: $TLPDBOptions{$opt}->[0]\n"); } } $localtlpdb->save; } else { # show current value - info ("$TLPDBOptionDesc{$opt} ($TLPDBOptionTlmgrName{$opt}): " . + info ("$TLPDBOptions{$opt}->[2] ($TLPDBOptions{$opt}->[1]): " . $localtlpdb->option($opt) . "\n"); } last; diff --git a/Master/texmf/scripts/texlive/tlmgrgui/gui-config.pl b/Master/texmf/scripts/texlive/tlmgrgui/gui-config.pl index 81a910deb28..f2bf48e0713 100644 --- a/Master/texmf/scripts/texlive/tlmgrgui/gui-config.pl +++ b/Master/texmf/scripts/texlive/tlmgrgui/gui-config.pl @@ -16,8 +16,8 @@ $fileassocdesc[1] = ___"fa_onlynew"; $fileassocdesc[2] = ___"fa_all"; my %defaults; -for my $key (keys %TeXLive::TLConfig::TLPDBOptionTlmgrName) { - if ($TeXLive::TLConfig::TLPDBOptionType{$key} eq "b") { +for my $key (keys %TeXLive::TLConfig::TLPDBOptions) { + if ($TeXLive::TLConfig::TLPDBOptions{$key}->[0] eq "b") { $defaults{$key} = ($localtlpdb->option($key) ? ___"yes" : ___"no"); } else { if ($key eq "file_assocs") { diff --git a/Master/tlpkg/TeXLive/TLConfig.pm b/Master/tlpkg/TeXLive/TLConfig.pm index bcf73275a1d..0313be0bf81 100644 --- a/Master/tlpkg/TeXLive/TLConfig.pm +++ b/Master/tlpkg/TeXLive/TLConfig.pm @@ -28,15 +28,11 @@ BEGIN { $TeXLiveURL @CriticalPackagesList $CriticalPackagesRegexp - @AllowedConfigOptions $WindowsMainMenuName $RelocPrefix $RelocTree - %TLPDBSettingType - %TLPDBSettingDesc - %TLPDBOptionType - %TLPDBOptionDesc - %TLPDBOptionTlmgrName + %TLPDBOptions + %TLPDBSettings ); @EXPORT = @EXPORT_OK; } @@ -87,22 +83,6 @@ if ($^O=~/^MSWin(32|64)$/i) { $CriticalPackagesRegexp = '^(texlive\.infra|tlperl\.win32$)'; } -our @AllowedConfigOptions = qw/ - available_architectures - opt_create_symlinks - opt_create_formats - opt_paper - opt_sys_bin - opt_sys_info - opt_sys_man - opt_install_docfiles - opt_install_srcfiles - platform - location - backupdir - autobackup - /; - # # definition of the option strings and their value types # possible types are: @@ -117,59 +97,70 @@ our @AllowedConfigOptions = qw/ # WARNING: keep these in sync! # -our %TLPDBOptionTlmgrName = ( - "location" => "location", - "create_formats" => "formats", - "desktop_integration" => "deskint", - "file_assocs" => "fileassocs", - "post_code" => "postcode", - "sys_bin" => "sys_bin", - "sys_info" => "sys_info", - "sys_man" => "sys_man", - "install_docfiles" => "docfiles", - "install_srcfiles" => "srcfiles", - "w32_multi_user" => "multiuser", - "autobackup" => "autobackup", - "backupdir" => "backupdir"); -our %TLPDBOptionType = ( - "location" => "u", - "create_formats" => "b", - "desktop_integration" => "b", - "file_assocs" => "n:0..2", - "post_code" => "b", - "sys_bin" => "p", - "sys_info" => "p", - "sys_man" => "p", - "install_docfiles" => "b", - "install_srcfiles" => "b", - "w32_multi_user" => "b", - "autobackup" => "n:-1..", - "backupdir" => "p"); -our %TLPDBOptionDesc = ( - "location" => "Default installation location", - "create_formats" => "Create formats on installation", - "desktop_integration" => "Create shortcuts (menu and desktop) in postinst", - "file_assocs" => "Change file associations in postinst", - "post_code" => "Run postinst code blobs", - "sys_bin" => "Destination for symlinks for binaries", - "sys_info" => "Destination for symlinks for info docs", - "sys_man" => "Destination for symlinks for man pages", - "install_docfiles" => "Install documentation files", - "install_srcfiles" => "Install source files", - "w32_multi_user" => "Install for shortcuts/menu items for all users (w32)", - "autobackup" => "Number of backups to keep", - "backupdir" => "Directory for backups"); - -our %TLPDBSettingType = ( - "platform" => "s", - "available_architectures" => "l" -); -our %TLPDBSettingDesc = ( - "platform" => "Main platform for this computer", - "available_architectures" => "All available/installed architectures" -); +# $TLPDBOptions{"option"}->[0] --> type +# ->[1] --> tlmgr name +# ->[2] --> tlmgr description +our %TLPDBOptions = ( + "location" => + [ "u", + "location", + "Default installation location" ], + "create_formats" => + [ "b", + "formats", + "Create formats on installation" ], + "desktop_integration" => + [ "b", + "desktop_integration", + "Create shortcuts (menu and desktop) in postinst" ], + "file_assocs" => + [ "n:0..2", + "fileassocs", + "Change file associations in postinst" ], + "post_code" => + [ "b", + "postcode", + "Run postinst code blobs" ], + "sys_bin" => + [ "p", + "sys_bin", + "Destination for symlinks for binaries" ], + "sys_man" => + [ "p", + "sys_man", + "Destination for symlinks for man pages" ], + "sys_info" => + [ "p", + "sys_info", + "Destination for symlinks for info docs" ], + "install_docfiles" => + [ "b", + "docfiles", + "Install documentation files" ], + "install_srcfiles" => + [ "b", + "srcfiles", + "Install source files" ], + "w32_multi_user" => + [ "b", + "multiuser", + "Install for shortcuts/menu items for all users (w32)" ], + "autobackup" => + [ "n:-1..", + "autobackup", + "Number of backups to keep" ], + "backupdir" => + [ "p", + "backupdir", + "Directory for backups" ] + ); +our %TLPDBSettings = ( + "platform" => [ "s", "Main platform for this computer" ], + "available_architectures" => [ "l", "All available/installed architectures" ] +); + our $WindowsMainMenuName = "TeX Live $ReleaseYear"; @@ -249,10 +240,6 @@ A list of all those packages which we do not update regularly since they are too central, currently only texlive.infra (and tlperl.win32 for Windows). -=item C<@TeXLive::TLConfig::AllowedConfigOptions> - -A list of a config options that can be set in 00texlive.installation. - =item C<$TeXLive::TLConfig::RelocTree> the texmf-tree name that can be relocated, defaults to "texmf-dist" diff --git a/Master/tlpkg/TeXLive/TLPDB.pm b/Master/tlpkg/TeXLive/TLPDB.pm index 7f61215f398..e91bea2620d 100644 --- a/Master/tlpkg/TeXLive/TLPDB.pm +++ b/Master/tlpkg/TeXLive/TLPDB.pm @@ -64,7 +64,7 @@ C -- A database of TeX Live Packages use TeXLive::TLConfig qw($CategoriesRegexp $DefaultCategory $InfraLocation $DatabaseName $MetaCategoriesRegexp $Archive - %TLPDBOptionType %TLPDBSettingType); + %TLPDBOptions %TLPDBSettings); use TeXLive::TLUtils qw(dirname mkdirhier member win32 info debug ddebug tlwarn); use TeXLive::TLPOBJ; @@ -1084,7 +1084,7 @@ sub setting_pkg { my $pkg = shift; my $key = shift; if (@_) { - if ($TLPDBSettingType{$key} eq "l") { + if ($TLPDBSettings{$key}->[0] eq "l") { $self->_set_value_pkg($pkg, "setting_", $key, "@_"); } else { $self->_set_value_pkg($pkg, "setting_", $key, shift); @@ -1092,7 +1092,7 @@ sub setting_pkg { } my $ret = $self->_value_pkg($pkg, "setting_", $key); # check the types of the settings, and if it is a "l" return a list - if ($TLPDBSettingType{$key} eq "l") { + if ($TLPDBSettings{$key}->[0] eq "l") { my @ret; if (defined $ret) { @ret = split(" ", $ret); @@ -1108,7 +1108,7 @@ sub setting { my $self = shift; my $key = shift; if (@_) { - if ($TLPDBSettingType{$key} eq "l") { + if ($TLPDBSettings{$key}->[0] eq "l") { $self->_set_setting_value($key, "@_"); } else { $self->_set_setting_value($key, shift); @@ -1116,7 +1116,7 @@ sub setting { } my $ret = $self->_setting_value($key); # check the types of the settings, and if it is a "l" return a list - if ($TLPDBSettingType{$key} eq "l") { + if ($TLPDBSettings{$key}->[0] eq "l") { my @ret; if (defined $ret) { @ret = split(" ", $ret); @@ -1158,11 +1158,11 @@ sub _keyshash { sub options { my $self = shift; - return ($self->_keyshash('opt_', \%TLPDBOptionType)); + return ($self->_keyshash('opt_', \%TLPDBOptions)); } sub settings { my $self = shift; - return ($self->_keyshash('setting_', \%TLPDBSettingType)); + return ($self->_keyshash('setting_', \%TLPDBSettings)); } =pod -- cgit v1.2.3