wok rev 22828

modified get-dropbox
author Hans-G?nter Theisgen
date Fri Feb 07 17:22:48 2020 +0100 (2020-02-07)
parents be5fbd5b2c7a
children 261355c410d6
files get-dropbox/receipt get-dropbox/stuff/get-dropbox
line diff
     1.1 --- a/get-dropbox/receipt	Fri Feb 07 16:26:49 2020 +0100
     1.2 +++ b/get-dropbox/receipt	Fri Feb 07 17:22:48 2020 +0100
     1.3 @@ -1,19 +1,26 @@
     1.4  # SliTaz package receipt.
     1.5  
     1.6  PACKAGE="get-dropbox"
     1.7 -VERSION="1.00"
     1.8 +VERSION="1.01"
     1.9  CATEGORY="non-free"
    1.10 +TAGS="sync storage"
    1.11  SHORT_DESC="Get Dropbox daemon and client for online storage."
    1.12  MAINTAINER="pankso@slitaz.org"
    1.13  LICENSE="BSD"
    1.14 -WEB_SITE="http://www.getdropbox.com/"
    1.15 -DEPENDS="wget"
    1.16 -TAGS="sync storage"
    1.17 +WEB_SITE="https://www.getdropbox.com/"
    1.18  
    1.19  # Rules to gen a SliTaz package suitable for Tazpkg.
    1.20  genpkg_rules()
    1.21  {
    1.22 -	mkdir -p $fs/usr/bin $fs/usr/share/pixmaps
    1.23 -	cp stuff/get-dropbox $fs/usr/bin
    1.24 -	cp stuff/dropbox.png $fs/usr/share/pixmaps
    1.25 +	mkdir -p $fs/usr/bin
    1.26 +	mkdir -p $fs/usr/share/pixmaps
    1.27 +
    1.28 +	cp stuff/get-dropbox	$fs/usr/bin
    1.29 +	cp stuff/dropbox.png	$fs/usr/share/pixmaps
    1.30  }
    1.31 +
    1.32 +post_install()
    1.33 +{
    1.34 +	echo "Now you may enter:
    1.35 +get-dropbox"
    1.36 +}
     2.1 --- a/get-dropbox/stuff/get-dropbox	Fri Feb 07 16:26:49 2020 +0100
     2.2 +++ b/get-dropbox/stuff/get-dropbox	Fri Feb 07 17:22:48 2020 +0100
     2.3 @@ -1,63 +1,146 @@
     2.4 -#!/bin/sh 
     2.5 +#!/bin/sh
     2.6 +#
     2.7 +# get-dropbox - create and install SliTaz package dropbox
     2.8 +#
     2.9 +# (C) 2020 SliTaz - GNU General Public License v3.
    2.10 +# Author : unknown
    2.11 +# modified by HGT on 2020-02-07
    2.12 +#
    2.13  
    2.14 -# Get and install Dropbox for Linux
    2.15 +#	=== Initialisations ===
    2.16  
    2.17 +PKGS_DB="/var/lib/tazpkg"	# packages database directory
    2.18  PACKAGE="dropbox"
    2.19 -WEB_SITE="http://www.dropbox.com"
    2.20 -PLATFORM="lnx.x86"	# or lnx.x86_64
    2.21 -TARBALL=$PACKAGE-$PLATFORM.tar.gz
    2.22 -URL="$WEB_SITE/download/?plat=$PLATFORM"
    2.23 -CUR_DIR=$(pwd)
    2.24 -TEMP_DIR=/tmp/$PACKAGE-$PLATFORM-$$
    2.25 -ROOT="$1"
    2.26 +WEB_SITE="https://www.dropbox.com"
    2.27 +CATEGORY="non-free"
    2.28 +DEPENDS="python"
    2.29  
    2.30 -# Check if we are root
    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 1
    2.35 +PLATFORM="lnx.x86"		# or lnx.x86_64
    2.36 +
    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 (unusable by now)
    2.73 +[ -z "$version" ] && version="latest"
    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 +[ -z "$tempdir" ] && TMP_DIR="/tmp/get-$PACKAGE"
    2.84 +
    2.85 +# Logging file (unused by now)
    2.86 +LOG=$TMP_DIR/get-$PACKAGE.log
    2.87 +
    2.88 +cat <<EOT
    2.89 +Options in use:
    2.90 +  root           : $root/
    2.91 +  install package: $install
    2.92 +  keep tazpkg    : $keep
    2.93 +  build directory: $TMP_DIR
    2.94 +
    2.95 +EOT
    2.96 +
    2.97 +separator; newline
    2.98 +
    2.99 +#	=== Remove package, if installed ===
   2.100 +if [ is_installed ]
   2.101 +  then
   2.102 +	action "Removing installed version..."
   2.103 +	tazpkg remove $PACKAGE --root="$root/"
   2.104 +	[ ! is_installed ] &&
   2.105 +	die "Can't remove installed version. Exiting."
   2.106  fi
   2.107  
   2.108 -# Create a TEMP_DIR
   2.109 -mkdir $TEMP_DIR
   2.110 -cd $TEMP_DIR
   2.111 -
   2.112 -# Download the file
   2.113 -wget --no-check-certificate -O $TARBALL $URL 
   2.114 -
   2.115 -if [ ! -f $TARBALL ]; then
   2.116 -	echo "Could not download $TARBALL. Exiting."
   2.117 -	cd $CUR_DIR
   2.118 -	rm -rf $TEMP_DIR
   2.119 -	exit 1
   2.120 +#	=== Fetch archive file, if not existing ===
   2.121 +if [ "$version" == "latest" ]
   2.122 +  then
   2.123 +	FILE=$PACKAGE-$PLATFORM.tar.gz
   2.124 +	WGET_URL="$WEB_SITE/download?plat=$PLATFORM"
   2.125 +  else
   2.126 +	die "A version cannot be specified. Exiting."
   2.127  fi
   2.128  
   2.129 -tar xzf $TARBALL
   2.130 -# extracted pkg can be removed: Save RAM
   2.131 -rm -f $TARBALL
   2.132 -VERSION="$(cat $TEMP_DIR/.dropbox-dist/VERSION)"
   2.133 +CUR_DIR=$(pwd)
   2.134 +mkdir -p $TMP_DIR
   2.135 +cd $TMP_DIR
   2.136 +if [ -f $FILE ]
   2.137 +  then
   2.138 +	echo "Using existing archive file $FILE"
   2.139 +  else
   2.140 +	action "Fetching the archive"
   2.141 +	newline
   2.142 +	wget	--no-check-certificate -O $FILE $WGET_URL
   2.143 +	if [ ! -f $FILE ]
   2.144 +	  then
   2.145 +		cd $CUR_DIR
   2.146 +		rm -rf $TMP_DIR
   2.147 +		echo "Could not transfer $FILE from $WGET_URL. Exiting."
   2.148 +		exit 1
   2.149 +	fi
   2.150 +fi
   2.151  
   2.152 -mkdir -p $PACKAGE-$VERSION/fs/usr/lib \
   2.153 -	$PACKAGE-$VERSION/fs/usr/bin \
   2.154 -	$PACKAGE-$VERSION/fs/usr/share/applications 
   2.155 +#	=== Extract files from archive ===
   2.156 +action "Extracting the archive"
   2.157 +newline
   2.158  
   2.159 -mv $TEMP_DIR/.dropbox-dist $PACKAGE-$VERSION/fs/usr/lib/dropbox
   2.160 -strip $PACKAGE-$VERSION/fs/usr/lib/dropbox 2>/dev/null
   2.161 +tar xzf $FILE
   2.162 +status
   2.163  
   2.164 -# Custom Dropboxd
   2.165 +# Remove archive file
   2.166 +rm -f $FILE
   2.167 +
   2.168 +#	=== Create SliTaz package ===
   2.169 +
   2.170 +VERSION="$(cat $TMP_DIR/.dropbox-dist/VERSION)"
   2.171 +
   2.172 +mkdir -p $PACKAGE-$VERSION/fs/usr/lib
   2.173 +mkdir -p $PACKAGE-$VERSION/fs/usr/bin
   2.174 +mkdir -p $PACKAGE-$VERSION/fs/usr/share/applications 
   2.175 +
   2.176 +mv $TMP_DIR/.dropbox-dist	$PACKAGE-$VERSION/fs/usr/lib/dropbox
   2.177 +strip				$PACKAGE-$VERSION/fs/usr/lib/dropbox 2>/dev/null
   2.178 +
   2.179 +# Customise Dropboxd
   2.180  cat > $PACKAGE-$VERSION/fs/usr/lib/dropbox/dropboxd << "EOT"
   2.181  #!/bin/sh
   2.182  PAR=$(ls -d /usr/lib/dropbox/dropbox-lnx*)
   2.183  LD_LIBRARY_PATH=$PAR:$LD_LIBRARY_PATH exec $PAR/dropboxd $@
   2.184  EOT
   2.185  
   2.186 -# Desktop file
   2.187 +# Create Desktop file
   2.188  cat > $PACKAGE-$VERSION/fs/usr/share/applications/dropbox.desktop << EOT
   2.189  [Desktop Entry]
   2.190  Type=Application
   2.191 @@ -68,37 +151,45 @@
   2.192  Categories=Network
   2.193  EOT
   2.194  
   2.195 -# Symlink to have Dropbox in PATH and fake nautilus
   2.196 +# Create symbolic links to have Dropbox in PATH and fake nautilus
   2.197  cd $PACKAGE-$VERSION/fs/usr/bin
   2.198  rm -f dropboxd nautilus
   2.199  ln -s ../lib/dropbox/dropboxd .
   2.200  ln -s /usr/bin/pcmanfm nautilus
   2.201  
   2.202 -cd $TEMP_DIR
   2.203 +cd $TMP_DIR
   2.204  
   2.205 +# Create recipe for SliTaz package
   2.206  cat > $PACKAGE-$VERSION/receipt << EOT
   2.207 +# SliTaz package receipt.
   2.208 +
   2.209  PACKAGE="$PACKAGE"
   2.210  VERSION="$VERSION"
   2.211 -CATEGORY="non-free"
   2.212 +CATEGORY="$CATEGORY"
   2.213  SHORT_DESC="Dropbox daemon and client for online storage."
   2.214 -DEPENDS="python"
   2.215  WEB_SITE="$WEB_SITE/"
   2.216 +
   2.217  SUGGESTED="ntlmaps"
   2.218 +DEPENDS="$DEPENDS"
   2.219  EOT
   2.220  
   2.221 +action "Creating the package $PACKAGE..."
   2.222  # Pack
   2.223  tazpkg pack $PACKAGE-$VERSION
   2.224  
   2.225 -# Clean to save RAM memory
   2.226 +# Remove package tree
   2.227  rm -rf $PACKAGE-$VERSION
   2.228  
   2.229 -# Install pseudo package
   2.230 -yes y | tazpkg install $PACKAGE-$VERSION.tazpkg --root=$ROOT
   2.231 +#	=== Install the SliTaz package ===
   2.232 +[ "$install" == "yes" ] &&
   2.233 +yes y | tazpkg install $PACKAGE-$VERSION.tazpkg --root="$root"
   2.234  
   2.235 -case " $@ " in
   2.236 -*\ --k*) mv $PACKAGE-$VERSION.tazpkg $CUR_DIR ;;
   2.237 -esac
   2.238 +#	=== Cleanup ===
   2.239 +# Preserve package file, if requested
   2.240 +[ "$keep" == "yes" ] &&
   2.241 +( mv $PACKAGE-$VERSION.tazpkg $CUR_DIR &&
   2.242 +  echo Saved $PACKAGE-$VERSION.tazpkg to $CUR_DIR )
   2.243  
   2.244 -# Clean
   2.245 +# Remove temporary build directory
   2.246  cd $CUR_DIR
   2.247 -rm -rf $TEMP_DIR
   2.248 +rm -rf $TMP_DIR