#!/usr/bin/perl $II2BUILDSTAMP = $ENV{"II2BUILDSTAMP"}; $II2PKGDIR = $ENV{"II2PKGDIR"}; $II2INSTALLDIR = $ENV{"II2INSTALLDIR"}; $II2RESOURCES = $ENV{"II2RESOURCES"}; $II2DOSERVER = $ENV{"II2DOSERVER"}; if (${II2BUILDSTAMP} < 1167840304) { warn "### You need at least i-Installer 2.87 for this package. Bailing out...\n"; exit 1; } $PROGNAME = `"${II2RESOURCES}/basename" "$0"`; chomp( $PROGNAME); my $arch = `uname -p`; chomp $arch; print "### ${PROGNAME}: Started...\n"; # Add our installed TeX to the beginning of the PATH so it will always # be found first. It would be better to add it to the end and check # with which that we have the right one. Too much work for now. $ENV{"PATH"} = "${II2INSTALLDIR}/bin/${arch}-apple-darwin-current:$ENV{'PATH'}"; # Load shared stuff if (not -e "${II2PKGDIR}/tex.sharedscript.pm") { my $msg = "A part of the package is missing. This might be a known bug in i-Installer 2.69 or older. Please reset your package to its default properties before trying again. You can do that with the Reset to default properties menu item in the i-Package menu.\n\nIf the problem remains, the problem is a network problem, not an i-Installer bug.\n\nThis action will now fail deliberately."; warn "### ${PROGNAME}: ${msg}"; `"${II2RESOURCES}/doalerter" -s "${II2DOSERVER}" -V -t Alert -T "Missing part/known bug" -I "${msg}" -1 "Accept"`; exit 1; } require "${II2PKGDIR}/tex.sharedscript.pm"; if (${II2INSTALLDIR} eq "") { ipkgwarn( "Your environment is damaged, your Mac OS X installation or your user account is probably damaged. Try running a disk repair program or install from another user's account. Bailing out...\n"); exit( 1); } if (not -d "${II2INSTALLDIR}") { print "### ${PROGNAME}: No TeX directory found.\n"; print "### ${PROGNAME}: I cannot remove a nonexistent TeX. Bailing out gracefully...\n"; `"${II2RESOURCES}/doalerter" -s "${II2DOSERVER}" -V -t Alert -T "TeX Unavailable" -I "It seems there is no TeX in this location so I will not proceed to remove." -1 "OK"`; exit( 0); } if (not -w "${II2INSTALLDIR}") { warn "### ${PROGNAME}: The install location is not writable. Removal cannot proceed. Bailing out...\n"; exit( 1); } if (not &checkinstallocation()) { die "### ${PROGNAME}: Bailing out on nonstandard location \"${II2INSTALLDIR}\"\n" } if (-d "${II2INSTALLDIR}/share/texmf.macosx") { warn "### ${PROGNAME}: This TeX still has the old directory structure\n"; $oldstyle = 1; $choices = "-TeX|-Local Settings"; } else { $oldstyle = 0; $choices = "-TeX Programs|-TeX Foundation|-Local Settings|-CLI Activation"; } $doresult = `"${II2RESOURCES}/doalerter" -s "${II2DOSERVER}" -V -t Select -C "$choices" -T "Select Parts?" -I "Select which part of TeX you want to remove." -1 "Select" -2 "Everything" -3 "Cancel"`; chomp( $doresult); if (($? >> 8) == 0) { @removeset = split( /\|/, $doresult); if ($oldstyle) { if ($removeset[0] =~ /^\+/) { $removeprograms = 1; $removefoundation = 1; } if ($removeset[1] =~ /^\+/) { $removelocal = 1; } } else { if ($removeset[0] =~ /^\+/) { $removeprograms = 1; } if ($removeset[1] =~ /^\+/) { $removefoundation = 1; } if ($removeset[2] =~ /^\+/) { $removelocal = 1; } if ($removeset[3] =~ /^\+/) { $removeclisetting = 1; } } } elsif (($? >> 8) == 1) { print "### ${PROGNAME}: Not removing TeX.\n"; $removeprograms = 0; $removefoundation = 0; $removelocal = 0; $removeclisetting = 0; } elsif (($? >> 8) == 2) { $removeprograms = 1; $removefoundation = 1; $removelocal = 1; $removeclisetting = 1; } if ($removeclisetting) { if (ipkgsystem( "\"${II2PKGDIR}/\"settexpath \"${II2INSTALLDIR}\" remove") == 0) { print "### ${PROGNAME}: sucessfully removed the CLI path settings.\n"; } else { warn "### ${PROGNAME}: failed to remove the CLI path settings.\n"; } } if ($removelocal) { &removetexlocal(); `"${II2RESOURCES}/doalerter" -s "${II2DOSERVER}" -V -t UnsetInstalledSelectorSets -P "tex4ht|xmljadetex"`; } `"${II2RESOURCES}/doalerter" -s "${II2DOSERVER}" -V -t IncrementProgress -p 10000`; if (not -d "${II2INSTALLDIR}/share/texmf.local") { # Has been removed now or earlier $nolocal = 1; } if ($removeprograms) { &removetexprograms(); `"${II2RESOURCES}/doalerter" -s "${II2DOSERVER}" -V -t UnsetInstalledSelectorSets -P "tl2003-bin-powerpc|tl2004-bin-powerpc|tl2005-bin-powerpc|tl2005-bin-i386|tl2003-lib-powerpc|tl2004-lib-powerpc|tl2005-lib-universal"`; } `"${II2RESOURCES}/doalerter" -s "${II2DOSERVER}" -V -t IncrementProgress -p 30000`; if (not -d "${II2INSTALLDIR}/bin") { # Has been removed now or earlier $noprograms = 1; } if ($removefoundation) { &removetexfoundation(); `"${II2RESOURCES}/doalerter" -s "${II2DOSERVER}" -V -t UnsetInstalledSelectorSets -P "tetex2-texmfe|tetex3-texmfe|gwtex23|tetex2-texmfdoc|tetex3-texmfdoc"`; } `"${II2RESOURCES}/doalerter" -s "${II2DOSERVER}" -V -t IncrementProgress -p 50000`; if (not -d "${II2INSTALLDIR}/share/texmf.tetex") { # Has been removed now or earlier $nofoundation = 1; } if ($removefoundation and $removeprograms and $removelocal) { print "### ${PROGNAME}: All main TeX parts have been removed. Removing miscellaneous other parts. Please wait...\n"; $removerest = 1; } elsif ($nofoundation and $noprograms and $nolocal) { print "### ${PROGNAME}: No main TeX parts found. Removing any miscellaneous other parts. Please wait...\n"; $removerest = 1; } if ($removerest) { &removetexrest(); } `"${II2RESOURCES}/doalerter" -s "${II2DOSERVER}" -V -t IncrementProgress -p 10000`; warn "### ${PROGNAME}: Finished.\n"; print "### ${PROGNAME}: Finished.\n"; exit( 0); # $Id: tex.remove 86 2006-10-28 13:52:23Z gctwnl $