get-scripts annotate libreoffice @ rev 40

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