wok view get-OpenOffice3/stuff/get-OpenOffice3 @ rev 23848

inkscape: update build_depends
author Richard Dunbar <mojo@slitaz.org>
date Sun Jun 14 23:18:03 2020 -0400 (2020-06-14)
parents c07aaa614a02
children
line source
1 #!/bin/sh
2 # get-OpenOffice3, install everything for OpenOffice.org exept KDE/Gnome integration and testsuite.
3 #
4 # (C) 2020 SliTaz - GNU General Public License v3.
5 #
6 # Author : Eric Joseph-Alexandre <erjo@slitaz.org>
7 # modified by HGT on 2020-02-07
8 #
9 # === Initialisations ===
11 PKGS_DB="/var/lib/tazpkg" # packages database directory
12 PACKAGE="OpenOffice3"
13 WEB_SITE="https://openoffice.org"
14 CATEGORY="office"
15 DEPENDS="java-jre"
17 PATTERN="Linux_x86_install-rpm"
18 EXCLUDE="kde|gnome|test"
20 # Declare functions check_root, status, ...
21 . /lib/libtaz.sh
22 # and make commandline options (if any) available as variables
24 is_installed()
25 {
26 if [ -d $ROOT$PKGS_DB/installed/$PACKAGE ]
27 then #package is deemed to be installed
28 return 0
29 else
30 return 1
31 fi
32 }
34 # Show commandline options, if requested by --help
35 if [ "$help" == "yes" ]
36 then
37 echo "Commandline options:
38 $0
39 --version=<version>
40 --root=<path-to-root>
41 --install=yes|no|quick
42 --keep=no|yes
43 --tmpdir=<directory-to-build-package>
44 --logfile=<logging-file>"
45 exit
46 fi
48 # Check for system administrator privileges
49 check_root
51 title "Package $PACKAGE will be build as SliTaz package and installed"
53 # Fetch latest version, unless version is set by option --version
54 [ -z "$version" ] && version="latest"
56 # Install SliTaz package, unless inhibited by option --install=no
57 [ -z "$install" ] && install="yes"
59 # Delete SliTaz package file $PACKAGE-$VERSION.tazpkg after installation,
60 # unless option --keep=yes is given
61 [ -z "$keep" ] && keep="no"
63 # Directory for temporary files
64 [ -z "$tempdir" ] && TMP_DIR="/tmp/get-$PACKAGE"
66 # Logging file
67 [ -z "$logfile" ] && LOG=$TMP_DIR/get-$PACKAGE.log
69 cat <<EOT
70 Options in use:
71 root : $root/
72 version : $version
73 install package: $install
74 keep tazpkg : $keep
75 build directory: $TMP_DIR
76 logging file : $LOG
78 EOT
80 separator; newline
82 # Set WGET_URL
83 # 3.3.0 no german rpm-Package available!
84 for MIRROR in \
85 http://ftp.free.fr/mirrors/ftp.openoffice.org \
86 http://ftp-stud.hs-esslingen.de/pub/Mirrors/ftp.openoffice.org \
87 http://www.ellak.gr/pub/openoffice \
88 http://ftp.snt.utwente.nl/pub/software/openoffice \
89 http://ftp.nluug.nl/pub/office/openoffice \
90 http://ftp.isu.edu.tw/pub/OpenOffice
91 do
92 wget -O - $MIRROR/ 2> /dev/null | grep -q localized || continue
93 DIR="stable"
94 LOC=$(wget -O - $MIRROR/localized/ 2> /dev/null | \
95 grep -E ">$LANG<|>$LANG/<|>${LANG/_/-}<|>${LANG/_/-}/<|>${LANG%_*}<|>${LANG%_*}/<" | \
96 head -1 | sed 's|.*href=\"\(.*\)/\".*|\1|')
97 [ -n "$LOC" ] && DIR="localized/$LOC"
98 VERSION="$(wget -O - $MIRROR/$DIR/ 2> /dev/null | \
99 grep href=\"[0-9] | tail -1 | sed 's|.*href=\"\(.*\)/\".*|\1|' 2> /dev/null)"
100 [ -n "$VERSION" ] && break
101 done
102 TARBALL=$(wget -O - $MIRROR/$DIR/$VERSION/ 2> /dev/null | \
103 grep $PATTERN | tail -1 | sed 's|.*href=\"\(.*\)\".*|\1|')
104 # bug in sed?:
105 TARBALL=${TARBALL%%\"*}
106 echo "Archive is $TARBALL ..."
108 # Set VERSION, unless supplied by --version
109 if [ "$version" == "latest" ]
110 then
111 echo "Selecting $DIR version $VERSION from $MIRROR ..."
112 WGET_URL=$MIRROR/$DIR/$VERSION/$TARBALL
113 else
114 TARBALL=${TARBALL/$VERSION/$version}
115 VERSION=$version
116 WGET_URL="$MIRROR/$DIR/$VERSION/$TARBALL"
117 fi
119 # === Remove package, if installed ===
120 if [ is_installed ]
121 then
122 action "Removing installed version..."
123 tazpkg remove $PACKAGE --root="$root/"
124 [ ! is_installed ] &&
125 die "Can't remove installed version. Exiting."
126 fi
128 # === Fetch archive file, if not existing ===
130 CUR_DIR=$(pwd)
131 mkdir -p $TMP_DIR
132 cd $TMP_DIR
133 if [ -f $TARBALL ]
134 then
135 echo "Using existing archive file $TARBALL"
136 else
137 action "Fetching the archive"
138 newline
139 wget --no-check-certificate $WGET_URL
140 if [ ! -f $TARBALL ]
141 then
142 cd $CUR_DIR
143 rm -rf $TMP_DIR
144 echo "Could not transfer $TARBALL from $WGET_URL. Exiting."
145 exit 1
146 fi
147 fi
149 # === Extract files from archive ===
150 action "Extracting the archive"
151 newline
153 tar x -vf $TARBALL > $LOG 2>&1 || \
154 (echo "Failed to extract $TARBALL" ; exit 1)
156 status
158 # Remove archive file
159 rm -f $TARBALL
161 # Extract everything from RPMS
162 cd $TMP_DIR/*/RPMS
163 for i in *.rpm
164 do
165 if (! echo $i | egrep -qi $EXCLUDE)
166 then
167 (rpm2cpio $i | cpio -id >> $LOG 2>&1 ) &&
168 echo rm -f $i
169 fi
170 done
171 rpm2cpio desktop-integration/*freedesktop*.rpm | cpio -id >> $LOG 2>&1
173 # extracted pkg can be removed
174 rm -f desktop-integration/*freedesktop*.rpm
176 # Make the package
177 mkdir -p $PACKAGE-$VERSION/fs/usr/lib/openoffice
178 mkdir -p $PACKAGE-$VERSION/fs/usr/share
180 # use mv instead of 'cp -a' to save space
181 mv opt/openoffice* $PACKAGE-$VERSION/fs/usr/lib/openoffice
182 mv usr/share/mime $PACKAGE-$VERSION/fs/usr/share
183 mv usr/share/icons $PACKAGE-$VERSION/fs/usr/share
184 mv usr/bin $PACKAGE-$VERSION/fs/usr
186 # relocalized OOo libexec directory
187 sed -i 's#/opt/#/usr/lib/openoffice/#' \
188 $PACKAGE-$VERSION/fs/usr/bin/openoffice*
190 # Create receipt
191 cat > $PACKAGE-$VERSION/receipt <<EOT
192 # SliTaz package receipt.
194 PACKAGE="$PACKAGE"
195 VERSION="$VERSION"
196 CATEGORY="office"
197 SHORT_DESC="Productivity suite."
198 DEPENDS="$DEPENDS"
199 WEB_SITE="$WEB_SITE"
201 post_install()
202 {
203 cd \$1/usr/share/applications
204 ln -s /usr/lib/openoffice/openoffice.org3/share/xdg/base.desktop openoffice.org3-base.desktop
205 ln -s /usr/lib/openoffice/openoffice.org3/share/xdg/impress.desktop openoffice.org3-impress.desktop
206 ln -s /usr/lib/openoffice/openoffice.org3/share/xdg/writer.desktop openoffice.org3-writer.desktop
207 ln -s /usr/lib/openoffice/openoffice.org3/share/xdg/calc.desktop openoffice.org3-calc.desktop
208 ln -s /usr/lib/openoffice/openoffice.org3/share/xdg/math.desktop openoffice.org3-math.desktop
209 ln -s /usr/lib/openoffice/openoffice.org3/share/xdg/draw.desktop openoffice.org3-draw.desktop
210 ln -s /usr/lib/openoffice/openoffice.org3/share/xdg/printeradmin.desktop openoffice.org3-printeradmin.desktop
212 cd \$1/usr/bin
213 ln -sf /usr/lib/openoffice/openoffice.org3/program/soffice
214 }
216 post_remove()
217 {
218 rm -f \$1/usr/share/applications/openoffice.org3-*
219 }
221 EOT
223 fake_install()
224 {
225 mkdir -p $root/var/lib/tazpkg/installed/$PACKAGE
226 echo "00000000000000000000000000000000 $PACKAGE-$VERSION.tazpkg" >> \
227 $root/var/lib/tazpkg/installed.md5
228 [ -s $1/description.txt $root/var/lib/tazpkg/installed/$PACKAGE
229 ( cd fs ; find *) | sed 's|^|/|' > \
230 $root/var/lib/tazpkg/installed/$PACKAGE/files.list
231 if grep -q ^CONFIG_FILES= $1/receipt
232 then
233 cd fs
234 find $( . ./receipt ; echo " $CONFIG_FILES" | sed 's# /# #g') |\
235 cpio -o -H newc | gzip -9 > \
236 $root/var/lib/tazpkg/installed/$PACKAGE/volatile.cpio.gz
237 for i in $( . ./receipt ; echo $CONFIG_FILES)
238 do
239 [ -e $root$i ] && rm -rf .$i
240 done
241 cd ..
242 fi
243 sed -i "s/^PACKAGE=/UNPACKED_SIZE=\"$(du -chs $1 | sed '$!d;s/.total//')\"\n&/" \
244 $1/receipt
245 cp $1/receipt $root/var/lib/tazpkg/installed/$PACKAGE
246 echo "Compute md5sum..."
247 find fs -type f | xargs md5sum | sed 's| fs/| /|' > \
248 $root/var/lib/tazpkg/installed/$PACKAGE/md5sum
249 echo "Move files..."
250 ( cd $1/fs ; find ) | while read file
251 do
252 [ -e $1/fs/$file -a ! -e $root/$file ] &&
253 mv $1/fs/$file $(dirname $root/$file)
254 done
255 }
257 [ "$install" == "quick" ] &&
258 fake_install $PACKAGE-$VERSION && return 0
260 # Pack
261 tazpkg pack $PACKAGE-$VERSION
262 # Remove package tree
263 rm -rf $PACKAGE-$VERSION
265 # === Install the SliTaz package ===
266 [ "$install" == "yes" ] &&
267 tazpkg install $PACKAGE-$VERSION.tazpkg --root="$root"
269 # === Cleanup ===
270 # Preserve package file, if requested
271 [ "$keep" == "yes" ] &&
272 ( mv $PACKAGE-$VERSION.tazpkg $CUR_DIR &&
273 echo Saved $PACKAGE-$VERSION.tazpkg to $CUR_DIR )
275 # Remove temporary build directory
276 cd $CUR_DIR
277 rm -rf $TMP_DIR