diff options
author | Norbert Preining <preining@logic.at> | 2010-09-29 01:06:37 +0000 |
---|---|---|
committer | Norbert Preining <preining@logic.at> | 2010-09-29 01:06:37 +0000 |
commit | 139d0280413b686b63b2aba949942aff984ddff7 (patch) | |
tree | fe2727c3d22cffab0931f579c56e2140c09f8701 | |
parent | b4eb58d9e0299d963626970dc7d85917199ff71e (diff) |
consistently use check_backupdir_selection sub instead of rewriting
it again and again, make warning messages more useful
git-svn-id: svn://tug.org/texlive/trunk@19941 c570f23f-e606-0410-a88d-b1316a301751
-rwxr-xr-x | Master/texmf/scripts/texlive/tlmgr.pl | 89 |
1 files changed, 18 insertions, 71 deletions
diff --git a/Master/texmf/scripts/texlive/tlmgr.pl b/Master/texmf/scripts/texlive/tlmgr.pl index 3360127a342..a32138dac7d 100755 --- a/Master/texmf/scripts/texlive/tlmgr.pl +++ b/Master/texmf/scripts/texlive/tlmgr.pl @@ -1211,8 +1211,9 @@ sub check_backupdir_selection { my $ob = abs_path($opts{"backupdir"}); $ob && ($opts{"backupdir"} = $ob); if (! -d $opts{"backupdir"}) { - $warntext .= "tlmgr: backupdir argument $opts{'backupdir'} is not a directory.\n"; - $warntext .= "Don't know from where to restore backups.\n"; + $warntext .= "tlmgr: backupdir argument\n"; + $warntext .= " $opts{'backupdir'}\n"; + $warntext .= "is not a directory.\n"; return (0, $warntext); } } else { @@ -1220,14 +1221,15 @@ sub check_backupdir_selection { init_local_db(1); $opts{"backupdir"} = norm_tlpdb_path($localtlpdb->option("backupdir")); if (!$opts{"backupdir"}) { - return (0, "Don't know from where to restore backups.\n"); + return (0, "tlmgr: No way to determine backupdir.\n"); } # we are still here, there is something set in tlpdb my $ob = abs_path($opts{"backupdir"}); $ob && ($opts{"backupdir"} = $ob); if (! -d $opts{"backupdir"}) { - $warntext = "backupdir as set in tlpdb $opts{'backupdir'} is not a directory.\n"; - $warntext .= "Don't know from where to restore backups.\n"; + $warntext = "tlmgr: backupdir as set in tlpdb\n"; + $warntext .= " $opts{'backupdir'}\n"; + $warntext .= "is not a directory.\n"; return (0, $warntext); } } @@ -1371,39 +1373,12 @@ sub action_backup { } } # check the backup dir argument - if ($opts{"backupdir"}) { - my $ob = abs_path($opts{"backupdir"}); - $ob && ($opts{"backupdir"} = $ob); - if (! -d $opts{"backupdir"}) { - tlwarn ("backupdir argument $opts{'backupdir'} is not a directory.\n"); - if ($clean_mode) { - tlwarn ("Cannot clean a non existing directory, terminating.\n"); - } else { - tlwarn ("Don't know where to save backups, terminating.\n"); - } - exit 1; - } - } else { - # no argument, check for presence in TLPDB - $opts{"backupdir"} = norm_tlpdb_path($localtlpdb->option("backupdir")); - if (!$opts{"backupdir"}) { - if ($clean_mode) { - tlwarn ("Cannot clean an unknown directory, terminating.\n"); - } else { - tlwarn ("Don't know where to save backups, terminating.\n"); - } - exit 1; - } - # we are stil here, there is something set in tlpdb - my $ob = abs_path($opts{"backupdir"}); - $ob && ($opts{"backupdir"} = $ob); - if (! -d $opts{"backupdir"}) { - tlwarn ("backupdir as set in tlpdb $opts{'backupdir'} is not a directory.\n"); - if ($clean_mode) { - tlwarn ("Cannot clean a non existing directory, terminating.\n"); - } else { - tlwarn ("Don't know where to save backups, terminating.\n"); - } + { + my ($a, $b) = check_backupdir_selection(); + if (!$a) { + # in all these cases we want to terminate in the non-gui mode + tlwarn($b); + tlwarn("Exiting.\n"); exit 1; } } @@ -1856,16 +1831,6 @@ sub action_update { } } - # do backup dir checking now so that we don't run into troubles - # later, and exit if that doesn't work - if ($opts{"backupdir"}) { - $opts{"backupdir"} = abs_path($opts{"backupdir"}); - if (! -d $opts{"backupdir"}) { - tlwarn("Argument for --backupdir must be an existing directory. Terminating.\n"); - exit 1; - } - } - my $autobackup = 0; # check for the tlpdb option autobackup, and if present and true (!= 0) # assume we are doing backups @@ -1893,29 +1858,11 @@ sub action_update { # cmd line --backup, we check for --backupdir, and if that is not given # we try to get the default from the tlpdb. If that doesn't work, exit. if ($opts{"backup"}) { - my $diebackupmsg = ""; - if (!$opts{"backupdir"}) { - # no path has been specified on the command line, check for settings - # in the local tlpdb - my $tlpdbbackupdir = $localtlpdb->option("backupdir"); - $opts{"backupdir"} = norm_tlpdb_path($tlpdbbackupdir); - if ($opts{"backupdir"}) { - # ok, something is saved in the tlpdb, but we have to check if - # that directory actually exists - $opts{"backupdir"} = abs_path($opts{"backupdir"}); - if (!(defined($opts{"backupdir"}) && -d $opts{"backupdir"})) { - $diebackupmsg = "The backup directory\n $tlpdbbackupdir\nas specified in the local TLPDB does not exist, exiting.\n"; - } - } else { - # not set in the tlpdb, and not set on cmd line, but asked for - # --backup - $diebackupmsg = "Backups should be made, but neither on the command line\nnor in the local TLPDB a backup directory has been specified, exiting.\n"; - } - } - # no else branch necessary, we already checked that --backupdir if - # given is ok, see above - if ($diebackupmsg) { - tlwarn($diebackupmsg); + my ($a, $b) = check_backupdir_selection(); + if (!$a) { + # in all these cases we want to terminate in the non-gui mode + tlwarn($b); + tlwarn("Exiting.\n"); exit 1; } } |