# Load shared stuff if (not -e "${II2RESOURCES}/ii2plfuncs.pm") { my $msg = "i-Installer is damaged. Perl support routines are missing."; warn "### ${PROGNAME}: ${msg}"; `"${II2RESOURCES}/doalerter" -s "${II2DOSERVER}" -V -t Alert -T "i-Installer is damaged" -I "${msg}" -1 "Accept"`; exit 1; } require "${II2RESOURCES}/ii2plfuncs.pm"; sub checkTeXEnvironmentVariables { my $warnstring = ''; # Warn about entries that people may have, e.g. in ~/.MacOSX/environment.plist # People: please do not use that file it is a source of trouble when the settings # there are picked up by apps for which they were not intended foreach my $envvar (("TEXMFMAIN", "TEXMF", "TEXMF", "TEXMF", "TEXMFCNF", "TEXINPUTS")) { $warnstring .= " \"${envvar}\"" if (exists $ENV{${envvar}}); } if ($warnstring ne '') { ipkgwarn( "There are TeX settings in your environment. In almost all circumstances this means that your TeX will not be configured correctly and that many thigs may go wrong.\n\nThe variables are:${warnstring}.\n\nA possible solution is to let i-Installer override the environment in its Preferences.\n\nI will proceed, hoping that your settings are not detrimental to this i-Package.\n"); } } sub checkTeXPath { my $arch = `uname -p`; chomp $arch; if (not -e "${II2INSTALLDIR}/bin/${arch}-apple-darwin-current/kpsewhich") { ipkgwarn( "I cannot locate the kpsewhich program. If this cannot be found, configuration is impossible. I will bail out...\n"); die "### ${PROGNAME}: Bailing out on missing kpsewhich (broken PATH setup? Missing program install?)\n"; } elsif (${II2LOGLEVEL} > 3) { print "### ${PROGNAME}: kpsewhich is at ${II2INSTALLDIR}/bin/${arch}-apple-darwin-current/kpsewhich\n"; } } sub checkTeXInstall { my $languagedatloc = `kpsewhich language.dat`; chomp $languagedatloc; if ($languagedatloc eq '') { ipkgwarn( "I cannot locate a language.dat file. If this cannot be found, configuration is probably impossible because of setup-problems. I will bail out...\n"); die "### ${PROGNAME}: Bailing out on missing language.dat\n"; } elsif (${II2LOGLEVEL} > 3) { print "### ${PROGNAME}: language.dat is at $languagedatloc\n"; } } sub checkinstallocation { if ("${II2INSTALLDIR}" ne "/usr/local/gwTeX") { my $doresult = `"${II2RESOURCES}/doalerter" -s "${II2DOSERVER}" -V -t Alert -T "Nondefault location" -I "The i-Package has a nonstandard install location.\n\nIf you use a nonstandard location, related i-Packages may or may not work properly, depending on how robust these have been written.\n\nIf the nonstandard location is used exclusively for this i-Package, you can go ahead. If not (e.g. if you install in a directory that is already used for other purposes) you may overwrite or delete things that are not part of this i-Package. I therefore strongly suggest using a dedicated directory as install location.\n\nClick Proceed to go ahead anyway." -1 "Proceed" -2 "Stop"`; chomp( $doresult); if (($? >> 8) == 0) { warn "### ${PROGNAME}: Proceeding with nonstandard location \"${II2INSTALLDIR}\".\n"; return 1; } else { warn "### ${PROGNAME}: Stopping because of nonstandard location \"${II2INSTALLDIR}\".\n"; return 0; } } else { if (${II2LOGLEVEL} > 3) { print "### ${PROGNAME}: Using standard location \"${II2INSTALLDIR}\".\n"; } return 1; } } sub migrateifnecessary { # Check if we need to migrate and if we do, migrate my $officialtexlive = getFileType( "/usr/local/texlive"); my $oldgwtex = getFileType( "/usr/local/TeXLive"); my $gwtex = getFileType( "/usr/local/gwTeX"); if (${II2INSTALLDIR} ne '/usr/local/gwTeX') { # The user has set his own install location. He'll get a warning later on # because he uses a non-default location and we do not migrate print "### ${PROGNAME}: Nonstandard location \"${II2INSTALLDIR}\". No migration attempt.\n"; if (${II2INSTALLDIR} =~ m|/+usr/+local/+gwtex/*|i) { # The changed location clashes on case preserving file systems # with the official default location. warn "### ${PROGNAME}: Your nonstandard location \"${II2INSTALLDIR}\" clashes with the default location on non case sensitive file systems.\n"; } return; } if ($gwtex eq 'none' or ($gwtex eq 'exact' and not -d '/usr/local/gwTeX/texmf.gwtex')) { # There is not yet an installed gwTeX, proceed if ($oldgwtex eq 'exact') { # There is an existing gwTeX install in an old location ipkgwarn( "The default location for this i-Package has changed. I will migrate your TeX to a new default location: /usr/local/gwTeX. You may need to adapt settings in any frontend you use.\n"); system( "/bin/mkdir /usr/local/gwTeX"); # May fail if run from prepare # Succeed if run from configure ipkgsystem( "/bin/mv /usr/local/TeXLive/* /usr/local/gwTeX/"); ipkgsystem( "/bin/rmdir /usr/local/TeXLive"); if (-l "/Library/TeXLive") { ipkgsystem( "/bin/rm /Library/TeXLive"); } if (-l "/Library/gwTeX") { ipkgsystem( "/bin/rm /Library/gwTeX"); } if (-l "/Library/teTeX") { ipkgsystem( "/bin/rm /Library/teTeX"); } return; } elsif ($oldgwtex =~ /caseless/) { # No exact match for /usr/local/TeXLive and # /usr/local/texlive exists exactly and /usr/local/TeXLive exists # in a different case, possibly /usr/local/texlive warn "### ${PROGNAME}: I have found a location which is a caseless match for /usr/local/TeXLive. I am ignoring this location as a possible source for migration.\n"; return; } } elsif ($gwtex eq 'caseless') { # If txmf.pkgs and texmf.gwtex exist, assume a changed install # location that is equal to the official one, but with a different case # else warn about a conflict name and die } elsif ($gwtex eq 'multiple caseless') { # Warn. warn "### ${PROGNAME}: I have found a multiple locations which are caseless matches for /usr/local/TeXLive. I am ignoring these locations as possible sources for migration.\n"; return; } else { # Print that the official location has been found and return print "### ${PROGNAME}: I have found /usr/local/gwTeX. No migration necessary.\n"; return; } } sub recreatedistributionlinks { my $texdistversion = "1"; my $DEFNAME = 'DefaultTeX'; my $arch = `uname -p`; chomp $arch; my $redirect = "1>&2"; $redirect = '>/dev/null 2>&1' if ($II2LOGLEVEL < 6); # ## Create gwTeX in $II2INSTALLDIR/texdist # my $gwtexlocation = "${II2INSTALLDIR}/texdist/gwTeX"; my $gwcontentslocation = "${gwtexlocation}/Contents"; # Remove old one ipkgsystem( "/bin/rm -rf \"${gwtexlocation}\""); # Build distribution setup (non-bundle) ipkgsystem( "/bin/mkdir -p \"$gwcontentslocation/Programs\""); ipkgsystem( "/bin/mkdir -p \"$gwcontentslocation/Developer/Lib\""); ipkgsystem( "/bin/mkdir -p \"$gwcontentslocation/Developer/Include\""); ipkgsystem( "/bin/mkdir -p \"$gwcontentslocation/AllTexmf\""); ipkgsystem( "/bin/mkdir -p \"$gwcontentslocation/Doc\""); ipkgsystem( "/usr/bin/unzip -u -d \"$gwcontentslocation\" \"${II2PKGDIR}/Resources-gwTeX.zip\" ${redirect}"); ipkgsystem( "/bin/ln -s \"../../..\" \"$gwcontentslocation/Root\""); ipkgsystem( "/bin/ln -s \"../../../../texmf.local\" \"$gwcontentslocation/AllTexmf/\""); ipkgsystem( "/bin/ln -s \"../../../../texmf.pkgs\" \"$gwcontentslocation/AllTexmf/\""); ipkgsystem( "/bin/ln -s \"../../../../texmf.texlive\" \"$gwcontentslocation/AllTexmf/\""); ipkgsystem( "/bin/ln -s \"../../../../texmf.gwtex\" \"$gwcontentslocation/AllTexmf/\""); ipkgsystem( "/bin/ln -s \"../../../../texmf\" \"$gwcontentslocation/AllTexmf/\""); ipkgsystem( "/bin/ln -s \"../../../../texmf.local/doc\" \"$gwcontentslocation/Doc/texmf-local-doc\""); ipkgsystem( "/bin/ln -s \"../../../../texmf.pkgs/doc\" \"$gwcontentslocation/Doc/texmf-pkgs-doc\""); ipkgsystem( "/bin/ln -s \"../../../../texmf.texlive/doc\" \"$gwcontentslocation/Doc/texmf-texlive-doc\""); ipkgsystem( "/bin/ln -s \"../../../../texmf.gwtex/doc\" \"$gwcontentslocation/Doc/texmf-gwtex-doc\""); ipkgsystem( "/bin/ln -s \"../../../../texmf/doc\" \"$gwcontentslocation/Doc/texmf-doc\""); ipkgsystem( "/bin/ln -s \"../../../texmf.local\" \"$gwcontentslocation/TexmfSysVar\""); ipkgsystem( "/bin/ln -s \"../../../texmf.pkgs\" \"$gwcontentslocation/TexmfLocal\""); ipkgsystem( "/bin/ln -s \"../../../man\" \"$gwcontentslocation/Man\""); ipkgsystem( "/bin/ln -s \"../../../info\" \"$gwcontentslocation/Info\""); ipkgsystem( "/bin/ln -s \"../../../../bin/i386-apple-darwin-current\" \"$gwcontentslocation/Programs/i386\""); ipkgsystem( "/bin/ln -s \"../../../../bin/powerpc-apple-darwin-current\" \"$gwcontentslocation/Programs/powerpc\""); ipkgsystem( "/bin/ln -s \"../../../../../lib\" \"$gwcontentslocation/Developer/Lib/i386\""); ipkgsystem( "/bin/ln -s \"../../../../../lib\" \"$gwcontentslocation/Developer/Lib/powerpc\""); ipkgsystem( "/bin/ln -s \"../../../../../include\" \"$gwcontentslocation/Developer/Include/i386\""); ipkgsystem( "/bin/ln -s \"../../../../../include\" \"$gwcontentslocation/Developer/Include/powerpc\""); ipkgsystem( "/bin/echo \"${texdistversion}\" >\"$gwcontentslocation/TeXDistVersion\""); # Create bundle pointer in /Library/TeX if (not -e "/Library/TeX/Distributions") { ipkgsystem( "/bin/mkdir -p /Library/TeX/Distributions"); } if (not -d "/Library/TeX/Distributions") { warn "### ${PROGNAME}: /Library/TeX/Distributions exist but is not a directory. I am leaving it alone. Sorry."; return; } if (not -e "/Library/TeX/Distributions/TeXDist-description.rtf") { ipkgsystem( "/bin/cp \"${II2PKGDIR}/TeXDist-description.rtf\" /Library/TeX/Distributions/"); } # Make gwTeX.texdist ipkgsystem( "/bin/rm -rf /Library/TeX/Distributions/gwTeX.texdist"); ipkgsystem( "/bin/mkdir -p /Library/TeX/Distributions/gwTeX.texdist"); ipkgsystem( "/bin/ln -s \"../../../..${gwcontentslocation}\" /Library/TeX/Distributions/gwTeX.texdist/Contents"); # Make Default link and point it to me ipkgsystem( "/bin/rm -rf \"/Library/TeX/Distributions/.${DEFNAME}\""); ipkgsystem( "/bin/mkdir -p \"/Library/TeX/Distributions/.${DEFNAME}\""); ipkgsystem( "/bin/ln -s ../gwTeX.texdist/Contents \"/Library/TeX/Distributions/.${DEFNAME}/Contents\""); # Make Default link for Programs if (-l "/usr/texbin") { # Recreate if it is a link ipkgsystem( "/bin/rm -f /usr/texbin"); } if (not -e "/usr/texbin") { # Only create if it does not exist if ($arch eq 'powerpc') { if (-e "/Library/TeX/Distributions/.${DEFNAME}/Contents/Programs/powerpc/tex") { ipkgsystem( "/bin/ln -s \"../Library/TeX/Distributions/.${DEFNAME}/Contents/Programs/powerpc\" \"/usr/texbin\""); } } elsif ($arch eq 'i386') { if (-e "/Library/TeX/Distributions/.${DEFNAME}/Contents/Programs/i386/tex") { ipkgsystem( "/bin/ln -s \"../Library/TeX/Distributions/.${DEFNAME}/Contents/Programs/i386\" \"/usr/texbin\""); } elsif (-e "/Library/TeX/Distributions/.${DEFNAME}/Contents/Programs/powerpc/tex") { ipkgsystem( "/bin/ln -s \"../Library/TeX/Distributions/.${DEFNAME}/Contents/Programs/powerpc\" \"/usr/texbin\""); ipkgwarn( "Your system is an intel system but you only have the PowerPC TeX binaries installed.\n\nI have created the system wide CLI setup to point to the PowerPC binaries which will run under Rosetta (slow emulation) on your Intel system."); } } } # Make Default link for Documentation and Root if (not -e "/Library/TeX/Documentation") { # Only create if it does not exist ipkgsystem( "/bin/ln -s \"Distributions/.${DEFNAME}/Contents/Doc\" \"/Library/TeX/Documentation\""); } if (not -e "/Library/TeX/Root") { # Only create if it does not exist ipkgsystem( "/bin/ln -s \"Distributions/.${DEFNAME}/Contents/Root\" \"/Library/TeX/Root\""); } # Create factory defaults for old gwTeX and TL 2004-2007 $factorydefaults = "/Library/TeX/Distributions/.FactoryDefaults"; if (not -e "$factorydefaults") { ipkgsystem( "/bin/mkdir -p \"$factorydefaults\""); } # ## gwTeX-2003-2005 # my $DISTNAME = 'gwTeX-2003-2005'; $gwtexlocation = "$factorydefaults/${DISTNAME}"; $gwcontentslocation = "${gwtexlocation}/Contents"; my $gwtexroot = "/usr/local/teTeX"; # Remove old one ipkgsystem( "/bin/rm -rf \"${gwtexlocation}\""); # Build distribution setup (non-bundle) ipkgsystem( "/bin/mkdir -p \"$gwcontentslocation/Programs\""); ipkgsystem( "/bin/mkdir -p \"$gwcontentslocation/Developer/Lib\""); ipkgsystem( "/bin/mkdir -p \"$gwcontentslocation/Developer/Include\""); ipkgsystem( "/bin/mkdir -p \"$gwcontentslocation/AllTexmf\""); ipkgsystem( "/bin/mkdir -p \"$gwcontentslocation/Doc\""); ipkgsystem( "/usr/bin/unzip -u -d \"$gwcontentslocation\" \"${II2PKGDIR}/Resources-gwTeX-2003-2005.zip\" ${redirect}"); ipkgsystem( "/bin/ln -s \"../../../../../..$gwtexroot\" \"$gwcontentslocation/Root\""); ipkgsystem( "/bin/ln -s \"../../../../../../..$gwtexroot/share/texmf.local\" \"$gwcontentslocation/AllTexmf/\""); ipkgsystem( "/bin/ln -s \"../../../../../../..$gwtexroot/share/texmf.tetex\" \"$gwcontentslocation/AllTexmf/\""); ipkgsystem( "/bin/ln -s \"../../../../../../..$gwtexroot/share/texmf.gwtex\" \"$gwcontentslocation/AllTexmf/\""); ipkgsystem( "/bin/ln -s \"../../../../../../..$gwtexroot/share/texmf\" \"$gwcontentslocation/AllTexmf/\""); ipkgsystem( "/bin/ln -s \"../../../../../../..$gwtexroot/share/texmf.local/doc\" \"$gwcontentslocation/Doc/texmf-local-doc\""); ipkgsystem( "/bin/ln -s \"../../../../../../..$gwtexroot/share/texmf.tetex/doc\" \"$gwcontentslocation/Doc/texmf-tetex-doc\""); ipkgsystem( "/bin/ln -s \"../../../../../../..$gwtexroot/share/texmf.gwtex/doc\" \"$gwcontentslocation/Doc/texmf-gwtex-doc\""); ipkgsystem( "/bin/ln -s \"../../../../../../..$gwtexroot/share/texmf/doc\" \"$gwcontentslocation/Doc/texmf-doc\""); ipkgsystem( "/bin/ln -s \"../../../../../..$gwtexroot/share/texmf.local\" \"$gwcontentslocation/TexmfSysVar\""); ipkgsystem( "/bin/ln -s \"../../../../../..$gwtexroot/share/texmf.local\" \"$gwcontentslocation/TexmfLocal\""); ipkgsystem( "/bin/ln -s \"../../../../../..$gwtexroot/man\" \"$gwcontentslocation/Man\""); ipkgsystem( "/bin/ln -s \"../../../../../..$gwtexroot/info\" \"$gwcontentslocation/Info\""); ipkgsystem( "/bin/ln -s \"../../../../../../..$gwtexroot/bin/i386-apple-darwin-current\" \"$gwcontentslocation/Programs/i386\""); ipkgsystem( "/bin/ln -s \"../../../../../../..$gwtexroot/bin/powerpc-apple-darwin-current\" \"$gwcontentslocation/Programs/powerpc\""); ipkgsystem( "/bin/ln -s \"../../../../../../../..$gwtexroot/lib\" \"$gwcontentslocation/Developer/Lib/i386\""); ipkgsystem( "/bin/ln -s \"../../../../../../../..$gwtexroot/lib\" \"$gwcontentslocation/Developer/Lib/powerpc\""); ipkgsystem( "/bin/ln -s \"../../../../../../../..$gwtexroot/include\" \"$gwcontentslocation/Developer/Include/i386\""); ipkgsystem( "/bin/ln -s \"../../../../../../../..$gwtexroot/include\" \"$gwcontentslocation/Developer/Include/powerpc\""); ipkgsystem( "/bin/echo \"${texdistversion}\" >\"$gwcontentslocation/TeXDistVersion\""); # Make gwTeX .texdist if it does not exist yet. if (not -e "/Library/TeX/Distributions/${DISTNAME}.texdist") { ipkgsystem( "/bin/mkdir -p /Library/TeX/Distributions/${DISTNAME}.texdist"); ipkgsystem( "/bin/ln -s \"../.FactoryDefaults/${DISTNAME}/Contents\" /Library/TeX/Distributions/${DISTNAME}.texdist/Contents"); } my @tlyearlist = ('2004', '2005', '2006', '2007'); for my $year (@tlyearlist) { # ## TeXLive-2005 and TeXLive-2005 etc. # my $DISTNAME = "TeXLive-$year"; my $texdistlocation = "$factorydefaults/${DISTNAME}"; my $contentslocation = "${texdistlocation}/Contents"; my $texrootparent = "/usr/local/texlive"; my $texroot = "$texrootparent/$year"; # Remove old one ipkgsystem( "/bin/rm -rf \"${texdistlocation}\""); ipkgsystem( "/bin/mkdir -p \"$contentslocation/Programs\""); ipkgsystem( "/bin/mkdir -p \"$contentslocation/AllTexmf\""); ipkgsystem( "/bin/mkdir -p \"$contentslocation/Doc\""); ipkgsystem( "/usr/bin/unzip -u -d \"$contentslocation\" \"${II2PKGDIR}/Resources-TeXLive-$year.zip\" ${redirect}"); ipkgsystem( "/bin/ln -s \"../../../../../..${texroot}\" \"$contentslocation/Root\""); ipkgsystem( "/bin/ln -s \"../../../../../../..$texrootparent/texmf-local\" \"$contentslocation/AllTexmf/\""); ipkgsystem( "/bin/ln -s \"../../../../../../..$texroot/texmf-var\" \"$contentslocation/AllTexmf/\""); ipkgsystem( "/bin/ln -s \"../../../../../../..$texroot/texmf-doc\" \"$contentslocation/AllTexmf/\""); ipkgsystem( "/bin/ln -s \"../../../../../../..$texroot/texmf-dist\" \"$contentslocation/AllTexmf/\""); ipkgsystem( "/bin/ln -s \"../../../../../../..$texroot/texmf\" \"$contentslocation/AllTexmf/\""); ipkgsystem( "/bin/ln -s \"../../../../../../..$texrootparent/texmf-local/doc\" \"$contentslocation/Doc/texmf-local-doc\""); ipkgsystem( "/bin/ln -s \"../../../../../../..$texroot/texmf-var/doc\" \"$contentslocation/Doc/texmf-var-doc\""); ipkgsystem( "/bin/ln -s \"../../../../../../..$texroot/texmf-doc/doc\" \"$contentslocation/Doc/texmf-doc-doc\""); ipkgsystem( "/bin/ln -s \"../../../../../../..$texroot/texmf-dist/doc\" \"$contentslocation/Doc/texmf-dist-doc\""); ipkgsystem( "/bin/ln -s \"../../../../../../..$texroot/texmf/doc\" \"$contentslocation/Doc/texmf-doc\""); ipkgsystem( "/bin/ln -s \"../../../../../..$texrootparent/texmf-local\" \"$contentslocation/TexmfLocal\""); ipkgsystem( "/bin/ln -s \"../../../../../..$texroot/texmf-var\" \"$contentslocation/TexmfSysVar\""); ipkgsystem( "/bin/ln -s \"../../../../../..$texroot/texmf/doc/man\" \"$contentslocation/Man\""); ipkgsystem( "/bin/ln -s \"../../../../../..$texroot/texmf/doc/info\" \"$contentslocation/Info\""); ipkgsystem( "/bin/ln -s \"../../../../../../..$texroot/bin/i386-darwin\" \"$contentslocation/Programs/i386\""); ipkgsystem( "/bin/ln -s \"../../../../../../..$texroot/bin/powerpc-darwin\" \"$contentslocation/Programs/powerpc\""); ipkgsystem( "/bin/echo \"${texdistversion}\" >\"$contentslocation/TeXDistVersion\""); # Make TL .texdist if it does not exist yet (e.g. others can overwrite) if (not -e "/Library/TeX/Distributions/${DISTNAME}.texdist") { ipkgsystem( "/bin/mkdir -p /Library/TeX/Distributions/${DISTNAME}.texdist"); ipkgsystem( "/bin/ln -s \"../.FactoryDefaults/${DISTNAME}/Contents\" /Library/TeX/Distributions/${DISTNAME}.texdist/Contents"); } } if (not -e "/Library/TeX/.scripts") { ipkgsystem( "/bin/mkdir -p \"/Library/TeX/.scripts\""); } if (not -d "/Library/TeX/.scripts") { warn "### $PROGNAME: No .scripts directory.\n"; } my $existingversion = '0.0'; if (-e "/Library/TeX/.scripts/texdist") { $existingversion = `/Library/TeX/.scripts/texdist --version`; } my $pkgversion = `"${II2PKGDIR}/texdist" --version`; if ($pkgversion gt $existingversion) { warn "### $PROGNAME: Installing texdist...\n"; ipkgsystem( "/bin/cp -p \"${II2PKGDIR}/texdist\" \"/Library/TeX/.scripts/texdist\""); } if (not -e "/usr/local/bin") { ipkgsystem( "/bin/mkdir -p /usr/local/bin"); } if (not -e "/usr/local/bin/texdist") { ipkgsystem( "/bin/ln -s \"/Library/TeX/.scripts/texdist\" /usr/local/bin/texdist"); } installtexdistprefpane(); installtexdisttool(); } sub installtexdisttool { my $location = '/Applications/TeX'; my $name = 'TeXDistTool'; my $appname = "$name.app"; my $tarname = "${II2PKGDIR}/${name}.tar.bz2"; my $uname = getpwuid( $>); # Get name of current effective user uid my (undef,undef,undef,$gid,undef,undef,undef,undef) = getpwnam( $uname); # Get gid of user my $gname = getgrgid( $gid); if (-e "/tmp/$appname") { warn "### ${PROGNAME}: Removing previous temporary unpackaged TeX Dist Tool\n"; ipkgsystem( "/bin/rm -rf /tmp/$appname"); } my $redirect = "1>&2"; $redirect = '>/dev/null 2>&1' if ($II2LOGLEVEL < 6); ipkgsystem( "/usr/bin/tar -C /tmp -jxvf \"${tarname}\" ${redirect}"); if (-e "/tmp/$appname") { if (-e "${location}/${appname}") { warn "### ${PROGNAME}: Checking installed TeX Dist Tool app...\n"; my $newbuild = `"/tmp/${appname}/Contents/MacOS/GetSourceVersion"`; my $installedbuild = `"/${location}/${appname}/Contents/MacOS/GetSourceVersion"`; if ($newbuild and $installedbuild and $newbuild > $installedbuild) { warn "### ${PROGNAME}: Installing updated TeX Dist Tool app ...\n"; } else { warn "### ${PROGNAME}: Not installing my TeX Dist Tool app. The installed one is not older or has a different structure.\n"; return; } } ipkgsystem( "/bin/mkdir -p \"${location}\""); ipkgsystem( "/usr/bin/tar -C \"${location}\" -jxvf \"${tarname}\" 1>&2"); ipkgsystem( "/usr/sbin/chown -R \"${uname}:${gname}\" \"${location}/${appname}\"") == 0 or warn "### ${PROGNAME}: failed to run chown on texdisttool. Bailing out...\n";; } else { warn "### ${PROGNAME}: Tmp install of pref pane failed. Bailing out...\n"; return; } } sub installtexdistprefpane { my $location = '/Library/PreferencePanes'; my $name = 'TeXDistPrefPane'; my $prefname = "$name.prefPane"; my $tarname = "${II2PKGDIR}/${name}.tar.bz2"; my $uname = getpwuid( $>); # Get name of current effective user uid my (undef,undef,undef,$gid,undef,undef,undef,undef) = getpwnam( $uname); # Get gid of user my $gname = getgrgid( $gid); my $redirect = "1>&2"; $redirect = '>/dev/null 2>&1' if ($II2LOGLEVEL < 6); if (-e "/tmp/$prefname") { warn "### ${PROGNAME}: Removing previous temporary unpackaged TeX Dist Preference Pane\n"; ipkgsystem( "/bin/rm -rf /tmp/$prefname"); } ipkgsystem( "/usr/bin/tar -C /tmp -jxvf \"${tarname}\" ${redirect}"); if (-e "/tmp/$prefname") { if (-e "${location}/${prefname}") { warn "### ${PROGNAME}: Checking installed Preference Pane...\n"; my $newbuild = `"/tmp/${prefname}/Contents/MacOS/GetSourceVersion"`; my $installedbuild = `"/${location}/${prefname}/Contents/MacOS/GetSourceVersion"`; if ($newbuild and $installedbuild and $newbuild > $installedbuild) { warn "### ${PROGNAME}: Installing updated Preference Pane...\n"; } else { warn "### ${PROGNAME}: Not installing my Preference Pane. The installed one is not older or has a different structure ($newbuild,$installedbuild).\n"; return; } } ipkgsystem( "/bin/mkdir -p \"${location}\""); ipkgsystem( "/usr/bin/tar -C \"${location}\" -jxvf \"${tarname}\" 1>&2"); ipkgsystem( "/usr/sbin/chown -R \"${uname}:${gname}\" \"${location}/${prefname}\"") == 0 or warn "### ${PROGNAME}: failed to run chown on prefpane. Bailing out...\n";; } else { warn "### ${PROGNAME}: Tmp install of pref pane failed. Bailing out...\n"; return; } } sub removedistributionlinks { my $DISTNAME = shift; # TODO: What if the default pointed to us? } sub removetexrest { # In case TeX is installed in a directory where there is already other # stuff, a rm -rf of II2INSTALLDIR would lead to data loss: print "### ${PROGNAME}: Removing remaining TeX stuff from your system. Please wait...\n"; ipkgsystem( "rmdir \"${II2INSTALLDIR}\" >/dev/null || ls \"${II2INSTALLDIR}\" 2>&1"); ipkgsystem( "rm -rf /var/tmp/texfonts >/dev/null 2>&1"); } sub removetexlocal { print "### ${PROGNAME}: Removing TeX Local Settings and additions. Please wait...\n"; ipkgsystem( "rm -rf \"${II2INSTALLDIR}\"/texmf.local >/dev/null 2>&1"); } sub removetexfoundation { &removetexfoundation(); &removegwtexfoundation(); } sub removetexfoundation { print "### ${PROGNAME}: Removing TeX Foundation. Please wait...\n"; ipkgsystem( "rm -rf \"${II2INSTALLDIR}\"/texmf.texlive >/dev/null 2>&1"); } sub removetexfoundationdocs { print "### ${PROGNAME}: Removing TeX Foundation docs. Please wait...\n"; ipkgsystem( "rm -rf \"${II2INSTALLDIR}\"/texmf.texlive/doc >/dev/null 2>&1"); ipkgsystem( "rmdir \"${II2INSTALLDIR}/texmf.texlive\" >/dev/null || ls \"${II2INSTALLDIR}/texmf.texlive\" 2>&1"); } sub removegwtexfoundation { print "### ${PROGNAME}: Removing gwTeX Foundation. Please wait...\n"; ipkgsystem( "rm -rf \"${II2INSTALLDIR}\"/texmf.gwtex >/dev/null 2>&1"); ipkgsystem( "rm -f \"${II2INSTALLDIR}\"/README.howtexfindsfiles >/dev/null 2>&1"); ipkgsystem( "rm -f \"${II2INSTALLDIR}\"/README.gwtex >/dev/null 2>&1"); } sub removetexprograms { &removetexprogramessentials() &removetexprogramextras() } sub removetexprogramessentials { print "### ${PROGNAME}: Removing TeX Program essentials. Please wait...\n"; ipkgsystem( "rm -rf \"${II2INSTALLDIR}/bin\" >/dev/null 2>&1"); ipkgsystem( "rm -rf \"${II2INSTALLDIR}/man\" >/dev/null 2>&1"); ipkgsystem( "rm -rf \"${II2INSTALLDIR}/texmf\" >/dev/null 2>&1"); ipkgsystem( "rm -rf \"${II2INSTALLDIR}/info\" >/dev/null 2>&1"); } sub removetexprogramextras { print "### ${PROGNAME}: Removing TeX Program developer extras. Please wait...\n"; ipkgsystem( "rm -rf \"${II2INSTALLDIR}/include\" >/dev/null 2>&1"); ipkgsystem( "rm -rf \"${II2INSTALLDIR}/lib\" >/dev/null 2>&1"); } sub setHomeTeXUse { my $hometexuse = shift; my $texmfcnf = "${II2INSTALLDIR}/texmf.cnf"; open( TEXMFCNF, "<${texmfcnf}") or die "### ${PROGNAME}: Cannot open $texmfcnf for reading}\n"; my @texmfcnfarray = ; close TEXMFCNF; open( TEXMFCNF, ">${texmfcnf}") or die "### ${PROGNAME}: Cannot open $texmfcnf for writing}\n"; foreach my $line (@texmfcnfarray) { if ($hometexuse) { $line =~ s/^\s*GWTEXVAR\s*=.*/GWTEXVAR=\$HOMETEXMF/; } else { $line =~ s/^\s*GWTEXVAR\s*=.*/GWTEXVAR=\$VARTEXMF/; } warn $line; print TEXMFCNF $line; } close TEXMFCNF; } sub setConfigUser { my $arch = `uname -p`; chomp $arch; if (-e "${II2INSTALLDIR}/bin/${arch}-apple-darwin-current/texconfig-sys") { if ($> == 0) { print "### ${PROGNAME}: System wide configuration, TL2005-style.\n"; ${configforuser} = 'root'; ${sudocmd} = "sudo -H -u ${configforuser}"; ${texconfigcmd} = "${sudocmd} texconfig-sys"; ${fmtutilcmd} = "${sudocmd} fmtutil-sys"; ${updmapcmd} = "${sudocmd} updmap-sys"; ${kpsewhichcmd} = "${sudocmd} kpsewhich"; } else { print "### ${PROGNAME}: Configuring system-wide for user $ENV{'II2USER'}, TL2005-style.\n"; ${configforuser} = $ENV{'II2USER'}; ${sudocmd} = ""; ${texconfigcmd} = "${sudocmd} texconfig-sys"; ${fmtutilcmd} = "${sudocmd} fmtutil-sys"; ${updmapcmd} = "${sudocmd} updmap-sys"; ${kpsewhichcmd} = "${sudocmd} kpsewhich"; } } else { if ($> == 0) { print "### ${PROGNAME}: System wide configuration, pre-TL2005-style.\n"; ${configforuser} = 'root'; ${sudocmd} = "sudo -H -u ${configforuser}"; ${texconfigcmd} = "${sudocmd} texconfig"; ${fmtutilcmd} = "${sudocmd} fmtutil"; ${updmapcmd} = "${sudocmd} updmap"; ${kpsewhichcmd} = "${sudocmd} kpsewhich"; } else { print "### ${PROGNAME}: Configuring system-wide for user $ENV{'II2USER'}, pre-TL2005-style.\n"; ${configforuser} = $ENV{'II2USER'}; ${sudocmd} = ""; ${texconfigcmd} = "${sudocmd} texconfig"; ${fmtutilcmd} = "${sudocmd} fmtutil"; ${updmapcmd} = "${sudocmd} updmap"; ${kpsewhichcmd} = "${sudocmd} kpsewhich"; } } } sub getFileType { # I am using opendir/readdir here to be able to test case-sensitively # By reading the dir I get the case preserved name and I do the check # myself. Possible results: # none = not found # caseless = found but with another case # exact my $fullpath = shift; my ($dir,$file) = $fullpath =~ m|(.*)/([^/]+)$|; if ($dir eq '') { $dir = '/'; } if ($file eq '') { return 'none'; } opendir( DIRHANDLE, $dir) || return 'none'; my @files = readdir( DIRHANDLE); closedir( DIRHANDLE); my $caseunsensitivematch = undef; my $casesensitivematch = undef; my $multiple = undef; foreach my $testfile (@files) { if ($testfile =~ /^${file}$/i) { $caseunsensitivematch = $testfile; if (defined $caseunsensitivematch) { # We have multiple case unsensitive matches, we are therefore # an a case sensitive filesystem $multiple = 1; } } if ($testfile =~ /^${file}$/) { $casesensitivematch = $testfile; } } if (defined( $casesensitivematch)) { return "exact"; } if (defined( $caseunsensitivematch)) { if ($mutiple) { return "multiple caseless"; } else { return "caseless"; } } return 'none'; } 1; # $Id$