summaryrefslogtreecommitdiff
path: root/Master/tlpkg/TeXLive/TLUtils.pm
diff options
context:
space:
mode:
authorKarl Berry <karl@freefriends.org>2022-06-13 01:11:19 +0000
committerKarl Berry <karl@freefriends.org>2022-06-13 01:11:19 +0000
commit6d5127ab20c78f342a1384a57a79bf7590633dea (patch)
tree29f49208cbd3d7ae81e45d204d3f8c8bdd31cfee /Master/tlpkg/TeXLive/TLUtils.pm
parent6ca73a5b746f4672f8b37033dcb891dfcda506d0 (diff)
install-tl (GetOptions): new options -no-installation, no-interaction,
-debug-setup-vars, -paper; also -texdir and other directory trees. (set_var_from_alternatives, set_standard_var): generalize method for setting the dir values. Expand tildes. (update_default_{scheme,paper}): new fns so scheme and paper size options are set before we go into the menus. (check_env): don't complain about INFOPATH or MANPATH; mention TEXLIVE_INSTALL_ENV_NOCHECK. Document new options; give a few examples. TLUtils.pm (get_user_home, expand_tilde): new fns. install-menu-text.pl: call them. git-svn-id: svn://tug.org/texlive/trunk@63571 c570f23f-e606-0410-a88d-b1316a301751
Diffstat (limited to 'Master/tlpkg/TeXLive/TLUtils.pm')
-rw-r--r--Master/tlpkg/TeXLive/TLUtils.pm41
1 files changed, 38 insertions, 3 deletions
diff --git a/Master/tlpkg/TeXLive/TLUtils.pm b/Master/tlpkg/TeXLive/TLUtils.pm
index 4751574b681..bc54b5c4440 100644
--- a/Master/tlpkg/TeXLive/TLUtils.pm
+++ b/Master/tlpkg/TeXLive/TLUtils.pm
@@ -43,6 +43,8 @@ C<TeXLive::TLUtils> - TeX Live infrastructure miscellany
TeXLive::TLUtils::run_cmd($cmd [, @envvars ]);
TeXLive::TLUtils::system_pipe($prog, $infile, $outfile, $removeIn, @args);
TeXLive::TLUtils::diskfree($path);
+ TeXLive::TLUtils::get_user_home();
+ TeXLive::TLUtils::expand_tilde($str);
=head2 File utilities
@@ -234,6 +236,8 @@ BEGIN {
&run_cmd
&system_pipe
&diskfree
+ &get_user_home
+ &expand_tilde
&announce_execute_actions
&add_symlinks
&remove_symlinks
@@ -868,7 +872,7 @@ sub diskfree {
}
$td .= "/" if ($td !~ m!/$!);
return (-1) if (! -e $td);
- debug("Checking for free diskspace in $td\n");
+ debug("checking diskfree() in $td\n");
($output, $retval) = run_cmd("df -P \"$td\"", POSIXLY_CORRECT => 1);
if ($retval == 0) {
# Output format should be this:
@@ -876,16 +880,47 @@ sub diskfree {
# /dev/sdb3 6099908248 3590818104 2406881416 60% /home
my ($h,$l) = split(/\n/, $output);
my ($fs, $nrb, $used, $avail, @rest) = split(' ', $l);
- debug("disk space: used=$used (512-block), avail=$avail (512-block)\n");
+ debug("diskfree: used=$used (512-block), avail=$avail (512-block)\n");
# $avail is in 512-byte blocks, so we need to divide by 2*1024 to
# obtain Mb. Require that at least 100M remain free.
return (int($avail / 2048));
} else {
- # error in running df -P out of whatever reason
+ # error in running df -P for whatever reason
return (-1);
}
}
+=item C<get_user_home()>
+
+Returns the current user's home directory (C<$HOME> on Unix,
+C<$USERPROFILE> on Windows, and C<~> if none of the two are
+set. Save in package variable C<$user_home_dir> after computing.
+
+=cut
+
+# only search for home directory once, and save expansion here
+my $user_home_dir;
+
+sub get_user_home {
+ return $user_home_dir if ($user_home_dir);
+ $user_home_dir = getenv (win32() ? 'USERPROFILE' : 'HOME') || '~';
+ return $user_home_dir;
+}
+
+=item C<expand_tilde($str)>
+
+Expands initial C<~> with the user's home directory in C<$str> if
+available, else leave C<~> in place.
+
+=cut
+
+sub expand_tilde {
+ my $str = shift;
+ my $h = get_user_home();
+ $str =~ s/^~/$h/;
+ return $str;
+}
+
=back
=head2 File utilities