wok rev 22806

updated get-algobox (1.00 -> 1.01)
author Hans-G?nter Theisgen
date Tue Jan 28 15:57:03 2020 +0100 (6 months ago)
parents 72dc2894e87b
children 0467021a4935
files get-algobox/receipt get-algobox/stuff/get-algobox
line diff
     1.1 --- a/get-algobox/receipt	Tue Jan 28 10:03:39 2020 +0100
     1.2 +++ b/get-algobox/receipt	Tue Jan 28 15:57:03 2020 +0100
     1.3 @@ -1,17 +1,19 @@
     1.4  # SliTaz package receipt.
     1.5  
     1.6  PACKAGE="get-algobox"
     1.7 -VERSION="1.00"
     1.8 +VERSION="1.01"
     1.9  CATEGORY="misc"
    1.10 -SHORT_DESC="Get the Algorithm creation tool for education"
    1.11 -MAINTAINER="devel@slitaz.org"
    1.12 +SHORT_DESC="Get the Algorithm creation tool for education."
    1.13 +MAINTAINER="maintainer@slitaz.org"
    1.14  LICENSE="BSD"
    1.15 -WEB_SITE="http://www.xm1math.net/algobox/"
    1.16 +WEB_SITE="https://www.xm1math.net/algobox/"
    1.17 +
    1.18 +# fetches latest version only!
    1.19 +# available versions are amd64 only!
    1.20  
    1.21  # Rules to gen a SliTaz package suitable for Tazpkg.
    1.22  genpkg_rules()
    1.23  {
    1.24  	mkdir -p $fs/usr/bin
    1.25 -	cp stuff/get-algobox $fs/usr/bin
    1.26 +	cp stuff/get-algobox	$fs/usr/bin
    1.27  }
    1.28 -
     2.1 --- a/get-algobox/stuff/get-algobox	Tue Jan 28 10:03:39 2020 +0100
     2.2 +++ b/get-algobox/stuff/get-algobox	Tue Jan 28 15:57:03 2020 +0100
     2.3 @@ -1,82 +1,185 @@
     2.4 -#!/bin/sh -e
     2.5 +#!/bin/sh
     2.6 +#
     2.7 +# get-package - create and install SliTaz package algobox
     2.8 +#
     2.9 +# (C) 2020 SliTaz - GNU General Public License v3.
    2.10 +# Author : unknown
    2.11 +# modified by HGT on 2020-01-28
    2.12 +#
    2.13 +#	=== Initialisations ===
    2.14  
    2.15 +PKGS_DB="/var/lib/tazpkg"	# packages database directory
    2.16  PACKAGE="algobox"
    2.17 -WEB_SITE="http://www.xm1math.net/algobox/"
    2.18 +WEB_SITE="https://www.xm1math.net/algobox/"
    2.19  CATEGORY="misc"
    2.20 -SHORT_DESC="Algorithm creation tool for education"
    2.21 +SHORT_DESC="Algorithm creation tool for education."
    2.22  DEPENDS="libQtWebkit libQtXml libQtGui libQtCore gcc-lib-base"
    2.23  URL="${WEB_SITE}download.html"
    2.24  
    2.25 -ROOT="$1"
    2.26 -[ -d "$ROOT" ] || ROOT=""
    2.27 +# Declare functions check_root, status, ...
    2.28 +. /lib/libtaz.sh
    2.29 +# and make commandline options (if any) available as variables
    2.30  
    2.31 -if test $(id -u) != 0 ; then
    2.32 -        echo -e "\nYou must be root to run `basename $0`."
    2.33 -        echo -e "Please type 'su' and root password to become super-user.\n"
    2.34 -        exit 0
    2.35 +is_installed()
    2.36 +{
    2.37 +	if [ -d $ROOT$PKGS_DB/installed/$PACKAGE ]
    2.38 +	  then	#package is deemed to be installed
    2.39 +	 	return 0
    2.40 +	  else
    2.41 +	 	return 1
    2.42 +	fi
    2.43 +}
    2.44 +
    2.45 +# Show commandline options, if requested by --help
    2.46 +if [ "$help" == "yes" ]
    2.47 +  then
    2.48 +	echo "Commandline options:
    2.49 +  $0
    2.50 +	--version=<version>
    2.51 +	--root=<path-to-root>
    2.52 +	--install=yes|no
    2.53 +	--keep=no|yes
    2.54 +	--tmpdir=<directory-to-build-package>"
    2.55 +	exit
    2.56  fi
    2.57  
    2.58 -if [ -d $ROOT/var/lib/tazpkg/installed/$PACKAGE ]; then
    2.59 -	[ -n "$ROOT" ] && exit 1
    2.60 -	tazpkg remove $PACKAGE
    2.61 -	[ -d /var/lib/tazpkg/installed/$PACKAGE ] && exit 1
    2.62 +# Check for system administrator privileges
    2.63 +check_root
    2.64 +
    2.65 +title "Package $PACKAGE will be build as SliTaz package and installed"
    2.66 +
    2.67 +# Fetch latest version, unless version is set by option --version
    2.68 +[ -z "$version" ] && version="latest"
    2.69 +
    2.70 +# Install SliTaz package, unless inhibited by option --install=no
    2.71 +[ -z "$install" ] && install="yes"
    2.72 +
    2.73 +# Delete SliTaz package file $PACKAGE-$VERSION.tazpkg after installation,
    2.74 +# unless option --keep=yes is given
    2.75 +[ -z "$keep" ] && keep="no"
    2.76 +
    2.77 +# Directory for temporary files
    2.78 +[ -z "$tempdir" ] && TMP_DIR="/tmp/get-$PACKAGE"
    2.79 +
    2.80 +# Logging file (unused by now)
    2.81 +LOG=$TMP_DIR/get-$PACKAGE.log
    2.82 +
    2.83 +cat <<EOT
    2.84 +Options in use:
    2.85 +  root           : $root/
    2.86 +  version        : $version
    2.87 +  install package: $install
    2.88 +  keep tazpkg    : $keep
    2.89 +  build directory: $TMP_DIR
    2.90 +
    2.91 +EOT
    2.92 +
    2.93 +separator; newline
    2.94 +
    2.95 +#	=== Remove package, if installed ===
    2.96 +if [ is_installed ]
    2.97 +  then
    2.98 +	action "Removing installed version..."
    2.99 +	tazpkg remove $PACKAGE --root="$root/"
   2.100 +	[ ! is_installed ] &&
   2.101 +	die "Can't remove installed version. Exiting."
   2.102  fi
   2.103  
   2.104 -TMP_DIR=/tmp/get-$PACKAGE-$$-$RANDOM
   2.105 -CUR_DIR=$(pwd)
   2.106 -mkdir -p $TMP_DIR && cd $TMP_DIR
   2.107 +#	=== Fetch archive file, if not existing ===
   2.108  
   2.109 -URL="$WEB_SITE$(wget -O - sed '/debian_wheezy_i386/!d;s/.*href=.\([^"]*\).*/\1/')"
   2.110 -FILE="$(basename $URL)"
   2.111 -
   2.112 -# Download deb
   2.113 -wget -O $FILE $URL
   2.114 -
   2.115 -if [ ! -f $FILE ]; then
   2.116 -	cd $CUR_DIR
   2.117 -	rm -rf $TMP_DIR
   2.118 -	echo "Could not download $FILE from $URL. Exiting."
   2.119 -	exit 1
   2.120 +if [ "$version" == "latest" ]
   2.121 +  then
   2.122 +	FILE=$(wget -q -O - $URL | sed '/debian_10_amd64.deb/!d; s|.*href=.\([^"]*\).*|\1|')
   2.123 +	WGET_URL="${WEB_SITE}$FILE"
   2.124 +	FILE=$(basename $FILE)
   2.125 +  else
   2.126 +	die "Can fetch latest version only. Exiting."
   2.127  fi
   2.128  
   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 +#	=== Extract files from archive ===
   2.149 +action "Extracting the archive"
   2.150 +
   2.151  mkdir $PACKAGE
   2.152 +# Extract metadata from Debian package
   2.153  dpkg-deb -e $FILE $PACKAGE/meta
   2.154 +# Extract files from Debian package
   2.155  dpkg-deb -x $FILE $PACKAGE/fs
   2.156 -# extracted pkg can be removed: Save RAM
   2.157 +status
   2.158 +
   2.159 +# Remove archive file
   2.160  rm -f $FILE
   2.161 -if ! grep -q "insert long description" $PACKAGE/meta/control ; then
   2.162 +
   2.163 +#	=== Create SliTaz package ===
   2.164 +
   2.165 +# Prepare metadata for SliTaz package
   2.166 +
   2.167 +if ! grep -q "insert long description" $PACKAGE/meta/control
   2.168 +  then
   2.169  	sed '/^Description:/,$!d;s/^Description://' \
   2.170  		< $PACKAGE/meta/control > $PACKAGE/description.txt
   2.171 -	SHORT_DESC="$(sed '/^Description:/!d;s/.*: //' $PACKAGE/meta/control)"
   2.172 -if
   2.173 +fi
   2.174 +SHORT_DESC="$(sed '/^Description:/!d; s/.*: //' $PACKAGE/meta/control)"
   2.175 +MAINTAINER="$(sed '/^Maintainer:/!d;  s/.*: //' $PACKAGE/meta/control)"
   2.176 +VERSION="$(   sed '/^Version:/!d;     s/.*: //' $PACKAGE/meta/control)"
   2.177  
   2.178 -MAINTAINER="$(sed '/^Maintainer:/!d;s/.*: //' $PACKAGE/meta/control)"
   2.179 -VERSION="$(sed '/^Version:/!d;s/.*: //' $PACKAGE/meta/control)"
   2.180 +# rename build directory
   2.181  mv $PACKAGE $PACKAGE-$VERSION
   2.182  
   2.183 -cat > $PACKAGE-$VERSION/receipt <<EOT
   2.184 +cd $PACKAGE-$VERSION
   2.185 +
   2.186 +# Create recipe for SliTaz package
   2.187 +cat > receipt <<EOT
   2.188 +# SliTaz package receipt.
   2.189 +
   2.190 +PACKED_SIZE=""
   2.191 +UNPACKED_SIZE=""
   2.192  PACKAGE="$PACKAGE"
   2.193  VERSION="$VERSION"
   2.194  CATEGORY="$CATEGORY"
   2.195 +TAGS="$TAGS"
   2.196  SHORT_DESC="$SHORT_DESC"
   2.197  MAINTAINER="$MAINTAINER"
   2.198 +LICENSE="non-free"
   2.199 +WEB_SITE="$WEB_SITE"
   2.200 +
   2.201  DEPENDS="$DEPENDS"
   2.202 -WEB_SITE="$WEB_SITE"
   2.203 +
   2.204  EOT
   2.205  
   2.206 +action "Creating the package $PACKAGE..."
   2.207  # Pack
   2.208 +cd ..
   2.209  tazpkg pack $PACKAGE-$VERSION
   2.210 -
   2.211 -# Clean to save RAM memory
   2.212 +# Remove package tree
   2.213  rm -rf $PACKAGE-$VERSION
   2.214  
   2.215 -# Install pseudo package
   2.216 -tazpkg install $PACKAGE-$VERSION.tazpkg --root=$ROOT
   2.217 -case " $@ " in
   2.218 -*\ --k*) mv $PACKAGE-$VERSION.tazpkg $CUR_DIR ;;
   2.219 -esac
   2.220 +#	=== Install the SliTaz package ===
   2.221 +[ "$install" == "yes" ] &&
   2.222 +tazpkg install $PACKAGE-$VERSION.tazpkg --root="$root"
   2.223  
   2.224 -# Clean
   2.225 +#	=== Cleanup ===
   2.226 +# Preserve package file, if requested
   2.227 +[ "$keep" == "yes" ] && mv $PACKAGE-$VERSION.tazpkg $CUR_DIR
   2.228 +
   2.229 +# Remove temporary build directory
   2.230  cd $CUR_DIR
   2.231  rm -rf $TMP_DIR
   2.232 -