summaryrefslogtreecommitdiff
path: root/Master/bin/powerpc-aix/getnonfreefonts
blob: 21dd7a0fff875dc32ba54277af29360170b45085 (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
#!/bin/sh

## getnonfreefonts
## Copyright 2005 Reinhard Kotucha <reinhard.kotucha@web.de>
#
# This work may be distributed and/or modified under the
# conditions of the LaTeX Project Public License, either version 1.3
# of this license or (at your option) any later version.
# The latest version of this license is in
#   http://www.latex-project.org/lppl.txt
# 
# The current maintainer is Reinhard Kotucha.


# invoke the right shell (code from Thomas Esser):
test -f /bin/ksh && test -z "$RUNNING_KSH" \
  && { UNAMES=`uname -s`; test "x$UNAMES" = xULTRIX; } 2>/dev/null \
  && { RUNNING_KSH=true; export RUNNING_KSH; exec /bin/ksh $0 ${1+"$@"}; }
unset RUNNING_KSH

test -f /bin/bsh && test -z "$RUNNING_BSH" \
  && { UNAMES=`uname -s`; test "x$UNAMES" = xAIX; } 2>/dev/null \
  && { RUNNING_BSH=true; export RUNNING_BSH; exec /bin/bsh $0 ${1+"$@"}; }
unset RUNNING_BSH


URL="${URL-ftp://tug.org/tex/getnonfreefonts/getfont}"

die () { echo "$1." 1>&2; exit 1; }

OLDIFS=$IFS
IFS=:
BINDIRS=`echo $PATH`
IFS=$OLDIFS

for BINDIR in $BINDIRS; do
  if test "$BINDIR" != "."; then
    for FTP_CLIENT in wget lftp ncftpget curl snarf gftp; do
	test -x $BINDIR/$FTP_CLIENT && FTP=$FTP_CLIENT && break
    done
  fi
done

test -n "$FTP" || die "No ftp client found"

export FTP

case $0 in 
  *-sys) SYS=true; GETFONT=getfont-sys;;
      *) SYS=false; GETFONT=getfont;;
esac
export SYS GETFONT

ALL=true
RUNSHELL=false

ARGS_FROM_GETNONFREEFONTS="$@"
export ARGS_FROM_GETNONFREEFONTS

for ARG in "$@"; do
  case $ARG in
    -*)
      case $ARG in
        -shell|--shell) RUNSHELL=true;;
        -ftp-client=*|--ftp-client=*)
          FTP=`echo "$ARG" | sed 's/.*=//'`;;
        -url=*|--url=*)
          URL=`echo "$ARG" | sed 's/.*=//'`;;
	-h|-help|--help) ALL=false;;
      esac;;
    *) ALL=false;;
  esac
done

export URL

tmpdir=${TMPDIR-${TEMP-${TMP-/tmp}}}/getnonfreefonts.$$
(umask 077; mkdir "${tmpdir}") || die "Can't mkdir ${tmpdir}"
trap 'rm -rf ${tmpdir}' 0 1 2 3 7 13 15

download () {
  echo "Downloading: $1"
  case ${FTP} in
        wget) wget "$1"        || die "$1: Download failed";;
        lftp) lftp -c "get $1" || die "$1: Download failed";;
    ncftpget) ncftpget "$1"    || die "$1: Download failed";;
        curl) curl -O "$1"     || die "$1: Download failed";;
       snarf) snarf "$1"       || die "$1: Download failed";;
        gftp) gftp -d "$1"     || die "$1: Download failed";;
           *) die "This can't happen";;
  esac
}

cd "${tmpdir}" || die "Can't cd ${tmpdir}"

echo -------------------------------------------------------
echo "FTP client:    ${FTP}"
echo "Temporary dir: ${tmpdir}"
echo "URL:           ${URL}"
echo -------------------------------------------------------

download ${URL}

chmod 700 getfont
ln -s getfont getfont-sys
PATH=${tmpdir}:${PATH}
export PATH

UPDMAP_NEEDED=false

if ${RUNSHELL}; then
  if ${SYS}; then
    PS1='[getfont-sys]\$ '
  else
    PS1='[getfont]\$ '
  fi
  export PS1
  echo -------------------------------------------------------
  echo "FTP client:    ${FTP}"
  echo "Temporary dir: ${tmpdir}"
  echo "URL:           ${URL}"
  echo "SYS:           ${SYS}"
  echo "ARGS:          ${ARGS_FROM_GETNONFREEFONTS}"
  echo -------------------------------------------------------
  echo "Run program \"getfont\" or \"getfont-sys\" for each font you want to install."
  echo; echo "Supported fonts are:"
  for f in `getfont --lsfonts`; do
    echo "     $f"
  done
  echo; echo "Type \"getfont --help\" for more information."
  echo "Type \"exit\" to leave this shell."; echo

# Start the shell.  We start a shell even if someone has
# SHELL=/sbin/shutdown in his environment.

  test -z ${SHELL} || SHELL="/bin/sh"
  case ${SHELL} in
    /bin/bash) /bin/bash;;
     /bin/ksh) /bin/ksh;;
     /bin/ksh) /bin/ksh;;
            *) /bin/sh;;
  esac

  echo "Please run \"updmap\" or \"updmap-sys\" now if necessary."
else # no shell
  if ${ALL} ; then
    for font in `getfont --lsfonts`; do
      ${GETFONT} ${ARGS_FROM_GETNONFREEFONTS} ${font} && UPDMAP_NEEDED=true
    done
  else
    ${GETFONT} ${ARGS_FROM_GETNONFREEFONTS} && UPDMAP_NEEDED=true
  fi

  if ${UPDMAP_NEEDED}; then
    if ${SYS}; then
      updmap-sys
    else 
      updmap
    fi
  fi
fi

cd /
rm -rf "${tmpdir}"

exit 0