get-scripts view openoffice3 @ rev 26
Add apk-studio
author | Pascal Bellard <pascal.bellard@slitaz.org> |
---|---|
date | Wed Nov 19 13:55:21 2014 +0100 (2014-11-19) |
parents | 2e6fc10e1b24 |
children | 6ca05e6839e1 |
line source
1 #!/bin/sh
2 # get-OpenOffice3, install everything for OpenOffice.org exept KDE/Gnome integration and testsuite.
3 #
4 # (C) 2008 SliTaz - GNU General Public License v3.
5 #
6 # Author : Eric Joseph-Alexandre <erjo@slitaz.org>
8 PACKAGE="OpenOffice3"
9 LICENSE="Apache"
10 URL="http://www.openoffice.org"
11 PATTERN="Linux_x86_install-rpm"
13 for MIRROR in \
14 http://mirror.switch.ch/ftp/mirror/OpenOffice \
15 http://openoffice.cict.fr \
16 http://wwwftp.ciril.fr/pub/openoffice \
17 http://artfiles.org/openoffice.org \
18 http://vesta.informatik.rwth-aachen.de/ftp/pub/mirror/OpenOffice \
19 http://ftp.ntua.gr/pub/OpenOffice \
20 http://ftp.iitm.ac.in/openoffice \
21 http://www.ring.gr.jp/archives/misc/openoffice \
22 http://ftp.nluug.nl/pub/office/openoffice \
24 do
25 wget -O - $MIRROR/ 2> /dev/null | grep -q localized || continue
26 DIR="stable"
27 LOC=$(wget -O - $MIRROR/localized/ 2> /dev/null | \
28 grep -E ">$LANG/|>${LANG/_/-}/|>${LANG%_*}/" | \
29 head -1 | sed 's/.*href=\"\(.*\)\/\".*/\1/')
30 [ -n "$LOC" ] && DIR="localized/$LOC"
31 VERSION="$(basename $(wget -O - $MIRROR/$DIR/ 2> /dev/null | grep \
32 href=\"[0-9] | tail -1 | sed 's/.*href=\"\(.*\)\".*/\1/') 2> /dev/null)"
33 [ -n "$VERSION" ] && break
34 done
36 if [ -z "$VERSION" ]; then
37 abort_package "Can't find VERSION. Abort."
38 fi
39 echo "Selecting $DIR version $VERSION ..."
40 TARBALL="$(wget -O - $MIRROR/$DIR/$VERSION/ \
41 2> /dev/null | grep $PATTERN | tail -1 | sed 's/.*href=\"\(.*\)\".*/\1/')"
42 echo "Archive is $TARBALL ..."
43 WGET_URL=$MIRROR/$DIR/$VERSION/$TARBALL
45 TEMP_DIR="/tmp/$PACKAGE.$$"
46 CUR_DIR=$(pwd)
47 SOURCE_DIR="/tmp/src.$$"
48 EXCLUDE="kde|gnome|test"
49 LOG="/tmp/$(basename $0 .sh).log"
51 # Check if we have the tarball before.
52 if [ ! -f $SOURCE_DIR/$TARBALL ]; then
53 echo "Downloading OppenOffice.org tarball (it's time to have a break)... "
54 #Check if $SOURCE_DIR exist
55 test -d $SOURCE_DIR || mkdir -p $SOURCE_DIR
56 # Get the file.
57 wget -c $WGET_URL -O $SOURCE_DIR/$TARBALL
58 status
59 fi
60 if [ ! -f $SOURCE_DIR/$TARBALL ]; then
61 rm -rf $SOURCE_DIR
62 abort_package "Could not download $TARBALL. Exiting."
63 fi
65 # Creates TEMP_DIR and extract tarball
66 mkdir -p $TEMP_DIR
67 echo -n "Extract files from archive..."
68 tar xvzf $SOURCE_DIR/$TARBALL -C $TEMP_DIR > $LOG 2>&1 ||
69 abort_package "Failed to extract $TARBALL"
70 status
72 # extracted pkg can be removed: Save RAM
73 rm -rf $SOURCE_DIR
75 cd $TEMP_DIR/*/RPMS
77 # Extract everything from RPMS
78 for i in *.rpm
79 do
80 if (! echo $i | egrep -qi $EXCLUDE); then
81 (rpm2cpio $i | cpio -id >> $LOG 2>&1 ) && rm -f $i
82 fi
83 done
84 rpm2cpio desktop-integration/*freedesktop*.rpm | cpio -id >> $LOG 2>&1
86 # extracted pkg can be removed: Save RAM
87 rm -f desktop-integration/*freedesktop*.rpm
90 # Make the package
91 mkdir -p $PACKAGE-$VERSION/fs/usr/lib/openoffice \
92 $PACKAGE-$VERSION/fs/usr/share
94 # use mv instead of 'cp -a' to save RAM
95 mv opt/openoffice* $PACKAGE-$VERSION/fs/usr/lib/openoffice
96 mv usr/share/mime $PACKAGE-$VERSION/fs/usr/share
97 mv usr/share/icons $PACKAGE-$VERSION/fs/usr/share
98 mv usr/bin $PACKAGE-$VERSION/fs/usr
100 # relocalized OOo libexec directory
101 sed -i 's#/opt/#/usr/lib/openoffice/#' $PACKAGE-$VERSION/fs/usr/bin/openoffice*
103 # Create receipt
104 cat > $PACKAGE-$VERSION/receipt <<EOT
105 # SliTaz package receipt.
107 PACKAGE="$PACKAGE"
108 VERSION="$VERSION"
109 CATEGORY="office"
110 SHORT_DESC="Productivity suite."
111 DEPENDS="java-jre"
112 WEB_SITE="$URL"
114 post_install()
115 {
116 cd \$1/usr/share/applications
117 ln -s /usr/lib/openoffice/openoffice.org3/share/xdg/base.desktop openoffice.org3-base.desktop
118 ln -s /usr/lib/openoffice/openoffice.org3/share/xdg/impress.desktop openoffice.org3-impress.desktop
119 ln -s /usr/lib/openoffice/openoffice.org3/share/xdg/writer.desktop openoffice.org3-writer.desktop
120 ln -s /usr/lib/openoffice/openoffice.org3/share/xdg/calc.desktop openoffice.org3-calc.desktop
121 ln -s /usr/lib/openoffice/openoffice.org3/share/xdg/math.desktop openoffice.org3-math.desktop
122 ln -s /usr/lib/openoffice/openoffice.org3/share/xdg/draw.desktop openoffice.org3-draw.desktop
123 ln -s /usr/lib/openoffice/openoffice.org3/share/xdg/printeradmin.desktop openoffice.org3-printeradmin.desktop
125 cd \$1/usr/bin
126 ln -sf /usr/lib/openoffice/openoffice.org3/program/soffice
127 }
129 post_remove()
130 {
131 rm -f \$1/usr/share/applications/openoffice.org3-*
132 }
134 EOT
136 fake_install()
137 {
138 mkdir -p $ROOT/var/lib/tazpkg/installed/$PACKAGE
139 echo "00000000000000000000000000000000 $PACKAGE-$VERSION.tazpkg" >> \
140 $ROOT/var/lib/tazpkg/installed.md5
141 [ -s $1/description.txt $ROOT/var/lib/tazpkg/installed/$PACKAGE
142 ( cd fs ; find *) | sed 's|^|/|' > \
143 $ROOT/var/lib/tazpkg/installed/$PACKAGE/files.list
144 if grep -q ^CONFIG_FILES= $1/receipt ; then
145 cd fs
146 find $( . ./receipt ; echo " $CONFIG_FILES" | sed 's| /| |g') |\
147 cpio -o -H newc | gzip -9 > \
148 $ROOT/var/lib/tazpkg/installed/$PACKAGE/volatile.cpio.gz
149 for i in $( . ./receipt ; echo $CONFIG_FILES) ; do
150 [ -e $ROOT$i ] && rm -rf .$i
151 done
152 cd ..
153 fi
154 sed -i "s/^PACKAGE=/UNPACKED_SIZE=\"$(du -chs $1 | sed '$!d;s/.total//')\"\n&/" \
155 $1/receipt
156 cp $1/receipt $ROOT/var/lib/tazpkg/installed/$PACKAGE
157 echo "Compute md5sum..."
158 find fs -type f | xargs md5sum | sed 's| fs/| /|' > \
159 $ROOT/var/lib/tazpkg/installed/$PACKAGE/md5sum
160 echo "Move files..."
161 ( cd $1/fs ; find ) | while read file ; do
162 [ -e $1/fs/$file -a ! -e $ROOT/$file ] &&
163 mv $1/fs/$file $(dirname $ROOT/$file)
164 done
165 }
166 set +e