get-scripts view libreoffice @ rev 31

javajre: tiny fix
author Pascal Bellard <pascal.bellard@slitaz.org>
date Mon Jan 26 10:44:20 2015 +0100 (2015-01-26)
parents 2e6fc10e1b24
children 6ca05e6839e1
line source
1 #!/bin/sh
2 # get-LibreOffice - install LibreOffice excl. KDE/Gnome integration & test suite.
3 #
4 # (C) 2010 SliTaz - GNU General Public License v3.
5 # Author : Ben Arnold <ben@seawolfsanctuary.com>
6 # via : get-OpenOffice3 (Eric Joseph-Alexandre <erjo@slitaz.org>)
7 #
9 PACKAGE="LibreOffice"
10 WEB_SITE="http://www.libreoffice.org"
11 CATEGORY="office"
12 SHORT_DESC="Productivity suite."
13 DEPENDS="cups"
14 SUGGESTED="java6-jre"
15 DIR="stable"
16 PREFIX="LibreOffice"
17 SUFFIX="Linux_x86_rpm.tar.gz"
18 WGET_URL="http://download.documentfoundation.org/libreoffice/$DIR"
19 LICENSE="LGPL3"
21 VERSION="$(basename $(wget -O - $WGET_URL/ 2> /dev/null | \
22 sed '/href=\"[0-9]/!d;s/.*href=\"//;s/[/\">].*//' | tail -1))"
23 if [ -z "$VERSION" ]; then
24 abort_package "Can't detect an appropriate version. The version numbering or URL may have changed. Aborted."
25 fi
26 VER="${VERSION/\-/}" # without hyphens
29 TARBALL="${PREFIX}_${VER}_${SUFFIX}"
31 for LOC in ${LANG/_/-} ${LANG%_*}; do
32 L_SUFFIX="Linux_x86_rpm_langpack_$LOC.tar.gz"
33 L_TARBALL="${PREFIX}_${VER}_${L_SUFFIX}"
34 LANG_URL="$WGET_URL/${VERSION}/rpm/x86/${L_TARBALL}"
35 busybox wget -s $LANG_URL 2> /dev/null || continue
36 echo "Added $LANG ($LOC)."
37 break
38 done
39 WGET_URL="$WGET_URL/${VERSION}/rpm/x86/${TARBALL}"
41 CUR_DIR=$(pwd)
42 TEMP_DIR="/tmp/$PACKAGE.$$"
43 SOURCE_DIR="/tmp/src.$$"
44 EXCLUDE="kde|gnome|test"
45 LOG="/tmp/$(basename $0 .sh).log"
47 # Check if we have the tarball before.
48 if [ ! -f $SOURCE_DIR/$TARBALL ]; then
49 echo "Downloading LibreOffice tarball (it's time to have a break)... "
50 # Check if $SOURCE_DIR exist
51 test -d $SOURCE_DIR || mkdir -p $SOURCE_DIR
52 # Get the file.
53 wget -c $WGET_URL -O $SOURCE_DIR/$TARBALL
54 if [ -n $L_TARBALL ] ; then # Are we localised?
55 wget -c $LANG_URL -O $SOURCE_DIR/$L_TARBALL
56 fi
57 status
58 fi
59 if [ ! -f $SOURCE_DIR/$TARBALL ]; then
60 rm -rf $SOURCE_DIR
61 abort_package "Could not download $TARBALL. Exiting."
62 fi
64 echo -n "Extracting files (this may take a while): "
66 # Creates TEMP_DIR and extract tarball
67 mkdir -p $TEMP_DIR
68 for TB in $TARBALL $L_TARBALL ; do
69 tar xvzf $SOURCE_DIR/$TB -C $TEMP_DIR > $LOG 2>&1 ||
70 abort_package "Failed to extract $TB"
71 done
73 # Get version found in archive (often directory is still RC version when final is present)
74 ARCHIVED_VERSION=$(find $TEMP_DIR -type d 2> /dev/null | sed "/$PREFIX/!d;\$!d;s/_/ /g" | awk '{print $2}')
75 echo -n "(found v${ARCHIVED_VERSION})"
77 # Consolidate localisations into main package
78 if [ -n $L_TARBALL ] ; then # Are we localised?
79 TARBALL_NAME="${TARBALL/.tar.gz/}"
80 L_TARBALL_NAME="${L_TARBALL/.tar.gz/}"
81 mv -f $TEMP_DIR/${L_TARBALL_NAME/$VERSION/$ARCHIVED_VERSION}/RPMS/*.rpm $TEMP_DIR/${TARBALL_NAME/$VERSION/$ARCHIVED_VERSION}/RPMS/
82 fi
83 status
85 # Extracted pkg can be removed: Save RAM
86 rm -rf $SOURCE_DIR
88 # Extract everything from RPMS
89 cd $TEMP_DIR/${TARBALL_NAME/$VERSION/$ARCHIVED_VERSION}/RPMS
90 for i in *.rpm
91 do
92 if (! echo $i | egrep -qi $EXCLUDE); then
93 echo -n "."
94 (rpm2cpio $i | cpio -id >> $LOG 2>&1 ) && rm -f $i
95 fi
96 done
97 rpm2cpio libobasis*-gnome-integration*.rpm | cpio -id >> $LOG 2>&1
99 # extracted pkg can be removed: Save RAM
100 rm -f libobasis*.rpm
102 status
103 echo -n "Preparing package... "
105 # Make the package
106 mkdir -p $PACKAGE-$VERSION/fs/usr/lib $PACKAGE-$VERSION/fs/usr/share
108 # use mv instead of 'cp -a' to save RAM
109 mv opt/libreoffice* $PACKAGE-$VERSION/fs/usr/lib/libreoffice
110 mv usr/share/mime $PACKAGE-$VERSION/fs/usr/share
111 mv usr/share/icons $PACKAGE-$VERSION/fs/usr/share
112 mv usr/bin $PACKAGE-$VERSION/fs/usr
114 # relocalized libexec directory
115 bin=$(echo $PACKAGE-$VERSION/fs/usr/bin/libreoffice${VERSION%.*})
116 if [ -L $bin ]; then
117 target=$(readlink $bin)
118 rm -f $bin
119 ln -s ${target/opt/usr\/lib\/libreoffice} $bin
120 else
121 sed -i 's#/opt/#/usr/lib/libreoffice/#' $bin
122 fi
124 # Create receipt
125 cat > $PACKAGE-$VERSION/receipt <<EOT
126 # SliTaz package receipt.
128 PACKAGE="$PACKAGE"
129 VERSION="$VERSION"
130 CATEGORY="$CATEGORY"
131 SHORT_DESC="$SHORT_DESC"
132 WEB_SITE="$WEB_SITE"
134 DEPENDS="$DEPENDS"
135 SUGGESTED="$SUGGESTED"
137 post_install()
138 {
139 cd \$1/usr/share/applications
140 ln -s /usr/lib/libreoffice*/share/xdg/base.desktop libreoffice-base.desktop
141 ln -s /usr/lib/libreoffice*/share/xdg/impress.desktop libreoffice-impress.desktop
142 ln -s /usr/lib/libreoffice*/share/xdg/writer.desktop libreoffice-writer.desktop
143 ln -s /usr/lib/libreoffice*/share/xdg/calc.desktop libreoffice-calc.desktop
144 ln -s /usr/lib/libreoffice*/share/xdg/math.desktop libreoffice-math.desktop
145 ln -s /usr/lib/libreoffice*/share/xdg/draw.desktop libreoffice-draw.desktop
146 ln -s /usr/lib/libreoffice*/share/xdg/printeradmin.desktop libreoffice-printeradmin.desktop
147 chmod +x /usr/lib/libreoffice*/share/xdg/*.desktop
149 cd \$1/usr/bin
150 ln -sf /usr/lib/libreoffice/program/soffice
151 ln -sf /usr/lib/libreoffice/program/soffice libreoffice${VERSION%.*}
152 }
154 post_remove()
155 {
156 rm -f \$1/usr/share/applications/libreoffice-*
157 }
159 EOT
160 status
161 set +e