wok view get-msttcorefonts/stuff/get-msttcorefonts @ rev 13782

Up tazpkg (5.1)
author Pascal Bellard <pascal.bellard@slitaz.org>
date Fri Jan 04 17:20:57 2013 +0100 (2013-01-04)
parents
children 6fab3264ba87
line source
1 #!/bin/sh
3 PACKAGE="msttcorefonts"
4 VERSION="2.0"
5 CUR_DIR=$(pwd)
6 TEMP_DIR=/tmp/$PACKAGE-$VERSION
7 ROOT=
9 # Check if we are root
10 if test $(id -u) != 0 ; then
11 echo -e "\nYou must be root to run `basename $0`."
12 echo -e "Please type 'su' and root password to become super-user.\n"
13 exit 1
14 fi
16 # Avoid reinstall
17 if [ -d $ROOT/var/lib/tazpkg/installed/$PACKAGE ]; then
18 echo -e "\n$PACKAGE package is already installed.\n"
19 exit 1
20 fi
22 # Create a TEMP_DIR
23 mkdir -p $TEMP_DIR/downloads
24 cd $TEMP_DIR/downloads
26 # this is the sourceforge mirrorlist as of 2006-04-30. If someone spots changes
27 # over at sourcforge, feel free to email me and I'll update the list
28 mirrors="easynews+heanet+superb-west+internap+switch+ufpr+surfnet+umn+kent+mesh+superb-east+jaist"
29 mirror_count=12
31 andale32_md5="cbdc2fdd7d2ed0832795e86a8b9ee19a andale32.exe"
32 arial32_md5="9637df0e91703179f0723ec095a36cb5 arial32.exe"
33 arialb32_md5="c9089ae0c3b3d0d8c4b0a95979bb9ff0 arialb32.exe"
34 comic32_md5="2b30de40bb5e803a0452c7715fc835d1 comic32.exe"
35 courie32_md5="4e412c772294403ab62fb2d247d85c60 courie32.exe"
36 georgi32_md5="4d90016026e2da447593b41a8d8fa8bd georgi32.exe"
37 impact32_md5="7907c7dd6684e9bade91cff82683d9d7 impact32.exe"
38 times32_md5="ed39c8ef91b9fb80f76f702568291bd5 times32.exe"
39 trebuc32_md5="0d7ea16cac6261f8513a061fbfcdb2b5 trebuc32.exe"
40 webdin32_md5="230a1d13a365b22815f502eb24d9149b webdin32.exe"
41 verdan32_md5="12d2a75f8156e10607be1eaa8e8ef120 verdan32.exe"
42 wd97vwr32_md5="efa72d3ed0120a07326ce02f051e9b42 wd97vwr32.exe"
44 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"
46 failures=0
48 set_mirror() {
49 local r m
50 r=`expr $RANDOM % $mirror_count + 1`
51 m=`echo $mirrors |cut -d+ -f$r`
52 mirror="http://${m}.dl.sourceforge.net/sourceforge/corefonts/"
53 }
55 check_file() {
56 matches=no
57 if [ ! -r $1 ]
58 then
59 echo "$1 does not exist"
60 return
61 fi
62 local variable_name=`basename $1 .exe`_md5
63 local stored_checksum
64 eval stored_checksum=\$$variable_name
65 local computed_checksum=`md5sum $1`
66 if [ "$stored_checksum" = "$computed_checksum" ]
67 then
68 matches=yes
69 else
70 rm $1
71 matches=no
72 fi
73 }
75 download() {
76 curl --retry 5 -H Pragma: -R -S -L -o "$2" $1$2
77 }
79 # Download the file
80 set_mirror
82 if [ ! -d /var/lib/tazpkg/installed/curl ]; then
83 tazpkg get-install curl
84 fi
85 if [ ! -f /usr/bin/curl ]; then
86 cd $CUR_DIR
87 echo "Could not find curl. Exiting."
88 exit
89 fi
91 for f in $download_files
92 do
93 check_file $f
94 while [ $matches != yes ]
95 do
96 download $mirror $f
97 check_file $f
98 if [ $matches != yes ]
99 then
100 echo "failed to download $mirror$f"
101 failures=`expr $failures + 1`
102 if [ $failures -gt 5 ]
103 then
104 echo "failed to download too many times."
105 exit
106 fi
107 set_mirror
108 fi
109 done
110 done
112 # Extract fonts
113 if [ ! -d /var/lib/tazpkg/installed/cabextract ]; then
114 tazpkg get-install cabextract
115 fi
116 if [ ! -f /usr/bin/cabextract ]; then
117 cd $CUR_DIR
118 echo "Could not find cabextract. Exiting."
119 exit
120 fi
122 cd $TEMP_DIR
123 rm -rf cab-contents && mkdir cab-contents
124 mkdir -p $PACKAGE-$VERSION/fs/usr/share/fonts/truetype/$PACKAGE/
126 font_files="andale32.exe arial32.exe arialb32.exe comic32.exe courie32.exe georgi32.exe impact32.exe times32.exe trebuc32.exe webdin32.exe verdan32.exe"
128 for i in $font_files
129 do
130 if [ -f downloads/$i ]
131 then
132 cabextract --lowercase --directory=cab-contents downloads/$i
133 fi
134 mv cab-contents/*.ttf $PACKAGE-$VERSION/fs/usr/share/fonts/truetype/$PACKAGE/
135 rm -f cab-contents/*
136 done
138 cabextract --lowercase --directory=cab-contents downloads/wd97vwr32.exe
139 cabextract --lowercase --directory=cab-contents cab-contents/viewer1.cab
140 mv cab-contents/*.ttf $PACKAGE-$VERSION/fs/usr/share/fonts/truetype/$PACKAGE/
141 rm -f cab-contents/*
143 cd $TEMP_DIR
145 cat > $PACKAGE-$VERSION/receipt << EOT
146 PACKAGE="$PACKAGE"
147 VERSION="$VERSION"
148 CATEGORY="non-free"
149 SHORT_DESC="TrueType core fonts for the web."
150 DEPENDS="fontconfig"
151 WEB_SITE="http://sourceforge.net/projects/corefonts"
152 TAGS="fonts"
154 # Pre and post install commands for Tazpkg.
155 post_install()
156 {
157 local root
158 root=\${1:-/}
159 echo "Processing post-install commands..."
160 chroot \$root/ /usr/bin/fc-cache /usr/share/fonts/truetype/msttcorefonts >/dev/null 2>&1
161 }
162 EOT
164 # Pack
165 tazpkg pack $PACKAGE-$VERSION
167 # Clean to save RAM memory
168 rm -rf $PACKAGE-$VERSION
170 # Install pseudo package
171 yes y | tazpkg install $PACKAGE-$VERSION.tazpkg --root=$ROOT
173 # Clean
174 cd $CUR_DIR
175 rm -rf $TEMP_DIR