wok diff get-LibreOffice/stuff/get-LibreOffice @ rev 21220
Up collectd-bind (5.8.1), foomatic-db-engine (4.0.13), freeimage (3.1.8.0), perl-datetime-format-mail (0.403)
author | Pascal Bellard <pascal.bellard@slitaz.org> |
---|---|
date | Wed Apr 10 13:37:55 2019 +0200 (2019-04-10) |
parents | d11fd3e3b9d3 |
children | 36cb14e87ba5 |
line diff
1.1 --- a/get-LibreOffice/stuff/get-LibreOffice Fri Mar 20 11:36:16 2015 +0100 1.2 +++ b/get-LibreOffice/stuff/get-LibreOffice Wed Apr 10 13:37:55 2019 +0200 1.3 @@ -1,238 +1,319 @@ 1.4 #!/bin/sh 1.5 -# get-LibreOffice - install LibreOffice excl. KDE/Gnome integration & test suite. 1.6 +# get-LibreOffice - create and install SliTaz package LibreOffice 1.7 +# excluding KDE and GNOME integration and test suite. 1.8 # 1.9 -# (C) 2010 SliTaz - GNU General Public License v3. 1.10 +# (C) 2019 SliTaz - GNU General Public License v3. 1.11 # Author : Ben Arnold <ben@seawolfsanctuary.com> 1.12 # via : get-OpenOffice3 (Eric Joseph-Alexandre <erjo@slitaz.org>) 1.13 +# modified by Hans-Günter Theisgen on 2019-04-07 1.14 # 1.15 1.16 -PACKAGE="LibreOffice" 1.17 -URL="http://www.libreoffice.org" 1.18 -ROOT="$1" 1.19 +# === Initialisations === 1.20 + 1.21 +PKGS_DB="/var/lib/tazpkg" # packages database directory 1.22 +PACKAGE="LibreOffice" # package to create and install 1.23 +CATEGORY="office" 1.24 +SHORT_DESC="Productivity suite." 1.25 +WEB_SITE="https://www.libreoffice.org" 1.26 +LICENCE="MPL v2.0" 1.27 + 1.28 DIR="stable" 1.29 SUFFIX="Linux_x86_rpm.tar.gz" 1.30 -WGET_URL="http://download.documentfoundation.org/libreoffice/$DIR" 1.31 +PREFIX="http://download.documentfoundation.org/libreoffice/$DIR" 1.32 1.33 -VERSION="$(basename $(wget -O - $WGET_URL/ 2> /dev/null | \ 1.34 - sed '/href=\"[0-9]/!d;s/.*href=\"//;s/[/\">].*//' | tail -1))" 1.35 -if [ -z "$VERSION" ]; then 1.36 - echo "Can't detect an appropriate version. The version numbering or URL may have changed. Aborted." 1.37 - exit 0 1.38 -fi 1.39 -VER="${VERSION/\-/}" # without hyphens 1.40 +DEPENDS="java6-jre cups" 1.41 +EXCLUDE="kde|gnome|test" 1.42 1.43 +# Declare functions check_root, status, ... 1.44 +. /lib/libtaz.sh 1.45 +# and make commandline options (if any) available as variables 1.46 1.47 -TARBALL="LibreOffice_${VER}_${SUFFIX}" 1.48 - 1.49 -for LOC in ${LANG/_/-} ${LANG%_*}; do 1.50 - L_SUFFIX="Linux_x86_rpm_langpack_$LOC.tar.gz" 1.51 - L_TARBALL="LibreOffice_${VER}_${L_SUFFIX}" 1.52 - LANG_URL="$WGET_URL/${VERSION}/rpm/x86/${L_TARBALL}" 1.53 - busybox wget -s $LANG_URL 2> /dev/null || continue 1.54 - echo "Added $LANG ($LOC)." 1.55 - break 1.56 -done 1.57 -WGET_URL="$WGET_URL/${VERSION}/rpm/x86/${TARBALL}" 1.58 - 1.59 -CUR_DIR=$(pwd) 1.60 -TEMP_DIR="/tmp/$PACKAGE.$$" 1.61 -SOURCE_DIR="/tmp/src.$$" 1.62 -EXCLUDE="kde|gnome|test" 1.63 -LOG="/tmp/$(basename $0 .sh).log" 1.64 - 1.65 - 1.66 -# Status function with color (supported by Ash). 1.67 -status() 1.68 +is_installed() 1.69 { 1.70 - local CHECK=$? 1.71 - echo -en "\\033[70G[ " 1.72 - if [ $CHECK = 0 ]; then 1.73 - echo -en "\\033[1;33mOK" 1.74 - else 1.75 - echo -en "\\033[1;31mFailed" 1.76 - fi 1.77 - echo -e "\\033[0;39m ]" 1.78 - return $CHECK 1.79 -} 1.80 - 1.81 -# Check if user is root to install, or remove packages. 1.82 -check_root() 1.83 -{ 1.84 - if test $(id -u) != 0 ; then 1.85 - echo -e "\nYou must be root to run `basename $0` with this option." 1.86 - echo -e "Please use 'su' and root password to become super-user.\n" 1.87 - exit 0 1.88 - fi 1.89 -} 1.90 - 1.91 -check_if_installed() 1.92 -{ 1.93 - # Avoid reinstall 1.94 - if [ -d $ROOT/var/lib/tazpkg/installed/$PACKAGE ];then 1.95 + if [ -d $root$PKGS_DB/installed/$PACKAGE ] 1.96 + then #package is deemed to be installed 1.97 return 0 1.98 - else 1.99 + else 1.100 return 1 1.101 fi 1.102 } 1.103 1.104 -# We need to be root 1.105 +# Show available commandline options, if requested by --help 1.106 +if [ "$help" = "yes" ] 1.107 + then 1.108 + echo "Available commandline options: 1.109 + $0 1.110 + --version=<version> 1.111 + --root=<path_to_root> 1.112 + --install=yes|no 1.113 + --keep=no|yes 1.114 + --srcdir=<directory_for_source_packages> 1.115 + --tmpdir=<directory_to_build-package>" 1.116 + exit 1.117 +fi 1.118 + 1.119 +# Check for system administrator privileges 1.120 check_root 1.121 1.122 -# Check if package already installed 1.123 -if (check_if_installed $PACKAGE); then 1.124 +title "Package $PACKAGE will be build as SliTaz package and installed" 1.125 + 1.126 +# Fetch latest $DIR version, unless version is set by option --version 1.127 +[ -z "$version" ] && version="latest" 1.128 + 1.129 +# Fetch language pack according to $LANG, unless otherwise set by option --lang 1.130 +[ -z "$lang" ] && lang="automatic" 1.131 + 1.132 +# Install SliTaz package, unless inhibited by option --install=no 1.133 +[ -z "$install" ] && install="yes" 1.134 + 1.135 +# Delete SliTaz package file $PACKAGE-$VERSION.tazpkg after installation, 1.136 +# unless option --keep=yes is given 1.137 +[ -z "$keep" ] && keep="no" 1.138 + 1.139 +# Directory for temporary files 1.140 +[ -z "$tempdir" ] && TEMP_DIR="/tmp/get-$PACKAGE" 1.141 + 1.142 +# Directory for source archives 1.143 +[ -z "$srcdir" ] && SOURCE_DIR="/tmp/src-$PACKAGE" 1.144 + 1.145 +# Logging file 1.146 +LOG="/tmp/$(basename $0 .sh).log" 1.147 + 1.148 +cat <<EOT 1.149 +Options in use: 1.150 + root : $root/ 1.151 + version : $version 1.152 + lang : $lang 1.153 + install package : $install 1.154 + keep tazpkg : $keep 1.155 + source directory: $SOURCE_DIR 1.156 + build directory : $TEMP_DIR 1.157 + 1.158 +EOT 1.159 + 1.160 +separator; newline 1.161 + 1.162 +# === Remove package, if installed === 1.163 +if is_installed 1.164 + then 1.165 echo "$PACKAGE is already installed." 1.166 - [ -n "$ROOT" ] && exit 0 1.167 - echo -n "Would you like to remove and reinstall this package [y/n]? " 1.168 + [ -n "$root" ] && exit 0 1.169 + echo -n "Would you like to remove and reinstall this package [y/N]? " 1.170 read answer 1.171 case "$answer" in 1.172 - y|Y) 1.173 - tazpkg remove $PACKAGE ;; 1.174 - *) 1.175 + (y|Y) 1.176 + action "Removing installed version..." 1.177 + tazpkg remove $PACKAGE --root="$root/" 1.178 + [ ! is_installed ] && 1.179 + die "Can't remove installed version. Exiting." ;; 1.180 + (*) 1.181 exit 0 ;; 1.182 esac 1.183 - 1.184 fi 1.185 1.186 +# === Fetch archive file, if not existing === 1.187 1.188 -# Check if we have the tarball before. 1.189 -if [ ! -f $SOURCE_DIR/$TARBALL ]; then 1.190 - echo "Downloading LibreOffice tarball (it's time to have a break)... " 1.191 - # Check if $SOURCE_DIR exist 1.192 - test -d $SOURCE_DIR || mkdir -p $SOURCE_DIR 1.193 - # Get the file. 1.194 +if [ "$version" == "latest" ] 1.195 + then 1.196 + VERSION="$(basename $(wget -O - $PREFIX/ 2> /dev/null | \ 1.197 + sed '/href=\"[0-9]/!d;s/.*href=\"//;s/[/\">].*//' | tail -1))" 1.198 + if [ -z "$VERSION" ] 1.199 + then 1.200 + echo "Can't detect an appropriate version. The version numbering or URL may have changed. Exiting." 1.201 + exit 1 1.202 + fi 1.203 + else 1.204 + VERSION="$version" 1.205 +fi 1.206 + 1.207 +VER="${VERSION/\-/}" # without hyphens 1.208 +TARBALL="LibreOffice_${VER}_${SUFFIX}" 1.209 +WGET_URL="$PREFIX/${VERSION}/rpm/x86/${TARBALL}" 1.210 + 1.211 +# Set LANG_URL to fetch language package 1.212 +if [ "$lang" = "automatic" ] 1.213 + then # use language from $LANG of running process 1.214 + for LOC in ${LANG/_/-} ${LANG%_*} 1.215 + do 1.216 + L_SUFFIX="Linux_x86_rpm_langpack_$LOC.tar.gz" 1.217 + L_TARBALL="LibreOffice_${VER}_${L_SUFFIX}" 1.218 + LANG_URL="$PREFIX/${VERSION}/rpm/x86/${L_TARBALL}" 1.219 + busybox wget -s $LANG_URL 2> /dev/null || continue 1.220 + echo "Added language pack for $LANG ($LOC)." 1.221 + break 1.222 + done 1.223 + else 1.224 + L_SUFFIX="Linux_x86_rpm_langpack_$lang.tar.gz" 1.225 + L_TARBALL="LibreOffice_${VER}_${L_SUFFIX}" 1.226 + LANG_URL="$PREFIX/${VERSION}/rpm/x86/${L_TARBALL}" 1.227 + busybox wget -s $LANG_URL 2> /dev/null && 1.228 + echo "Added language pack for $lang." 1.229 +fi 1.230 + 1.231 +CUR_DIR=$(pwd) 1.232 +mkdir -p $TEMP_DIR 1.233 +cd $TEMP_DIR 1.234 + 1.235 +if [ -f $SOURCE_DIR/$TARBALL ] 1.236 + then 1.237 + echo "Using existing archive file $TARBALL" 1.238 + else 1.239 + action "Fetching the archives..." 1.240 + newline 1.241 + # Check if $SOURCE_DIR exists 1.242 + [ -d $SOURCE_DIR ] || mkdir -p $SOURCE_DIR 1.243 wget -c $WGET_URL -O $SOURCE_DIR/$TARBALL 1.244 - if [ -n $L_TARBALL ] ; then # Are we localised? 1.245 + if [ -n $L_TARBALL ] # language pack required? 1.246 + then 1.247 wget -c $LANG_URL -O $SOURCE_DIR/$L_TARBALL 1.248 fi 1.249 status 1.250 - 1.251 fi 1.252 1.253 -if [ ! -f $SOURCE_DIR/$TARBALL ]; then 1.254 +if [ ! -f $SOURCE_DIR/$TARBALL ] 1.255 + then 1.256 rm -rf $SOURCE_DIR 1.257 - echo "Could not download $TARBALL. Exiting." 1.258 + echo "Could not get $TARBALL. Exiting." 1.259 exit 1 1.260 fi 1.261 1.262 -echo -n "Extracting files (this may take a while): " 1.263 +# === Extract files from archives === 1.264 +action "Extracting the archives..." 1.265 +newline 1.266 +mkdir -p $TEMP_DIR 1.267 +for TB in $TARBALL $L_TARBALL 1.268 + do 1.269 + tar xvzf $SOURCE_DIR/$TB -C $TEMP_DIR > $LOG 2>&1 || 1.270 + (echo "Failed to extract $TB" ; exit 1) 1.271 + done 1.272 1.273 -# Creates TEMP_DIR and extract tarball 1.274 -mkdir -p $TEMP_DIR 1.275 -for TB in $TARBALL $L_TARBALL ; do 1.276 - tar xvzf $SOURCE_DIR/$TB -C $TEMP_DIR > $LOG 2>&1 || \ 1.277 - (echo "Failed to extract $TB" ; exit 1) 1.278 -done 1.279 +# === Create SliTaz package === 1.280 1.281 -# Get version found in archive (often directory is still RC version when final is present) 1.282 -ARCHIVED_VERSION=`cd $TEMP_DIR;find . -type d 2> /dev/null | grep LibreOffice | head -n 1 | sed 's/_/ /g' | awk '{print $2}'` 1.283 -echo -n "(found v${ARCHIVED_VERSION})" 1.284 +# Prepare metadata for SliTaz package 1.285 1.286 -# Consolidate localisations into main package 1.287 -if [ -n $L_TARBALL ] ; then # Are we localised? 1.288 - TARBALL_NAME="${TARBALL/.tar.gz/}" 1.289 +# Get version found in archive 1.290 +# (often directory is still RC version when final is present) 1.291 +VERSION_FROM_ARCHIVE=$(cd $TEMP_DIR;find . -type d 2> /dev/null \ 1.292 + | grep LibreOffice | head -n 1 | sed 's/_/ /g' | awk '{print $2}') 1.293 +echo -n "(found v${VERSION_FROM_ARCHIVE})" 1.294 + 1.295 +# Merge language pack into main package 1.296 +if [ -n $L_TARBALL ] # language pack required? 1.297 + then 1.298 + TARBALL_NAME="${TARBALL/.tar.gz/}" 1.299 L_TARBALL_NAME="${L_TARBALL/.tar.gz/}" 1.300 - mv -f $TEMP_DIR/${L_TARBALL_NAME/$VERSION/$ARCHIVED_VERSION}/RPMS/*.rpm $TEMP_DIR/${TARBALL_NAME/$VERSION/$ARCHIVED_VERSION}/RPMS/ 1.301 + mv -f $TEMP_DIR/${L_TARBALL_NAME/$VERSION/$VERSION_FROM_ARCHIVE}/RPMS/*.rpm \ 1.302 + $TEMP_DIR/${TARBALL_NAME/$VERSION/$VERSION_FROM_ARCHIVE}/RPMS/ 1.303 fi 1.304 status 1.305 1.306 -# Extracted pkg can be removed: Save RAM 1.307 +# Extracted archives can be removed 1.308 rm -rf $SOURCE_DIR 1.309 1.310 -# Extract everything from RPMS 1.311 -cd $TEMP_DIR/${TARBALL_NAME/$VERSION/$ARCHIVED_VERSION}/RPMS 1.312 +# Extract almost everything from RPMS directory 1.313 +action "Extracting RPMs..." 1.314 +newline 1.315 +cd $TEMP_DIR/${TARBALL_NAME/$VERSION/$VERSION_FROM_ARCHIVE}/RPMS 1.316 for i in *.rpm 1.317 -do 1.318 - if (! echo $i | egrep -qi $EXCLUDE); then 1.319 + do 1.320 + if (! echo $i | egrep -qi $EXCLUDE) 1.321 + then 1.322 echo -n "." 1.323 (rpm2cpio $i | cpio -id >> $LOG 2>&1 ) && rm -f $i 1.324 fi 1.325 -done 1.326 + done 1.327 +status 1.328 1.329 -#rpm2cpio desktop-integration/*freedesktop*.rpm | cpio -id >> $LOG 2>&1 1.330 -#rpm2cpio *freedesktop*.rpm | cpio -id >> $LOG 2>&1 1.331 +# Move files to package tree $PACKAGE-$VERSION/fs/ 1.332 +action "Preparing package..." 1.333 +mkdir -p $PACKAGE-$VERSION/fs/usr/lib/libreoffice 1.334 +mkdir -p $PACKAGE-$VERSION/fs/usr/share 1.335 1.336 -# extracted pkg can be removed: Save RAM 1.337 -rm -f desktop-integration/*freedesktop*.rpm 1.338 +# use mv instead of 'cp -a' to save space 1.339 +mv opt/libreoffice* $PACKAGE-$VERSION/fs/usr/lib 1.340 +mv usr/share/mime $PACKAGE-$VERSION/fs/usr/share 1.341 +mv usr/share/icons $PACKAGE-$VERSION/fs/usr/share 1.342 +mv usr/bin $PACKAGE-$VERSION/fs/usr 1.343 1.344 -status 1.345 -echo -n "Preparing package... " 1.346 +# relocalised libexec directory 1.347 +bin=$PACKAGE-$VERSION/fs/usr/bin/libreoffice${VERSION:0:3} 1.348 +if [ -L $bin ] 1.349 + then 1.350 + target=$(readlink $bin) 1.351 + rm -f $bin 1.352 + ln -s ${target/opt/usr\/lib\/libreoffice} $bin 1.353 + else 1.354 + sed -i 's#/opt/#/usr/lib/libreoffice/#' $bin 1.355 +fi 1.356 1.357 -# Make the package 1.358 -mkdir -p $PACKAGE-$VERSION/fs/usr/lib/libreoffice \ 1.359 - $PACKAGE-$VERSION/fs/usr/share 1.360 - 1.361 -# use mv instead of 'cp -a' to save RAM 1.362 -mv opt/libreoffice* $PACKAGE-$VERSION/fs/usr/lib 1.363 -mv usr/share/mime $PACKAGE-$VERSION/fs/usr/share 1.364 -mv usr/share/icons $PACKAGE-$VERSION/fs/usr/share 1.365 -mv usr/bin $PACKAGE-$VERSION/fs/usr 1.366 - 1.367 -# relocalized libexec directory 1.368 -bin=$(echo $PACKAGE-$VERSION/fs/usr/bin/libreoffice???) 1.369 -if [ -L $bin ]; then 1.370 - target=$(readlink $bin) 1.371 - rm -f $bin 1.372 - ln -s ${target/opt/usr\/lib\/libreoffice} $bin 1.373 -else 1.374 - sed -i 's#/opt/#/usr/lib/libreoffice/#' $bin 1.375 -fi 1.376 - 1.377 -# Create receipt 1.378 +# Create recipe for SliTaz package 1.379 cat > $PACKAGE-$VERSION/receipt <<EOT 1.380 # SliTaz package receipt. 1.381 1.382 PACKAGE="$PACKAGE" 1.383 VERSION="$VERSION" 1.384 -CATEGORY="office" 1.385 -SHORT_DESC="Productivity suite." 1.386 -DEPENDS="java6-jre cups" 1.387 -WEB_SITE="$URL" 1.388 +CATEGORY="$CATEGORY" 1.389 +TAGS="writer spreadsheet database" 1.390 +SHORT_DESC="$SHORT_DESC" 1.391 +LICENSE="$LICENCE" 1.392 +WEB_SITE="$WEB_SITE" 1.393 +DEPENDS="$DEPENDS" 1.394 1.395 post_install() 1.396 { 1.397 - ln -sf /usr/lib/libreoffice?* /usr/lib/libreoffice 1.398 - path_libreoffice=\$(find /usr/lib/libreoffice -name libreoffice*.*) 1.399 + ln -sf /usr/lib/libreoffice?* \ 1.400 + /usr/lib/libreoffice 1.401 + path_libreoffice=\$(find /usr/lib/libreoffice -name libreoffice*.*) 1.402 1.403 - # Remove links if exist 1.404 - rm -f /usr/share/applications/libreoffice-* 1.405 + # Remove links, if existing 1.406 + rm -f /usr/share/applications/libreoffice-* 1.407 1.408 - # Create links 1.409 - cd /usr/share/applications 1.410 - ln -sf \$path_libreoffice/share/xdg/base.desktop libreoffice-base.desktop 1.411 - ln -sf \$path_libreoffice/share/xdg/impress.desktop libreoffice-impress.desktop 1.412 - ln -sf \$path_libreoffice/share/xdg/writer.desktop libreoffice-writer.desktop 1.413 - ln -sf \$path_libreoffice/share/xdg/calc.desktop libreoffice-calc.desktop 1.414 - ln -sf \$path_libreoffice/share/xdg/math.desktop libreoffice-math.desktop 1.415 - ln -sf \$path_libreoffice/share/xdg/draw.desktop libreoffice-draw.desktop 1.416 + # Create links 1.417 + cd /usr/share/applications 1.418 + ln -sf \$path_libreoffice/share/xdg/base.desktop \ 1.419 + libreoffice-base.desktop 1.420 + ln -sf \$path_libreoffice/share/xdg/impress.desktop \ 1.421 + libreoffice-impress.desktop 1.422 + ln -sf \$path_libreoffice/share/xdg/writer.desktop \ 1.423 + libreoffice-writer.desktop 1.424 + ln -sf \$path_libreoffice/share/xdg/calc.desktop \ 1.425 + libreoffice-calc.desktop 1.426 + ln -sf \$path_libreoffice/share/xdg/math.desktop \ 1.427 + libreoffice-math.desktop 1.428 + ln -sf \$path_libreoffice/share/xdg/draw.desktop \ 1.429 + libreoffice-draw.desktop 1.430 1.431 - chmod +x \$path_libreoffice/share/xdg/*.desktop 1.432 + chmod +x \$path_libreoffice/share/xdg/*.desktop 1.433 1.434 # If necessary, recreate links for soffice 1.435 - rm -f /usr/bin/soffice /usr/bin/libreoffice 1.436 - ln -sf \$path_libreoffice/program/soffice /usr/bin/libreoffice 1.437 - ln -sf \$path_libreoffice/program/soffice /usr/bin/soffice 1.438 + rm -f /usr/bin/soffice 1.439 + rm -f /usr/bin/libreoffice 1.440 + ln -sf \$path_libreoffice/program/soffice /usr/bin/libreoffice 1.441 + ln -sf \$path_libreoffice/program/soffice /usr/bin/soffice 1.442 } 1.443 1.444 post_remove() 1.445 { 1.446 rm -f /usr/share/applications/libreoffice-* 1.447 } 1.448 +EOT 1.449 1.450 -EOT 1.451 status 1.452 1.453 -# Pack 1.454 +# Create the package 1.455 tazpkg pack $PACKAGE-$VERSION 1.456 1.457 -# Clean to save RAM memory 1.458 +# Remove package tree 1.459 rm -rf $PACKAGE-$VERSION 1.460 1.461 -# Install pseudo package 1.462 -tazpkg install $PACKAGE-$VERSION.tazpkg --root=$ROOT 1.463 -case " $@ " in 1.464 -*\ --k*) mv $PACKAGE-$VERSION.tazpkg $CUR_DIR ;; 1.465 -esac 1.466 +# === Install the SliTaz package === 1.467 +[ "$install" == "yes" ] && 1.468 +tazpkg install $PACKAGE-$VERSION.tazpkg --root="$root" 1.469 1.470 -# Clean 1.471 +# === Cleanup === 1.472 +# Preserve package file, if requested 1.473 +[ "$keep" == "yes" ] && mv $PACKAGE-$VERSION.tazpkg $CUR_DIR 1.474 + 1.475 +# Remove temporary build directory 1.476 cd $CUR_DIR 1.477 rm -rf $TEMP_DIR