summaryrefslogtreecommitdiff
path: root/Master/tlpkg/bin/tl-makeself-from-tlnet
blob: 6e1c068513f0d076ca4ecef0923c788f78ea4cff (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
#!/bin/sh -e
# $Id$
# Copyright 2008 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 and bin-texlive
# packages on Unix, similar to the .exe we create for Windows.  Both are
# created in the nightly cron from tl-update-tlcritical.

TMP=`mktemp -d`
CWD=`pwd`

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

cd $TMP
mkdir master
cd master

# unpack texlive.infra and bin-texlive archives for all platforms,
# except w32.
for pkg in texlive.infra bin-texlive; do
  for i in $ARCHIVE/$pkg*.tar.lzma ; do
    case "$i" in 
      *win32*) ;;
      *) lzmadec <$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 <<'END_RUNME'
#!/bin/sh
# Updater for tlmgr and infrastructure on Unix.
# Runs in unpacked archive directory.

ROOT=`kpsewhich --var-value=SELFAUTOPARENT`
if test -r "$ROOT/tlpkg/texlive.tlpdb"; then
  echo "$0: updating in $ROOT..."
  
  # move the architecture-specific files to the top level.
  mv ./master/bin .
  mv ./master/tlpkg/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/lzma
  mkdir -p $t_instdir/wget

  # start the list of tlpobjs we will install
  tlpobjs="$t_objdir/bin-texlive.tlpobj $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/bin-texlive.$b.tlpobj"
    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/lzma/lzmadec.$b $t_instdir/lzma/
    cp installer/lzma/lzma.$b $t_instdir/lzma/
    test -r installer/wget/wget.$b \
    && cp installer/wget/wget.$b $t_instdir/wget
  done
else
  cat <<END_ABORT_NODIR >&2
$0: Cannot find TeX Live root using kpsewhich --var-value=SELFAUTOPARENT.
$0: Please call update-tlmgr-latest.sh --noexec --keep
$0: and then call the runme.sh script in the unpacked directory
$0: with the directory root as the first argument, something like:
$0: sh runme.sh /path/to/your/texlive/installation/2008
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=`svnversion $mydir | sed s/[^0-9].*//`  # just the number, no status
makeself $TMP update-tlmgr-r$rev.sh "TeX Live Manager Updater" ./runme.sh
rm -rf $TMP

# vim:set tabstop=2 expandtab: #