wok view get-LibreOffice/stuff/get-LibreOffice @ rev 23528

updated python-pillow (2.3.0 -> 6.2.2)
author Hans-G?nter Theisgen
date Mon Apr 06 14:39:48 2020 +0100 (2020-04-06)
parents a31ec0e0df8e
children 2781677bb539
line source
1 #!/bin/sh
2 # get-LibreOffice - create and install SliTaz package LibreOffice
3 # excluding KDE and GNOME integration and test suite.
4 #
5 # (C) 2019 SliTaz - GNU General Public License v3.
6 # Author : Ben Arnold <ben@seawolfsanctuary.com>
7 # via : get-OpenOffice3 (Eric Joseph-Alexandre <erjo@slitaz.org>)
8 # modified by Hans-Günter Theisgen on 2019-04-07
9 # modified by Hans-Günter Theisgen on 220-03-17
10 #
12 # === Initialisations ===
14 PKGS_DB="/var/lib/tazpkg" # packages database directory
15 PACKAGE="LibreOffice" # package to create and install
16 CATEGORY="office"
17 SHORT_DESC="Productivity suite."
18 WEB_SITE="https://www.libreoffice.org"
19 LICENCE="MPL v2.0"
21 DIR="stable"
22 SUFFIX="Linux_x86_rpm.tar.gz"
23 PREFIX="http://download.documentfoundation.org/libreoffice/$DIR"
25 DEPENDS="cups"
26 EXCLUDE="kde|gnome|test"
28 # Declare functions check_root, status, ...
29 . /lib/libtaz.sh
30 # and make commandline options (if any) available as variables
32 is_installed()
33 {
34 if [ -d $root$PKGS_DB/installed/$PACKAGE ]
35 then #package is deemed to be installed
36 return 0
37 else
38 return 1
39 fi
40 }
42 # Show available commandline options, if requested by --help
43 if [ "$help" = "yes" ]
44 then
45 echo "Available commandline options:
46 $0
47 --version=<version>
48 --root=<path_to_root>
49 --install=yes|no
50 --keep=no|yes
51 --srcdir=<directory_for_source_packages>
52 --tmpdir=<directory_to_build-package>"
53 exit
54 fi
56 # Check for system administrator privileges
57 check_root
59 title "Package $PACKAGE will be build as SliTaz package and installed"
61 # Fetch latest $DIR version, unless version is set by option --version
62 [ -z "$version" ] && version="latest"
64 # Fetch language pack according to $LANG, unless otherwise set by option --lang
65 [ -z "$lang" ] && lang="automatic"
67 # Install SliTaz package, unless inhibited by option --install=no
68 [ -z "$install" ] && install="yes"
70 # Delete SliTaz package file $PACKAGE-$VERSION.tazpkg after installation,
71 # unless option --keep=yes is given
72 [ -z "$keep" ] && keep="no"
74 # Directory for temporary files
75 [ -z "$tempdir" ] && TEMP_DIR="/tmp/get-$PACKAGE"
77 # Directory for source archives
78 [ -z "$srcdir" ] && SOURCE_DIR="/tmp/src-$PACKAGE"
80 # Logging file
81 LOG="/tmp/$(basename $0 .sh).log"
83 cat <<EOT
84 Options in use:
85 root : $root/
86 version : $version
87 lang : $lang
88 install package : $install
89 keep tazpkg : $keep
90 source directory: $SOURCE_DIR
91 build directory : $TEMP_DIR
92 logging file: $LOG
94 EOT
96 separator; newline
98 # === Remove package, if installed ===
99 if is_installed
100 then
101 echo "$PACKAGE is already installed."
102 [ -n "$root" ] && exit 0
103 echo -n "Would you like to remove and reinstall this package [y/N]? "
104 read answer
105 case "$answer" in
106 (y|Y)
107 action "Removing installed version..."
108 tazpkg remove $PACKAGE --root="$root/"
109 [ ! is_installed ] &&
110 die "Can't remove installed version. Exiting." ;;
111 (*)
112 exit 0 ;;
113 esac
114 fi
116 # === Fetch archive file, if not existing ===
118 if [ "$version" == "latest" ]
119 then
120 VERSIONS="$(wget -qO - $PREFIX/ | \
121 sed '/href=\"[0-9]/!d;s/.*href=\"//;s/[/\">].*//' | tac)"
122 if [ -z "$VERSIONS" ]
123 then
124 echo "Can't detect an appropriate version. The version numbering or URL may have changed. Exiting."
125 exit 1
126 fi
127 else
128 DIR="old"
129 PREFIX="http://downloadarchive.documentfoundation.org/libreoffice/$DIR"
130 VERSIONS="$version"
131 fi
133 for VERSION in $VERSIONS
134 do # foreach VERSION
136 VER="${VERSION/\-/}" # without hyphens
137 TARBALL="LibreOffice_${VER}_${SUFFIX}"
138 WGET_URL="$PREFIX/${VERSION}/rpm/x86/${TARBALL}"
140 # Set LANG_URL to fetch language package
141 if [ "$lang" = "automatic" ]
142 then # use language from $LANG of running process
143 for LOC in ${LANG/_/-} ${LANG%_*}
144 do
145 L_SUFFIX="Linux_x86_rpm_langpack_$LOC.tar.gz"
146 L_TARBALL="LibreOffice_${VER}_${L_SUFFIX}"
147 LANG_URL="$PREFIX/${VERSION}/rpm/x86/${L_TARBALL}"
148 busybox wget -s $LANG_URL 2> /dev/null || continue
149 echo "Added language pack for $LANG ($LOC)."
150 break
151 done
152 else
153 L_SUFFIX="Linux_x86_rpm_langpack_$lang.tar.gz"
154 L_TARBALL="LibreOffice_${VER}_${L_SUFFIX}"
155 LANG_URL="$PREFIX/${VERSION}/rpm/x86/${L_TARBALL}"
156 busybox wget -s $LANG_URL 2> /dev/null &&
157 echo "Added language pack for $lang."
158 fi
160 CUR_DIR=$(pwd)
161 mkdir -p $TEMP_DIR
162 cd $TEMP_DIR
164 if [ -f $SOURCE_DIR/$TARBALL ]
165 then
166 echo "Using existing archive file $TARBALL"
167 else
168 action "Fetching the archives..."
169 newline
170 # Check if $SOURCE_DIR exists
171 [ -d $SOURCE_DIR ] || mkdir -p $SOURCE_DIR
172 wget -c $WGET_URL -O $SOURCE_DIR/$TARBALL || continue
173 if [ -n $L_TARBALL ] # language pack required?
174 then
175 wget -c $LANG_URL -O $SOURCE_DIR/$L_TARBALL
176 fi
177 status
178 fi
180 break
182 done # foreach VERSION
184 if [ ! -f $SOURCE_DIR/$TARBALL ]
185 then
186 rm -rf $SOURCE_DIR
187 echo "Could not get $TARBALL. Exiting."
188 exit 1
189 fi
191 # === Extract files from archives ===
192 action "Extracting the archives..."
193 newline
194 mkdir -p $TEMP_DIR
195 for TB in $TARBALL $L_TARBALL
196 do
197 tar xvzf $SOURCE_DIR/$TB -C $TEMP_DIR > $LOG 2>&1 ||
198 (echo "Failed to extract $TB" ; exit 1)
199 done
201 # === Create SliTaz package ===
203 # Prepare metadata for SliTaz package
205 # Get version found in archive
206 # (often directory is still RC version when final is present)
207 VERSION_FROM_ARCHIVE=$(cd $TEMP_DIR;find . -type d 2> /dev/null \
208 | grep LibreOffice | head -n 1 | sed 's/_/ /g' | awk '{print $2}')
209 echo -n "(found v${VERSION_FROM_ARCHIVE})"
211 # Merge language pack into main package
212 if [ -n $L_TARBALL ] # language pack required?
213 then
214 TARBALL_NAME="${TARBALL/.tar.gz/}"
215 L_TARBALL_NAME="${L_TARBALL/.tar.gz/}"
216 mv -f $TEMP_DIR/${L_TARBALL_NAME/$VERSION/$VERSION_FROM_ARCHIVE}/RPMS/*.rpm \
217 $TEMP_DIR/${TARBALL_NAME/$VERSION/$VERSION_FROM_ARCHIVE}/RPMS/
218 fi
219 status
221 # Extracted archives can be removed
222 rm -rf $SOURCE_DIR
224 # Extract almost everything from RPMS directory
225 action "Extracting RPMs..."
226 newline
227 cd $TEMP_DIR/${TARBALL_NAME/$VERSION/$VERSION_FROM_ARCHIVE}/RPMS
228 for i in *.rpm
229 do
230 if (! echo $i | egrep -qi $EXCLUDE)
231 then
232 echo -n "."
233 (rpm2cpio $i | cpio -id >> $LOG 2>&1 ) && rm -f $i
234 fi
235 done
236 status
238 # Move files to package tree $PACKAGE-$VERSION/fs/
239 action "Preparing package..."
240 mkdir -p $PACKAGE-$VERSION/fs/usr/lib/libreoffice
241 mkdir -p $PACKAGE-$VERSION/fs/usr/share
243 # use mv instead of 'cp -a' to save space
244 mv opt/libreoffice* $PACKAGE-$VERSION/fs/usr/lib
245 mv usr/share/mime $PACKAGE-$VERSION/fs/usr/share
246 mv usr/share/icons $PACKAGE-$VERSION/fs/usr/share
247 mv usr/bin $PACKAGE-$VERSION/fs/usr
249 # relocalised libexec directory
250 bin=$PACKAGE-$VERSION/fs/usr/bin/libreoffice${VERSION:0:3}
251 if [ -L $bin ]
252 then
253 target=$(readlink $bin)
254 rm -f $bin
255 ln -s ${target/opt/usr\/lib\/libreoffice} $bin
256 else
257 sed -i 's#/opt/#/usr/lib/libreoffice/#' $bin
258 fi
260 # Create recipe for SliTaz package
261 cat > $PACKAGE-$VERSION/receipt <<EOT
262 # SliTaz package receipt.
264 PACKAGE="$PACKAGE"
265 VERSION="$VERSION"
266 CATEGORY="$CATEGORY"
267 TAGS="writer spreadsheet database"
268 SHORT_DESC="$SHORT_DESC"
269 LICENSE="$LICENCE"
270 WEB_SITE="$WEB_SITE"
271 DEPENDS="$DEPENDS"
273 post_install()
274 {
275 ln -sf /usr/lib/libreoffice?* \\
276 /usr/lib/libreoffice
277 path_libreoffice=\$(find /usr/lib/libreoffice -name libreoffice*.*)
279 # Remove links, if existing
280 rm -f /usr/share/applications/libreoffice-*
282 # Create links
283 cd /usr/share/applications
284 ln -sf \$path_libreoffice/share/xdg/base.desktop \\
285 libreoffice-base.desktop
286 ln -sf \$path_libreoffice/share/xdg/impress.desktop \\
287 libreoffice-impress.desktop
288 ln -sf \$path_libreoffice/share/xdg/writer.desktop \\
289 libreoffice-writer.desktop
290 ln -sf \$path_libreoffice/share/xdg/calc.desktop \\
291 libreoffice-calc.desktop
292 ln -sf \$path_libreoffice/share/xdg/math.desktop \\
293 libreoffice-math.desktop
294 ln -sf \$path_libreoffice/share/xdg/draw.desktop \\
295 libreoffice-draw.desktop
297 chmod +x \$path_libreoffice/share/xdg/*.desktop
299 # Fix menu entries
300 sed -i 's|^\\([Ee]xec=libreoffice\\)[0-9\\.]*|\\0|' \\
301 \$path_libreoffice/share/xdg/*.desktop
303 # If necessary, recreate links for soffice
304 rm -f /usr/bin/soffice
305 rm -f /usr/bin/libreoffice
306 ln -sf \$path_libreoffice/program/soffice /usr/bin/libreoffice
307 ln -sf \$path_libreoffice/program/soffice /usr/bin/soffice
308 }
310 post_remove()
311 {
312 rm -f /usr/share/applications/libreoffice-*
313 }
314 EOT
316 status
318 # Create the package
319 tazpkg pack $PACKAGE-$VERSION
321 # Remove package tree
322 rm -rf $PACKAGE-$VERSION
324 # === Install the SliTaz package ===
325 [ "$install" == "yes" ] &&
326 tazpkg install $PACKAGE-$VERSION.tazpkg --root="$root"
328 # === Cleanup ===
329 # Preserve package file, if requested
330 [ "$keep" == "yes" ] &&
331 ( mv $PACKAGE-$VERSION.tazpkg $CUR_DIR &&
332 echo Saved $PACKAGE-$VERSION.tazpkg to $CUR_DIR )
334 # Remove temporary build directory
335 cd $CUR_DIR
336 rm -rf $TEMP_DIR