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

Add mirror-tools
author Pascal Bellard <pascal.bellard@slitaz.org>
date Wed Nov 19 10:32:58 2008 +0000 (2008-11-19)
parents 81afad9999f9
children a373634791a5
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 VERSION="3.0.0"
10 URL="http://www.openoffice.org"
11 ROOT="$1"
13 if [ "$LANG" = "fr_FR" ]; then
14 TARBALL="OOo_${VERSION}_LinuxIntel_install_fr.tar.gz"
15 WGET_URL="ftp://ftp.proxad.net/mirrors/ftp.openoffice.org/localized/fr/${VERSION}/${TARBALL}"
16 else
17 TARBALL="OOo_${VERSION}_LinuxIntel_install_en-US.tar.gz"
18 WGET_URL="ftp://ftp.proxad.net/mirrors/ftp.openoffice.org/stable/${VERSION}/${TARBALL}"
19 fi
21 TEMP_DIR="/home/slitaz/build/$PACKAGE.$$"
22 SOURCE_DIR="/home/slitaz/src"
23 EXCLUDE="kde|gnome|test"
24 LOG="/tmp/$(basename $0 .sh).log"
26 # Status function with color (supported by Ash).
27 status()
28 {
29 local CHECK=$?
30 echo -en "\\033[70G[ "
31 if [ $CHECK = 0 ]; then
32 echo -en "\\033[1;33mOK"
33 else
34 echo -en "\\033[1;31mFailed"
35 fi
36 echo -e "\\033[0;39m ]"
37 return $CHECK
38 }
40 # Check if user is root to install, or remove packages.
41 check_root()
42 {
43 if test $(id -u) != 0 ; then
44 echo -e "\nYou must be root to run `basename $0` with this option."
45 echo -e "Please use 'su' and root password to become super-user.\n"
46 exit 0
47 fi
48 }
50 check_if_installed()
51 {
52 # Avoid reinstall
53 if [ -d $ROOT/var/lib/tazpkg/installed/$PACKAGE ];then
54 return 0
55 else
56 return 1
57 fi
58 }
60 #We need to bee root
61 check_root
63 #check if package already installed
64 if (check_if_installed $PACKAGE); then
65 echo "$PACKAGE is already installed."
66 [ -n "$ROOT" ] && exit 0
67 echo -n "Would you like to remove and reinstall this package [y/n]? "
68 read answer
69 case "$answer" in
70 y|Y)
71 tazpkg remove $PACKAGE ;;
72 *)
73 exit 0 ;;
74 esac
76 fi
79 # Check if we have the tarball before.
80 if [ ! -f $SOURCE_DIR/$TARBALL ]; then
81 echo "Downloading OppenOffice.org tarball (it's time to have a break)... "
82 #Check if $SOURCE_DIR exist
83 test -d $SOURCE_DIR || mkdir -p $SOURCE_DIR
84 # Get the file.
85 wget -c $WGET_URL -O $SOURCE_DIR/$TARBALL
86 status
87 fi
91 # Creates TEM_DIR and extract tarball
92 mkdir -p $TEMP_DIR
93 echo -n "Extract files from archive..."
94 tar xvzf $SOURCE_DIR/$TARBALL -C $TEMP_DIR > $LOG 2>&1 || \
95 (echo "Failed to extract $TARBALL" ; exit 1)
96 status
98 cd $TEMP_DIR/*/RPMS
100 # Extract everything from RPMS
101 for i in *.rpm
102 do
103 if (! echo $i | egrep -qi $EXCLUDE); then
104 rpm2cpio $i | cpio -id >> $LOG 2>&1
105 fi
106 done
107 rpm2cpio desktop-integration/*freedesktop*.rpm | cpio -id >> $LOG 2>&1
109 # Make the package
110 mkdir -p $PACKAGE-$VERSION/fs/usr/lib/openoffice \
111 $PACKAGE-$VERSION/fs/usr/share
113 cp -a opt/openoffice* $PACKAGE-$VERSION/fs/usr/lib/openoffice
114 cp -a usr/share/mime $PACKAGE-$VERSION/fs/usr/share
115 cp -a usr/share/icons $PACKAGE-$VERSION/fs/usr/share
116 cp -a usr/bin $PACKAGE-$VERSION/fs/usr
118 # relocalized OOo libexec directory
119 sed -i 's#/opt/#/usr/lib/openoffice/#' $PACKAGE-$VERSION/fs/usr/bin/openoffice*
121 # Create receipt
122 cat > $PACKAGE-$VERSION/receipt <<EOT
123 # SliTaz package receipt.
125 PACKAGE="$PACKAGE"
126 VERSION="$VERSION"
127 CATEGORY="office"
128 SHORT_DESC="Productivity suite."
129 DEPENDS=""
130 WEB_SITE="$URL"
132 post_install()
133 {
134 cd /usr/share/applications
135 ln -s /usr/lib/openoffice/openoffice.org3/share/xdg/base.desktop openoffice.org3-base.desktop
136 ln -s /usr/lib/openoffice/openoffice.org3/share/xdg/impress.desktop openoffice.org3-impress.desktop
137 ln -s /usr/lib/openoffice/openoffice.org3/share/xdg/writer.desktop openoffice.org3-writer.desktop
138 ln -s /usr/lib/openoffice/openoffice.org3/share/xdg/calc.desktop openoffice.org3-calc.desktop
139 ln -s /usr/lib/openoffice/openoffice.org3/share/xdg/math.desktop openoffice.org3-math.desktop
140 ln -s /usr/lib/openoffice/openoffice.org3/share/xdg/draw.desktop openoffice.org3-draw.desktop
141 ln -s /usr/lib/openoffice/openoffice.org3/share/xdg/printeradmin.desktop openoffice.org3-printeradmin.desktop
143 cd /usr/bin
144 ln -sf /usr/lib/openoffice/openoffice.org3/program/soffice
145 }
147 post_remove()
148 {
149 rm -f /usr/share/applications/openoffice.org3-*
150 }
152 EOT
154 # Pack
155 tazpkg pack $PACKAGE-$VERSION
157 # Install pseudo package
158 tazpkg install $PACKAGE-$VERSION.tazpkg --root=$ROOT
160 # Clean
161 rm -rf $TEMP_DIR
162 rm -rf $PACKAGE-$VERSION