wok diff get-msttcorefonts/stuff/get-msttcorefonts @ rev 13953

Up cookutils (3.1.1)
author Pascal Bellard <pascal.bellard@slitaz.org>
date Wed Jan 30 08:50:27 2013 +0100 (2013-01-30)
parents
children 6fab3264ba87
line diff
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/get-msttcorefonts/stuff/get-msttcorefonts	Wed Jan 30 08:50:27 2013 +0100
     1.3 @@ -0,0 +1,175 @@
     1.4 +#!/bin/sh
     1.5 +
     1.6 +PACKAGE="msttcorefonts"
     1.7 +VERSION="2.0"
     1.8 +CUR_DIR=$(pwd)
     1.9 +TEMP_DIR=/tmp/$PACKAGE-$VERSION
    1.10 +ROOT=
    1.11 +
    1.12 +# Check if we are root
    1.13 +if test $(id -u) != 0 ; then
    1.14 +    echo -e "\nYou must be root to run `basename $0`."
    1.15 +    echo -e "Please type 'su' and root password to become super-user.\n"
    1.16 +    exit 1
    1.17 +fi
    1.18 +
    1.19 +# Avoid reinstall
    1.20 +if [ -d $ROOT/var/lib/tazpkg/installed/$PACKAGE ]; then
    1.21 +    echo -e "\n$PACKAGE package is already installed.\n"
    1.22 +    exit 1
    1.23 +fi
    1.24 +
    1.25 +# Create a TEMP_DIR
    1.26 +mkdir -p $TEMP_DIR/downloads
    1.27 +cd $TEMP_DIR/downloads
    1.28 +
    1.29 +# this is the sourceforge mirrorlist as of 2006-04-30. If someone spots changes
    1.30 +# over at sourcforge, feel free to email me and I'll update the list
    1.31 +mirrors="easynews+heanet+superb-west+internap+switch+ufpr+surfnet+umn+kent+mesh+superb-east+jaist"
    1.32 +mirror_count=12
    1.33 +
    1.34 +andale32_md5="cbdc2fdd7d2ed0832795e86a8b9ee19a  andale32.exe"
    1.35 +arial32_md5="9637df0e91703179f0723ec095a36cb5  arial32.exe"
    1.36 +arialb32_md5="c9089ae0c3b3d0d8c4b0a95979bb9ff0  arialb32.exe"
    1.37 +comic32_md5="2b30de40bb5e803a0452c7715fc835d1  comic32.exe"
    1.38 +courie32_md5="4e412c772294403ab62fb2d247d85c60  courie32.exe"
    1.39 +georgi32_md5="4d90016026e2da447593b41a8d8fa8bd  georgi32.exe"
    1.40 +impact32_md5="7907c7dd6684e9bade91cff82683d9d7  impact32.exe"
    1.41 +times32_md5="ed39c8ef91b9fb80f76f702568291bd5  times32.exe"
    1.42 +trebuc32_md5="0d7ea16cac6261f8513a061fbfcdb2b5  trebuc32.exe"
    1.43 +webdin32_md5="230a1d13a365b22815f502eb24d9149b  webdin32.exe"
    1.44 +verdan32_md5="12d2a75f8156e10607be1eaa8e8ef120  verdan32.exe"
    1.45 +wd97vwr32_md5="efa72d3ed0120a07326ce02f051e9b42  wd97vwr32.exe"
    1.46 +
    1.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"
    1.48 +
    1.49 +failures=0
    1.50 +
    1.51 +set_mirror() {
    1.52 +	local r m
    1.53 +	r=`expr $RANDOM % $mirror_count + 1`
    1.54 +	m=`echo $mirrors |cut -d+ -f$r`
    1.55 +	mirror="http://${m}.dl.sourceforge.net/sourceforge/corefonts/"
    1.56 +}
    1.57 +
    1.58 +check_file() {
    1.59 +	matches=no
    1.60 +	if [ ! -r $1 ]
    1.61 +	then
    1.62 +		echo "$1 does not exist"
    1.63 +		return
    1.64 +	fi
    1.65 +	local variable_name=`basename $1 .exe`_md5
    1.66 +	local stored_checksum
    1.67 +	eval stored_checksum=\$$variable_name
    1.68 +	local computed_checksum=`md5sum $1`
    1.69 +	if [ "$stored_checksum" = "$computed_checksum" ]
    1.70 +	then
    1.71 +		matches=yes
    1.72 +	else
    1.73 +		rm $1
    1.74 +		matches=no
    1.75 +	fi
    1.76 +}
    1.77 +
    1.78 +download() {
    1.79 +	curl --retry 5 -H Pragma: -R -S -L -o "$2" $1$2
    1.80 +}
    1.81 +
    1.82 +# Download the file
    1.83 +set_mirror
    1.84 +
    1.85 +if [ ! -d /var/lib/tazpkg/installed/curl ]; then
    1.86 +    tazpkg get-install curl
    1.87 +fi
    1.88 +if [ ! -f /usr/bin/curl ]; then
    1.89 +    cd $CUR_DIR
    1.90 +    echo "Could not find curl. Exiting."
    1.91 +    exit
    1.92 +fi
    1.93 +
    1.94 +for f in $download_files
    1.95 +do
    1.96 +	check_file $f
    1.97 +	while [ $matches != yes ]
    1.98 +	do
    1.99 +		download $mirror $f
   1.100 +		check_file $f
   1.101 +		if [ $matches != yes ]
   1.102 +		then
   1.103 +			echo "failed to download $mirror$f"
   1.104 +			failures=`expr $failures + 1`
   1.105 +			if [ $failures -gt 5 ]
   1.106 +			then
   1.107 +				echo "failed to download too many times."
   1.108 +				exit
   1.109 +			fi
   1.110 +			set_mirror
   1.111 +		fi
   1.112 +	done
   1.113 +done
   1.114 +
   1.115 +# Extract fonts
   1.116 +if [ ! -d /var/lib/tazpkg/installed/cabextract ]; then
   1.117 +    tazpkg get-install cabextract
   1.118 +fi
   1.119 +if [ ! -f /usr/bin/cabextract ]; then
   1.120 +    cd $CUR_DIR
   1.121 +    echo "Could not find cabextract. Exiting."
   1.122 +    exit
   1.123 +fi
   1.124 +
   1.125 +cd $TEMP_DIR
   1.126 +rm -rf cab-contents && mkdir cab-contents
   1.127 +mkdir -p $PACKAGE-$VERSION/fs/usr/share/fonts/truetype/$PACKAGE/
   1.128 +
   1.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"
   1.130 +
   1.131 +for i in $font_files
   1.132 +do
   1.133 +	if [ -f downloads/$i ]
   1.134 +	then
   1.135 +		cabextract --lowercase --directory=cab-contents downloads/$i
   1.136 +	fi
   1.137 +	mv cab-contents/*.ttf $PACKAGE-$VERSION/fs/usr/share/fonts/truetype/$PACKAGE/
   1.138 +	rm -f cab-contents/*
   1.139 +done
   1.140 +
   1.141 +cabextract --lowercase --directory=cab-contents downloads/wd97vwr32.exe
   1.142 +cabextract --lowercase --directory=cab-contents cab-contents/viewer1.cab
   1.143 +mv cab-contents/*.ttf $PACKAGE-$VERSION/fs/usr/share/fonts/truetype/$PACKAGE/
   1.144 +rm -f cab-contents/*
   1.145 +
   1.146 +cd $TEMP_DIR
   1.147 +
   1.148 +cat > $PACKAGE-$VERSION/receipt << EOT
   1.149 +PACKAGE="$PACKAGE"
   1.150 +VERSION="$VERSION"
   1.151 +CATEGORY="non-free"
   1.152 +SHORT_DESC="TrueType core fonts for the web."
   1.153 +DEPENDS="fontconfig"
   1.154 +WEB_SITE="http://sourceforge.net/projects/corefonts"
   1.155 +TAGS="fonts"
   1.156 +
   1.157 +# Pre and post install commands for Tazpkg.
   1.158 +post_install()
   1.159 +{
   1.160 +	local root
   1.161 +	root=\${1:-/}
   1.162 +	echo "Processing post-install commands..."
   1.163 +	chroot \$root/ /usr/bin/fc-cache /usr/share/fonts/truetype/msttcorefonts >/dev/null 2>&1
   1.164 +}
   1.165 +EOT
   1.166 +
   1.167 +# Pack
   1.168 +tazpkg pack $PACKAGE-$VERSION
   1.169 +
   1.170 +# Clean to save RAM memory
   1.171 +rm -rf $PACKAGE-$VERSION
   1.172 +
   1.173 +# Install pseudo package
   1.174 +yes y | tazpkg install $PACKAGE-$VERSION.tazpkg --root=$ROOT
   1.175 +
   1.176 +# Clean
   1.177 +cd $CUR_DIR
   1.178 +rm -rf $TEMP_DIR