wok-stable rev 5325

Add get-msttcorefonts
author Liu Peng <rocky@slitaz.org>
date Fri Apr 23 04:59:47 2010 +0000 (2010-04-23)
parents 0e59fefac994
children 30f4697aaf2b
files get-msttcorefonts/receipt get-msttcorefonts/stuff/get-msttcorefonts
line diff
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/get-msttcorefonts/receipt	Fri Apr 23 04:59:47 2010 +0000
     1.3 @@ -0,0 +1,17 @@
     1.4 +# SliTaz package receipt.
     1.5 +# http://corefonts.sourceforge.net/
     1.6 +
     1.7 +PACKAGE="get-msttcorefonts"
     1.8 +VERSION="1.00"
     1.9 +CATEGORY="non-free"
    1.10 +SHORT_DESC="An easy way to install Microsoft's TrueType core fonts on linux."
    1.11 +MAINTAINER="rocky@slitaz.org"
    1.12 +WEB_SITE="http://sourceforge.net/projects/corefonts"
    1.13 +TAGS="utilities"
    1.14 +
    1.15 +# Rules to gen a SliTaz package suitable for Tazpkg.
    1.16 +genpkg_rules()
    1.17 +{
    1.18 +    mkdir -p $fs/usr/bin
    1.19 +    cp stuff/get-msttcorefonts $fs/usr/bin
    1.20 +}
     2.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     2.2 +++ b/get-msttcorefonts/stuff/get-msttcorefonts	Fri Apr 23 04:59:47 2010 +0000
     2.3 @@ -0,0 +1,175 @@
     2.4 +#!/bin/sh
     2.5 +
     2.6 +PACKAGE="msttcorefonts"
     2.7 +VERSION="2.0"
     2.8 +CUR_DIR=$(pwd)
     2.9 +TEMP_DIR=/tmp/$PACKAGE-$VERSION
    2.10 +ROOT=
    2.11 +
    2.12 +# Check if we are root
    2.13 +if test $(id -u) != 0 ; then
    2.14 +    echo -e "\nYou must be root to run `basename $0`."
    2.15 +    echo -e "Please type 'su' and root password to become super-user.\n"
    2.16 +    exit 1
    2.17 +fi
    2.18 +
    2.19 +# Avoid reinstall
    2.20 +if [ -d $ROOT/var/lib/tazpkg/installed/$PACKAGE ]; then
    2.21 +    echo -e "\n$PACKAGE package is already installed.\n"
    2.22 +    exit 1
    2.23 +fi
    2.24 +
    2.25 +# Create a TEMP_DIR
    2.26 +mkdir -p $TEMP_DIR/downloads
    2.27 +cd $TEMP_DIR/downloads
    2.28 +
    2.29 +# this is the sourceforge mirrorlist as of 2006-04-30. If someone spots changes
    2.30 +# over at sourcforge, feel free to email me and I'll update the list
    2.31 +mirrors="easynews+heanet+superb-west+internap+switch+ufpr+surfnet+umn+kent+mesh+superb-east+jaist"
    2.32 +mirror_count=12
    2.33 +
    2.34 +andale32_md5="cbdc2fdd7d2ed0832795e86a8b9ee19a  andale32.exe"
    2.35 +arial32_md5="9637df0e91703179f0723ec095a36cb5  arial32.exe"
    2.36 +arialb32_md5="c9089ae0c3b3d0d8c4b0a95979bb9ff0  arialb32.exe"
    2.37 +comic32_md5="2b30de40bb5e803a0452c7715fc835d1  comic32.exe"
    2.38 +courie32_md5="4e412c772294403ab62fb2d247d85c60  courie32.exe"
    2.39 +georgi32_md5="4d90016026e2da447593b41a8d8fa8bd  georgi32.exe"
    2.40 +impact32_md5="7907c7dd6684e9bade91cff82683d9d7  impact32.exe"
    2.41 +times32_md5="ed39c8ef91b9fb80f76f702568291bd5  times32.exe"
    2.42 +trebuc32_md5="0d7ea16cac6261f8513a061fbfcdb2b5  trebuc32.exe"
    2.43 +webdin32_md5="230a1d13a365b22815f502eb24d9149b  webdin32.exe"
    2.44 +verdan32_md5="12d2a75f8156e10607be1eaa8e8ef120  verdan32.exe"
    2.45 +wd97vwr32_md5="efa72d3ed0120a07326ce02f051e9b42  wd97vwr32.exe"
    2.46 +
    2.47 +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"
    2.48 +
    2.49 +failures=0
    2.50 +
    2.51 +set_mirror() {
    2.52 +	local r m
    2.53 +	r=`expr $RANDOM % $mirror_count + 1`
    2.54 +	m=`echo $mirrors |cut -d+ -f$r`
    2.55 +	mirror="http://${m}.dl.sourceforge.net/sourceforge/corefonts/"
    2.56 +}
    2.57 +
    2.58 +check_file() {
    2.59 +	matches=no
    2.60 +	if [ ! -r $1 ]
    2.61 +	then
    2.62 +		echo "$1 does not exist"
    2.63 +		return
    2.64 +	fi
    2.65 +	local variable_name=`basename $1 .exe`_md5
    2.66 +	local stored_checksum
    2.67 +	eval stored_checksum=\$$variable_name
    2.68 +	local computed_checksum=`md5sum $1`
    2.69 +	if [ "$stored_checksum" = "$computed_checksum" ]
    2.70 +	then
    2.71 +		matches=yes
    2.72 +	else
    2.73 +		rm $1
    2.74 +		matches=no
    2.75 +	fi
    2.76 +}
    2.77 +
    2.78 +download() {
    2.79 +	curl --retry 5 -H Pragma: -R -S -L -o "$2" $1$2
    2.80 +}
    2.81 +
    2.82 +# Download the file
    2.83 +set_mirror
    2.84 +
    2.85 +if [ ! -d /var/lib/tazpkg/installed/curl ]; then
    2.86 +    tazpkg get-install curl
    2.87 +fi
    2.88 +if [ ! -f /usr/bin/curl ]; then
    2.89 +    cd $CUR_DIR
    2.90 +    echo "Could not find curl. Exiting."
    2.91 +    exit
    2.92 +fi
    2.93 +
    2.94 +for f in $download_files
    2.95 +do
    2.96 +	check_file $f
    2.97 +	while [ $matches != yes ]
    2.98 +	do
    2.99 +		download $mirror $f
   2.100 +		check_file $f
   2.101 +		if [ $matches != yes ]
   2.102 +		then
   2.103 +			echo "failed to download $mirror$f"
   2.104 +			failures=`expr $failures + 1`
   2.105 +			if [ $failures -gt 5 ]
   2.106 +			then
   2.107 +				echo "failed to download too many times."
   2.108 +				exit
   2.109 +			fi
   2.110 +			set_mirror
   2.111 +		fi
   2.112 +	done
   2.113 +done
   2.114 +
   2.115 +# Extract fonts
   2.116 +if [ ! -d /var/lib/tazpkg/installed/cabextract ]; then
   2.117 +    tazpkg get-install cabextract
   2.118 +fi
   2.119 +if [ ! -f /usr/bin/cabextract ]; then
   2.120 +    cd $CUR_DIR
   2.121 +    echo "Could not find cabextract. Exiting."
   2.122 +    exit
   2.123 +fi
   2.124 +
   2.125 +cd $TEMP_DIR
   2.126 +rm -rf cab-contents && mkdir cab-contents
   2.127 +mkdir -p $PACKAGE-$VERSION/fs/usr/share/fonts/truetype/$PACKAGE/
   2.128 +
   2.129 +font_files="andale32.exe arial32.exe arialb32.exe comic32.exe courie32.exe georgi32.exe impact32.exe times32.exe trebuc32.exe webdin32.exe verdan32.exe"
   2.130 +
   2.131 +for i in $font_files
   2.132 +do
   2.133 +	if [ -f downloads/$i ]
   2.134 +	then
   2.135 +		cabextract --lowercase --directory=cab-contents downloads/$i
   2.136 +	fi
   2.137 +	mv cab-contents/*.ttf $PACKAGE-$VERSION/fs/usr/share/fonts/truetype/$PACKAGE/
   2.138 +	rm -f cab-contents/*
   2.139 +done
   2.140 +
   2.141 +cabextract --lowercase --directory=cab-contents downloads/wd97vwr32.exe
   2.142 +cabextract --lowercase --directory=cab-contents cab-contents/viewer1.cab
   2.143 +mv cab-contents/*.ttf $PACKAGE-$VERSION/fs/usr/share/fonts/truetype/$PACKAGE/
   2.144 +rm -f cab-contents/*
   2.145 +
   2.146 +cd $TEMP_DIR
   2.147 +
   2.148 +cat > $PACKAGE-$VERSION/receipt << EOT
   2.149 +PACKAGE="$PACKAGE"
   2.150 +VERSION="$VERSION"
   2.151 +CATEGORY="non-free"
   2.152 +SHORT_DESC="TrueType core fonts for the web."
   2.153 +DEPENDS="fontconfig"
   2.154 +WEB_SITE="http://sourceforge.net/projects/corefonts"
   2.155 +TAGS="fonts"
   2.156 +
   2.157 +# Pre and post install commands for Tazpkg.
   2.158 +post_install()
   2.159 +{
   2.160 +	local root
   2.161 +	root=\${1:-/}
   2.162 +	echo "Processing post-install commands..."
   2.163 +	chroot \$root/ /usr/bin/fc-cache /usr/share/fonts/truetype/msttcorefonts >/dev/null 2>&1
   2.164 +}
   2.165 +EOT
   2.166 +
   2.167 +# Pack
   2.168 +tazpkg pack $PACKAGE-$VERSION
   2.169 +
   2.170 +# Clean to save RAM memory
   2.171 +rm -rf $PACKAGE-$VERSION
   2.172 +
   2.173 +# Install pseudo package
   2.174 +yes y | tazpkg install $PACKAGE-$VERSION.tazpkg --root=$ROOT
   2.175 +
   2.176 +# Clean
   2.177 +cd $CUR_DIR
   2.178 +rm -rf $TEMP_DIR