File fetchmsttfonts.sh.in of Package fetchmsttfonts

#!/bin/sh

EULA="http://corefonts.sourceforge.net/eula.htm"

POST_MESSAGE="/var/adm/update-messages/__NAME__-__VERSION__-__RELEASE__-1"

FONTS=" \
https://sourceforge.net/projects/corefonts/files/the%20fonts/final/andale32.exe \
https://sourceforge.net/projects/corefonts/files/the%20fonts/final/arial32.exe  \
https://sourceforge.net/projects/corefonts/files/the%20fonts/final/arialb32.exe \
https://sourceforge.net/projects/corefonts/files/the%20fonts/final/comic32.exe  \
https://sourceforge.net/projects/corefonts/files/the%20fonts/final/courie32.exe \
https://sourceforge.net/projects/corefonts/files/the%20fonts/final/georgi32.exe \
https://sourceforge.net/projects/corefonts/files/the%20fonts/final/impact32.exe \
https://sourceforge.net/projects/corefonts/files/the%20fonts/final/times32.exe  \
https://sourceforge.net/projects/corefonts/files/the%20fonts/final/trebuc32.exe \
https://sourceforge.net/projects/corefonts/files/the%20fonts/final/verdan32.exe \
https://sourceforge.net/projects/corefonts/files/the%20fonts/final/webdin32.exe \
"

# same order like FONTS...
FILES="andalemo.ttf arial.ttf arialbi.ttf comic.ttf cour.ttf georgia.ttf impact.ttf times.ttf trebuc.ttf verdana.ttf webdings.ttf"

CURL_OPTIONS="-L -s --speed-limit 3500 --speed-time 15"

echo "EULA:"
if [ -e /usr/share/doc/corefonts/EULA.html ]; then
    echo "already present"
else
    echo -n "  Fetching   ... "
    curl $CURL_OPTIONS -o /usr/share/doc/corefonts/EULA.html $EULA || \
      rm -f /usr/share/doc/corefonts/EULA.html
    echo "done"
fi

tmpname=$(basename "$0")
tmpdir=$(mktemp -d "/tmp/$tmpname.XXXXXX")
trap "rm -rf $tmpdir" EXIT
if [ $? -ne 0 ]; then
  echo "$0: Can't create temp dir, exiting..."
  exit 4
fi

cd "$tmpdir"

all_skipped=true
for archive in $FONTS; do
    # POSIX sh does not know arrays, so just pop the first element from FILES 'list'
    font=${FILES%% *}
    FILES=${FILES#* }
    file=${archive##*/}
    echo "$file ($archive):"
    if [ -e "/usr/share/fonts/truetype/$font" ]; then
        echo "font already installed, skipping..."
        continue
    fi
    all_skipped=false
    echo -n "  Fetching   ... "

    if ! curl $CURL_OPTIONS -o "$file" "$archive"; then
        rm -f "$file"
        echo "failed ... deleted!"
        continue
    fi

    if ! grep "$file" "/usr/share/__NAME__/corefonts.sha512" | sha512sum --check --quiet --status > /dev/null 2>&1; then
        rm -f "$file"
        echo "checksum mismatch for $file ... deleted!"
        continue
    fi

    echo "done"
    echo -n "  Extracting ... "
    if ! cabextract -l "$file" >/dev/null 2>&1; then
        rm -f "$file"
        echo "failed ... deleted!"
    else
        cabextract "$file" >/dev/null 2>&1
        echo "done"
        success=true
    fi

    rm -f "$file"
done

if $all_skipped; then
    echo "*** No update necessary. ***"
    # do not annoy with an interactive update message, just exit
    # also skip EULA display
    exit
fi

if [ "x$success" != "x" ]; then 
    for i in ./*.[Tt][Tt][CFcf]; do
        lower=$(echo "$i" | tr "[:upper:]" "[:lower:]")
        test "$i" != "$lower" && mv "$i" "$lower"
    done

    chmod 644 ./*.tt[cf]
    mv -f ./*.tt[cf] /usr/share/fonts/truetype
    /usr/sbin/fonts-config
    echo "*** Fonts installed. ***" | tee $POST_MESSAGE
else
    echo "*** No Fonts installed. ***" | tee $POST_MESSAGE
fi

test -f /usr/share/doc/corefonts/EULA.html && w3m -dump /usr/share/doc/corefonts/EULA.html | tee $POST_MESSAGE
openSUSE Build Service is sponsored by