wok-next view get-anydesk/stuff/get-anydesk @ rev 21727

created recipe for vbindiff
author Hans-G?nter Theisgen
date Sat Nov 21 14:32:44 2020 +0100 (2020-11-21)
parents
children
line source
1 #!/bin/sh
2 #
3 # get-anydesk - create and install SliTaz package anydesk
4 #
5 # (C) 2020 SliTaz - GNU General Public License v3.
6 # Author : HGT
7 #
9 # === Initialisations ===
11 PKGS_DB="/var/lib/tazpkg" # packages database directory
12 PACKAGE="anydesk"
13 CATEGORY="non-free"
14 SHORT=DESC="remote access"
15 MAINTAINER="nobody@slitaz.org"
16 LICENSE="non-free"
17 WEB_SITE="https://anydesk.com/packagename/"
18 #DEPENDS="libglu-mesa"
20 # Declare functions check_root, status, ...
21 . /lib/libtaz.sh
22 # and make commandline options (if any) available as variables
24 is_installed()
25 {
26 if [ -d $ROOT$PKGS_DB/installed/$PACKAGE ]
27 then #package is deemed to be installed
28 return 0
29 else
30 return 1
31 fi
32 }
34 # Show commandline options, if requested by --help
35 if [ "$help" == "yes" ]
36 then
37 echo "Commandline options:
38 $0
39 --version=<version>
40 --root=<path-to-root>
41 --install=yes|no
42 --keep=no|yes
43 --tmpdir=<directory-to-build-package>
44 --logfile=<logging-file>"
45 exit
46 fi
48 # Check for system administrator privileges
49 check_root
51 title "Package $PACKAGE will be build as SliTaz package and installed"
53 # Fetch latest version, unless version is set by option --version
54 [ -z "$version" ] && version="latest"
56 # Install SliTaz package, unless inhibited by option --install=no
57 [ -z "$install" ] && install="yes"
59 # Delete SliTaz package file $PACKAGE-$VERSION.tazpkg after installation,
60 # unless option --keep=yes is given
61 [ -z "$keep" ] && keep="no"
63 # Directory for temporary files
64 TMP_DIR="$tmpdir"
65 [ -z "$tmpdir" ] && TMP_DIR="/tmp/get-$PACKAGE"
67 # Logging file (unused by now)
68 LOG="$logfile"
69 [ -z "$logfile" ] && LOG=$TMP_DIR/get-$PACKAGE.log
71 cat <<EOT
72 Options in use:
73 root : $root/
74 version : $version
75 install package: $install
76 keep tazpkg : $keep
77 build directory: $TMP_DIR
78 logging file : $LOG
80 EOT
82 separator; newline
84 # === Remove package, if installed ===
85 if is_installed
86 then
87 echo "$PACKAGE is already installed."
88 echo -n "Would you like to remove and reinstall this package [y/n]? "
89 read answer
90 case "$answer" in
91 y|Y)
92 action "Removing installed version..."
93 tazpkg remove $PACKAGE --root="$root/"
94 [ ! is_installed ] &&
95 die "Can't remove installed version. Exiting."
96 ;;
97 *)
98 echo "Leaving $PACKAGE untouched."
99 exit 0
100 ;;
101 esac
102 fi
104 # === Fetch Debian package, if not existing ===
105 if [ "$version" == "latest" ]
106 then
107 VERSION="$(wget --no-check-certificate -O - https://anydesk.com/en/downloads/linux | \
108 sed -n '/i386.deb">.*option/p' | sed 's|.*_\(.*\)_.*|\1|' )"
109 FILE="${PACKAGE}_${VERSION}_i386.deb"
110 WGET_URL="https://download.anydesk.com/linux/$FILE"
111 else
112 VERSION=$version
113 FILE="${PACKAGE}_${VERSION}_i386.deb"
114 WGET_URL="https://download.anydesk.com/linux/deb/$FILE"
115 fi
117 CUR_DIR=$(pwd)
118 mkdir -p $TMP_DIR
119 cd $TMP_DIR
120 if [ -f $FILE ]
121 then
122 echo "Using existing archive file $FILE"
123 else
124 action "Fetching the archive"
125 newline
126 wget --no-check-certificate $WGET_URL
127 if [ ! -f $FILE ]
128 then
129 cd $CUR_DIR
130 rm -rf $TMP_DIR
131 echo "Could not transfer $FILE from $WGET_URL. Exiting."
132 exit 1
133 fi
134 fi
136 # === Convert Debian package to SliTaz package ===
137 action "Converting the package"
138 newline
140 tazpkg convert $FILE
141 status
142 VERSION=${VERSION%-*}
144 # Remove archive file
145 rm -f $FILE
147 # === Install the SliTaz package ===
148 [ "$install" == "yes" ] &&
149 tazpkg install $PACKAGE-$VERSION.tazpkg --root="$root"
151 # === Cleanup ===
152 # Preserve package file, if requested
153 [ "$keep" == "yes" ] &&
154 ( mv $PACKAGE-$VERSION.tazpkg $CUR_DIR &&
155 echo "Saved $PACKAGE-$VERSION.tazpkg to $CUR_DIR" )
157 # Remove temporary build directory
158 cd $CUR_DIR
159 rm -rf $TMP_DIR