summaryrefslogtreecommitdiff
path: root/Master/install-pkg-compr.sh
blob: 30a4f6b34b2ae4fee388ca7becd8cea9e21608e3 (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
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
#!/bin/sh
# $Id$
# 
# install-pkg-compr.sh -- install individual packages from the compressed
# (inst) distribution into running installations.
#
# Copyright (c) Thomas Esser, Sebastian Rahtz 1996, 1997, 1998, 1999,
# 2002, 2003, 2004, 2005, 2006.
#
#    This program is free software; you can redistribute it and/or modify
#    it under the terms of the GNU General Public License as published by
#    the Free Software Foundation; either version 2 of the License, or
#    (at your option) any later version.
# 
#    This program is distributed in the hope that it will be useful,
#    but WITHOUT ANY WARRANTY; without even the implied warranty of
#    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
#    GNU General Public License for more details.
# 
#    You should have received a copy of the GNU General Public License
#    along with this program; if not, write to the Free Software
#    Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
#    02110-1301, USA.
#     
#    Send bug reports or suggestions to tex-live@tug.org.

# Call this script with a full-featured bourne shell, which may be
#   /bin/sh, /bin/bsh (e.g. AIX-4.XX), /bin/sh5 (e.g. ULTRIX) or
#   /bin/bash (on GNU systems) on your system.

HERE=`cd \`dirname $0\` && /bin/pwd`
. $HERE/utils.sh
. $HERE/common.sh

list_bundle()
{
    name=$1
    if test -f $CDDIR/archive/$name.zip; then
      echo $name >> LIST
      morecols=`grep "^-" $LISTS/$name | sed 's/.//'`
      packages=`grep "^+" $LISTS/$name | sed 's/.//'`
      grep "^[a-z]" $LISTS/$name >> tmp
    else
      echo "(missing archive $CDDIR/archive/$name.zip)"
    fi
    
    for i in $packages; do
      if echo "$i" | grep '^collection-' >/dev/null; then
        echo "(ignoring dependency on collection $i)"
        continue
      fi
      test -f $CDDIR/archive/$i.zip && list_bundle $i
    done

    # (see comments in install-pkg-compr.sh about the bin lists we check.)
    for binlist in bin-$name bin-$name.$System bin-${name}k.$System; do
      if test -f $LISTS/$binlist; then
        $verbose && echo "found binary $binlist"
        echo $binlist >> LIST
        grep "^[a-z]" $LISTS/$binlist >> tmp
      fi
    done

    for p in $morecols; do
      echo "(skipping dependency on collection $p)"
    done
}

list=false; src=true; doc=true; hash=true; config=false;verbose=false
unset col pkg cddir
: ${TEXMF=`kpsewhich -expand-var '$TEXMFMAIN'`}
: ${TEXMFSYSVAR=`kpsewhich -expand-var '$TEXMFSYSVAR'`}
TEXDIR=`echo $TEXMF | sed 's/texmf.*//'`

# Require it to exist.
if test ! -d $TEXDIR; then
  echo "$0: No directory $TEXDIR." >&2
  echo "$0: Set TEXMFMAIN to override, or make the directory." >&2
  echo "$0: (or use --archive to make a tar archive instead of installing.)">&2
  exit 1
fi

while test $# -gt 0; do
  case $1 in
    -p) if test $# -ge 2; then
          pkg=$2; shift
        else
          fatal "Missing argument for -p"
        fi;;
    --texdir=*)
	  TEXDIR=`echo $1 | sed 's/.*=//'`;;
    --collection=*)
          col=`echo $1 | sed -e 's/.*=//' -e 's/collection-//'`;;
    --package=*)
          pkg=`echo $1 | sed 's/.*=//'`;;
    --nodoc)
          doc=false;;
    --nosrc)
          src=false;;
    --nohash)
          hash=false;;
    --noconfig)
          config=false;;
    --config)
          config=true;;
    --listonly)
          list=true;;
    --verbose)
          verbose=true;;
    --cddir=*)
          cddir=`echo $1 | sed 's/.*=//'`;;
    --listdir=*)
          listdir=`echo $1 | sed 's/.*=//'`;;
     *) echo "$0: $1 is not a valid option, goodbye." >&2; exit 1;;
  esac
  shift
done

thisdir=`pwd`
CDDIR=${cddir-${OVERRIDE_CDDIR-$thisdir}}
LISTS=${listdir-${OVERRIDE_LISTS-$CDDIR/texmf/lists}}

