~dobey/+junk/binkplayer-installer

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
#!/bin/sh

set -e

PRODUCT="Bink Player"
PACKAGE=binkplayer
FILENAME=BinkLinuxPlayer.7z
PROGFILE=@PROGFILE@
PROGNAME=BinkPlayer
SHA256SUM="edcd0483ece42aa11cb99c85f93878798dc5817a8136930e787aa6cc9bbae4f9"
PARTNER_URL=http://www.radgametools.com/down/Bink/$FILENAME


. /usr/share/debconf/confmodule

mc_exit_with_error() {
	echo $1
	echo "$PRODUCT is NOT installed."
	db_fset $PACKAGE/httpget seen false
	db_set $PACKAGE/httpget false
	exit 1
}

mc_download_and_unpack() {

	cd /var/cache/$PACKAGE

	db_get $PACKAGE/httpget
	if [ "$RET" != "true" ]; then
		mc_exit_with_error "download or license refused"
	fi

    # use apt proxy
	APT_PROXIES=$(apt-config shell \
		http_proxy Acquire::http::Proxy \
		https_proxy Acquire::https::Proxy \
		ftp_proxy Acquire::ftp::Proxy \
		)

	if [ -n "$APT_PROXIES" ]; then
		eval export $APT_PROXIES
	fi

	# setting wget options
	:> wgetrc
	echo "noclobber = off" >> wgetrc
	echo "dir_prefix = ." >> wgetrc
	echo "dirstruct = off" >> wgetrc
	echo "verbose = on" >> wgetrc
	echo "progress = dot:default" >> wgetrc
	echo "tries = 2" >> wgetrc

	# downloading the plugin
	echo "Downloading..."
	rm -f $FILENAME
	WGETRC=wgetrc wget $PARTNER_URL \
		|| mc_exit_with_error "download failed"
	rm -f wgetrc
	echo "Download done."

	# verify SHA256 checksum of (copied or downloaded) tarball
	echo "$SHA256SUM  $FILENAME" | sha256sum -c > /dev/null 2>&1 \
		|| mc_exit_with_error "sha256sum mismatch $FILENAME"
}

mc_download_and_unpack

p7zip -d $FILENAME
install -m $PROGFILE 755 $ /usr/bin/$PROGNAME
rm -rf ${PROGNAME} ${PROGNAME}64

echo "$PRODUCT installed."

db_fset $PACKAGE/httpget seen false
db_set $PACKAGE/httpget false

#DEBHELPER#

exit 0

# vim: ts=2 sw=2