wok-current rev 22827

modified get-OpenOffice3
author Hans-G?nter Theisgen
date Fri Feb 07 16:26:49 2020 +0100 (2020-02-07)
parents d77b60725297
children 44e5646831ce
files get-OpenOffice3/receipt get-OpenOffice3/stuff/get-OpenOffice3
line diff
     1.1 --- a/get-OpenOffice3/receipt	Fri Feb 07 16:15:46 2020 +0100
     1.2 +++ b/get-OpenOffice3/receipt	Fri Feb 07 16:26:49 2020 +0100
     1.3 @@ -1,19 +1,24 @@
     1.4  # SliTaz package receipt.
     1.5  
     1.6  PACKAGE="get-OpenOffice3"
     1.7 -VERSION="1.2"
     1.8 +VERSION="1.20"
     1.9  CATEGORY="office"
    1.10 -SHORT_DESC="Productivity suite"
    1.11 +TAGS="office word excel ppt openoffice"
    1.12 +SHORT_DESC="Productivity suite."
    1.13  MAINTAINER="erjo@slitaz.org"
    1.14  LICENSE="GPL3"
    1.15 -WEB_SITE="http://www.openoffice.org"
    1.16 -TAGS="office word excel ppt openoffice"
    1.17 +WEB_SITE="https://openoffice.org"
    1.18  
    1.19  # Rules to gen a SliTaz package suitable for Tazpkg.
    1.20  genpkg_rules()
    1.21  {
    1.22  	mkdir -p $fs/usr/bin
    1.23 -	install -o root -g root -m755 stuff/get-OpenOffice3 $fs/usr/bin
    1.24 +	install -o root -g root -m755 stuff/get-OpenOffice3	$fs/usr/bin
    1.25  	ln -s get-OpenOffice3 $fs/usr/bin/get-openoffice
    1.26  }
    1.27  
    1.28 +post_install()
    1.29 +{
    1.30 +	echo "Now you may enter:
    1.31 +get-openoffice"
    1.32 +}
     2.1 --- a/get-OpenOffice3/stuff/get-OpenOffice3	Fri Feb 07 16:15:46 2020 +0100
     2.2 +++ b/get-OpenOffice3/stuff/get-OpenOffice3	Fri Feb 07 16:26:49 2020 +0100
     2.3 @@ -1,159 +1,191 @@
     2.4  #!/bin/sh
     2.5  # get-OpenOffice3, install everything for OpenOffice.org exept KDE/Gnome integration and testsuite.
     2.6  #
     2.7 -# (C) 2008 SliTaz - GNU General Public License v3.
     2.8 +# (C) 2020 SliTaz - GNU General Public License v3.
     2.9  #
    2.10  # Author : Eric Joseph-Alexandre <erjo@slitaz.org>
    2.11 +# modified by HGT on 2020-02-07
    2.12 +#
    2.13 +#	=== Initialisations ===
    2.14  
    2.15 +PKGS_DB="/var/lib/tazpkg"	# packages database directory
    2.16  PACKAGE="OpenOffice3"
    2.17 -URL="http://www.openoffice.org"
    2.18 -ROOT="$1"
    2.19 +WEB_SITE="https://openoffice.org"
    2.20 +CATEGORY="office"
    2.21 +DEPENDS="java-jre"
    2.22 +
    2.23  PATTERN="Linux_x86_install-rpm"
    2.24 +EXCLUDE="kde|gnome|test"
    2.25  
    2.26 -for MIRROR in \
    2.27 -http://mirror.switch.ch/ftp/mirror/OpenOffice \
    2.28 -http://openoffice.cict.fr \
    2.29 -http://wwwftp.ciril.fr/pub/openoffice \
    2.30 -http://artfiles.org/openoffice.org \
    2.31 -http://vesta.informatik.rwth-aachen.de/ftp/pub/mirror/OpenOffice \
    2.32 -http://ftp.ntua.gr/pub/OpenOffice \
    2.33 -http://ftp.iitm.ac.in/openoffice \
    2.34 -http://www.ring.gr.jp/archives/misc/openoffice \
    2.35 -http://ftp.nluug.nl/pub/office/openoffice \
    2.36 +# Declare functions check_root, status, ...
    2.37 +. /lib/libtaz.sh
    2.38 +# and make commandline options (if any) available as variables
    2.39  
    2.40 -do
    2.41 -	wget -O - $MIRROR/ 2> /dev/null | grep -q localized || continue
    2.42 -	DIR="stable"
    2.43 -	LOC=$(wget -O - $MIRROR/localized/ 2> /dev/null | \
    2.44 -		grep -E ">$LANG/|>${LANG/_/-}/|>${LANG%_*}/" | \
    2.45 -		head -1 | sed 's/.*href=\"\(.*\)\/\".*/\1/')
    2.46 -	[ -n "$LOC" ] && DIR="localized/$LOC"
    2.47 -	VERSION="$(basename $(wget -O - $MIRROR/$DIR/ 2> /dev/null | grep \
    2.48 -	href=\"[0-9] | tail -1 | sed 's/.*href=\"\(.*\)\".*/\1/') 2> /dev/null)"
    2.49 -	[ -n "$VERSION" ] && break
    2.50 -done
    2.51 -
    2.52 -if [ -z "$VERSION" ]; then
    2.53 -	echo "Can't find VERSION. Abort."
    2.54 -	exit 0
    2.55 -fi
    2.56 -echo "Selecting $DIR version $VERSION ..."
    2.57 -TARBALL="$(wget -O - $MIRROR/$DIR/$VERSION/ \
    2.58 -	2> /dev/null | grep $PATTERN | tail -1 | sed 's/.*href=\"\(.*\)\".*/\1/')"
    2.59 -echo "Archive is $TARBALL ..."
    2.60 -WGET_URL=$MIRROR/$DIR/$VERSION/$TARBALL
    2.61 -
    2.62 -TEMP_DIR="/tmp/$PACKAGE.$$"
    2.63 -CUR_DIR=$(pwd)
    2.64 -SOURCE_DIR="/tmp/src.$$"
    2.65 -EXCLUDE="kde|gnome|test"
    2.66 -LOG="/tmp/$(basename $0 .sh).log"
    2.67 -
    2.68 -# Status function with color (supported by Ash).
    2.69 -status()
    2.70 +is_installed()
    2.71  {
    2.72 -	local CHECK=$?
    2.73 -	echo -en "\\033[70G[ "
    2.74 -	if [ $CHECK = 0 ]; then
    2.75 -		echo -en "\\033[1;33mOK"
    2.76 -	else
    2.77 -		echo -en "\\033[1;31mFailed"
    2.78 -	fi
    2.79 -	echo -e "\\033[0;39m ]"
    2.80 -	return $CHECK
    2.81 -}
    2.82 -
    2.83 -# Check if user is root to install, or remove packages.
    2.84 -check_root()
    2.85 -{
    2.86 -	if test $(id -u) != 0 ; then
    2.87 -		echo -e "\nYou must be root to run `basename $0` with this option."
    2.88 -		echo -e "Please use 'su' and root password to become super-user.\n"
    2.89 -		exit 0
    2.90 -	fi
    2.91 -}
    2.92 -
    2.93 -check_if_installed()
    2.94 -{
    2.95 -	 # Avoid reinstall
    2.96 -	 if [ -d $ROOT/var/lib/tazpkg/installed/$PACKAGE ];then
    2.97 +	if [ -d $ROOT$PKGS_DB/installed/$PACKAGE ]
    2.98 +	  then	#package is deemed to be installed
    2.99  	 	return 0
   2.100 -	 else
   2.101 +	  else
   2.102  	 	return 1
   2.103  	 fi
   2.104  }
   2.105  
   2.106 -#We need to bee root
   2.107 +# Show commandline options, if requested by --help
   2.108 +if [ "$help" == "yes" ]
   2.109 +  then
   2.110 +	echo "Commandline options:
   2.111 +  $0
   2.112 +	--version=<version>
   2.113 +	--root=<path-to-root>
   2.114 +	--install=yes|no|quick
   2.115 +	--keep=no|yes
   2.116 +	--tmpdir=<directory-to-build-package>
   2.117 +	--logfile=<logging-file>"
   2.118 +	exit
   2.119 +fi
   2.120 +
   2.121 +# Check for system administrator privileges
   2.122  check_root
   2.123  
   2.124 -#check if package already installed
   2.125 -if (check_if_installed $PACKAGE); then
   2.126 -	echo "$PACKAGE is already installed."
   2.127 -	[ -n "$ROOT" ] && exit 0
   2.128 -	echo -n "Would you like to remove and reinstall this package [y/n]? "
   2.129 -	read answer
   2.130 -	case "$answer" in
   2.131 -	y|Y)
   2.132 -		tazpkg remove $PACKAGE ;;
   2.133 -	*)
   2.134 -		exit 0 ;;
   2.135 -	esac
   2.136 -		
   2.137 +title "Package $PACKAGE will be build as SliTaz package and installed"
   2.138 +
   2.139 +# Fetch latest version, unless version is set by option --version
   2.140 +[ -z "$version" ] && version="latest"
   2.141 +
   2.142 +# Install SliTaz package, unless inhibited by option --install=no
   2.143 +[ -z "$install" ] && install="yes"
   2.144 +
   2.145 +# Delete SliTaz package file $PACKAGE-$VERSION.tazpkg after installation,
   2.146 +# unless option --keep=yes is given
   2.147 +[ -z "$keep" ] && keep="no"
   2.148 +
   2.149 +# Directory for temporary files
   2.150 +[ -z "$tempdir" ] && TMP_DIR="/tmp/get-$PACKAGE"
   2.151 +
   2.152 +# Logging file
   2.153 +[ -z "$logfile" ] && LOG=$TMP_DIR/get-$PACKAGE.log
   2.154 +
   2.155 +cat <<EOT
   2.156 +Options in use:
   2.157 +  root           : $root/
   2.158 +  version        : $version
   2.159 +  install package: $install
   2.160 +  keep tazpkg    : $keep
   2.161 +  build directory: $TMP_DIR
   2.162 +  logging file   : $LOG
   2.163 +
   2.164 +EOT
   2.165 +
   2.166 +separator; newline
   2.167 +
   2.168 +# Set WGET_URL
   2.169 +# 3.3.0 no german rpm-Package available!
   2.170 +for MIRROR in								\
   2.171 +	http://ftp.free.fr/mirrors/ftp.openoffice.org			\
   2.172 +	http://ftp-stud.hs-esslingen.de/pub/Mirrors/ftp.openoffice.org	\
   2.173 +	http://www.ellak.gr/pub/openoffice				\
   2.174 +	http://ftp.snt.utwente.nl/pub/software/openoffice		\
   2.175 +	http://ftp.nluug.nl/pub/office/openoffice			\
   2.176 +	http://ftp.isu.edu.tw/pub/OpenOffice
   2.177 +  do
   2.178 +	wget -O - $MIRROR/ 2> /dev/null | grep -q localized || continue
   2.179 +	DIR="stable"
   2.180 +	LOC=$(wget -O - $MIRROR/localized/ 2> /dev/null | \
   2.181 +		grep -E ">$LANG<|>$LANG/<|>${LANG/_/-}<|>${LANG/_/-}/<|>${LANG%_*}<|>${LANG%_*}/<" | \
   2.182 +		head -1 | sed 's|.*href=\"\(.*\)/\".*|\1|')
   2.183 +	[ -n "$LOC" ] && DIR="localized/$LOC"
   2.184 +	VERSION="$(wget -O - $MIRROR/$DIR/ 2> /dev/null | \
   2.185 +	grep href=\"[0-9] | tail -1 | sed 's|.*href=\"\(.*\)/\".*|\1|' 2> /dev/null)"
   2.186 +	[ -n "$VERSION" ] && break
   2.187 +  done
   2.188 +TARBALL=$(wget -O - $MIRROR/$DIR/$VERSION/ 2> /dev/null | \
   2.189 +	grep $PATTERN | tail -1 | sed 's|.*href=\"\(.*\)\".*|\1|')
   2.190 +# bug in sed?:
   2.191 +TARBALL=${TARBALL%%\"*}
   2.192 +echo "Archive is $TARBALL ..."
   2.193 +
   2.194 +# Set VERSION, unless supplied by --version
   2.195 +if [ "$version" == "latest" ]
   2.196 +  then
   2.197 +	echo "Selecting $DIR version $VERSION from $MIRROR ..."
   2.198 +	WGET_URL=$MIRROR/$DIR/$VERSION/$TARBALL
   2.199 +  else
   2.200 +	TARBALL=${TARBALL/$VERSION/$version}
   2.201 +	VERSION=$version
   2.202 +	WGET_URL="$MIRROR/$DIR/$VERSION/$TARBALL"
   2.203  fi
   2.204  
   2.205 -
   2.206 -# Check if we have the tarball before.
   2.207 -if [ ! -f $SOURCE_DIR/$TARBALL ]; then
   2.208 -	echo "Downloading OppenOffice.org tarball (it's time to have a break)... "
   2.209 -	#Check if $SOURCE_DIR exist
   2.210 -	test -d $SOURCE_DIR || mkdir -p $SOURCE_DIR
   2.211 -	# Get the file.
   2.212 -	wget -c $WGET_URL -O $SOURCE_DIR/$TARBALL
   2.213 -	status
   2.214 -fi
   2.215 -if [ ! -f $SOURCE_DIR/$TARBALL ]; then
   2.216 -	rm -rf $SOURCE_DIR
   2.217 -	echo "Could not download $TARBALL. Exiting."
   2.218 -	exit 1
   2.219 +#	=== Remove package, if installed ===
   2.220 +if [ is_installed ]
   2.221 +  then
   2.222 +	action "Removing installed version..."
   2.223 +	tazpkg remove $PACKAGE --root="$root/"
   2.224 +	[ ! is_installed ] &&
   2.225 +	die "Can't remove installed version. Exiting."
   2.226  fi
   2.227  
   2.228 -# Creates TEMP_DIR and extract tarball
   2.229 -mkdir -p $TEMP_DIR
   2.230 -echo -n "Extract files from archive..."
   2.231 -busybox tar xvf $SOURCE_DIR/$TARBALL -C $TEMP_DIR > $LOG 2>&1 || \
   2.232 +#	=== Fetch archive file, if not existing ===
   2.233 +
   2.234 +CUR_DIR=$(pwd)
   2.235 +mkdir -p $TMP_DIR
   2.236 +cd $TMP_DIR
   2.237 +if [ -f $TARBALL ]
   2.238 +  then
   2.239 +	echo "Using existing archive file $TARBALL"
   2.240 +  else
   2.241 +	action "Fetching the archive"
   2.242 +	newline
   2.243 +	wget	--no-check-certificate $WGET_URL
   2.244 +	if [ ! -f $TARBALL ]
   2.245 +	  then
   2.246 +		cd $CUR_DIR
   2.247 +		rm -rf $TMP_DIR
   2.248 +		echo "Could not transfer $TARBALL from $WGET_URL. Exiting."
   2.249 +		exit 1
   2.250 +	fi
   2.251 +fi
   2.252 +
   2.253 +#	=== Extract files from archive ===
   2.254 +action "Extracting the archive"
   2.255 +newline
   2.256 +
   2.257 +tar x -vf $TARBALL > $LOG 2>&1 || \
   2.258   (echo "Failed to extract $TARBALL" ; exit 1)
   2.259 +
   2.260  status
   2.261  
   2.262 -# extracted pkg can be removed: Save RAM
   2.263 -rm -rf $SOURCE_DIR
   2.264 -
   2.265 -cd $TEMP_DIR/*/RPMS
   2.266 +# Remove archive file
   2.267 +rm -f $TARBALL
   2.268  
   2.269  # Extract everything from RPMS
   2.270 +cd $TMP_DIR/*/RPMS
   2.271  for i in *.rpm
   2.272 -do
   2.273 -	if (! echo $i | egrep -qi $EXCLUDE); then
   2.274 -		(rpm2cpio $i | cpio -id >> $LOG 2>&1 ) && rm  -f $i
   2.275 +  do
   2.276 +	if (! echo $i | egrep -qi $EXCLUDE)
   2.277 +	  then
   2.278 +		(rpm2cpio $i | cpio -id >> $LOG 2>&1 ) &&
   2.279 +		echo rm -f $i
   2.280  	fi
   2.281 -done
   2.282 +  done
   2.283  rpm2cpio desktop-integration/*freedesktop*.rpm | cpio -id >> $LOG 2>&1
   2.284  	
   2.285 -# extracted pkg can be removed: Save RAM
   2.286 +# extracted pkg can be removed
   2.287  rm -f desktop-integration/*freedesktop*.rpm
   2.288  
   2.289 +# Make the package
   2.290 +mkdir -p $PACKAGE-$VERSION/fs/usr/lib/openoffice
   2.291 +mkdir -p $PACKAGE-$VERSION/fs/usr/share
   2.292  
   2.293 -# Make the package
   2.294 -mkdir -p $PACKAGE-$VERSION/fs/usr/lib/openoffice  \
   2.295 -  $PACKAGE-$VERSION/fs/usr/share
   2.296 -
   2.297 -# use mv instead of 'cp -a' to save RAM
   2.298 -mv opt/openoffice* $PACKAGE-$VERSION/fs/usr/lib/openoffice
   2.299 -mv usr/share/mime $PACKAGE-$VERSION/fs/usr/share
   2.300 -mv usr/share/icons $PACKAGE-$VERSION/fs/usr/share
   2.301 -mv usr/bin $PACKAGE-$VERSION/fs/usr
   2.302 +# use mv instead of 'cp -a' to save space
   2.303 +mv opt/openoffice*	$PACKAGE-$VERSION/fs/usr/lib/openoffice
   2.304 +mv usr/share/mime	$PACKAGE-$VERSION/fs/usr/share
   2.305 +mv usr/share/icons	$PACKAGE-$VERSION/fs/usr/share
   2.306 +mv usr/bin		$PACKAGE-$VERSION/fs/usr
   2.307  
   2.308  # relocalized OOo libexec directory
   2.309 -sed -i 's#/opt/#/usr/lib/openoffice/#'  $PACKAGE-$VERSION/fs/usr/bin/openoffice*
   2.310 +sed -i 's#/opt/#/usr/lib/openoffice/#' \
   2.311 +	$PACKAGE-$VERSION/fs/usr/bin/openoffice*
   2.312  
   2.313  # Create receipt
   2.314  cat > $PACKAGE-$VERSION/receipt <<EOT
   2.315 @@ -163,8 +195,8 @@
   2.316  VERSION="$VERSION"
   2.317  CATEGORY="office"
   2.318  SHORT_DESC="Productivity suite."
   2.319 -DEPENDS="java-jre"
   2.320 -WEB_SITE="$URL"
   2.321 +DEPENDS="$DEPENDS"
   2.322 +WEB_SITE="$WEB_SITE"
   2.323  
   2.324  post_install()
   2.325  {
   2.326 @@ -176,7 +208,7 @@
   2.327  	ln -s /usr/lib/openoffice/openoffice.org3/share/xdg/math.desktop openoffice.org3-math.desktop
   2.328  	ln -s /usr/lib/openoffice/openoffice.org3/share/xdg/draw.desktop openoffice.org3-draw.desktop
   2.329  	ln -s /usr/lib/openoffice/openoffice.org3/share/xdg/printeradmin.desktop openoffice.org3-printeradmin.desktop
   2.330 -	
   2.331 +
   2.332  	cd \$1/usr/bin
   2.333  	ln -sf /usr/lib/openoffice/openoffice.org3/program/soffice
   2.334  }
   2.335 @@ -190,54 +222,56 @@
   2.336  
   2.337  fake_install()
   2.338  {
   2.339 -	mkdir -p $ROOT/var/lib/tazpkg/installed/$PACKAGE
   2.340 +	mkdir -p $root/var/lib/tazpkg/installed/$PACKAGE
   2.341  	echo "00000000000000000000000000000000  $PACKAGE-$VERSION.tazpkg" >> \
   2.342 -		$ROOT/var/lib/tazpkg/installed.md5
   2.343 -	[ -s $1/description.txt $ROOT/var/lib/tazpkg/installed/$PACKAGE
   2.344 +		$root/var/lib/tazpkg/installed.md5
   2.345 +	[ -s $1/description.txt $root/var/lib/tazpkg/installed/$PACKAGE
   2.346  	( cd fs ; find *) | sed 's|^|/|' > \
   2.347 -		$ROOT/var/lib/tazpkg/installed/$PACKAGE/files.list
   2.348 -	if grep -q ^CONFIG_FILES= $1/receipt ; then
   2.349 +		$root/var/lib/tazpkg/installed/$PACKAGE/files.list
   2.350 +	if grep -q ^CONFIG_FILES= $1/receipt
   2.351 +	  then
   2.352  		cd fs
   2.353 -		find $( . ./receipt ; echo " $CONFIG_FILES" | sed 's| /| |g') |\
   2.354 +		find $( . ./receipt ; echo " $CONFIG_FILES" | sed 's# /# #g') |\
   2.355  			cpio -o -H newc | gzip -9 > \
   2.356 -			$ROOT/var/lib/tazpkg/installed/$PACKAGE/volatile.cpio.gz
   2.357 -		for i in $( . ./receipt ; echo $CONFIG_FILES) ; do
   2.358 -			[ -e $ROOT$i ] && rm -rf .$i
   2.359 -		done
   2.360 +			$root/var/lib/tazpkg/installed/$PACKAGE/volatile.cpio.gz
   2.361 +		for i in $( . ./receipt ; echo $CONFIG_FILES)
   2.362 +		  do
   2.363 +			[ -e $root$i ] && rm -rf .$i
   2.364 +		  done
   2.365  		cd ..
   2.366  	fi
   2.367  	sed -i "s/^PACKAGE=/UNPACKED_SIZE=\"$(du -chs $1 | sed '$!d;s/.total//')\"\n&/" \
   2.368  		$1/receipt
   2.369 -	cp $1/receipt $ROOT/var/lib/tazpkg/installed/$PACKAGE
   2.370 +	cp $1/receipt	$root/var/lib/tazpkg/installed/$PACKAGE
   2.371  	echo "Compute md5sum..."
   2.372  	find fs -type f | xargs md5sum | sed 's|  fs/|  /|' > \
   2.373 -		$ROOT/var/lib/tazpkg/installed/$PACKAGE/md5sum
   2.374 +		$root/var/lib/tazpkg/installed/$PACKAGE/md5sum
   2.375  	echo "Move files..."
   2.376 -	( cd $1/fs ; find ) | while read file ; do 
   2.377 -		[ -e $1/fs/$file -a ! -e $ROOT/$file ] &&
   2.378 -		mv $1/fs/$file $(dirname $ROOT/$file)
   2.379 -	done
   2.380 +	( cd $1/fs ; find ) | while read file
   2.381 +	  do 
   2.382 +		[ -e $1/fs/$file -a ! -e $root/$file ] &&
   2.383 +		mv $1/fs/$file $(dirname $root/$file)
   2.384 +	  done
   2.385  }
   2.386  
   2.387 -case " $@ " in
   2.388 -*\ --q*)	# --quick
   2.389 -	fake_install $PACKAGE-$VERSION ;;
   2.390 -*)
   2.391 -	# Pack
   2.392 -	tazpkg pack $PACKAGE-$VERSION
   2.393 +[ "$install" == "quick" ] &&
   2.394 +fake_install $PACKAGE-$VERSION && return 0
   2.395  
   2.396 -	# Clean to save RAM memory
   2.397 -	rm -rf $PACKAGE-$VERSION
   2.398 +# Pack
   2.399 +tazpkg pack $PACKAGE-$VERSION
   2.400 +# Remove package tree
   2.401 +rm -rf $PACKAGE-$VERSION
   2.402  
   2.403 -	# Install pseudo package
   2.404 -	tazpkg install $PACKAGE-$VERSION.tazpkg --root=$ROOT
   2.405 +#	=== Install the SliTaz package ===
   2.406 +[ "$install" == "yes" ] &&
   2.407 +tazpkg install $PACKAGE-$VERSION.tazpkg --root="$root"
   2.408  
   2.409 -	echo " $@ " | grep -q ' --k' &&
   2.410 -	mv $PACKAGE-$VERSION.tazpkg $CUR_DIR
   2.411 -	;;
   2.412 -esac
   2.413 +#	=== Cleanup ===
   2.414 +# Preserve package file, if requested
   2.415 +[ "$keep" == "yes" ] &&
   2.416 +( mv $PACKAGE-$VERSION.tazpkg $CUR_DIR &&
   2.417 +  echo Saved $PACKAGE-$VERSION.tazpkg to $CUR_DIR )
   2.418  
   2.419 +# Remove temporary build directory
   2.420  cd $CUR_DIR
   2.421 -
   2.422 -# Clean
   2.423 -rm -rf $TEMP_DIR
   2.424 +rm -rf $TMP_DIR