diff options
author | Norbert Preining <preining@logic.at> | 2009-08-31 17:16:41 +0000 |
---|---|---|
committer | Norbert Preining <preining@logic.at> | 2009-08-31 17:16:41 +0000 |
commit | 2e0c4bb1eff08d3034f952774b56bbe070e21529 (patch) | |
tree | 63240ca6d326e7590ceb92ec335326b25d20586c | |
parent | a62b7f8aa5a42830330af8f0d3206a5388178b33 (diff) |
warn and return if an action is asked for but no write permissions are given
git-svn-id: svn://tug.org/texlive/trunk@14968 c570f23f-e606-0410-a88d-b1316a301751
-rwxr-xr-x | Master/texmf/scripts/texlive/tlmgr.pl | 32 |
1 files changed, 32 insertions, 0 deletions
diff --git a/Master/texmf/scripts/texlive/tlmgr.pl b/Master/texmf/scripts/texlive/tlmgr.pl index 69027fb8bf4..7bef7d376e1 100755 --- a/Master/texmf/scripts/texlive/tlmgr.pl +++ b/Master/texmf/scripts/texlive/tlmgr.pl @@ -689,6 +689,7 @@ sub action_remove { my %already_removed; my @more_removal; init_local_db(); + return if !check_on_writable(); info("remove: dry run, no changes will be made\n") if $opts{"dry-run"}; my @packs = @ARGV; # @@ -826,6 +827,7 @@ sub action_paper { tlwarn("tlmgr: expected `a4' or `letter' after paper, not $newpaper\n"); } else { # tlmgr paper {a4|letter} => do it. + return if !check_on_writable(); TeXLive::TLPaper::paper_all($texmfsysconfig,$newpaper); } @@ -840,6 +842,9 @@ sub action_paper { # the do_paper progs check for the argument --list, so if given # restore it to the cmd line. unshift(@ARGV, "--list") if $opts{"list"}; + if (@ARGV) { + return if !check_on_writable(); + } TeXLive::TLPaper::do_paper($prog,$texmfsysconfig,@ARGV); } } @@ -1163,6 +1168,7 @@ sub action_restore { } # we did arrive here, so we try to restore ... if (defined($backups{$pkg}->{$rev})) { + return if !check_on_writable(); if (!$opts{"force"}) { print "Do you really want to restore $pkg to revision $rev (y/N): "; my $yesno = <STDIN>; @@ -1574,6 +1580,10 @@ sub action_update { @excluded_pkgs = @{$opts{"exclude"}}; } + if (!$opts{"list"}) { + return if !check_on_writable(); + } + # check for updates to tlmgr and die unless either --force or --list or --self # is given my @critical = check_for_critical_updates($localtlpdb, $tlmediatlpdb); @@ -2313,6 +2323,7 @@ sub action_install { action_gui("install"); } init_local_db(1); + return if !check_on_writable(); # initialize the TLMedia from $location $opts{"no-depends"} = 1 if $opts{"no-depends-at-all"}; init_tlmedia(); @@ -2534,6 +2545,7 @@ sub action_option { # the option argument matches the name my $val = shift @ARGV; if (defined($val)) { + return if !check_on_writable(); # set new value # here we have to care for some special cases if ($what eq $TLPDBOptions{"location"}->[2]) { @@ -2683,6 +2695,7 @@ sub action_arch { print "You can add new architectures with tlmgr arch add arch1 arch2\n"; finish(0); } elsif ($what =~ m/^add$/i) { + return if !check_on_writable(); init_tlmedia(); my $mediatlpdb = $tlmediasrc->tlpdb; my @already_installed_arch = $localtlpdb->available_architectures; @@ -2730,6 +2743,7 @@ sub action_arch { $localtlpdb->save; } } elsif ($what =~ m/^remove$/i) { + return if !check_on_writable(); my @already_installed_arch = $localtlpdb->available_architectures; my @todoarchs; my $currentarch = $localtlmedia->platform(); @@ -2916,6 +2930,7 @@ sub action_uninstall { if ($opts{"gui"}) { action_gui("uninstall"); } + return if !check_on_writable(); my $force = defined($opts{"force"}) ? $opts{"force"} : 0; if (!$force) { print("If you answer yes here the whole TeX Live installation will be removed!\n"); @@ -2958,6 +2973,7 @@ sub action_uninstall { # RECREATE TLPDB # sub action_recreate_tlpdb { + return if !check_on_writable(); my $tlpdb = TeXLive::TLPDB->new; $tlpdb->root($Master); my $inst = TeXLive::TLPOBJ->new; @@ -3963,6 +3979,22 @@ sub packagecmp { } } +sub check_on_writable { + if (!TeXLive::TLUtils::dir_writable("$Master/tlpkg")) { + tlwarn("You don't have permissions to change the installation in any way.\n"); + tlwarn("Please contact the administrator or call this program as administrator.\n"); + if ($opts{"dry-run"}) { + tlwarn("Continuing due to --dry-run\n"); + return 1; + } else { + return 0; + } + } + return 1; +} + + + 1; __END__ |