#!/bin/sh # This needs to be run as root! ISO_URL=ftp://ftp.join.uni-muenster.de/pub/software/CTAN/systems/texlive/Images/texlive2007-inst-20070212.iso TMPDIR=`mktemp -d -p /tmp/` || exit 1 if [ $UID != 0 ] then echo "This needs to be run as root. Exiting..." exit 1 fi function cleanup { rm -fr "$TMPDIR" } function failure { cleanup exit 1 } trap cleanup EXIT SIGHUP SIGINT SIGTERM # Download and mount iso image echo "Downloading to ${TMPDIR}." mkdir "${TMPDIR}/mnt" || failure cd "${TMPDIR}" wget "$ISO_URL" "${TMPDIR}/texlive.iso" || failure mount -o loop -t iso9660 "${TMPDIR}/texlive.iso" "${TMPDIR}/mnt" || failure # Make packages echo "Building packages." cd "${TMPDIR}/mnt" tar cjspf "${TMPDIR}/texlive-2007-texmf.tar.bz2" texmf || failure tar cjspf "${TMPDIR}/texlive-2007-texmf-dist.tar.bz2" texmf-dist || failure mkdir "${TMPDIR}/texlive-2007" || failure cd "${TMPDIR}/texlive-2007" tar xpfj "${TMPDIR}/mnt/source/source.tar.bz2" || failure cd "${TMPDIR}" tar cjspf "${TMPDIR}/texlive-2007-src.tar.bz2" texlive-2007 || failure echo "Moving packages to /usr/portage/distfiles/." mv "${TMPDIR}/texlive-2007-*.tar.bz2" /usr/portage/distfiles/ umount "${TMPDIR}/mnt"