summaryrefslogtreecommitdiff
path: root/Master/tlpkg/bin/tl-makeself-from-tlnet
diff options
context:
space:
mode:
Diffstat (limited to 'Master/tlpkg/bin/tl-makeself-from-tlnet')
-rwxr-xr-xMaster/tlpkg/bin/tl-makeself-from-tlnet167
1 files changed, 108 insertions, 59 deletions
diff --git a/Master/tlpkg/bin/tl-makeself-from-tlnet b/Master/tlpkg/bin/tl-makeself-from-tlnet
index f3bc140466a..5fa0b9c34f5 100755
--- a/Master/tlpkg/bin/tl-makeself-from-tlnet
+++ b/Master/tlpkg/bin/tl-makeself-from-tlnet
@@ -1,12 +1,21 @@
#!/bin/sh -e
# $Id$
-# Copyright 2008-2014 Norbert Preining
+# Copyright 2008-2017 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.
+# Creates an executable script update-tlmgr-r*.sh (in the current
+# directory) for updating the texlive.infra package and its per-platform
+# subpackages on Unix, similar to the .exe we create for Windows. (Both
+# are created in the nightly cron from tl-update-tlcritical.) We use
+# the makeself utility to create the executable.
+#
+# The resulting update-tlmgr-*.sh is run (by the user) in the TL
+# installation directory to be updated; it uses kpsewhich from PATH to
+# determine what to do update.
+
+mydir=`cd \`dirname "$0"\` && pwd` # Master/tlpkg/bin
+PATH=$mydir:$PATH # for tlpkginfo
TLNET=$1
if test ! -d "$TLNET"; then
@@ -21,55 +30,73 @@ if test ! -d "$ARCHIVE"; then
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`
+NETRELEASE=`sed -n 's!^depend release/!!p' "$TLNET/tlpkg/texlive.tlpdb"`
+MINRELEASE=`sed -n 's!^depend minrelease/!!p' "$TLNET/tlpkg/texlive.tlpdb"`
+if test -z "$NETRELEASE" || test -z "$MINRELEASE"; then
+ echo "$0: could not find release or minrease from $TLNET/tlpkg/texlive.tlpdb"\
+ >&2; exit 1
+fi
-CWD=`pwd` # save original dir
-TMP=`mktemp -d`
-cd $TMP
+CWD=`pwd` # save original dir
+TMP=`mktemp -d` # work in new temp dir
+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
+# this gives us the tlpobj files along with the actual content files.
+infrapkg=texlive.infra
+#
+# determine revision of infrastructure while we're here,
+# for naming the archive later.
+infrarev=`tlpkginfo --revision $infrapkg "$TLNET"`
+if test -z "$infrarev"; then
+ echo "$0: tlpkginfo --revision $infrapkg $TLNET failed, goodbye." >&2
+ exit 1
+fi
+#
+# don't think quotes are needed here, except for possible sh bugs?
+for i in "$ARCHIVE"/$infrapkg*.tar.xz; do
+ case "$i" in
+ *win32*) ;;
+ *) xzdec <"$i" | tar -xf - || exit 1;;
+ esac
done
-cd ..
+cd .. # back to the (temp) dir where we building things up
+#
# create the script which will be run on the user's machine to do the update.
-#
+#
cat >runme.sh <<END_RUNME
#!/bin/sh
-# Updater for tlmgr and infrastructure on Unix.
+# \$Id$
+# Updater for tlmgr and TL infrastructure on Unix. Public domain.
# Runs in unpacked archive directory.
+# Created by `basename $0` at `date`.
NETRELEASE=$NETRELEASE
MINRELEASE=$MINRELEASE
-
+infrapkg=$infrapkg
END_RUNME
-# append to runme literally now.
+# append to runme literally now -- no more variable expansions.
cat >>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.
+# We are depending on the user's PATH to find kpsewhich, tlmgr, etc.
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}'`
+ if test -z "$tlmgrversion"; then
+ echo "$0: tlmgr version did not include version, goodbye." >&2
+ tlmgr version >&2
+ exit 1
+ fi
+ #
echo "$0: tlmgr version says this is TeX Live $tlmgrversion"
if test "x$1" = "x--upgrade"; then
if test "x$NETRELEASE" = "x$tlmgrversion"; then
@@ -94,37 +121,45 @@ if test -r "$ROOT/tlpkg/texlive.tlpdb" && test -d "$ROOT/tlpkg/tlpobj/"; then
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
+ (cd master && tar cf - *) | (cd "$ROOT" && tar xf -) || exit 1
+
t_instdir=$ROOT/tlpkg/installer # target installer dir
-
+ t_xzdir=$t_instdir/xz
+ t_wgetdir=$t_instdir/wget
+ #
# 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
+ mkdir -p "$t_xzdir" "$t_wgetdir"
+
+ # Start the list of tlpobjs we will install with the
+ # platform-independent part of the infrastructure package.
+ #
+ # We use the tlpobjs from our own dir here, using relative names,
+ # since we constructed this directory tree and thus know there are no
+ # spaces in the names. That is not true for $ROOT. (The files are the
+ # same since we just updated $ROOT with the untar above.)
+ src_tlpobj=master/tlpkg/tlpobj
+ tlpobjs=$src_tlpobj/$infrapkg.tlpobj
+
+ # for each platform directory of binaries
+ 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"
+ b=`basename "$a"` # just the architecture name
+
+ # add the tlpobjs for this platform to the list.
+ tlpobjs="$tlpobjs $src_tlpobj/$infrapkg.$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/
+ (cd bin && tar cf - "$b") | (cd "$ROOT/bin" && tar xf -) || exit 1
+
+ # copy the installer binaries; not everything provides wget.
+ cp installer/xz/xzdec."$b" "$t_xzdir/" || exit 1
+ cp installer/xz/xz."$b" "$t_xzdir/" || exit 1
test -r installer/wget/wget.$b \
- && cp installer/wget/wget.$b $t_instdir/wget
+ && { cp installer/wget/wget.$b "$t_wgetdir/" || exit 1; }
done
+
else
cat <<END_ABORT_NODIR >&2
$0: Cannot find TeX Live root using kpsewhich --var-value=SELFAUTOPARENT.
@@ -133,20 +168,34 @@ END_ABORT_NODIR
exit 1
fi
-# invoke secret tlmgr action with the tlpobjs we found.
+# Invoke special tlmgr action with the tlpobjs we found.
# Hopefully the result will be a clean tlpdb state.
-tlmgr -v _include_tlpobj $tlpobjs
+# We are running the new tlmgr, from our own archive, here,
+# due to the untar above.
+tlmgr_path=`which tlmgr 2>/dev/null` # provide complete path if we can
+test -z "$tlmgr_path" && tlmgr_path=tlmgr # but no biggie if we can't
+echo "$0: $tlmgr_path including objects: $tlpobjs"
+#debug: (pwd; ls -l $tlpobjs; ls -lR) >/tmp/ls
+#debug: -vv here gives more info. (Also -vx on the #! line above.)
+if tlmgr -v _include_tlpobj $tlpobjs; then :; else
+ echo "$0: $tlmgr_path failed, goodbye." >&2
+ exit 1
+fi
echo "$0: done."
END_RUNME
+#
+#debug: cp -f runme.sh /tmp
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
+# make the self-extracting archive back in the directory from which
+# we were invoked.
+cd "$CWD"
+makeself -q $TMP \
+ update-tlmgr-r$infrarev.sh \
+ "TeX Live Manager Updater" \
+ ./runme.sh
+
rm -rf $TMP
# vim:set tabstop=2 expandtab: #