diff --git a/update-ms-fonts b/update-ms-fonts index 9a0012b..4fdd4f8 100755 --- a/update-ms-fonts +++ b/update-ms-fonts @@ -1,36 +1,21 @@ #!/bin/sh -# Download and install the Microsoft Core Fonts for the Web -# -# (C) 2000,2001 Eric Sharkey. -# You may freely distribute this file under the terms of the GNU General -# Public License, version 2 or later. -#abort if anything goes wrong -#set -e +set -e + +. /usr/share/debconf/confmodule + FONTDIR=/usr/share/fonts/truetype/msttcorefonts -#if [ `id -u` != 0 ] ; then -# echo "update-ms-fonts can only be run as root." -# exit -1 -#fi -# #for opt in "$@"; do # case "$opt" in # -q) QUIET_MODE=1 ;; -# -c) CHECK_ONLY=1 ;; -# -s*) SAVEDIR=${opt#-s} ;; # -u*) URLOVERRIDE=${opt#-u} ;; # *) LOCALCOPY=$opt ;; # esac #done -if [ "`echo $LOCALCOPY | tr '[:upper:]' '[:lower:]'`" = "none" ] ; then - exit 0 -fi EXITCODE=0 -export http_proxy - mstt_exit_with_error() { echo "$1" >&2 echo "The fonts are NOT installed." >&2 @@ -38,28 +23,33 @@ mstt_exit_with_error() { exit 1 } -# Base URL for Microsoft fonts -# Can be more than one to try, but here we just use SF.net's redirection, -# which will work in most cases. The others serve as fallbacks to retry. -URLROOTS="http://downloads.sourceforge.net/corefonts/ - http://switch.dl.sourceforge.net/sourceforge/corefonts/ - http://dfn.dl.sourceforge.net/sourceforge/corefonts/ - http://heanet.dl.sourceforge.net/sourceforge/corefonts/ - http://jaist.dl.sourceforge.net/sourceforge/corefonts/ - http://nchc.dl.sourceforge.net/sourceforge/corefonts/ - http://ufpr.dl.sourceforge.net/sourceforge/corefonts/ - http://internode.dl.sourceforge.net/sourceforge/corefonts/ - http://voxel.dl.sourceforge.net/sourceforge/corefonts/ - http://kent.dl.sourceforge.net/sourceforge/corefonts/" +db_get msttcorefonts/accepted-mscorefonts-eula || true +if [ "$RET" != "true" ]; then + mstt_exit_with_error "user did not accept the $license license" +fi -if [ "$URLOVERRIDE" ] ; then - URLROOTS="$URLOVERRIDE" +if [ -z "$QUIET_MODE" ] ; then + cat < msfonts.info 48d9bc613917709d3b0e0f4a6d4fe33a5c544c5035dffe9e90bc11e50e822071 Andale_Mono.ttf andale32.exe andalemo.ttf dad7c04acb26e23dfe4780e79375ca193ddaf68409317e81577a30674668830e Arial_Black.ttf arialb32.exe ariblk.ttf @@ -93,121 +83,45 @@ c8f5065ba91680f596af3b0378e2c3e713b95a523be3d56ae185ca2b8f5f0b23 Verdana_Bold.tt 10d099c88521b1b9e380b7690cbe47b54bb19396ca515358cfdc15ac249e2f5d Webdings.ttf webdin32.exe webdings.ttf EOF -for ttf in `awk '{print $2}' msfonts.info` ; do - if [ ! -e $FONTDIR/$ttf ] || \ - [ `sha256sum $FONTDIR/$ttf | awk '{print $1}'` != `awk "/$ttf/ {print \\$1 }" msfonts.info` ] - then - THISFILE=`grep $ttf msfonts.info | awk '{print $3}'` - if ! echo $FONTFILES | grep -q $THISFILE ; then - FONTFILES="$FONTFILES $THISFILE" - fi +for ff in "$@"; do + cabextract $ff 1>&2 || EXITCODE=1 + #rm $ff +done + +#Add some level of predictability by folding everything to lower case +for x in *; do + y=`echo $x | tr '[A-Z]' '[a-z]'` + if [ "$x" != "$y" ]; then + mv "$x" "$y" fi done -FFDONE="" -FFFAILED="" -if [ -n "$CHECK_ONLY" ] ; then - if [ -n "$FONTFILES" ] ; then - EXITCODE=1 - fi -elif [ -n "$FONTFILES" ] ; then +chmod 644 * - if [ -z "$QUIET_MODE" ] ; then - cat <&2 - FFDONE="$FFDONE $ff" - else - FFFAILED="$FFFAILED $ff" - EXITCODE=1 - fi - if [ -n "$SAVEDIR" ] ; then - cp $ff "$SAVEDIR" - fi - rm $ff - done - - FONTFILES=$FFDONE - FFDONE="" - #Add some level of predictability by folding everything to lower case - for x in *; do - y=`echo $x | tr '[A-Z]' '[a-z]'` - if [ "$x" != "$y" ]; then - mv "$x" "$y" - fi - done - - chmod 644 * - - # Give sane names. These are nearly the same names MS uses for the - # Macintosh versions - - mkdir -p /usr/share/doc/ttf-mscorefonts-installer $FONTDIR - if [ -e licen.txt ] ; then - mv licen.txt '/usr/share/doc/ttf-mscorefonts-installer/READ_ME!' - gzip -f -9 '/usr/share/doc/ttf-mscorefonts-installer/READ_ME!' - fi - for ff in $FONTFILES; do - for ttf in `grep $ff msfonts.info | awk '{print $4}'`; do - longname=`awk "/$ttf/ { print \\$2 }" msfonts.info` - mv $ttf $FONTDIR/$longname - ln -sf $longname $FONTDIR/$ttf - done - done - - # Make a note of what we installed so we can uninstall it later - awk '{print $2}' msfonts.info > /var/lib/msttcorefonts/ms-fonts - awk '{print $4}' msfonts.info >> /var/lib/msttcorefonts/ms-fonts +mkdir -p /usr/share/doc/ttf-mscorefonts-installer $FONTDIR +if [ -e licen.txt ] ; then + mv licen.txt '/usr/share/doc/ttf-mscorefonts-installer/READ_ME!' + gzip -f -9 '/usr/share/doc/ttf-mscorefonts-installer/READ_ME!' fi +:> /var/lib/msttcorefonts/ms-fonts + +awk "{ print \$4 \" \" \$2 }" msfonts.info | while read ttf longname +do + if ! mv $ttf $FONTDIR/$longname; then + FFFAILED="$FFFAILED $ttf" + EXITCODE=1 + continue + fi + ln -sf $longname $FONTDIR/$ttf + # Make a note of what we installed so we can uninstall it later + echo $longname >> /var/lib/msttcorefonts/ms-fonts + echo $ttf >> /var/lib/msttcorefonts/ms-fonts +done + cd / rm -rf $SCRATCHDIR @@ -223,6 +137,4 @@ if [ -z "$QUIETMODE" ] ; then fi fi -#DEBHELPER# - exit $EXITCODE