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

updated python-cython (0.29.16 -> 0.29.30)
author Hans-G?nter Theisgen
date Fri Jul 01 15:27:05 2022 +0100 (23 months ago)
parents 2781677bb539
children
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) 2020 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 2020-03-17
10 # modified by Hans-Günter Theisgen on 2020-07-24
11 # modified by Hans-Günter Theisgen on 2022-06-15
12 #
14 # === Initialisations ===
16 PKGS_DB="/var/lib/tazpkg" # packages database directory
17 PACKAGE="LibreOffice" # package to create and install
18 CATEGORY="office"
19 SHORT_DESC="Productivity suite."
20 WEB_SITE="https://www.libreoffice.org"
21 LICENCE="MPL v2.0"
23 DIR="stable"
24 SUFFIX="Linux_x86_rpm.tar.gz"
25 PREFIX="http://download.documentfoundation.org/libreoffice/$DIR"
27 DEPENDS="cups"
28 EXCLUDE="kde|gnome|test"
30 # Declare functions check_root, status, ...
31 . /lib/libtaz.sh
32 # and make commandline options (if any) available as variables
34 is_installed()
35 {
36 if [ -d $root$PKGS_DB/installed/$PACKAGE ]
37 then #package is deemed to be installed
38 return 0
39 else
40 return 1
41 fi
42 }
44 # Show available commandline options, if requested by --help
45 if [ "$help" = "yes" ]
46 then
47 echo "Available commandline options:
48 $0
49 --version=<version>
50 --lang=<language_package_required>
51 --root=<path_to_root>
52 --install=yes|no
53 --keep=no|yes
54 --srcdir=<directory_for_source_packages>
55 --tmpdir=<directory_to_build-package>"
56 exit
57 fi
59 # Check for system administrator privileges
60 check_root
62 title "Package $PACKAGE will be build as SliTaz package and installed"
64 # Fetch latest $DIR version, unless version is set by option --version
65 #[ -z "$version" ] && version="latest"
66 [ -z "$version" ] && version="6.2.8.2" &&
67 echo "Newer versions than 6.2.8.2 are not available in 32-bit flavour!"
69 # Fetch language pack according to $LANG, unless otherwise set by option --lang
70 [ -z "$lang" ] && lang="automatic"
72 # Install SliTaz package, unless inhibited by option --install=no
73 [ -z "$install" ] && install="yes"
75 # Delete SliTaz package file $PACKAGE-$VERSION.tazpkg after installation,
76 # unless option --keep=yes is given
77 [ -z "$keep" ] && keep="no"
79 # Directory for temporary files
80 [ -z "$tempdir" ] && TEMP_DIR="/tmp/get-$PACKAGE"
82 # Directory for source archives
83 [ -z "$srcdir" ] && SOURCE_DIR="/tmp/src-$PACKAGE"
85 # Logging file
86 LOG="/tmp/$(basename $0 .sh).log"
88 cat <<EOT
89 Options in use:
90 root : $root/
91 version : $version
92 lang : $lang
93 install package : $install
94 keep tazpkg : $keep
95 source directory: $SOURCE_DIR
96 build directory : $TEMP_DIR
97 logging file: $LOG
99 EOT
101 separator; newline
103 # === Remove package, if installed ===
104 if is_installed
105 then
106 echo "$PACKAGE is already installed."
107 [ -n "$root" ] && exit 0
108 echo -n "Would you like to remove and reinstall this package [y/N]? "
109 read answer
110 case "$answer" in
111 (y|Y)
112 action "Removing installed version..."
113 tazpkg remove $PACKAGE --root="$root/"
114 [ ! is_installed ] &&
115 die "Can't remove installed version. Exiting." ;;
116 (*)
117 exit 0 ;;
118 esac
119 fi
121 # === Fetch archive file, if not existing ===
123 if [ "$version" == "latest" ]
124 then
125 VERSIONS="$(wget -qO - $PREFIX/ | \
126 sed '/href=\"[0-9]/!d;s/.*href=\"//;s/[/\">].*//' | tac)"
127 if [ -z "$VERSIONS" ]
128 then
129 echo "Can't detect an appropriate version. The version numbering or URL may have changed. Exiting."
130 exit 1
131 fi
132 else
133 DIR="old"
134 PREFIX="http://downloadarchive.documentfoundation.org/libreoffice/$DIR"
135 VERSIONS="$version"
136 fi
138 for VERSION in $VERSIONS
139 do # foreach VERSION
141 VER="${VERSION/\-/}" # without hyphens
142 TARBALL="LibreOffice_${VER}_${SUFFIX}"
143 WGET_URL="$PREFIX/${VERSION}/rpm/x86/${TARBALL}"
145 # Set LANG_URL to fetch language package
146 if [ "$lang" = "automatic" ]
147 then # use language from $LANG of running process
148 for LOC in ${LANG/_/-} ${LANG%_*}
149 do
150 L_SUFFIX="Linux_x86_rpm_langpack_$LOC.tar.gz"
151 L_TARBALL="LibreOffice_${VER}_${L_SUFFIX}"
152 LANG_URL="$PREFIX/${VERSION}/rpm/x86/${L_TARBALL}"
153 busybox wget -s $LANG_URL 2> /dev/null || continue
154 echo "Added language pack for $LANG ($LOC)."
155 break
156 done
157 else
158 L_SUFFIX="Linux_x86_rpm_langpack_$lang.tar.gz"
159 L_TARBALL="LibreOffice_${VER}_${L_SUFFIX}"
160 LANG_URL="$PREFIX/${VERSION}/rpm/x86/${L_TARBALL}"
161 busybox wget -s $LANG_URL 2> /dev/null &&
162 echo "Added language pack for $lang."
163 fi
165 CUR_DIR=$(pwd)
166 mkdir -p $TEMP_DIR
167 cd $TEMP_DIR
169 if [ -f $SOURCE_DIR/$TARBALL ]
170 then
171 echo "Using existing archive file $TARBALL"
172 else
173 action "Fetching the archives..."
174 newline
175 # Check if $SOURCE_DIR exists
176 [ -d $SOURCE_DIR ] || mkdir -p $SOURCE_DIR
177 wget -c $WGET_URL -O $SOURCE_DIR/$TARBALL || continue
178 if [ -n $L_TARBALL ] # language pack required?
179 then
180 wget -c $LANG_URL -O $SOURCE_DIR/$L_TARBALL
181 fi
182 status
183 fi
185 break
187 done # foreach VERSION
189 if [ ! -f $SOURCE_DIR/$TARBALL ]
190 then
191 rm -rf $SOURCE_DIR
192 echo "Could not get $TARBALL. Exiting."
193 exit 1
194 fi
196 # === Extract files from archives ===
197 action "Extracting the archives..."
198 newline
199 mkdir -p $TEMP_DIR
200 for TB in $TARBALL $L_TARBALL
201 do
202 tar xvzf $SOURCE_DIR/$TB -C $TEMP_DIR > $LOG 2>&1 ||
203 (echo "Failed to extract $TB" ; exit 1)
204 done
206 # === Create SliTaz package ===
208 # Prepare metadata for SliTaz package
210 # Get version found in archive
211 # (often directory is still RC version when final is present)
212 VERSION_FROM_ARCHIVE=$(cd $TEMP_DIR;find . -type d 2> /dev/null \
213 | grep LibreOffice | head -n 1 | sed 's/_/ /g' | awk '{print $2}')
214 echo -n "(found v${VERSION_FROM_ARCHIVE})"
216 # Merge language pack into main package
217 if [ -n $L_TARBALL ] # language pack required?
218 then
219 TARBALL_NAME="${TARBALL/.tar.gz/}"
220 L_TARBALL_NAME="${L_TARBALL/.tar.gz/}"
221 mv -f $TEMP_DIR/${L_TARBALL_NAME/$VERSION/$VERSION_FROM_ARCHIVE}/RPMS/*.rpm \
222 $TEMP_DIR/${TARBALL_NAME/$VERSION/$VERSION_FROM_ARCHIVE}/RPMS/
223 fi
224 status
226 # Extracted archives can be removed
227 rm -rf $SOURCE_DIR
229 # Extract almost everything from RPMS directory
230 action "Extracting RPMs..."
231 newline
232 cd $TEMP_DIR/${TARBALL_NAME/$VERSION/$VERSION_FROM_ARCHIVE}/RPMS
233 for i in *.rpm
234 do
235 if (! echo $i | egrep -qi $EXCLUDE)
236 then
237 echo -n "."
238 (rpm2cpio $i | cpio -id >> $LOG 2>&1 ) && rm -f $i
239 fi
240 done
241 status
243 # Move files to package tree $PACKAGE-$VERSION/fs/
244 action "Preparing package..."
245 mkdir -p $PACKAGE-$VERSION/fs/usr/lib/libreoffice
246 mkdir -p $PACKAGE-$VERSION/fs/usr/share
248 # use mv instead of 'cp -a' to save space
249 mv opt/libreoffice* $PACKAGE-$VERSION/fs/usr/lib
250 mv usr/share/mime $PACKAGE-$VERSION/fs/usr/share
251 mv usr/share/icons $PACKAGE-$VERSION/fs/usr/share
252 mv usr/bin $PACKAGE-$VERSION/fs/usr
254 # relocalised libexec directory
255 bin=$PACKAGE-$VERSION/fs/usr/bin/libreoffice${VERSION:0:3}
256 if [ -L $bin ]
257 then
258 target=$(readlink $bin)
259 rm -f $bin
260 ln -s ${target/opt/usr\/lib\/libreoffice} $bin
261 else
262 sed -i 's#/opt/#/usr/lib/libreoffice/#' $bin
263 fi
265 # Create recipe for SliTaz package
266 cat > $PACKAGE-$VERSION/receipt <<EOT
267 # SliTaz package receipt.
269 PACKAGE="$PACKAGE"
270 VERSION="$VERSION"
271 CATEGORY="$CATEGORY"
272 TAGS="writer spreadsheet database"
273 SHORT_DESC="$SHORT_DESC"
274 LICENSE="$LICENCE"
275 WEB_SITE="$WEB_SITE"
276 DEPENDS="$DEPENDS"
278 post_install()
279 {
280 ln -sf /usr/lib/libreoffice?* \\
281 /usr/lib/libreoffice
282 path_libreoffice=\$(find /usr/lib/libreoffice -name libreoffice*.*)
284 # Remove links, if existing
285 rm -f /usr/share/applications/libreoffice-*
287 # Create links
288 cd /usr/share/applications
289 ln -sf \$path_libreoffice/share/xdg/base.desktop \\
290 libreoffice-base.desktop
291 ln -sf \$path_libreoffice/share/xdg/impress.desktop \\
292 libreoffice-impress.desktop
293 ln -sf \$path_libreoffice/share/xdg/writer.desktop \\
294 libreoffice-writer.desktop
295 ln -sf \$path_libreoffice/share/xdg/calc.desktop \\
296 libreoffice-calc.desktop
297 ln -sf \$path_libreoffice/share/xdg/math.desktop \\
298 libreoffice-math.desktop
299 ln -sf \$path_libreoffice/share/xdg/draw.desktop \\
300 libreoffice-draw.desktop
302 chmod +x \$path_libreoffice/share/xdg/*.desktop
304 # Fix menu entries
305 sed -i 's|^\\([Ee]xec=libreoffice\\)[0-9\\.]*|\\0|' \\
306 \$path_libreoffice/share/xdg/*.desktop
308 # If necessary, recreate links for soffice
309 rm -f /usr/bin/soffice
310 rm -f /usr/bin/libreoffice
311 ln -sf \$path_libreoffice/program/soffice /usr/bin/libreoffice
312 ln -sf \$path_libreoffice/program/soffice /usr/bin/soffice
313 }
315 post_remove()
316 {
317 rm -f /usr/share/applications/libreoffice-*
318 }
319 EOT
321 status
323 # Create the package
324 tazpkg pack $PACKAGE-$VERSION
326 # Remove package tree
327 rm -rf $PACKAGE-$VERSION
329 # === Install the SliTaz package ===
330 [ "$install" == "yes" ] &&
331 tazpkg install $PACKAGE-$VERSION.tazpkg --root="$root"
333 # === Cleanup ===
334 # Preserve package file, if requested
335 [ "$keep" == "yes" ] &&
336 ( mv $PACKAGE-$VERSION.tazpkg $CUR_DIR &&
337 echo Saved $PACKAGE-$VERSION.tazpkg to $CUR_DIR )
339 # Remove temporary build directory
340 cd $CUR_DIR
341 rm -rf $TEMP_DIR