#!/bin/sh -e # $Id$ # Copyright 2008-2014 Norbert Preining # This file is licensed under the GNU General Public License version 2 # or any later version. # # Creates a .run file for updating the texlive.infra # packages on Unix, similar to the .exe we create for Windows. Both are # created in the nightly cron from tl-update-tlcritical. TLNET=$1 if test ! -d "$TLNET"; then echo "$0: No tlnet directory given as argument, aborting." >&2 exit 1 fi ARCHIVE=$TLNET/archive if test ! -d "$ARCHIVE"; then echo "$0: subdirectory archive/ in $TLNET not found, aborting." >&2 exit 1 fi # extract some version values from the tlnet tlpdb. NETRELEASE=`sed -n 's!^depend release/!!p' $TLNET/tlpkg/texlive.tlpdb` MINRELEASE=`sed -n 's!^depend minrelease/!!p' $TLNET/tlpkg/texlive.tlpdb` CWD=`pwd` # save original dir TMP=`mktemp -d` cd $TMP mkdir master cd master maxrev=0 # unpack texlive.infra archives for all platforms, except w32. for pkg in texlive.infra; do pkgrev=`tlpkginfo --revision $pkg $TLNET` if [ $pkgrev -gt $maxrev ] ; then maxrev=$pkgrev fi for i in $ARCHIVE/$pkg*.tar.xz; do case "$i" in *win32*) ;; *) xzdec <$i | tar -xf - ;; esac done done cd .. # create the script which will be run on the user's machine to do the update. # cat >runme.sh <>runme.sh <<'END_RUNME' # see if we can determine where the TL to be upgraded lives. # need tlpdb and a tlpobj dir (i.e., not the svn Master tree) at least. ROOT=`kpsewhich --var-value=SELFAUTOPARENT` if test -r "$ROOT/tlpkg/texlive.tlpdb" && test -d "$ROOT/tlpkg/tlpobj/"; then echo "$0: updating in $ROOT..." tlmgrversion=`tlmgr version | grep '^TeX Live.*version' | awk '{print $NF}'` echo "$0: tlmgr version says this is TeX Live $tlmgrversion" if test "x$1" = "x--upgrade"; then if test "x$NETRELEASE" = "x$tlmgrversion"; then echo "$0: have TL $tlmgrversion, new version also $NETRELEASE;">&2 echo "$0: using --upgrade doesn't make sense; terminating." >&2 exit 1 elif test "$tlmgrversion" -lt "$MINRELEASE"; then echo "$0: upgrading from $tlmgrversion not supported;" >&2 echo "$0: can only upgrade from $MINRELEASE to $NETRELEASE." >&2 echo "$0: terminating." >&2 exit 1 else echo "$0: ok, doing full release upgrade " \ "from $tlmgrversion to $NETRELEASE." fi else echo "$0: proceeding with tlmgr update." fi # move the architecture-specific files to the top level. mv ./master/bin . mkdir ./installer mv ./master/tlpkg/installer/xz ./installer mv ./master/tlpkg/installer/wget ./installer # install the architecture-independent files. (cd master && tar cf - *) | (cd $ROOT && tar xf -) # try to get the list of installed architectures by listing the # directories in $ROOT/bin. t_objdir=$ROOT/tlpkg/tlpobj # target tlpobj directory t_instdir=$ROOT/tlpkg/installer # target installer dir # ensure these target directories exist. mkdir -p $t_instdir/xz mkdir -p $t_instdir/wget # start the list of tlpobjs we will install tlpobjs="$t_objdir/texlive.infra.tlpobj" for a in $ROOT/bin/*; do test -d "$a" || continue # skip any cruft files b=`basename $a` # just the architecture name # add the tlpobjs for this platform t the list. tlpobjs="$tlpobjs $t_objdir/texlive.infra.$b.tlpobj" # install the bin dir for this platform. (cd bin && tar cf - $b) | (cd $ROOT/bin && tar xf -) # copy the installer binaries. cp installer/xz/xzdec.$b $t_instdir/xz/ cp installer/xz/xz.$b $t_instdir/xz/ test -r installer/wget/wget.$b \ && cp installer/wget/wget.$b $t_instdir/wget done else cat <&2 $0: Cannot find TeX Live root using kpsewhich --var-value=SELFAUTOPARENT. $0: Please set your PATH as needed, otherwise it's hopeless. END_ABORT_NODIR exit 1 fi # invoke secret tlmgr action with the tlpobjs we found. # Hopefully the result will be a clean tlpdb state. tlmgr -v _include_tlpobj $tlpobjs echo "$0: done." END_RUNME chmod ugo+x runme.sh # make the self-extracting archive back in the directory from where we # were invoked. cd $CWD mydir=`cd \`dirname $0\` && pwd` # Master/tlpkg/bin rev=$maxrev makeself $TMP update-tlmgr-r$rev.sh "TeX Live Manager Updater" ./runme.sh rm -rf $TMP # vim:set tabstop=2 expandtab: #