wok rev 22838

modified get-linuxqq
author Hans-G?nter Theisgen
date Tue Feb 11 09:52:23 2020 +0100 (6 months ago)
parents 0e12529acd24
children 4668ebef1dbf
files get-linuxqq/receipt get-linuxqq/stuff/get-linuxqq
line diff
     1.1 --- a/get-linuxqq/receipt	Tue Feb 11 08:08:11 2020 +0100
     1.2 +++ b/get-linuxqq/receipt	Tue Feb 11 09:52:23 2020 +0100
     1.3 @@ -1,16 +1,16 @@
     1.4  # SliTaz package receipt.
     1.5  
     1.6  PACKAGE="get-linuxqq"
     1.7 -VERSION="1.01"
     1.8 +VERSION="1.02"
     1.9  CATEGORY="non-free"
    1.10 +TAGS="im instant-messaging"
    1.11  SHORT_DESC="Instant messaging software from Tencent Inc."
    1.12  MAINTAINER="lufeng369@slitaz.org"
    1.13  LICENSE="BSD"
    1.14  WEB_SITE="http://im.qq.com/"
    1.15 -TAGS="im instant-messaging"
    1.16  
    1.17  genpkg_rules()
    1.18  {
    1.19      mkdir -p $fs/usr/bin
    1.20 -    cp stuff/get-linuxqq $fs/usr/bin
    1.21 +    cp stuff/get-linuxqq	$fs/usr/bin
    1.22  }
     2.1 --- a/get-linuxqq/stuff/get-linuxqq	Tue Feb 11 08:08:11 2020 +0100
     2.2 +++ b/get-linuxqq/stuff/get-linuxqq	Tue Feb 11 09:52:23 2020 +0100
     2.3 @@ -1,51 +1,142 @@
     2.4 -#!/bin/sh 
     2.5 +#!/bin/sh
     2.6 +#
     2.7 +# get-linuxqq - create and install SliTaz package linuxqq (Tencent QQ)
     2.8 +#
     2.9 +# (C) 2020 SliTaz - GNU General Public License v3.
    2.10 +# Author : unknown
    2.11 +# modified by HGT on 2020-02-11
    2.12 +#
    2.13  
    2.14 -# Get and install Tencent QQ for Linux
    2.15 +#	=== Initialisations ===
    2.16  
    2.17 +PKGS_DB="/var/lib/tazpkg"	# packages database directory
    2.18  PACKAGE="linuxqq"
    2.19 -VERSION="v1.0.2"
    2.20 -TARGZ="${PACKAGE}_${VERSION}_i386.tar.gz"
    2.21 -URL="http://dl_dir.qq.com/linuxqq/$TARGZ"
    2.22 -CUR_DIR=$(pwd)
    2.23 -TEMP_DIR=/tmp/$PACKAGE-$VERSION-$$
    2.24 -ROOT="$1"
    2.25 +VERSION="1.0.2"			# latest versions as 64-bit variants only
    2.26 +CATEGORY="non-free"
    2.27 +TAGS="chat im"
    2.28 +SHORT_DESC="QQ for Linux $VERSION."
    2.29 +WEB_SITE="http://im.qq.com/"
    2.30 +DEPENDS="gtk+ gdk-pixbuf"
    2.31  
    2.32 -# Check if we are root
    2.33 -if test $(id -u) != 0 ; then
    2.34 -    echo -e "\nYou must be root to run `basename $0`."
    2.35 -    echo -e "Please type 'su' and root password to become super-user.\n"
    2.36 -    exit 1
    2.37 +# Declare functions check_root, status, ...
    2.38 +. /lib/libtaz.sh
    2.39 +# and make commandline options (if any) available as variables
    2.40 +
    2.41 +is_installed()
    2.42 +{
    2.43 +	if [ -d $ROOT$PKGS_DB/installed/$PACKAGE ]
    2.44 +	  then	#package is deemed to be installed
    2.45 +	 	return 0
    2.46 +	  else
    2.47 +	 	return 1
    2.48 +	 fi
    2.49 +}
    2.50 +
    2.51 +# Show commandline options, if requested by --help
    2.52 +if [ "$help" == "yes" ]
    2.53 +  then
    2.54 +	echo "Commandline options:
    2.55 +  $0
    2.56 +	--root=<path-to-root>
    2.57 +	--install=yes|no
    2.58 +	--keep=no|yes
    2.59 +	--tmpdir=<directory-to-build-package>"
    2.60 +	exit
    2.61  fi
    2.62  
    2.63 -# Avoid reinstall
    2.64 -if [ -d $ROOT/var/lib/tazpkg/installed/$PACKAGE ]; then
    2.65 -    echo -e "\n$PACKAGE package is already installed.\n"
    2.66 -    exit 1
    2.67 +# Check for system administrator privileges
    2.68 +check_root
    2.69 +
    2.70 +title "Package $PACKAGE will be build as SliTaz package and installed"
    2.71 +
    2.72 +# Fetch latest version, unless version is set by option --version
    2.73 +[ -z "$version" ] && version="latest"	# unused
    2.74 +
    2.75 +# Install SliTaz package, unless inhibited by option --install=no
    2.76 +[ -z "$install" ] && install="yes"
    2.77 +
    2.78 +# Delete SliTaz package file $PACKAGE-$VERSION.tazpkg after installation,
    2.79 +# unless option --keep=yes is given
    2.80 +[ -z "$keep" ] && keep="no"
    2.81 +
    2.82 +# Directory for temporary files
    2.83 +TMP_DIR="$tmpdir"
    2.84 +[ -z "$tmpdir" ] && TMP_DIR="/tmp/get-$PACKAGE"
    2.85 +
    2.86 +# Logging file (unused by now)
    2.87 +LOG="$logfile"
    2.88 +[ -z "$logfile" ] && LOG=$TMP_DIR/get-$PACKAGE.log
    2.89 +
    2.90 +cat <<EOT
    2.91 +Options in use:
    2.92 +  root           : $root/
    2.93 +  install package: $install
    2.94 +  keep tazpkg    : $keep
    2.95 +  build directory: $TMP_DIR
    2.96 +
    2.97 +EOT
    2.98 +
    2.99 +separator; newline
   2.100 +
   2.101 +#	=== Remove package, if installed ===
   2.102 +if is_installed
   2.103 +  then
   2.104 +	echo "$PACKAGE is already installed."
   2.105 +	echo -n "Would you like to remove and reinstall this package [y/n]? "
   2.106 +	read answer
   2.107 +	case "$answer" in
   2.108 +		y|Y)
   2.109 +			action "Removing installed version..."
   2.110 +			tazpkg remove $PACKAGE --root="$root/"
   2.111 +			[ ! is_installed ] &&
   2.112 +			die "Can't remove installed version. Exiting."
   2.113 +			;;
   2.114 +		*)
   2.115 +			echo "Leaving $PACKAGE untouched."
   2.116 +			exit 0
   2.117 +			;;
   2.118 +	esac
   2.119  fi
   2.120  
   2.121 -# Create a TEMP_DIR
   2.122 -mkdir $TEMP_DIR
   2.123 -cd $TEMP_DIR
   2.124 -
   2.125 -# Download the file
   2.126 -wget $URL 
   2.127 -if [ ! -f $TARGZ ]; then
   2.128 -	cd $CUR_DIR
   2.129 -	rm -rf $TEMP_DIR
   2.130 -	echo "Could not download $TARGZ. Exiting."
   2.131 -	exit 1
   2.132 +#	=== Fetch archive file, if not existing ===
   2.133 +CUR_DIR=$(pwd)
   2.134 +mkdir -p $TMP_DIR
   2.135 +cd $TMP_DIR
   2.136 +FILE="${PACKAGE}_v${VERSION}_i386.tar.gz"
   2.137 +WGET_URL="http://dl_dir.qq.com/linuxqq/$FILE"
   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 -tar xzf $TARGZ
   2.155 +#	=== Extract files from archive ===
   2.156 +action "Extracting the archive"
   2.157 +newline
   2.158 +
   2.159 +tar xzf $FILE
   2.160  mkdir -p $PACKAGE-$VERSION/fs/usr/share/tencent/
   2.161  mkdir -p $PACKAGE-$VERSION/fs/usr/share/applications/
   2.162  mkdir -p $PACKAGE-$VERSION/fs/usr/bin/
   2.163 -mv $TEMP_DIR/${PACKAGE}_${VERSION}_i386 $TEMP_DIR/$PACKAGE-$VERSION/fs/usr/share/tencent/qq
   2.164 +mv $TMP_DIR/${PACKAGE}_v${VERSION}_i386 \
   2.165 +	$TMP_DIR/$PACKAGE-$VERSION/fs/usr/share/tencent/qq
   2.166  
   2.167 -# extracted pkg can be removed: Save RAM
   2.168 -rm -rf $TARGZ
   2.169 +# Remove archive file
   2.170 +rm -f $FILE
   2.171  
   2.172 -cd $TEMP_DIR
   2.173 +cd $TMP_DIR
   2.174 +
   2.175 +#	=== Create SliTaz package ===
   2.176  
   2.177  cat > $PACKAGE-$VERSION/fs/usr/bin/qq << EOT
   2.178  #!/bin/sh
   2.179 @@ -71,16 +162,21 @@
   2.180  Comment[zh_CN]=腾讯QQ
   2.181  EOT
   2.182  
   2.183 +# Create recipe for SliTaz package
   2.184  cat > $PACKAGE-$VERSION/receipt << EOT
   2.185 +# SliTaz package receipt.
   2.186 +
   2.187  PACKAGE="$PACKAGE"
   2.188  VERSION="$VERSION"
   2.189 -CATEGORY="non-free"
   2.190 -SHORT_DESC="QQ for Linux $VERSION."
   2.191 -DEPENDS="gtk+ gdk-pixbuf"
   2.192 -WEB_SITE="http://im.qq.com/"
   2.193 -TAGS="chat im"
   2.194 +CATEGORY="$CATEGORY"
   2.195 +TAGS="$TAGS"
   2.196 +SHORT_DESC="$SHORT_DESC"
   2.197 +WEB_SITE="$WEB_SITE"
   2.198  
   2.199 -post_install() {
   2.200 +DEPENDS="$DEPENDS"
   2.201 +
   2.202 +post_install()
   2.203 +{
   2.204      chroot $1/ /usr/bin/gdk-pixbuf-query-loaders --update-cache
   2.205  }
   2.206  EOT
   2.207 @@ -206,17 +302,25 @@
   2.208  YX35w3g+soD/l+P/AMNbZ955C9USAAAAAElFTkSuQmCC
   2.209  ====
   2.210  !
   2.211 -} > $TEMP_DIR/$PACKAGE-$VERSION/fs/usr/share/tencent/qq/qq.png
   2.212 +} > $TMP_DIR/$PACKAGE-$VERSION/fs/usr/share/tencent/qq/qq.png
   2.213  
   2.214 +action "Creating the package $PACKAGE..."
   2.215  # Pack
   2.216  tazpkg pack $PACKAGE-$VERSION
   2.217  
   2.218 -# Clean to save RAM memory
   2.219 +# Remove package tree
   2.220  rm -rf $PACKAGE-$VERSION
   2.221  
   2.222 -# Install pseudo package
   2.223 -yes y | tazpkg install $PACKAGE-$VERSION.tazpkg --root=$ROOT
   2.224 +#	=== Install the SliTaz package ===
   2.225 +[ "$install" == "yes" ] &&
   2.226 +yes y | tazpkg install $PACKAGE-$VERSION.tazpkg --root="$root"
   2.227  
   2.228 -# Clean
   2.229 +#	=== Cleanup ===
   2.230 +# Preserve package file, if requested
   2.231 +[ "$keep" == "yes" ] &&
   2.232 +( mv $PACKAGE-$VERSION.tazpkg $CUR_DIR &&
   2.233 +  echo Saved $PACKAGE-$VERSION.tazpkg to $CUR_DIR )
   2.234 +
   2.235 +# Remove temporary build directory
   2.236  cd $CUR_DIR
   2.237 -rm -rf $TEMP_DIR
   2.238 +rm -rf $TMP_DIR