get-scripts view libreoffice @ rev 61

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