# HG changeset patch # User Liu Peng # Date 1271998787 0 # Node ID 3fb94ab57a3c81a47394f0673b7113cdab0a5205 # Parent 0e59fefac994b5763cdeeea2a5b90c104d2f9f9e Add get-msttcorefonts diff -r 0e59fefac994 -r 3fb94ab57a3c get-msttcorefonts/receipt --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/get-msttcorefonts/receipt Fri Apr 23 04:59:47 2010 +0000 @@ -0,0 +1,17 @@ +# SliTaz package receipt. +# http://corefonts.sourceforge.net/ + +PACKAGE="get-msttcorefonts" +VERSION="1.00" +CATEGORY="non-free" +SHORT_DESC="An easy way to install Microsoft's TrueType core fonts on linux." +MAINTAINER="rocky@slitaz.org" +WEB_SITE="http://sourceforge.net/projects/corefonts" +TAGS="utilities" + +# Rules to gen a SliTaz package suitable for Tazpkg. +genpkg_rules() +{ + mkdir -p $fs/usr/bin + cp stuff/get-msttcorefonts $fs/usr/bin +} diff -r 0e59fefac994 -r 3fb94ab57a3c get-msttcorefonts/stuff/get-msttcorefonts --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/get-msttcorefonts/stuff/get-msttcorefonts Fri Apr 23 04:59:47 2010 +0000 @@ -0,0 +1,175 @@ +#!/bin/sh + +PACKAGE="msttcorefonts" +VERSION="2.0" +CUR_DIR=$(pwd) +TEMP_DIR=/tmp/$PACKAGE-$VERSION +ROOT= + +# Check if we are root +if test $(id -u) != 0 ; then + echo -e "\nYou must be root to run `basename $0`." + echo -e "Please type 'su' and root password to become super-user.\n" + exit 1 +fi + +# Avoid reinstall +if [ -d $ROOT/var/lib/tazpkg/installed/$PACKAGE ]; then + echo -e "\n$PACKAGE package is already installed.\n" + exit 1 +fi + +# Create a TEMP_DIR +mkdir -p $TEMP_DIR/downloads +cd $TEMP_DIR/downloads + +# this is the sourceforge mirrorlist as of 2006-04-30. If someone spots changes +# over at sourcforge, feel free to email me and I'll update the list +mirrors="easynews+heanet+superb-west+internap+switch+ufpr+surfnet+umn+kent+mesh+superb-east+jaist" +mirror_count=12 + +andale32_md5="cbdc2fdd7d2ed0832795e86a8b9ee19a andale32.exe" +arial32_md5="9637df0e91703179f0723ec095a36cb5 arial32.exe" +arialb32_md5="c9089ae0c3b3d0d8c4b0a95979bb9ff0 arialb32.exe" +comic32_md5="2b30de40bb5e803a0452c7715fc835d1 comic32.exe" +courie32_md5="4e412c772294403ab62fb2d247d85c60 courie32.exe" +georgi32_md5="4d90016026e2da447593b41a8d8fa8bd georgi32.exe" +impact32_md5="7907c7dd6684e9bade91cff82683d9d7 impact32.exe" +times32_md5="ed39c8ef91b9fb80f76f702568291bd5 times32.exe" +trebuc32_md5="0d7ea16cac6261f8513a061fbfcdb2b5 trebuc32.exe" +webdin32_md5="230a1d13a365b22815f502eb24d9149b webdin32.exe" +verdan32_md5="12d2a75f8156e10607be1eaa8e8ef120 verdan32.exe" +wd97vwr32_md5="efa72d3ed0120a07326ce02f051e9b42 wd97vwr32.exe" + +download_files="andale32.exe arial32.exe arialb32.exe comic32.exe courie32.exe georgi32.exe impact32.exe times32.exe trebuc32.exe webdin32.exe verdan32.exe wd97vwr32.exe" + +failures=0 + +set_mirror() { + local r m + r=`expr $RANDOM % $mirror_count + 1` + m=`echo $mirrors |cut -d+ -f$r` + mirror="http://${m}.dl.sourceforge.net/sourceforge/corefonts/" +} + +check_file() { + matches=no + if [ ! -r $1 ] + then + echo "$1 does not exist" + return + fi + local variable_name=`basename $1 .exe`_md5 + local stored_checksum + eval stored_checksum=\$$variable_name + local computed_checksum=`md5sum $1` + if [ "$stored_checksum" = "$computed_checksum" ] + then + matches=yes + else + rm $1 + matches=no + fi +} + +download() { + curl --retry 5 -H Pragma: -R -S -L -o "$2" $1$2 +} + +# Download the file +set_mirror + +if [ ! -d /var/lib/tazpkg/installed/curl ]; then + tazpkg get-install curl +fi +if [ ! -f /usr/bin/curl ]; then + cd $CUR_DIR + echo "Could not find curl. Exiting." + exit +fi + +for f in $download_files +do + check_file $f + while [ $matches != yes ] + do + download $mirror $f + check_file $f + if [ $matches != yes ] + then + echo "failed to download $mirror$f" + failures=`expr $failures + 1` + if [ $failures -gt 5 ] + then + echo "failed to download too many times." + exit + fi + set_mirror + fi + done +done + +# Extract fonts +if [ ! -d /var/lib/tazpkg/installed/cabextract ]; then + tazpkg get-install cabextract +fi +if [ ! -f /usr/bin/cabextract ]; then + cd $CUR_DIR + echo "Could not find cabextract. Exiting." + exit +fi + +cd $TEMP_DIR +rm -rf cab-contents && mkdir cab-contents +mkdir -p $PACKAGE-$VERSION/fs/usr/share/fonts/truetype/$PACKAGE/ + +font_files="andale32.exe arial32.exe arialb32.exe comic32.exe courie32.exe georgi32.exe impact32.exe times32.exe trebuc32.exe webdin32.exe verdan32.exe" + +for i in $font_files +do + if [ -f downloads/$i ] + then + cabextract --lowercase --directory=cab-contents downloads/$i + fi + mv cab-contents/*.ttf $PACKAGE-$VERSION/fs/usr/share/fonts/truetype/$PACKAGE/ + rm -f cab-contents/* +done + +cabextract --lowercase --directory=cab-contents downloads/wd97vwr32.exe +cabextract --lowercase --directory=cab-contents cab-contents/viewer1.cab +mv cab-contents/*.ttf $PACKAGE-$VERSION/fs/usr/share/fonts/truetype/$PACKAGE/ +rm -f cab-contents/* + +cd $TEMP_DIR + +cat > $PACKAGE-$VERSION/receipt << EOT +PACKAGE="$PACKAGE" +VERSION="$VERSION" +CATEGORY="non-free" +SHORT_DESC="TrueType core fonts for the web." +DEPENDS="fontconfig" +WEB_SITE="http://sourceforge.net/projects/corefonts" +TAGS="fonts" + +# Pre and post install commands for Tazpkg. +post_install() +{ + local root + root=\${1:-/} + echo "Processing post-install commands..." + chroot \$root/ /usr/bin/fc-cache /usr/share/fonts/truetype/msttcorefonts >/dev/null 2>&1 +} +EOT + +# Pack +tazpkg pack $PACKAGE-$VERSION + +# Clean to save RAM memory +rm -rf $PACKAGE-$VERSION + +# Install pseudo package +yes y | tazpkg install $PACKAGE-$VERSION.tazpkg --root=$ROOT + +# Clean +cd $CUR_DIR +rm -rf $TEMP_DIR