summaryrefslogtreecommitdiff
path: root/Master/install-live.sh
blob: 27a303b617677991b4b06d5a0db39a8439a5094e (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
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
#!/bin/sh
# $Id$
# 
# install-live.sh -- install live packages.  This is install-tl.sh
# in the `demo' and `live' distributions.
# 
# Copyright (c) Thomas Esser, Sebastian Rahtz, 1996, 1997, 1998, 1999,
# 2000, 2001, 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.


# set this for debugging...
debug=${OVERRIDE_DEBUG-false}

unset CDPATH  # avoid unwanted output

while test $# -gt 0; do
  case $1 in
    --debug) debug=true;;
    --cddir=*)
          cddir=`echo $1 | sed 's/.*=//'`;;
     *) break;;
  esac
  shift
done

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

series_init()
{
  thisdir=`pwd`
  CDDIR=${cddir-${OVERRIDE_CDDIR-$thisdir}}
  LISTS=${OVERRIDE_LISTS-$CDDIR/texmf/lists}
  BIN=${OVERRIDE_LISTS-$CDDIR/bin}
  test -d $LISTS || fatal "$0: $LISTS: no such directory. Are you sure this is the TeX Live CD?"

  echo "Initializing collections... "
  setvars
  systems=`(cd $LISTS; ls bin-tex.* | sed  -e 's/bin-tex.//')`

  all_schemes=`(cd $LISTS; ls *.scheme | sed -e 's/-/_/g' -e 's/\.scheme//' | sort )`
  sc=24
  for s in $all_schemes; do
    S=`echo $s | sed -e 's/_/-/g' `
    sc=`expr $sc + 1`
    eval N=\"\$iden_${sc}\"
    eval SCHEMES_${N}=\"$s\"
    T=`grep '^\*Title' $LISTS/$S.scheme | sed -e 's/\*Title: //'`
    C=`grep '^\*Size'  $LISTS/$S.scheme | sed -e 's/\*Size: //'`
    C=`expr $C / 1000`
    eval schemes_${s}_n=\"$T\"
    eval schemes_${s}_ident=\"$N\"
    eval schemes_${s}_du=\"$C\"
  done

  all_lang_collections=`(cd $LISTS; ls collection-lang* | sed 's/-/_/g' | sort )`
  sc=0
  for s in $all_lang_collections; do
    S=`echo $s | sed 's/_/-/g'`
    sc=`expr $sc + 1`
    eval N=\"\$iden_${sc}\"
    eval LP_${N}=\"$s\"
    T=`grep '^\*Title' $LISTS/$S | sed -e 's/\*Title: //'`
    C=`grep '^\*Size'  $LISTS/$S | sed -e 's/\*Size: //'`
    C=`expr $C / 1000`
    eval p_${s}_n=\"$T\"
    eval p_${s}_ident=\"$N\"
    eval p_${s}_du=\"$C\"
    series_select_level $s 0
  done

  all_collections=`(cd $LISTS; ls collection* | grep -v collection-lang |  sed 's/-/_/g' | sort )`
  sc=0
  for s in $all_collections; do
    S=`echo $s | sed 's/_/-/g'`
    sc=`expr $sc + 1`
    eval N=\"\$iden_${sc}\"
    eval P_${N}=\"$s\"
    T=`grep '^\*Title' $LISTS/$S | sed -e 's/\*Title: //'`
    C=`grep '^\*Size'  $LISTS/$S | sed -e 's/\*Size: //'`
    C=`expr $C / 1000`
    eval p_${s}_n=\"$T\"
    eval p_${s}_ident=\"$N\"
    eval p_${s}_du=\"$C\"
    series_select_level $s 0
  done
  scheme_select scheme_full
  selected_scheme=scheme_full
  echo "Done initializing collections."
  all_collections_anz=`echo $all_lang_collections $all_collections | awk '{print NF}'`
  systems_init
}


