wok rev 22839

modified get-litecoin
author Hans-G?nter Theisgen
date Tue Feb 11 10:43:44 2020 +0100 (6 months ago)
parents 950cf198f5a1
children bd6074cbab4c
files get-litecoin/receipt get-litecoin/stuff/get-litecoin
line diff
     1.1 --- a/get-litecoin/receipt	Tue Feb 11 09:52:23 2020 +0100
     1.2 +++ b/get-litecoin/receipt	Tue Feb 11 10:43:44 2020 +0100
     1.3 @@ -1,17 +1,16 @@
     1.4  # SliTaz package receipt.
     1.5  
     1.6  PACKAGE="get-litecoin"
     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 -WEB_SITE="http://litecoin.org/"
    1.14 +WEB_SITE="https://litecoin.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-litecoin $fs/usr/bin
    1.21 +	cp $stuff/get-litecoin	$fs/usr/bin
    1.22  }
    1.23 -
     2.1 --- a/get-litecoin/stuff/get-litecoin	Tue Feb 11 09:52:23 2020 +0100
     2.2 +++ b/get-litecoin/stuff/get-litecoin	Tue Feb 11 10:43:44 2020 +0100
     2.3 @@ -1,56 +1,150 @@
     2.4 -#!/bin/sh -e
     2.5 +#!/bin/sh
     2.6 +#
     2.7 +# get-litecoin - create and install SliTaz package litecoin
     2.8 +#
     2.9 +# (C) 2020 SliTaz - GNU General Public License v3.
    2.10 +# Author : Pascal Bellard
    2.11 +# modified by HGT on 2020-02-11
    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="litecoin"
    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://litecoin.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 +TMP_DIR="$tmpdir"
    2.80 +[ -z "$tmpdir" ] && TMP_DIR="/tmp/get-$PACKAGE"
    2.81 +
    2.82 +# Logging file (unused by now)
    2.83 +LOG="$logfile"
    2.84 +[ -z "$logfile" ] && LOG=$TMP_DIR/get-$PACKAGE.log
    2.85 +
    2.86 +cat <<EOT
    2.87 +Options in use:
    2.88 +  root           : $root/
    2.89 +  version        : $version
    2.90 +  install package: $install
    2.91 +  keep tazpkg    : $keep
    2.92 +  build directory: $TMP_DIR
    2.93 +
    2.94 +EOT
    2.95 +
    2.96 +separator; newline
    2.97 +
    2.98 +#	=== Remove package, if installed ===
    2.99 +if is_installed
   2.100 +  then
   2.101 +	echo "$PACKAGE is already installed."
   2.102 +	echo -n "Would you like to remove and reinstall this package [y/n]? "
   2.103 +	read answer
   2.104 +	case "$answer" in
   2.105 +		y|Y)
   2.106 +			action "Removing installed version..."
   2.107 +			tazpkg remove $PACKAGE --root="$root/"
   2.108 +			[ ! is_installed ] &&
   2.109 +			die "Can't remove installed version. Exiting."
   2.110 +			;;
   2.111 +		*)
   2.112 +			echo "Leaving $PACKAGE untouched."
   2.113 +			exit 0
   2.114 +			;;
   2.115 +	esac
   2.116  fi
   2.117  
   2.118 -TMP_DIR=/tmp/get-$PACKAGE-$$-$RANDOM
   2.119 -CUR_DIR=$(pwd)
   2.120 -mkdir -p $TMP_DIR && cd $TMP_DIR
   2.121 -
   2.122 -# Download tarball
   2.123 -URL=$(wget -O - $WEB_SITE | sed '/linux.tar/!d;;s/.*href="\([^"]*\).*/\1/')
   2.124 -FILE="$(basename $URL)"
   2.125 -VERSION="$(echo $FILE | sed 's/.*coin-\(.*\)-linux.tar.*/\1/')"
   2.126 -wget -O $FILE "$URL"
   2.127 -
   2.128 -if [ ! -f $FILE ]; then
   2.129 -	cd $CUR_DIR
   2.130 -	rm -rf $TMP_DIR
   2.131 -	echo "Could not download $FILE from $URL. Exiting."
   2.132 -	exit 1
   2.133 +#	=== Fetch archive file, if not existing ===
   2.134 +if [ "$version" == "latest" ]
   2.135 +  then
   2.136 +	WGET_URL=$(wget --no-check-certificate -O - $WEB_SITE | \
   2.137 +		sed '/i686-pc-linux-gnu.tar/!d;;s/.*href="\([^"]*\).*/\1/')
   2.138 +	FILE="$(basename $WGET_URL)"
   2.139 +	VERSION="$(echo $WGET_URL | sed 's|.*coin-\(.*\)/linux.*|\1|')"
   2.140 +  else
   2.141 +	FILE="litecoin-${version}-i686-pc-linux-gnu.tar.gz"
   2.142 +	WGET_URL="https://download.litecoin.org/litecoin-$version/linux/$FILE"
   2.143 +	VERSION=$version
   2.144  fi
   2.145  
   2.146 +CUR_DIR=$(pwd)
   2.147 +mkdir -p $TMP_DIR
   2.148 +cd $TMP_DIR
   2.149 +if [ -f $FILE ]
   2.150 +  then
   2.151 +	echo "Using existing archive file $FILE"
   2.152 +  else
   2.153 +	action "Fetching the archive"
   2.154 +	newline
   2.155 +	wget	--no-check-certificate $WGET_URL
   2.156 +	if [ ! -f $FILE ]
   2.157 +	  then
   2.158 +		cd $CUR_DIR
   2.159 +		rm -rf $TMP_DIR
   2.160 +		echo "Could not transfer $FILE from $WGET_URL. Exiting."
   2.161 +		exit 1
   2.162 +	fi
   2.163 +fi
   2.164 +
   2.165 +#	=== Extract files from archive ===
   2.166 +action "Extracting the archive"
   2.167 +newline
   2.168 +set -x
   2.169  mkdir -p $PACKAGE-$VERSION/fs/usr/bin
   2.170  busybox tar xf $FILE
   2.171 +mv $PACKAGE-$VERSION/bin/*	$PACKAGE-$VERSION/fs/usr/bin
   2.172  
   2.173 -mv $PACKAGE-$VERSION-linux/bin/32/* $PACKAGE-$VERSION/fs/usr/bin
   2.174 -rm -rf $PACKAGE-$VERSION-linux
   2.175 -
   2.176 -# extracted pkg can be removed: Save RAM
   2.177 +# Remove archive file
   2.178  rm -f $FILE
   2.179  
   2.180  cd $PACKAGE-$VERSION/fs
   2.181  
   2.182 -# Create menu
   2.183 +# Create desktop file
   2.184  mkdir -p usr/share/applications
   2.185  cat > usr/share/applications/$PACKAGE.desktop <<EOT
   2.186  [Desktop Entry]
   2.187 @@ -65,31 +159,39 @@
   2.188  Type=Application
   2.189  Categories=Office;
   2.190  EOT
   2.191 +
   2.192  cd ../..
   2.193  
   2.194 +# Create recipe for SliTaz package
   2.195  cat > $PACKAGE-$VERSION/receipt <<EOT
   2.196 +# SliTaz package receipt.
   2.197 +
   2.198  PACKAGE="$PACKAGE"
   2.199  VERSION="$VERSION"
   2.200  CATEGORY="$CATEGORY"
   2.201  SHORT_DESC="$SHORT_DESC"
   2.202  MAINTAINER="$MAINTAINER"
   2.203 +WEB_SITE="$WEB_SITE"
   2.204 +
   2.205  DEPENDS="$DEPENDS"
   2.206 -WEB_SITE="$WEB_SITE"
   2.207  EOT
   2.208  
   2.209 +action "Creating the package $PACKAGE..."
   2.210  # Pack
   2.211  tazpkg pack $PACKAGE-$VERSION
   2.212 -
   2.213 -# Clean to save RAM memory
   2.214 +# Remove package tree
   2.215  rm -rf $PACKAGE-$VERSION
   2.216  
   2.217 -# Install pseudo package
   2.218 -tazpkg install $PACKAGE-$VERSION.tazpkg --root=$ROOT
   2.219 -case " $@ " in
   2.220 -*\ --k*) mv $PACKAGE-$VERSION.tazpkg $CUR_DIR ;;
   2.221 -esac
   2.222 +#	=== Install the SliTaz package ===
   2.223 +[ "$install" == "yes" ] &&
   2.224 +tazpkg install $PACKAGE-$VERSION.tazpkg --root="$root"
   2.225  
   2.226 -# Clean
   2.227 +#	=== Cleanup ===
   2.228 +# Preserve package file, if requested
   2.229 +[ "$keep" == "yes" ] &&
   2.230 +( mv $PACKAGE-$VERSION.tazpkg $CUR_DIR &&
   2.231 +  echo Saved $PACKAGE-$VERSION.tazpkg to $CUR_DIR )
   2.232 +
   2.233 +# Remove temporary build directory
   2.234  cd $CUR_DIR
   2.235  rm -rf $TMP_DIR
   2.236 -