diff options
author | Karl Berry <karl@freefriends.org> | 2008-06-01 21:40:23 +0000 |
---|---|---|
committer | Karl Berry <karl@freefriends.org> | 2008-06-01 21:40:23 +0000 |
commit | cf4e0a0a5c6c0b5fe935b2460a14ab7f6577cc19 (patch) | |
tree | 0bf02af05f2dcd77cf43094acaef29156c276688 /Master | |
parent | 767708a9e27f368959bab0f62e00dc7140ad6fa2 (diff) |
new script to conveniently update TL binaries.
git-svn-id: svn://tug.org/texlive/trunk@8456 c570f23f-e606-0410-a88d-b1316a301751
Diffstat (limited to 'Master')
-rwxr-xr-x | Master/tlpkg/bin/tl-update-bindir | 203 |
1 files changed, 203 insertions, 0 deletions
diff --git a/Master/tlpkg/bin/tl-update-bindir b/Master/tlpkg/bin/tl-update-bindir new file mode 100755 index 00000000000..2f432168e6b --- /dev/null +++ b/Master/tlpkg/bin/tl-update-bindir @@ -0,0 +1,203 @@ +#!/bin/sh -e +# Update a TeX Live Master/bin/PLATFORM directory. + +vc_id='$Id$' +unset CDPATH +unset LS_COLORS + +tmpdir=${TMPDIR-/tmp}/tlupbin.$$ +trap "rm -rf $tmpdir" 0 1 2 15 + +usage="$0 [OPTION]... TL-PLATFORM... + +Update the TeX Live executables for each TL-PLATFORM (which must be a TL +platform name, e.g., i386-linux) from a build directory. + +The new binaries are taken from the location specified by --bin-loc, +either a directory (whose contents are copied), or a tar file (which is +unpacked and then copied). + +The output directory is computed relative to the location of this script +by default, or can be explicitly specified via --master. An upper-level +directory is specified so multiple platforms can be installed. + +This checks for broken symlinks, and symlinks with the svn:executable +property set (which would mess up Subversion; see the thread around +http://svn.haxx.se/users/archive-2007-03/1259.shtml.) + +It also takes care of doing the explicit remove/add sequence Subversion +requires when a symlink is replaced by a file or vice versa. + +Options: + --bin-loc DIR-OR-TAR use binaries from DIR-OR-TAR + --master DIR install binaries to DIR/bin/TL-PLATFORM + [default is the bin dir relative to this script] + + --help display this help and exit + --quiet, --silent no progress reports + --version output version information and exit + +For more information about building TeX Live, see +http://tug.org/texlive/build.html. + +Report bugs to tlbuild@tug.org." + +# parse options. +bin_loc= +msg=echo +tlnames= +while test $# -gt 0; do + case $1 in + --help|-help|-v) echo "$usage"; exit 0;; + --version|-version|-v) echo "$vc_id"; exit 0;; + --quiet|-quiet|-q|--silent|-silent|-s) msg=true;; + + --master) shift; Master=$1;; + --bin-loc) shift; bin_loc=$1;; + + --*) echo "$0: unrecognized option \`$1'; try --help if you need it." >&2 + exit 1;; + + *) tlnames="$tlnames $1";; + esac + shift +done + +if test -z "$tlnames"; then + echo "$0: missing TL platform name; try --help if you need it." >&2 + exit 1 +fi + +if test -z "$Master"; then + mydir=`dirname $0` + Master=`cd $mydir/../.. && pwd` +fi +if test ! -d "$Master/bin"; then + echo "$0: Master directory $Master has no bin/ subdir; goodbye." >&2 + exit 1 +fi + +# loop through tl platform names +for tlname in $tlnames; do + destdir=$Master/bin/$tlname + if test ! -d $destdir; then + echo "$0: unrecognized platform name \`$tlname'" >&2 + echo "$0: (no directory $destdir)" >&2 + exit 1 + fi + + # karl convenience + default_bin_loc= + if test x"$USER" = xkarl; then + case $tlname in + i386-linux) + default_bin_loc=/home/texlive/sarge/tmp/source/inst/bin/i686-pc-linux-gnu;; + esac + fi + + test -z "$bin_loc" && test -n "$default_bin_loc" \ + && bin_loc=$default_bin_loc + if test -z "$bin_loc"; then + echo "$0: missing binary location, try --help if you need it." >&2 + exit 1 + fi + + $msg "installing from $bin_loc to $destdir" + rm -rf $tmpdir + mkdir $tmpdir + + # if we were given a tar file, unpack it. + if test -f "$bin_loc"; then + srcdir=$tmpdir/unpacked + (cd $srcdir && tar xf $bin_loc) + + elif test -d "$bin_loc"; then + srcdir=$bin_loc # already have a directory + + else + echo "$0: strange non-file non-directory binary location $bin_loc" >&2 + exit 1 + fi + + # state of things. srcdir is full of the new binaries. + (cd $destdir && ls) >$tmpdir/now + (cd $srcdir && ls) >$tmpdir/new + + ourdel=$tmpdir/2del + ouradd=$tmpdir/2add + comm -23 $tmpdir/now $tmpdir/new >$ourdel # looking for deletions + comm -13 $tmpdir/now $tmpdir/new >$ouradd # looking for additions + + # get symlink list. + (cd $destdir && find -type l | sort) >$tmpdir/now.symlink + (cd $srcdir && find -type l | sort) >$tmpdir/new.symlink + + cd $destdir || exit 1 + + # svn requires separate delete/add operations when symlinks change to + # regular files or vice versa. + # + # remove symlinks which have become files. + comm -23 $tmpdir/now.symlink $tmpdir/new.symlink >$tmpdir/s.now + replaced_symlinks= + for sl in `cat $tmpdir/s.now`; do + test -f $srcdir/$sl && replaced_symlinks="$replaced_symlinks $sl" + done + test -n "$replaced_symlinks" \ + && $msg "removing symlinks which have become files..." \ + && svn rm $replaced_symlinks + # + # remove files which have become symlinks. + comm -13 $tmpdir/now.symlink $tmpdir/new.symlink >$tmpdir/s.new + replaced_files= + for sl in `cat $tmpdir/s.new`; do + test -f $destdir/$sl && replaced_files="$replaced_files $sl" + done + test -n "$replaced_files" \ + && $msg "removing files which have become symlinks..." \ + && svn rm $replaced_files + + # the bulk copy. + $msg "copying from $srcdir" + $msg "to $destdir" + (cd $srcdir && tar cf - *) | tar xf - + + # the normal deletions and additions. + $msg "removing old..." + test -s $ourdel && svn rm `cat $ourdel` + $msg "adding new..." + test -s $ouradd && svn add `cat $ouradd` + + # anything which is no longer a symlink but still exists + # needs to be added. + test -n "$replaced_symlinks" \ + && $msg "adding files that replaced symlinks..." \ + && svn add $replaced_symlinks + + # anything which is now a symlink but didn't used to be + # also needs to be added. + test -n "$replaced_files" \ + && $msg "adding symlinks that replaced files..." \ + && svn add $replaced_files + + # be sure the svn:executable property is not set on any symlink. + # there is also a pre-commit hook on the repo, but of course we don't + # want to unnecessarily trigger it. + badlinks=`svn propget svn:executable \`cat $tmpdir/new.symlink\` \ + | awk '{print $1}'` + if test -n "$badlinks"; then + $msg "removing svn:executable property from symlinks..." + svn propdel svn:executable $badlinks + fi + + # check for broken symlinks. + for sl in `cat $tmpdir/new.symlink`; do + test ! -r "$sl" && echo "$0: broken new symlink $sl" >&2 + done + + # final results. + $msg "final svn status..." + svn status + + rm -rf $tmpdir +done |