work_dir=${TMP-/tmp}/tmpkginst.$$
trap 'cd /; rm -rf $work_dir; trap 0' 0 1 2 15
{ mkdir $work_dir && cd $work_dir; } || exit

test -d $CDDIR || fatal "$0: $CDDIR: no such directory. Are you sure this is the TeX Live CD?"

platform_guess
find_echo

cd $work_dir || exit 1
filters=" "
$src || filters="$filters texmf-dist/source\*"
$doc || filters="$filters texmf-dist/doc\*"

System=`echo $Sys | sed 's/_/-/g'`

if $verbose; then
  echo Package [$pkg] / Collection [$col] >&2
  echo Install point is $TEXDIR >&2
  echo Install binaries for system $System >&2
fi

if test -n "$col"; then
  colfile=$LISTS/collection-$col
  if test -f $colfile; then
    :>tmp
    list_bundle collection-$col
    eval grep '\^\!' tmp | tr ' ' '=' > jobs
    rm tmp
  else
    echo "$0: $col: no such collection (missing $colfile)." >&2
  fi
fi

if test -n "$pkg"; then
  pkgfile=$LISTS/$pkg
  if test -f $pkgfile; then
    :>tmp
    list_bundle $pkg 
    eval grep '\^\!' tmp | tr ' ' '=' > jobs
  else
    echo "$0: $pkg: no such package (missing $pkgfile)." >&2
    exit 1
   fi
fi

if $list; then
for f in `sort -u $work_dir/LIST`
  do
  if test -f $CDDIR/archive/$f.zip
  then
    $verbose && echo list $CDDIR/archive/$f.zip >&2
    unzip -l $CDDIR/archive/$f.zip
  fi
  done
  exit
fi
zipoption=" -qq "
$verbose && zipoption=""
test -z $pkg$col && exit
  $verbose && echo "unpack in $TEXDIR" >&2
  for f in `sort -u $work_dir/LIST`
  do
   if test -f $CDDIR/archive/$f.zip
   then
    $verbose && echo "  Install files from $f" >&2
    (cd $TEXDIR && unzip -o $zipoption $CDDIR/archive/$f -x $filters)
   fi
 done 
 $verbose && echo "* Done unpacking." >&2

if $config 
then 
  $verbose && echo "Files unpacked only. No configuration done"
  exit 0
fi

X=`kpsewhich language.dat`
if test -n "$X"; then
  cd `dirname $X`
  Z=`pwd`

  if $verbose; then
   echo Making language.dat in $Z >&2
   echo " from your language selections." >&2
  fi
  Y=`kpsewhich language.us`
  cd `dirname $Y`
  cat language.us language.*.dat > $Z/language.dat
fi

for f in `ls $work_dir/jobs`
do
  echo " do work items listed in $f" >&2
  for j in `sort $f | uniq`
  do
    command=`echo $j | sed 's/.\(.*\)=.*/\1/'`
    parameter=`echo $j | sed 's/.*=\(.*\)/\1/'`
    echo "   EXECUTE $command on $parameter" >&2
    case $command in
        addMap)
	    echo "Map $parameter" >> $TEXMFSYSVAR/web2c/updmap.cfg;;
        addMixedMap)
	    echo "MixedMap $parameter" >> $TEXMFSYSVAR/web2c/updmap.cfg;;
        addDvipsMap)
	    echo "p +$parameter" >> $TEXMFSYSVAR/dvips/config/config.ps;;
        addDvipdfmMap)
	    test -f $TEXMFSYSVAR/dvipdfm/config/config && echo "f $parameter" >> $TEXMFSYSVAR/dvipdfm/config/config;;
    esac
  done
done

: ${TEXMFDIST=`kpsewhich -expand-var '$TEXMFDIST'`}
$hash && mktexlsr $TEXMF $TEXMFDIST
updmap-sys --nohash --cnffile=$TEXMFSYSVAR/web2c/updmap.cfg \
           --dvipsoutputdir=$TEXMFSYSVAR/fonts/map/dvips/updmap \
           --dvipdfmoutputdir=$TEXMFSYSVAR/fonts/map/dvipdfm/updmap \
           --pdftexoutputdir=$TEXMFSYSVAR/fonts/map/pdftex/updmap
$config && texconfig-sys init
$config || echo "PLEASE RUN texconfig or texconfig-sys to make new formats."