# This is run when the user does "R" to run live.
# (Not available for the compressed image.)
# 
install_cd()
{
  TEXDIR=$CDDIR
  unset TEXMFCNF
  unset TEXMFMAIN
  TEXMFCNF_DIR=$TEXDIR/texmf/web2c
  echo "Preparing destination directories... " >&2
  test -d "$CDDIR" || fatal "$CDDIR does not seem to be the TeX Live CD-ROM."
  alldirs="$TEXMFSYSVAR"
  test -z "$TEXMFSYSVAR" || alldirs="$alldirs $TEXMFSYSVAR/fonts/pk $TEXMFSYSVAR/fonts/tfm $TEXMFSYSVAR/web2c $TEXMFSYSVAR/pdftex/config $TEXMFSYSVAR/tex/generic/config $TEXMFSYSVAR/web2c $TEXMFSYSVAR/xdvi  $TEXMFSYSVAR/dvips/config  $TEXMFSYSVAR/etex/plain/config"
  for dir in $alldirs; do
    while test ! -d $dir || test ! -w $dir; do
      mkdirhier $dir
      test -d $dir || { warn "could not make directory '$dir'"; continue; }
      test -w $dir || { warn "cannot write to directory '$dir'"; continue; }
    done
  done
  test -z "$TEXMFSYSVAR" || chmod -R a+w $TEXMFSYSVAR ||
     warn "command 'chmod -R a+w $TEXMFSYSVAR' failed"
  test -z "$opt_varfonts_dir" ||
    chmod 1777 $opt_varfonts_dir/pk $opt_varfonts_dir/tfm ||
    warn "command 'chmod 1777 $opt_varfonts_dir/pk $opt_varfonts_dir/tfm' failed"
  pd=$this_platform_fn
  have_system=false
  if test -x $TEXDIR/bin/$pd/mktexlsr; then
    have_system=true
    bindir=$TEXDIR/bin/$pd
    PATH=$TEXDIR/bin/$pd:$PATH
    export PATH TEXMFSYSVAR
    echo Current system detected as $pd.
  fi
 make_var_skeleton
 cp $TEXDIR/texmf/tex/generic/config/language.dat $TEXMFSYSVAR/tex/generic/config/language.dat
 test -f $TEXDIR/texmf-dist/tex/plain/config/language.def && cp $TEXDIR/texmf-dist/tex/plain/config/language.def $TEXMFSYSVAR/tex/plain/config
 test -f $TEXDIR/texmf/xdvi/XDvi && cp $TEXDIR/texmf/xdvi/XDvi $TEXMFSYSVAR/xdvi
 cp $CDDIR/texmf/dvips/config/config.ps  $TEXMFSYSVAR/dvips/config/config.ps
 cp $CDDIR/texmf/dvipdfm/config/config $TEXMFSYSVAR/dvipdfm/config
 cp $TEXDIR/texmf/web2c/mktex.cnf $TEXMFSYSVAR/web2c
 cp $TEXDIR/texmf/web2c/updmap.cfg $TEXMFSYSVAR/web2c
 cp $CDDIR/texmf-dist/tex/context/config/cont-usr.tex $TEXMFSYSVAR/tex/context/config/cont-usr.tex
 cp $CDDIR/texmf/tex/generic/config/pdftexconfig.tex $TEXMFSYSVAR/tex/generic/config/pdftexconfig.tex
test -z "$TEXMFSYSVAR" || chmod -R a+w $TEXMFSYSVAR ||
     warn "command 'chmod -R a+w $TEXMFSYSVAR' failed"
 TEXMFCNF__fix_fmtutil
 make_local_skeleton
 $bindir/updmap --nohash --quiet --cnffile $TEXMFSYSVAR/web2c/updmap.cfg --dvipsoutputdir=$TEXMFSYSVAR/fonts/map/dvips/updmap --dvipdfmoutputdir=$TEXMFSYSVAR/fonts/map/dvipdfm/updmap --pdftexoutputdir=$TEXMFSYSVAR/fonts/map/pdftex/updmap
 $have_system && $bindir/mktexlsr
cat <<ENDC
    For future configuration, edit files in $TEXMFSYSVAR

    You should now add these setup statements to your environment,
    depending on what shell is running,
    
    For csh (~/.cshrc):
     setenv TEXMFSYSVAR $TEXMFSYSVAR
     setenv PATH $TEXDIR/bin/$pd:\$PATH

    For bash (~/.bash_profile) or sh (~/.profile):
     TEXMFSYSVAR=$TEXMFSYSVAR
     PATH=$TEXDIR/bin/$pd:\$PATH
     export PATH TEXMFSYSVAR
ENDC
  greetings
  exit
}

list_system_files()
{
  arg=$1
  :>$work_dir/$arg.list
  for i in $all_collections
  do
    I=`echo $i | sed 's/_/-/g'`
    grep "^[A-Za-z0-9]" $LISTS/$I.$arg >>  $work_dir/$arg.list
  done
  for i in $all_lang_collections
  do
    I=`echo $i | sed 's/_/-/g'`
    grep "^[A-Za-z0-9]" $LISTS/$I.$arg >>  $work_dir/$arg.list
  done
}


