#!/usr/bin/env perl # For testing, edit $ro_dir and $wr_dir as needed. # $ro_dir should be read-only. # $wr_dir should be writable. #!/usr/bin/env perl use strict; BEGIN { $^W = 1; my $me=$0; $me=~s!\\!/!g if $^O=~/^MSWin(32|64)$/i; if ($me=~m!/!) { ($::installerdir=$me)=~s!(.*)/.*$!$1!; } else { # This shouldn't occur if called from batchfile $::installerdir='.'; } unshift (@INC, "$::installerdir/tlpkg"); # unshift (@INC, "$::installerdir/bin/win32") if $^O=~/^MSWin(32|64)$/i; } use TeXLive::TLWinGoo; # safe under Unix/Linux! my $ro_dir = "z:/aps"; sub maybenot { my $bool = shift; return $bool ? " is " : " is not "; } sub create_file { my $name = shift; return if -e $name; open DUMMY, ">".$name; print DUMMY "Hello"; close DUMMY; } sub print_search_paths { print "System path: ".get_system_path()."\n"; print "User path: ".get_user_path()."\n"; } print ((join "\n", @INC)."\n"); # admin if (admin()) { print "Admin or not on Windows\n"; } else { print "Not admin\n"; } # country print "Country: " . reg_country() . "\n"; # global_tmpdir print "Global tempdir: " . global_tmpdir()."\n"; if ($^O !~ /^MSWin(32|64)$/i) { print "Not Windows; bailing out...\n"; exit; } # dir_writable my $wr_dir = $ENV{'USERPROFILE'}; $wr_dir =~ s/\\/\//g; mkdir $wr_dir unless -e $wr_dir; print $wr_dir . maybenot(dir_writable($wr_dir)) . "writable\n"; print $ro_dir . maybenot(dir_writable($ro_dir)) . "writable\n"; # expand_string print expand_string("pre\\%systemROOT%\\post")."\n"; # win_which_dir print "cmd.exe found in " . TeXLive::TLWinGoo::win_which_dir("cmd.exe") . "\n"; # adding and removing texbindir my $wr_dir1 = $wr_dir . "/tex1"; mkdir $wr_dir1 unless -e $wr_dir1; create_file( $wr_dir1."/tex.exe" ); add_texbindir_to_path($wr_dir1); print_search_paths(); print "tex.exe found in " . TeXLive::TLWinGoo::win_which_dir("tex.exe") . "\n"; my $wr_dir2 = $wr_dir . "/tex2"; mkdir $wr_dir2 unless -e $wr_dir2; create_file( $wr_dir2."/tex.exe" ); add_texbindir_to_path($wr_dir2); print_search_paths(); print "tex.exe found in " . TeXLive::TLWinGoo::win_which_dir("tex.exe") . "\n"; # the problem case: no admin, but TeX on system path if (!admin()) { my $fn = expand_string("%windir%")."/TEX.EXE"; $fn =~ s/\\/\//g; create_file($fn); # a tex.exe on the system path! add_texbindir_to_path(expand_string($wr_dir2)); my @wge = wg_error(); if (@wge) { print $wge[1]."\n"; } print_search_paths(); print "tex.exe found in " . TeXLive::TLWinGoo::win_which_dir("tex.exe") . "\n"; unlink $fn; } # adding a filetype register_script_type(".rb","x:/ruby/bin/ruby.exe"); # broadcast environment changes broadcast_env();