#!/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 tar.gz files." cp "${TMPDIR}/mnt/source/source.tar.gz" "/usr/portage/distfiles/texlive-2007-src.tar.gz" || failure tar czspf "${TMPDIR}/texlive-2007-texmf.tar.gz" "${TMPDIR}/mnt/texmf" || failure tar czspf "${TMPDIR}/texlive-2007-texmf-dist.tar.gz" "${TMPDIR}/mnt/texmf-dist" || failure echo "Moving packages to /usr/portage/distfiles/." mv "${TMPDIR}/texlive-2007-*.tar.gz" /usr/portage/distfiles/