summaryrefslogtreecommitdiff
path: root/Master/tlpkg/TeXLive/TLUtils.pm
diff options
context:
space:
mode:
authorSiep Kroonenberg <siepo@cybercomm.nl>2023-02-20 09:58:19 +0000
committerSiep Kroonenberg <siepo@cybercomm.nl>2023-02-20 09:58:19 +0000
commit81112f8b0ad3c7f836f0c69aafee1f6a813772b8 (patch)
tree98427b5826ba54609138a95a8d9b0515843beb62 /Master/tlpkg/TeXLive/TLUtils.pm
parent7a0c724008ca1fd567252a5582c94a37e69ba04f (diff)
Transition 32-bit => 64-bit for Windows; ,pm files
git-svn-id: svn://tug.org/texlive/trunk@65950 c570f23f-e606-0410-a88d-b1316a301751
Diffstat (limited to 'Master/tlpkg/TeXLive/TLUtils.pm')
-rw-r--r--Master/tlpkg/TeXLive/TLUtils.pm96
1 files changed, 50 insertions, 46 deletions
diff --git a/Master/tlpkg/TeXLive/TLUtils.pm b/Master/tlpkg/TeXLive/TLUtils.pm
index 342e4f34f95..2dc83012380 100644
--- a/Master/tlpkg/TeXLive/TLUtils.pm
+++ b/Master/tlpkg/TeXLive/TLUtils.pm
@@ -27,7 +27,7 @@ C<TeXLive::TLUtils> - TeX Live infrastructure miscellany
TeXLive::TLUtils::platform();
TeXLive::TLUtils::platform_name($canonical_host);
TeXLive::TLUtils::platform_desc($platform);
- TeXLive::TLUtils::win32();
+ TeXLive::TLUtils::wndws();
TeXLive::TLUtils::unix();
=head2 System tools
@@ -265,7 +265,7 @@ BEGIN {
@EXPORT = qw(setup_programs download_file process_logging_options
tldie tlwarn info log debug ddebug dddebug debug
debug_hash_str debug_hash
- win32 xchdir xsystem run_cmd system_pipe sort_archs);
+ wndws xchdir xsystem run_cmd system_pipe sort_archs);
}
use Cwd;
@@ -285,7 +285,7 @@ our $SshURIRegex = '^((ssh|scp)://([^@]*)@([^/]*)/|([^@]*)@([^:]*):).*$';
=item C<platform>
If C<$^O =~ /MSWin/i> is true we know that we're on
-Windows and we set the global variable C<$::_platform_> to C<win32>.
+Windows and we set the global variable C<$::_platform_> to C<windows>.
Otherwise we call C<platform_name> with the output of C<config.guess>
as argument.
@@ -301,9 +301,13 @@ C</bin/ksh> if it exists, else C</bin/bash> if it exists, else give up.
=cut
sub platform {
+ if (defined $::_platform_) {
+ print STDERR "_platform_: already defined as $::_platform_\n";
+ }
unless (defined $::_platform_) {
if ($^O =~ /^MSWin/i) {
- $::_platform_ = "win32";
+ print STDERR "\$^O is $^O\n";
+ $::_platform_ = "windows";
} else {
my $config_guess = "$::installerdir/tlpkg/installer/config.guess";
@@ -528,7 +532,7 @@ sub platform_desc {
'sparc-linux' => 'GNU/Linux on Sparc',
'sparc-solaris' => 'Solaris on Sparc',
'universal-darwin' => 'MacOSX current (10.14-) on ARM/x86_64',
- 'win32' => 'Windows',
+ 'windows' => 'Windows',
'x86_64-cygwin' => 'Cygwin on x86_64',
'x86_64-darwinlegacy' => 'MacOSX legacy (10.6-) on x86_64',
'x86_64-dragonfly' => 'DragonFlyBSD on x86_64',
@@ -551,21 +555,21 @@ sub platform_desc {
}
-=item C<win32>
+=item C<wndws>
Return C<1> if platform is Windows and C<0> otherwise. The test is
currently based on the value of Perl's C<$^O> variable.
=cut
-sub win32 {
+sub wndws {
if ($^O =~ /^MSWin/i) {
return 1;
} else {
return 0;
}
# the following needs config.guess, which is quite bad ...
- # return (&platform eq "win32")? 1:0;
+ # return (&platform eq "windows")? 1:0;
}
@@ -576,7 +580,7 @@ Return C<1> if platform is UNIX and C<0> otherwise.
=cut
sub unix {
- return (&platform eq "win32")? 0:1;
+ return (&platform eq "windows")? 0:1;
}
@@ -600,7 +604,7 @@ sub getenv {
my $envvar=shift;
my $var=$ENV{"$envvar"};
return 0 unless (defined $var);
- if (&win32) {
+ if (&wndws) {
$var=~s!\\!/!g; # change \ -> / (required by Perl)
}
return "$var";
@@ -622,7 +626,7 @@ sub which {
my @PATH;
my $PATH = getenv('PATH');
- if (&win32) {
+ if (&wndws) {
my @PATHEXT = split (';', getenv('PATHEXT'));
push (@PATHEXT, ''); # in case argument contains an extension
@PATH = split (';', $PATH);
@@ -789,7 +793,7 @@ sub system_pipe {
my ($prog, $infile, $outfile, $removeIn, @extraargs) = @_;
my $progQuote = quotify_path_with_spaces($prog);
- if (win32()) {
+ if (wndws()) {
$infile =~ s!/!\\!g;
$outfile =~ s!/!\\!g;
}
@@ -822,7 +826,7 @@ computing the disk space.
sub diskfree {
my $td = shift;
my ($output, $retval);
- if (win32()) {
+ if (wndws()) {
# the powershell one-liner only works from win8 on.
my @winver = Win32::GetOSVersion();
if ($winver[1]<=6 && $winver[2]<=1) {
@@ -905,7 +909,7 @@ my $user_home_dir;
sub get_user_home {
return $user_home_dir if ($user_home_dir);
- $user_home_dir = getenv (win32() ? 'USERPROFILE' : 'HOME') || '~';
+ $user_home_dir = getenv (wndws() ? 'USERPROFILE' : 'HOME') || '~';
return $user_home_dir;
}
@@ -940,7 +944,7 @@ Return both C<dirname> and C<basename>. Example:
sub dirname_and_basename {
my $path=shift;
my ($share, $base) = ("", "");
- if (win32) {
+ if (wndws()) {
$path=~s!\\!/!g;
}
# do not try to make sense of paths ending with /..
@@ -949,7 +953,7 @@ sub dirname_and_basename {
# eliminate `/.' path components
while ($path =~ s!/\./!/!) {};
# UNC path? => first split in $share = //xxx/yy and $path = /zzzz
- if (win32() and $path =~ m!^(//[^/]+/[^/]+)(.*)$!) {
+ if (wndws() and $path =~ m!^(//[^/]+/[^/]+)(.*)$!) {
($share, $path) = ($1, $2);
if ($path =~ m!^/?$!) {
$path = $share;
@@ -1007,7 +1011,7 @@ sub basename {
sub tl_abs_path {
my $path = shift;
- if (win32) {
+ if (wndws()) {
$path=~s!\\!/!g;
}
if (-e $path) {
@@ -1017,13 +1021,13 @@ sub tl_abs_path {
} else{
# collapse /./ components
$path =~ s!/\./!/!g;
- # no support for .. path components or for win32 long-path syntax
+ # no support for .. path components or for windows long-path syntax
# (//?/ path prefix)
die "Unsupported path syntax" if $path =~ m!/\.\./! || $path =~ m!/\.\.$!
|| $path =~ m!^\.\.!;
- die "Unsupported path syntax" if win32() && $path =~ m!^//\?/!;
+ die "Unsupported path syntax" if wndws() && $path =~ m!^//\?/!;
if ($path !~ m!^(.:)?/!) { # relative path
- if (win32() && $path =~ /^.:/) { # drive letter
+ if (wndws() && $path =~ /^.:/) { # drive letter
my $dcwd;
# starts with drive letter: current dir on drive
$dcwd = Cwd::getdcwd ($1);
@@ -1057,7 +1061,7 @@ sub dir_slash {
sub dir_creatable {
my $path=shift;
#print STDERR "testing $path\n";
- $path =~ s!\\!/!g if win32;
+ $path =~ s!\\!/!g if wndws;
return 0 unless -d $path;
$path .= '/' unless $path =~ m!/$!;
#print STDERR "testing $path\n";
@@ -1099,7 +1103,7 @@ a fileserver.
sub dir_writable {
my ($path) = @_;
return 0 unless -d $path;
- $path =~ s!\\!/!g if win32;
+ $path =~ s!\\!/!g if wndws;
$path .= '/' unless $path =~ m!/$!;
my $i = 0;
my $f;
@@ -1143,9 +1147,9 @@ sub mkdirhier {
$ret = 1;
} else {
my $subdir = "";
- # win32 is special as usual: we need to separate //servername/ part
+ # windows is special as usual: we need to separate //servername/ part
# from the UNC path, since (! -d //servername/) tests true
- $subdir = $& if ( win32() && ($tree =~ s!^//[^/]+/!!) );
+ $subdir = $& if ( wndws() && ($tree =~ s!^//[^/]+/!!) );
my @dirs = split (/[\/\\]/, $tree);
for my $dir (@dirs) {
@@ -1618,13 +1622,13 @@ sub removed_dirs {
# what should we do with not existing entries????
next if (! -r "$f");
my $abs_f = Cwd::abs_path ($f);
- # the following is necessary because on win32,
+ # the following is necessary because on windows,
# abs_path("tl-portable")
# returns
# c:\tl test\...
# and not forward slashes, while, if there is already a forward /
# in the path, also the rest is done with forward slashes.
- $abs_f =~ s!\\!/!g if win32();
+ $abs_f =~ s!\\!/!g if wndws();
if (!$abs_f) {
warn ("oops, no abs_path($f) from " . `pwd`);
next;
@@ -1884,7 +1888,7 @@ sub do_postaction {
sub _do_postaction_fileassoc {
my ($how, $mode, $tlpobj, $pa) = @_;
- return 1 unless win32();
+ return 1 unless wndws();
my ($errors, %keyval) =
parse_into_keywords($pa, qw/extension filetype/);
@@ -1922,7 +1926,7 @@ sub _do_postaction_fileassoc {
sub _do_postaction_filetype {
my ($how, $tlpobj, $pa) = @_;
- return 1 unless win32();
+ return 1 unless wndws();
my ($errors, %keyval) =
parse_into_keywords($pa, qw/name cmd/);
@@ -1967,7 +1971,7 @@ sub _do_postaction_filetype {
# associated program shows up in `open with' menu
sub _do_postaction_progid {
my ($how, $tlpobj, $pa) = @_;
- return 1 unless win32();
+ return 1 unless wndws();
my ($errors, %keyval) =
parse_into_keywords($pa, qw/extension filetype/);
@@ -2017,7 +2021,7 @@ sub _do_postaction_script {
return 0;
}
my $file = $keyval{'file'};
- if (win32() && defined($keyval{'filew32'})) {
+ if (wndws() && defined($keyval{'filew32'})) {
$file = $keyval{'filew32'};
}
my $texdir = `kpsewhich -var-value=TEXMFROOT`;
@@ -2047,7 +2051,7 @@ sub _do_postaction_script {
sub _do_postaction_shortcut {
my ($how, $tlpobj, $do_menu, $do_desktop, $pa) = @_;
- return 1 unless win32();
+ return 1 unless wndws();
my ($errors, %keyval) =
parse_into_keywords($pa, qw/type name icon cmd args hide/);
@@ -2318,7 +2322,7 @@ sub add_remove_symlinks {
my $plat_bindir = "$Master/bin/$arch";
# nothing to do with symlinks on Windows, of course.
- return if win32();
+ return if wndws();
my $info_dir = "$Master/texmf-dist/doc/info";
if ($mode eq "add") {
@@ -2404,7 +2408,7 @@ be called to make the changes immediately visible.
sub w32_add_to_path {
my ($bindir, $multiuser) = @_;
- return if (!win32());
+ return if (!wndws());
my $path = TeXLive::TLWinGoo::get_system_env() -> {'/Path'};
$path =~ s/[\s\x00]+$//;
@@ -2649,7 +2653,7 @@ sub untar {
# on w32 don't extract file modified time, because AV soft can open
# files in the mean time causing time stamp modification to fail
- my $taropt = win32() ? "xmf" : "xf";
+ my $taropt = wndws() ? "xmf" : "xf";
if (system($tar, $taropt, $tarfile) != 0) {
tlwarn("TLUtils::untar: $tar $taropt $tarfile failed (in $targetdir)\n");
$ret = 0;
@@ -3147,7 +3151,7 @@ sub _download_file_lwp {
sub _download_file_program {
my ($url, $dest, $type) = @_;
- if (win32()) {
+ if (wndws()) {
$dest =~ s!/!\\!g;
}
@@ -3196,7 +3200,7 @@ Return C</dev/null> on Unix and C<nul> on Windows.
=cut
sub nulldev {
- return (&win32()) ? 'nul' : '/dev/null';
+ return (&wndws()) ? 'nul' : '/dev/null';
}
=item C<get_full_line ($fh)>
@@ -4059,7 +4063,7 @@ sub texdir_check {
# Unfortunately we have lots of special characters.
# On Windows, backslashes are normal but will already have been changed
# to slashes by tl_abs_path. And we should only check for : on Unix.
- my $colon = win32() ? "" : ":";
+ my $colon = wndws() ? "" : ":";
if ($texdir =~ /[,$colon;\\{}\$]/) {
if ($warn) {
print " !! TEXDIR value has problematic characters: $orig_texdir\n";
@@ -4072,7 +4076,7 @@ sub texdir_check {
return 0;
}
# w32: for now, reject the root of a samba share
- return 0 if win32() && $texdir =~ m!^//[^/]+/[^/]+$!;
+ return 0 if wndws() && $texdir =~ m!^//[^/]+/[^/]+$!;
# if texdir already exists, make sure we can write into it.
return dir_writable($texdir) if (-d $texdir);
@@ -4103,7 +4107,7 @@ are (erroneously) eradicated.
sub quotify_path_with_spaces {
my $p = shift;
- my $m = win32() ? '[+=^&();,!%\s]' : '.';
+ my $m = wndws() ? '[+=^&();,!%\s]' : '.';
if ( $p =~ m/$m/ ) {
$p =~ s/"//g; # remove any existing double quotes
$p = "\"$p\"";
@@ -4151,13 +4155,13 @@ slashes after reading a path. They both are no-ops on Unix.
sub native_slashify {
my ($r) = @_;
- $r =~ s!/!\\!g if win32();
+ $r =~ s!/!\\!g if wndws();
return $r;
}
sub forward_slashify {
my ($r) = @_;
- $r =~ s!\\!/!g if win32();
+ $r =~ s!\\!/!g if wndws();
return $r;
}
@@ -4239,7 +4243,7 @@ END_NO_SSL
#
sub query_ctan_mirror_curl {
my $max_trial = 3;
- my $warg = (win32() ? '-w "%{url_effective}" ' : "-w '%{url_effective}' ");
+ my $warg = (wndws() ? '-w "%{url_effective}" ' : "-w '%{url_effective}' ");
for (my $i = 1; $i <= $max_trial; $i++) {
# -L -> follow redirects
# -s -> silent
@@ -4846,7 +4850,7 @@ sub mktexupd {
die "mktexupd: exec file does not exist: $file" if (! -f $file);
}
}
- my $delim= (&win32)? ';' : ':';
+ my $delim= (&wndws)? ';' : ':';
my $TEXMFDBS;
chomp($TEXMFDBS=`kpsewhich --show-path="ls-R"`);
@@ -4856,8 +4860,8 @@ sub mktexupd {
foreach my $path (keys %files) {
foreach my $db (@texmfdbs) {
$db=substr($db, -1) if ($db=~m|/$|); # strip leading /
- $db = lc($db) if win32();
- my $up = (win32() ? lc($path) : $path);
+ $db = lc($db) if wndws();
+ my $up = (wndws() ? lc($path) : $path);
if (substr($up, 0, length("$db/")) eq "$db/") {
# we appended a / because otherwise "texmf" is recognized as a
# substring of "texmf-dist".
@@ -4989,7 +4993,7 @@ directory for PATH.
sub prepend_own_path {
my $bindir = dirname(Cwd::abs_path(which('kpsewhich')));
- if (win32()) {
+ if (wndws()) {
$bindir =~ s!\\!/!g;
$ENV{'PATH'} = "$bindir;$ENV{PATH}";
} else {