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

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