wok-current rev 22807

updated get-bitcoin (1.00 -> 1.01)
author Hans-G?nter Theisgen
date Wed Jan 29 07:32:34 2020 +0100 (2020-01-29)
parents 666b1da48c97
children d95ae0b39830
files get-bitcoin/receipt get-bitcoin/stuff/get-bitcoin
line diff
     1.1 --- a/get-bitcoin/receipt	Tue Jan 28 15:57:03 2020 +0100
     1.2 +++ b/get-bitcoin/receipt	Wed Jan 29 07:32:34 2020 +0100
     1.3 @@ -1,17 +1,16 @@
     1.4  # SliTaz package receipt.
     1.5  
     1.6  PACKAGE="get-bitcoin"
     1.7 -VERSION="1.00"
     1.8 +VERSION="1.01"
     1.9  CATEGORY="misc"
    1.10  SHORT_DESC="Get digital currency tool for instant payments to anyone, anywhere."
    1.11  MAINTAINER="pascal.bellard@slitaz.org"
    1.12 -LICENSE="BSD"
    1.13 +LICENSE="GPLv3"
    1.14  WEB_SITE="http://bitcoin.org/"
    1.15  
    1.16  # Rules to gen a SliTaz package suitable for Tazpkg.
    1.17  genpkg_rules()
    1.18  {
    1.19  	mkdir -p $fs/usr/bin
    1.20 -	cp $stuff/get-bitcoin $fs/usr/bin
    1.21 +	cp $stuff/get-bitcoin	$fs/usr/bin
    1.22  }
    1.23 -
     2.1 --- a/get-bitcoin/stuff/get-bitcoin	Tue Jan 28 15:57:03 2020 +0100
     2.2 +++ b/get-bitcoin/stuff/get-bitcoin	Wed Jan 29 07:32:34 2020 +0100
     2.3 @@ -1,53 +1,136 @@
     2.4 -#!/bin/sh -e
     2.5 +#!/bin/sh
     2.6 +#
     2.7 +# get-bitcoin - create and install SliTaz package bitcoin
     2.8 +#
     2.9 +# (C) 2020 SliTaz - GNU General Public License v3.
    2.10 +# Author : unknown
    2.11 +# modified by HGT on 2020-01-29
    2.12 +#
    2.13  
    2.14 -PACKAGE="$(basename $0 | sed 's/get-//')"
    2.15 +#	=== Initialisations ===
    2.16 +
    2.17 +PKGS_DB="/var/lib/tazpkg"	# packages database directory
    2.18 +PACKAGE="bitcoin"
    2.19  CATEGORY="misc"
    2.20 -WEB_SITE="http://$PACKAGE.org/"
    2.21  SHORT_DESC="New digital currency for instant payments to anyone, anywhere."
    2.22  MAINTAINER="somebody@$PACKAGE.org"
    2.23 +WEB_SITE="https://bitcoin.org/"
    2.24  DEPENDS="libQtGui bzlib"
    2.25  
    2.26 -ROOT="$1"
    2.27 -[ -d "$ROOT" ] || ROOT=""
    2.28 +# Declare functions check_root, status, ...
    2.29 +. /lib/libtaz.sh
    2.30 +# and make commandline options (if any) available as variables
    2.31  
    2.32 -if test $(id -u) != 0 ; then
    2.33 -        echo -e "\nYou must be root to run `basename $0`."
    2.34 -        echo -e "Please type 'su' and root password to become super-user.\n"
    2.35 -        exit 0
    2.36 +is_installed()
    2.37 +{
    2.38 +	if [ -d $ROOT$PKGS_DB/installed/$PACKAGE ]
    2.39 +	  then	#package is deemed to be installed
    2.40 +	 	return 0
    2.41 +	  else
    2.42 +	 	return 1
    2.43 +	 fi
    2.44 +}
    2.45 +
    2.46 +# Show commandline options, if requested by --help
    2.47 +if [ "$help" == "yes" ]
    2.48 +  then
    2.49 +	echo "Commandline options:
    2.50 +  $0
    2.51 +	--version=<version>
    2.52 +	--root=<path-to-root>
    2.53 +	--install=yes|no
    2.54 +	--keep=no|yes
    2.55 +	--tmpdir=<directory-to-build-package>"
    2.56 +	exit
    2.57  fi
    2.58  
    2.59 -if [ -d $ROOT/var/lib/tazpkg/installed/$PACKAGE ]; then
    2.60 -	[ -n "$ROOT" ] && exit 1
    2.61 -	tazpkg remove $PACKAGE
    2.62 -	[ -d /var/lib/tazpkg/installed/$PACKAGE ] && exit 1
    2.63 +# Check for system administrator privileges
    2.64 +check_root
    2.65 +
    2.66 +title "Package $PACKAGE will be build as SliTaz package and installed"
    2.67 +
    2.68 +# Fetch latest version, unless version is set by option --version
    2.69 +[ -z "$version" ] && version="latest"
    2.70 +
    2.71 +# Install SliTaz package, unless inhibited by option --install=no
    2.72 +[ -z "$install" ] && install="yes"
    2.73 +
    2.74 +# Delete SliTaz package file $PACKAGE-$VERSION.tazpkg after installation,
    2.75 +# unless option --keep=yes is given
    2.76 +[ -z "$keep" ] && keep="no"
    2.77 +
    2.78 +# Directory for temporary files
    2.79 +[ -z "$tempdir" ] && TMP_DIR="/tmp/get-$PACKAGE"
    2.80 +
    2.81 +# Logging file (unused by now)
    2.82 +LOG=$TMP_DIR/get-$PACKAGE.log
    2.83 +
    2.84 +cat <<EOT
    2.85 +Options in use:
    2.86 +  root           : $root/
    2.87 +  version        : $version
    2.88 +  install package: $install
    2.89 +  keep tazpkg    : $keep
    2.90 +  build directory: $TMP_DIR
    2.91 +
    2.92 +EOT
    2.93 +
    2.94 +separator; newline
    2.95 +
    2.96 +#	=== Remove package, if installed ===
    2.97 +if [ is_installed ]
    2.98 +  then
    2.99 +	action "Removing installed version..."
   2.100 +	tazpkg remove $PACKAGE --root="$root/"
   2.101 +	[ ! is_installed ] &&
   2.102 +	die "Can't remove installed version. Exiting."
   2.103  fi
   2.104  
   2.105 -TMP_DIR=/tmp/get-$PACKAGE-$$-$RANDOM
   2.106 -CUR_DIR=$(pwd)
   2.107 -mkdir -p $TMP_DIR && cd $TMP_DIR
   2.108 -
   2.109 -# Download tarball
   2.110 -URL=$(wget -O - $WEB_SITE/en/download | sed \
   2.111 -      '/linux.tar/!d;s/.*href="\([^"]*\).*/\1/;s|/download$||')
   2.112 -FILE="$(basename $URL)"
   2.113 -VERSION="$(echo $FILE | sed 's/.*coin-\(.*\)-linux.tar.*/\1/')"
   2.114 -wget -O $FILE "$URL"
   2.115 -
   2.116 -if [ ! -f $FILE ]; then
   2.117 -	cd $CUR_DIR
   2.118 -	rm -rf $TMP_DIR
   2.119 -	echo "Could not download $FILE from $URL. Exiting."
   2.120 -	exit 1
   2.121 +#	=== Fetch archive file, if not existing ===
   2.122 +if [ "$version" == "latest" ]
   2.123 +  then
   2.124 +	WGET_URL=$(wget -q --no-check-certificate -O - ${WEB_SITE}en/download | \
   2.125 +		sed '/linux-gnu.tar/!d; /i686/!d; s/.*href="\([^"]*\).*/\1/; s|/download$||')
   2.126 +	WGET_URL=${WEB_SITE}$WGET_URL
   2.127 +	FILE="$(basename $WGET_URL)"
   2.128 +	VERSION="$(echo $FILE | sed 's|.*coin-\(.*\)-i686.*|\1|')"
   2.129 +  else
   2.130 +	FILE="bitcoin-$version-i686-pc-linux-gnu.tar.gz"
   2.131 +	WGET_URL="https://bitcoincore.org/bin/bitcoin-core-$version/$FILE"
   2.132 +	VERSION=$version
   2.133  fi
   2.134  
   2.135 +CUR_DIR=$(pwd)
   2.136 +mkdir -p $TMP_DIR
   2.137 +cd $TMP_DIR
   2.138 +if [ -f $FILE ]
   2.139 +  then
   2.140 +	echo "Using existing archive file $FILE"
   2.141 +  else
   2.142 +	action "Fetching the archive"
   2.143 +	newline
   2.144 +	wget	--no-check-certificate $WGET_URL
   2.145 +	if [ ! -f $FILE ]
   2.146 +	  then
   2.147 +		cd $CUR_DIR
   2.148 +		rm -rf $TMP_DIR
   2.149 +		echo "Could not transfer $FILE from $WGET_URL. Exiting."
   2.150 +		exit 1
   2.151 +	fi
   2.152 +fi
   2.153 +
   2.154 +#	=== Extract files from archive ===
   2.155 +action "Extracting the archive"
   2.156 +newline
   2.157 +busybox tar x -f $FILE
   2.158 +
   2.159  mkdir -p $PACKAGE-$VERSION/fs/usr/bin
   2.160 -busybox tar xf $FILE
   2.161 +mv $PACKAGE-$VERSION/bin/*	$PACKAGE-$VERSION/fs/usr/bin
   2.162  
   2.163 -mv $PACKAGE-$VERSION-linux/bin/32/* $PACKAGE-$VERSION/fs/usr/bin
   2.164 -rm -rf $PACKAGE-$VERSION-linux
   2.165 +# Remove archive file
   2.166 +rm -f $FILE
   2.167  
   2.168 -# extracted pkg can be removed: Save RAM
   2.169 -rm -f $FILE
   2.170 +#	=== Create SliTaz package ===
   2.171  
   2.172  cd $PACKAGE-$VERSION/fs
   2.173  
   2.174 @@ -66,9 +149,11 @@
   2.175  Type=Application
   2.176  Categories=Office;
   2.177  EOT
   2.178 -cd ../..
   2.179  
   2.180 -cat > $PACKAGE-$VERSION/receipt <<EOT
   2.181 +cd ..
   2.182 +
   2.183 +# Create recipe for SliTaz package
   2.184 +cat > receipt <<EOT
   2.185  PACKAGE="$PACKAGE"
   2.186  VERSION="$VERSION"
   2.187  CATEGORY="$CATEGORY"
   2.188 @@ -78,19 +163,24 @@
   2.189  WEB_SITE="$WEB_SITE"
   2.190  EOT
   2.191  
   2.192 +cd $TMP_DIR
   2.193 +
   2.194 +action "Creating the package $PACKAGE..."
   2.195  # Pack
   2.196  tazpkg pack $PACKAGE-$VERSION
   2.197  
   2.198 -# Clean to save RAM memory
   2.199 +# Remove package tree
   2.200  rm -rf $PACKAGE-$VERSION
   2.201  
   2.202 -# Install pseudo package
   2.203 -tazpkg install $PACKAGE-$VERSION.tazpkg --root=$ROOT
   2.204 -case " $@ " in
   2.205 -*\ --k*) mv $PACKAGE-$VERSION.tazpkg $CUR_DIR ;;
   2.206 -esac
   2.207 +#	=== Install the SliTaz package ===
   2.208 +[ "$install" == "yes" ] &&
   2.209 +tazpkg install $PACKAGE-$VERSION.tazpkg --root="$root"
   2.210  
   2.211 -# Clean
   2.212 +#	=== Cleanup ===
   2.213 +# Preserve package file, if requested
   2.214 +[ "$keep" == "yes" ] &&
   2.215 +mv $PACKAGE-$VERSION.tazpkg	$CUR_DIR
   2.216 +
   2.217 +# Remove temporary build directory
   2.218  cd $CUR_DIR
   2.219  rm -rf $TMP_DIR
   2.220 -