get-scripts view libreoffice @ rev 36

bitcoin: update
author Pascal Bellard <pascal.bellard@slitaz.org>
date Wed Apr 29 16:35:57 2015 +0200 (2015-04-29)
parents 8b66f6a75a05
children 1b30389a08fc
line source
1 SHORT_DESC="Productivity suite."
2 WEB_SITE="http://www.libreoffice.org"
3 # end of get.list data
4 #!/bin/sh
5 # get-LibreOffice - install LibreOffice excl. KDE/Gnome integration & test suite.
6 #
7 # (C) 2010 SliTaz - GNU General Public License v3.
8 # Author : Ben Arnold <ben@seawolfsanctuary.com>
9 # via : get-OpenOffice3 (Eric Joseph-Alexandre <erjo@slitaz.org>)
10 #
12 PACKAGE="LibreOffice"
13 CATEGORY="office"
14 DEPENDS="cups"
15 SUGGESTED="java6-jre"
16 DIR="stable"
17 PREFIX="LibreOffice"
18 SUFFIX="Linux_x86_rpm.tar.gz"
19 WGET_URL="http://download.documentfoundation.org/libreoffice/$DIR"
20 LICENSE="LGPL3"
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 VER="${VERSION/\-/}" # without hyphens
30 TARBALL="${PREFIX}_${VER}_${SUFFIX}"
32 for LOC in ${LANG/_/-} ${LANG%_*}; do
33 L_SUFFIX="Linux_x86_rpm_langpack_$LOC.tar.gz"
34 L_TARBALL="${PREFIX}_${VER}_${L_SUFFIX}"
35 LANG_URL="$WGET_URL/${VERSION}/rpm/x86/${L_TARBALL}"
36 busybox wget -s $LANG_URL 2> /dev/null || continue
37 echo "Added $LANG ($LOC)."
38 break
39 done
40 WGET_URL="$WGET_URL/${VERSION}/rpm/x86/${TARBALL}"
42 CUR_DIR=$(pwd)
43 TEMP_DIR="/tmp/$PACKAGE.$$"
44 SOURCE_DIR="/tmp/src.$$"
45 EXCLUDE="kde|gnome|test"
46 LOG="/tmp/$(basename $0 .sh).log"
48 # Check if we have the tarball before.
49 if [ ! -f $SOURCE_DIR/$TARBALL ]; then
50 echo "Downloading LibreOffice tarball (it's time to have a break)... "
51 # Check if $SOURCE_DIR exist
52 test -d $SOURCE_DIR || mkdir -p $SOURCE_DIR
53 # Get the file.
54 wget -c $WGET_URL -O $SOURCE_DIR/$TARBALL
55 if [ -n $L_TARBALL ] ; then # Are we localised?
56 wget -c $LANG_URL -O $SOURCE_DIR/$L_TARBALL
57 fi
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 echo -n "Extracting files (this may take a while): "
67 # Creates TEMP_DIR and extract tarball
68 mkdir -p $TEMP_DIR
69 for TB in $TARBALL $L_TARBALL ; do
70 tar xvzf $SOURCE_DIR/$TB -C $TEMP_DIR > $LOG 2>&1 ||
71 abort_package "Failed to extract $TB"
72 done
74 # Get version found in archive (often directory is still RC version when final is present)
75 ARCHIVED_VERSION=$(find $TEMP_DIR -type d 2> /dev/null | sed "/$PREFIX/!d;\$!d;s/_/ /g" | awk '{print $2}')
76 echo -n "(found v${ARCHIVED_VERSION})"
78 # Consolidate localisations into main package
79 if [ -n $L_TARBALL ] ; then # Are we localised?
80 TARBALL_NAME="${TARBALL/.tar.gz/}"
81 L_TARBALL_NAME="${L_TARBALL/.tar.gz/}"
82 mv -f $TEMP_DIR/${L_TARBALL_NAME/$VERSION/$ARCHIVED_VERSION}/RPMS/*.rpm $TEMP_DIR/${TARBALL_NAME/$VERSION/$ARCHIVED_VERSION}/RPMS/
83 fi
84 status
86 # Extracted pkg can be removed: Save RAM
87 rm -rf $SOURCE_DIR
89 # Extract everything from RPMS
90 cd $TEMP_DIR/${TARBALL_NAME/$VERSION/$ARCHIVED_VERSION}/RPMS
91 for i in *.rpm
92 do
93 if (! echo $i | egrep -qi $EXCLUDE); then
94 echo -n "."
95 (rpm2cpio $i | cpio -id >> $LOG 2>&1 ) && rm -f $i
96 fi
97 done
98 rpm2cpio libobasis*-gnome-integration*.rpm | cpio -id >> $LOG 2>&1
100 # extracted pkg can be removed: Save RAM
101 rm -f libobasis*.rpm
103 status
104 echo -n "Preparing package... "
106 # Make the package
107 mkdir -p $PACKAGE-$VERSION/fs/usr/lib $PACKAGE-$VERSION/fs/usr/share
109 # use mv instead of 'cp -a' to save RAM
110 mv opt/libreoffice* $PACKAGE-$VERSION/fs/usr/lib/libreoffice
111 mv usr/share/mime $PACKAGE-$VERSION/fs/usr/share
112 mv usr/share/icons $PACKAGE-$VERSION/fs/usr/share
113 mv usr/bin $PACKAGE-$VERSION/fs/usr
115 # relocalized libexec directory
116 bin=$(echo $PACKAGE-$VERSION/fs/usr/bin/libreoffice${VERSION%.*})
117 if [ -L $bin ]; then
118 target=$(readlink $bin)
119 rm -f $bin
120 ln -s ${target/opt/usr\/lib\/libreoffice} $bin
121 else
122 sed -i 's#/opt/#/usr/lib/libreoffice/#' $bin
123 fi
125 # Create receipt
126 cat > $PACKAGE-$VERSION/receipt <<EOT
127 # SliTaz package receipt.
129 PACKAGE="$PACKAGE"
130 VERSION="$VERSION"
131 CATEGORY="$CATEGORY"
132 SHORT_DESC="$SHORT_DESC"
133 WEB_SITE="$WEB_SITE"
135 DEPENDS="$DEPENDS"
136 SUGGESTED="$SUGGESTED"
138 post_install()
139 {
140 cd \$1/usr/share/applications
141 ln -s /usr/lib/libreoffice*/share/xdg/base.desktop libreoffice-base.desktop
142 ln -s /usr/lib/libreoffice*/share/xdg/impress.desktop libreoffice-impress.desktop
143 ln -s /usr/lib/libreoffice*/share/xdg/writer.desktop libreoffice-writer.desktop
144 ln -s /usr/lib/libreoffice*/share/xdg/calc.desktop libreoffice-calc.desktop
145 ln -s /usr/lib/libreoffice*/share/xdg/math.desktop libreoffice-math.desktop
146 ln -s /usr/lib/libreoffice*/share/xdg/draw.desktop libreoffice-draw.desktop
147 ln -s /usr/lib/libreoffice*/share/xdg/printeradmin.desktop libreoffice-printeradmin.desktop
148 chmod +x /usr/lib/libreoffice*/share/xdg/*.desktop
150 cd \$1/usr/bin
151 ln -sf /usr/lib/libreoffice/program/soffice
152 ln -sf /usr/lib/libreoffice/program/soffice libreoffice${VERSION%.*}
153 }
155 post_remove()
156 {
157 rm -f \$1/usr/share/applications/libreoffice-*
158 }
160 EOT
161 status
162 set +e