wok-6.x rev 21192

updated command procedure get-google-earth
author Hans-G?nter Theisgen
date Fri Apr 05 16:34:43 2019 +0100 (2019-04-05)
parents a5dec5e18569
children 4fdb154bc832
files get-google-earth/receipt get-google-earth/stuff/get-google-earth
line diff
     1.1 --- a/get-google-earth/receipt	Wed Apr 03 18:28:33 2019 +0200
     1.2 +++ b/get-google-earth/receipt	Fri Apr 05 16:34:43 2019 +0100
     1.3 @@ -1,15 +1,15 @@
     1.4  # SliTaz package receipt.
     1.5  
     1.6  PACKAGE="get-google-earth"
     1.7 -VERSION="1.00"
     1.8 +VERSION="1.01"
     1.9  CATEGORY="non-free"
    1.10 +TAGS="map visualization"
    1.11  SHORT_DESC="Get Google Earth."
    1.12  MAINTAINER="pascal.bellard@slitaz.org"
    1.13  LICENSE="BSD"
    1.14 -WEB_SITE="http://earth.google.com/"
    1.15 -TAGS="map visualization"
    1.16 +WEB_SITE="https://google.com/earth/"
    1.17  
    1.18 -DEPENDS="bzip2 xorg-base-fonts"
    1.19 +DEPENDS=""
    1.20  
    1.21  # Rules to gen a SliTaz package suitable for Tazpkg.
    1.22  genpkg_rules()
    1.23 @@ -17,4 +17,3 @@
    1.24  	mkdir -p $fs/usr/bin
    1.25  	cp stuff/get-google-earth $fs/usr/bin
    1.26  }
    1.27 -
     2.1 --- a/get-google-earth/stuff/get-google-earth	Wed Apr 03 18:28:33 2019 +0200
     2.2 +++ b/get-google-earth/stuff/get-google-earth	Fri Apr 05 16:34:43 2019 +0100
     2.3 @@ -1,80 +1,194 @@
     2.4 -#!/bin/sh -e
     2.5 +#!/bin/sh
     2.6 +#
     2.7 +# get-google-earth - create and install SliTaz package google-earth
     2.8 +#
     2.9 +# (C) 2019 SliTaz - GNU General Public License v3.
    2.10 +# Author : unknown
    2.11 +# modified by HGT on 2019-04-05
    2.12 +#
    2.13  
    2.14 -DEPENDS="mesa"
    2.15 -ROOT="$1"
    2.16 -PACKAGE="google-earth"
    2.17 +#	=== Initialisations ===
    2.18  
    2.19 -if test $(id -u) != 0 ; then
    2.20 -	echo -e "\nYou must be root to run `basename $0`."
    2.21 -	echo -e "Please type 'su' and root password to become super-user.\n"
    2.22 -	exit 0
    2.23 +PKGS_DB="/var/lib/tazpkg"	# packages database directory
    2.24 +PACKAGE="google-earth"		# package to create and install
    2.25 +WEB_SITE="https://google.com/earth/"
    2.26 +CATEGORY="non-free"
    2.27 +DEPENDS="libglu-mesa"
    2.28 +
    2.29 +# Declare functions check_root, status, ...
    2.30 +. /lib/libtaz.sh
    2.31 +# and make commandline options (if any) available as variables
    2.32 +
    2.33 +is_installed()
    2.34 +{
    2.35 +	 if [ -d $ROOT$PKGS_DB/installed/$PACKAGE ]
    2.36 +	  then	#package is deemed to be installed
    2.37 +	 	return 0
    2.38 +	  else
    2.39 +	 	return 1
    2.40 +	 fi
    2.41 +}
    2.42 +
    2.43 +
    2.44 +# Show commandline options, if requested by --help
    2.45 +if [ "$help" == "yes" ]
    2.46 +	then
    2.47 +	echo "Commandline options:
    2.48 +  $0
    2.49 +	--version=<version>
    2.50 +	--root=<path-to-root>
    2.51 +	--install=yes|no
    2.52 +	--keep=no|yes
    2.53 +	--tmpdir=<directory-to-build-package>"
    2.54 +	exit
    2.55  fi
    2.56  
    2.57 -if [ -d $ROOT/var/lib/tazpkg/installed/google-earth ]; then
    2.58 -  [ -n "$ROOT" ] && exit 1
    2.59 -  tazpkg remove google-earth
    2.60 -  [ -d /var/lib/tazpkg/installed/google-earth ] && exit 1
    2.61 +# Check for system administrator privileges
    2.62 +check_root
    2.63 +
    2.64 +title "Package $PACKAGE will be build as SliTaz package and installed"
    2.65 +
    2.66 +# Fetch latest version, unless version is set by option --version
    2.67 +[ -z "$version" ] && version="latest"
    2.68 +
    2.69 +# Install SliTaz package, unless inhibited by option --install=no
    2.70 +[ -z "$install" ] && install="yes"
    2.71 +
    2.72 +# Delete SliTaz package file $PACKAGE-$VERSION.tazpkg after installation,
    2.73 +# unless option --keep=yes is given
    2.74 +[ -z "$keep" ] && keep="no"
    2.75 +
    2.76 +# Directory for temporary files
    2.77 +[ -z "$tempdir" ] && TMP_DIR="/tmp/get-$PACKAGE"
    2.78 +
    2.79 +# Logging file (unused by now)
    2.80 +LOG=$TMP_DIR/get-$PACKAGE.log
    2.81 +
    2.82 +cat <<EOT
    2.83 +Options in use:
    2.84 +  root           : $root/
    2.85 +  version        : $version
    2.86 +  install package: $install
    2.87 +  keep tazpkg    : $keep
    2.88 +  build directory: $TMP_DIR
    2.89 +
    2.90 +EOT
    2.91 +
    2.92 +separator; newline
    2.93 +
    2.94 +#	=== Remove package, if installed ===
    2.95 +if [ is_installed ]
    2.96 +	then
    2.97 +		action "Removing installed version..."
    2.98 +		tazpkg remove $PACKAGE --root="$root/"
    2.99 +		[ ! is_installed ] &&
   2.100 +		die "Can't remove installed version. Exiting."
   2.101  fi
   2.102  
   2.103 -TMP_DIR=/tmp/get-google-earth-$$-$RANDOM
   2.104 -CUR_DIR=$(pwd)
   2.105 -mkdir -p $TMP_DIR && cd $TMP_DIR
   2.106 +#	=== Fetch archive file, if not existing ===
   2.107  
   2.108 -# Download tarball
   2.109 -wget http://dl.google.com/earth/client/current/GoogleEarthLinux.bin
   2.110 -if [ ! -f GoogleEarthLinux.bin ]; then
   2.111 -	cd $CUR_DIR
   2.112 -	rm -rf $TMP_DIR
   2.113 -	echo "Could not download GoogleEarthLinux.bin. Exiting."
   2.114 -	exit 1
   2.115 +if [ "$version" == "latest" ]
   2.116 +	then
   2.117 +	  FILE="google-earth-stable_current_i386.deb"
   2.118 +	  WGET_URL="https://dl.google.com/dl/earth/client/current/$FILE"
   2.119 +	else
   2.120 +		# only available version is 7.3.0.3832-r0
   2.121 +	  FILE="google-earth-pro-stable_${version}_i386.deb"
   2.122 +	  V1=${version%%.*}
   2.123 +	  V3=${version%.*}
   2.124 +	  WGET_URL="https://dl.google.com/dl/earth/client/GE$V1/release_${V3//./_}/$FILE"
   2.125  fi
   2.126  
   2.127 -chmod +x GoogleEarthLinux.bin
   2.128 -sed -i 's/bzip2 -d/bunzip2/g' GoogleEarthLinux.bin
   2.129 +CUR_DIR=$(pwd)
   2.130 +mkdir -p $TMP_DIR
   2.131 +cd $TMP_DIR
   2.132 +if [ -f $FILE ]
   2.133 +	then
   2.134 +		echo "Using existing archive file $FILE"
   2.135 +	else
   2.136 +		action "Fetching the archive"
   2.137 +		newline
   2.138 +		wget	--no-check-certificate $WGET_URL
   2.139 +		if [ ! -f $FILE ]
   2.140 +		  then
   2.141 +			cd $CUR_DIR
   2.142 +			rm -rf $TMP_DIR
   2.143 +			echo "Could not transfer $FILE from $URL. Exiting."
   2.144 +			exit 1
   2.145 +		fi
   2.146 +fi
   2.147  
   2.148 -VERSION=$(head GoogleEarthLinux.bin | grep ^label | sed 's/.*Linux \(.*\)"/\1/')
   2.149 +#	=== Extract files from archive ===
   2.150 +action "Extracting the archive"
   2.151  
   2.152 -# Add depends
   2.153 -for i in $DEPENDS; do
   2.154 -	yes y | tazpkg get-install $i
   2.155 -done
   2.156 +mkdir $PACKAGE
   2.157 +# Extract metadata
   2.158 +dpkg-deb -e $FILE $PACKAGE/meta
   2.159 +# Extract files
   2.160 +dpkg-deb -x $FILE $PACKAGE/fs
   2.161 +status
   2.162  
   2.163 -# Extract
   2.164 -./GoogleEarthLinux.bin
   2.165 +# Remove archive file
   2.166 +rm -f $FILE
   2.167  
   2.168 -# extracted pkg can be removed: Save RAM
   2.169 -rm -rf GoogleEarthLinux.bin
   2.170 +#	=== Create SliTaz package ===
   2.171  
   2.172 -# Create pseudo package
   2.173 -while read file; do
   2.174 -	dest=google-earth-$VERSION/fs$(dirname $file)
   2.175 -	[ -d $dest ] || mkdir -p $dest
   2.176 -	cp -a $file $dest
   2.177 -done <<EOT
   2.178 -$(ls /*bin/googleearth /usr/*bin/googleearth 2> /dev/null)
   2.179 -$(ls /usr/share/applications/*googleearth*.desktop)
   2.180 -/usr/share/applications/defaults.list
   2.181 -$(ls -d /usr/*/google-earth)
   2.182 -EOT
   2.183 -cat > google-earth-$VERSION/receipt <<EOT
   2.184 -PACKAGE="google-earth"
   2.185 +# Prepare metadata for SliTaz package
   2.186 +sed '/^Description:/,$!d; /^Description:/d' $PACKAGE/meta/control \
   2.187 +	> $PACKAGE/description.txt
   2.188 +
   2.189 +SHORT_DESC="$(sed '/^Description:/!d; s/.*: //' $PACKAGE/meta/control)"
   2.190 +MAINTAINER="$(sed '/^Maintainer:/!d;  s/.*: //' $PACKAGE/meta/control)"
   2.191 +VERSION="$(   sed '/^Version:/!d;     s/.*: //' $PACKAGE/meta/control)"
   2.192 +VERSION=${VERSION%-*}	# remove -r* suffix
   2.193 + 
   2.194 +mv $PACKAGE $PACKAGE-$VERSION
   2.195 +
   2.196 +cd $PACKAGE-$VERSION
   2.197 +
   2.198 +# Create recipe for SliTaz package
   2.199 +cat > receipt <<EOT
   2.200 +# SliTaz package receipt.
   2.201 +
   2.202 +PACKAGE="$PACKAGE"
   2.203  VERSION="$VERSION"
   2.204 -CATEGORY="non-free"
   2.205 -SHORT_DESC="3D planet viewer."
   2.206 -WEB_SITE="http://earth.google.com/"
   2.207 +CATEGORY="$CATEGORY"
   2.208 +TAGS="maps"
   2.209 +SHORT_DESC="$SHORT_DESC"
   2.210 +MAINTAINER="$MAINTAINER"
   2.211 +LICENSE="non-free"
   2.212 +WEB_SITE="$WEB_SITE"
   2.213 +
   2.214  DEPENDS="$DEPENDS"
   2.215 +
   2.216 +post_install()
   2.217 +{
   2.218 +	# Due to different conventions in Debian
   2.219 +	[ -L /lib/ld-lsb.so.3 ] || ln -s ld-2.14.1.so /lib/ld-lsb.so.3
   2.220 +}
   2.221  EOT
   2.222  
   2.223 +# Copy desktop file
   2.224 +cp 	fs/opt/google/earth/pro/google-earth-pro.desktop \
   2.225 +	fs/usr/share/applications/$PACKAGE.desktop
   2.226 +
   2.227 +cd $TMP_DIR
   2.228 +
   2.229 +action "Creating the package $PACKAGE..."
   2.230  # Pack
   2.231  tazpkg pack $PACKAGE-$VERSION
   2.232  
   2.233 -# Clean to save RAM memory
   2.234 +# Remove package tree
   2.235  rm -rf $PACKAGE-$VERSION
   2.236  
   2.237 -# Install pseudo package
   2.238 -tazpkg install google-earth-$VERSION.tazpkg --root=$ROOT
   2.239 +#	=== Install the SliTaz package ===
   2.240 +[ "$install" == "yes" ] &&
   2.241 +tazpkg install $PACKAGE-$VERSION.tazpkg --root="$root"
   2.242  
   2.243 -# Clean
   2.244 +#	=== Cleanup ===
   2.245 +# Preserve package file, if requested
   2.246 +[ "$keep" == "yes" ] && mv $PACKAGE-$VERSION.tazpkg $CUR_DIR
   2.247 +
   2.248 +# Remove temporary build directory
   2.249  cd $CUR_DIR
   2.250  rm -rf $TMP_DIR
   2.251 -