list_files()
{
  :>$work_dir/tmp.jobs
  :>$work_dir/tmp
  col=`echo $1 | sed 's/_/-/g'`
  $debug && echo "         [ -> collection $col]" >&2
  packages=
  morecols=
  filters="| grep -v '^ *$'  "
  if test "$opt_source" = X; then
     filters="$filters | grep -v texmf-dist/source/"
  fi
  if test "$opt_doc" = X; then
     filters="$filters | grep -v texmf-dist/doc/"
  fi
  if test -f $LISTS/$col; then
    packages=`grep "^+" $LISTS/$col | sed 's/.//'`
    morecols=`grep "^-" $LISTS/$col | sed 's/.//'`
    grep "^[a-z]" $LISTS/$col >> $work_dir/tmp
    grep '^\!' $LISTS/$col >> $work_dir/tmp.jobs
    for i in $all_systems
    do
      eval \$p_${i}_s || continue
      eval this=\$p_${i}_fn
      if test -f $LISTS/$col.$this; then
        $debug && echo "      debug:system package $col.$this"  >&2
        grep "^[\!a-z]" $LISTS/$col.$this >> $work_dir/tmp
      fi
    done
    for i in $packages
    do
      list_package $i $col
    done

    eval sort -u < $work_dir/tmp $filters >> $work_dir/$col.list
    eval sort -u < $work_dir/tmp.jobs | tr ' ' '=' >> $work_dir/$col.jobs
  fi
  rm $work_dir/tmp $work_dir/tmp.jobs
  for p in $morecols
  do
      list_files $p
  done

}

list_package()
{
  :>$work_dir/ptmp.jobs
  :>$work_dir/ptmp
  pack=`echo $1 | sed 's/_/-/g'`
  # if no lists file, return.  Many packages exist only on win32, e.g.,
  # lib-geturl, and so we won't have lists for them when not installing
  # that arch.
  test -s $LISTS/$pack || return
  col=$2
  filters="| grep -v '^ *$'  "
  if test "$opt_source" = X; then
     filters="$filters | grep -v texmf-dist/source/"
  fi
  if test "$opt_doc" = X; then
     filters="$filters | grep -v texmf-dist/doc/"
  fi
  $debug && echo "      debug:package $pack"  >&2
      grep "^[A-Za-z0-9]" $LISTS/$pack >> $work_dir/ptmp
      grep '^\!' $LISTS/$pack >> $work_dir/ptmp.jobs
      for j in $all_systems
      do
      eval \$p_${j}_s || continue
        eval this=\$p_${j}_fn
        if test -f $LISTS/$pack.$this; then
          $debug && echo "        debug:list_package:system package $pack.$this"  >&2
         grep "^[A-Za-z0-9]" $LISTS/$pack.$this >> $work_dir/ptmp
        fi
      done

    eval sort -u < $work_dir/ptmp $filters  >> $work_dir/$col.list
    eval sort -u < $work_dir/ptmp.jobs  | tr ' ' '=' >> $work_dir/$col.jobs
  rm $work_dir/ptmp $work_dir/ptmp.jobs
  for i in `grep "^+" $LISTS/$pack | sed 's/.//'`
  do
    list_package $i $col
  done
}

# This is run when the user does "I" for a normal disk install.
# 
install_now()
{
   list_file_func=list_files
   list_package_func=list_package
  common_start_install

  echo >&2
  echo "Now copying selected files" >&2
  $debug && echo " from the lists in $work_dir... " >&2

  if $debug; then
    tarverbose=v
  else
    tarverbose=
  fi

  for f in `ls $work_dir/*.*list`; do
   $debug && echo "Copy files listed in $f" >&2
   $debug || $echon "`basename $f .list` " >&2
   test -s $f || continue  # do not tar if empty
   
   sort -u $f >$f.uniq
   if test "x$TAROPT" = "x"; then
     (cd $CDDIR && $XARGS sh -c 'tar cf - $* \
        | (cd '"$TEXDIR && umask 0 && $TARPROG x${tarverbose}f -)" sh <$f.uniq)
   else
     (cd $CDDIR && $TARPROG -c -f - $TAROPT $f.uniq) \
        | (cd $TEXDIR && umask 0 && $TARPROG -x $tarverbose -f -)
   fi
  done 
  echo
  echo "Done copying." >&2

  test -f $TEXDIR/texmf-dist/tex/plain/config/language.def && cp $TEXDIR/texmf-dist/tex/plain/config/language.def $TEXMFSYSVAR/tex/plain/config
  test -f $TEXDIR/texmf/xdvi/XDvi && cp $TEXDIR/texmf/xdvi/XDvi $TEXMFSYSVAR/xdvi
  cp $TEXDIR/texmf/dvips/config/config.ps  $TEXMFSYSVAR/dvips/config/config.ps
  cp $TEXDIR/texmf/dvipdfm/config/config $TEXMFSYSVAR/dvipdfm/config
  cp $TEXDIR/texmf/web2c/mktex.cnf $TEXMFSYSVAR/web2c
  cp $CDDIR/texmf-dist/tex/context/config/cont-usr.tex $TEXMFSYSVAR/tex/context/config/cont-usr.tex
  cp $CDDIR/texmf/tex/generic/config/pdftexconfig.tex $TEXMFSYSVAR/tex/generic/config/pdftexconfig.tex

  common_end_install
}

################################################################
# main()
################################################################
unset TEXCONFIG
cd `dirname $0`
init
menu_main