get-scripts view libreoffice @ rev 80

libreoffice: fix menu entries (again)
author Pascal Bellard <pascal.bellard@slitaz.org>
date Sun Jun 09 11:40:00 2019 +0200 (2019-06-09)
parents 918e81123812
children
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 PACKAGE="LibreOffice"
7 DEPENDS="cups"
8 SUGGESTED="java6-jre"
9 DIR="stable"
10 PREFIX="LibreOffice"
11 SUFFIX="Linux_x86_rpm.tar.gz"
12 WGET_URL="http://download.documentfoundation.org/libreoffice/$DIR"
14 VERSION="$(basename $(wget -O - $WGET_URL/ 2> /dev/null | \
15 sed '/href=\"[0-9]/!d;s/.*href=\"//;s/[/\">].*//' | tail -1))"
16 if [ -z "$VERSION" ]; then
17 abort_package "Can't detect an appropriate version. The version numbering or URL may have changed. Aborted."
18 fi
19 [ "$1" = "--get-version" ] && echo $VERSION && exit
20 VER="${VERSION/\-/}" # without hyphens
23 TARBALL="${PREFIX}_${VER}_${SUFFIX}"
25 for LOC in ${LANG/_/-} ${LANG%_*}; do
26 L_SUFFIX="Linux_x86_rpm_langpack_$LOC.tar.gz"
27 L_TARBALL="${PREFIX}_${VER}_${L_SUFFIX}"
28 LANG_URL="$WGET_URL/${VERSION}/rpm/x86/${L_TARBALL}"
29 busybox wget -s $LANG_URL 2> /dev/null || continue
30 echo "Added $LANG ($LOC)."
31 break
32 done
33 WGET_URL="$WGET_URL/${VERSION}/rpm/x86/${TARBALL}"
35 CUR_DIR=$(pwd)
36 TEMP_DIR="/tmp/$PACKAGE.$$"
37 SOURCE_DIR="/tmp/src.$$"
38 EXCLUDE="kde|gnome|test"
39 LOG="/tmp/$(basename $0 .sh).log"
41 # Check if we have the tarball before.
42 if [ ! -f $SOURCE_DIR/$TARBALL ]; then
43 echo "Downloading LibreOffice tarball (it's time to have a break)... "
44 # Check if $SOURCE_DIR exist
45 test -d $SOURCE_DIR || mkdir -p $SOURCE_DIR
46 # Get the file.
47 wget -c $WGET_URL -O $SOURCE_DIR/$TARBALL
48 if [ -n $L_TARBALL ] ; then # Are we localised?
49 wget -c $LANG_URL -O $SOURCE_DIR/$L_TARBALL
50 fi
51 status
52 fi
53 if [ ! -f $SOURCE_DIR/$TARBALL ]; then
54 rm -rf $SOURCE_DIR
55 abort_package
56 fi
58 echo -n "Extracting files (this may take a while): "
60 # Creates TEMP_DIR and extract tarball
61 mkdir -p $TEMP_DIR
62 for TB in $TARBALL $L_TARBALL ; do
63 tar xvzf $SOURCE_DIR/$TB -C $TEMP_DIR > $LOG 2>&1 ||
64 abort_package "Failed to extract $TB"
65 done
67 # Get version found in archive (often directory is still RC version when final is present)
68 ARCHIVED_VERSION=$(find $TEMP_DIR -type d 2> /dev/null | sed "/$PREFIX/!d;\$!d;s/_/ /g" | awk '{print $2}')
69 echo -n "(found v${ARCHIVED_VERSION})"
71 # Consolidate localisations into main package
72 if [ -n $L_TARBALL ] ; then # Are we localised?
73 TARBALL_NAME="${TARBALL/.tar.gz/}"
74 L_TARBALL_NAME="${L_TARBALL/.tar.gz/}"
75 mv -f $TEMP_DIR/${L_TARBALL_NAME/$VERSION/$ARCHIVED_VERSION}/RPMS/*.rpm $TEMP_DIR/${TARBALL_NAME/$VERSION/$ARCHIVED_VERSION}/RPMS/
76 fi
77 status
79 # Extracted pkg can be removed: Save RAM
80 rm -rf $SOURCE_DIR
82 # Extract everything from RPMS
83 cd $TEMP_DIR/${TARBALL_NAME/$VERSION/$ARCHIVED_VERSION}/RPMS
84 for i in *.rpm
85 do
86 if (! echo $i | egrep -qi $EXCLUDE); then
87 echo -n "."
88 (rpm2cpio $i | cpio -id >> $LOG 2>&1 ) && rm -f $i
89 fi
90 done
91 rpm2cpio libobasis*-gnome-integration*.rpm | cpio -id >> $LOG 2>&1
93 # extracted pkg can be removed: Save RAM
94 rm -f libobasis*.rpm
96 status
97 echo -n "Preparing package... "
99 # Make the package
100 USR=$PACKAGE-$VERSION/fs/usr
101 mkdir -p $USR/lib $USR/share
103 # use mv instead of 'cp -a' to save RAM
104 mv opt/libreoffice* $USR/lib/libreoffice
105 mv usr/share/mime usr/share/icons $USR/share
106 mv usr/bin $USR
108 # relocalized libexec directory
109 bin=$(echo $USR/bin/libreoffice${VERSION%.*})
110 if [ -L $bin ]; then
111 target=$(readlink $bin)
112 rm -f $bin
113 ln -s ${target/opt/usr\/lib\/libreoffice} $bin
114 else
115 sed -i 's#/opt/#/usr/lib/libreoffice/#' $bin
116 fi
118 # Create receipt
119 cat > $PACKAGE-$VERSION/receipt <<EOT
120 # SliTaz package receipt.
122 PACKAGE="$PACKAGE"
123 VERSION="$VERSION"
124 CATEGORY="$CATEGORY"
125 SHORT_DESC="$SHORT_DESC"
126 WEB_SITE="$WEB_SITE"
128 DEPENDS="$DEPENDS"
129 SUGGESTED="$SUGGESTED"
131 post_install()
132 {
133 cd \$1/usr/share/applications
134 ln -s /usr/lib/libreoffice*/share/xdg/base.desktop libreoffice-base.desktop
135 ln -s /usr/lib/libreoffice*/share/xdg/impress.desktop libreoffice-impress.desktop
136 ln -s /usr/lib/libreoffice*/share/xdg/writer.desktop libreoffice-writer.desktop
137 ln -s /usr/lib/libreoffice*/share/xdg/calc.desktop libreoffice-calc.desktop
138 ln -s /usr/lib/libreoffice*/share/xdg/math.desktop libreoffice-math.desktop
139 ln -s /usr/lib/libreoffice*/share/xdg/draw.desktop libreoffice-draw.desktop
140 ln -s /usr/lib/libreoffice*/share/xdg/printeradmin.desktop libreoffice-printeradmin.desktop
141 chmod +x \$1/usr/lib/libreoffice*/share/xdg/*.desktop
142 sed -i 's|^\\([Ee]xec=libreoffice\\)[0-9\\.]*|\\0|' \$1/usr/lib/libreoffice*/share/xdg/*.desktop
144 cd \$1/usr/bin
145 ln -sf /usr/lib/libreoffice/program/soffice
146 ln -sf /usr/lib/libreoffice/program/soffice libreoffice${VERSION%.*}
147 }
149 post_remove()
150 {
151 rm -f \$1/usr/share/applications/libreoffice-*
152 }
154 EOT
155 status