summaryrefslogtreecommitdiff
blob: 9b4016d24c8982149c75b48a46474fd9c86e9638 (plain)
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
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
# Copyright 1999-2008 Gentoo Foundation
# Distributed under the terms of the GNU General Public License v2
# $Header: $
##
## Created by Wolfram Schlich <wschlich@gentoo.org>
##
## TODO
## - install: shutdown running programs?
## - install: show EULA?!
## - install/config: copy keyfile?
##

inherit eutils multilib

DESCRIPTION="AVIRA AntiVir virus scanner (core)"
MY_P="${PN/core/workstation}-prof-${PV/_p/-}"
SRC_URI="http://dl.antivir.de/down/unix/packages/${MY_P}.tar.gz
	mirror? ( http://dl.antivir.de/down/unix/mirror.zip )
	smc? ( http://dl.antivir.de/down/unix/packages/antivir-updateplugin-prof-2.1.10.tar.gz )"
HOMEPAGE="http://www.antivir.de/"
LICENSE="AVIRA-AntiVir"
SLOT="0"
KEYWORDS="~x86 ~amd64"
IUSE="crypt gui mirror smc"
DEPEND=""
RDEPEND=""
S="${WORKDIR}/${MY_P}"
# prevent installation functions from stripping binaries
# otherwise the antivir selfcheck fails. also don't try
# to fetch the distribution tarball from a mirror.
RESTRICT="strip mirror"

#
# Settings overridable by user supplied environment variables
#

AVHOMEDIR="${AVHOMEDIR:-/usr/lib/AntiVir}"
AVCONFDIR="${AVCONFDIR:-/etc}"
AVGROUP="${AVGROUP:-antivir}"
AVGID="${AVGID:-220}"

#
# Standard ebuild functions
#

pkg_setup() {

	#
	# Add GROUP
	#

	enewgroup "${AVGROUP}" "${AVGID}"

}

src_install () {

	#
	# Home directory
	#

	diropts -oroot -groot -m0755
	dodir "${AVHOMEDIR}"
	diropts -oroot -g"${AVGROUP}" -m0770
	dodir "${AVHOMEDIR}/.storage" "${AVHOMEDIR}/updcomp"
	insinto "${AVHOMEDIR}"
	insopts -oroot -g"${AVGROUP}" -m0644

	#
	# Executables, libraries and misc components
	#

	exeopts -oroot -g"${AVGROUP}" -m2755
	exeinto "${AVHOMEDIR}"
	doexe bin/linux_glibc22/antivir
	diropts ""
	dodir \
		"${DESTTREE}/bin" \
		"${DESTTREE}/sbin"
	dosym "${AVHOMEDIR}/antivir" "${DESTTREE}/bin/antivir"
	if use mirror; then
		exeopts -oroot -g"${AVGROUP}" -m0750
		doexe "${WORKDIR}"/antivir-mirror
	fi

	#
	# VDF
	#

	insinto "${AVHOMEDIR}"
	doins vdf/*.vdf

	#
	# Key file (TODO FIXME)
	#

	if [ -f "${FILESDIR}/hbedv.key" ]; then
		insopts -oroot -g"${AVGROUP}" -m0640
		insinto "${AVHOMEDIR}"
		doins "${FILESDIR}/hbedv.key"
	fi
#	dodir /etc/env.d && echo "CONFIG_PROTECT=\"${AVHOMEDIR}/hbedv.key\"" >"${D}/etc/env.d/99antivir"

	#
	# Config
	#

	insopts -oroot -g"${AVGROUP}" -m0640
	insinto "${AVCONFDIR}"
	doins \
		"${FILESDIR}"/${PV}/avupdater.conf
	if use mirror; then
		newins "${WORKDIR}"/antivir-mirror.conf.default antivir-mirror.conf
	fi

	## TODO:GUI

	## TODO:SMC

	#
	# Documents
	#

	dodoc \
		LICENSE \
		LICENSE.DE \
		README \
		doc/CHANGELOG \
		doc/MANUAL \
		legal/LICENSE.*
	if use crypt; then
		dodoc pgp/antivir.gpg
		newdoc pgp/README README.gpg
	fi
	if use mirror; then
		newdoc "${WORKDIR}"/README README.mirror
		newdoc "${WORKDIR}"/LIESMICH LIESMICH.mirror
		newdoc "${WORKDIR}"/product-types.txt antivir-mirror.product-types.txt
	fi

}

pkg_preinst() {

	#
	# Check for legacy files
	#

	# Updater config: antivir.conf -> avupdater.conf
	if [ -e "${AVCONFDIR}/antivir.conf" ]; then
		ewarn
		ewarn "You have a deprecated antivir.conf in ${AVCONFDIR}/."
		ewarn "Please use ${AVCONFDIR}/avupdater.conf for the AntiVir Updater settings."
		ewarn "A sample avupdater.conf has been installed to ${AVCONFDIR}/avupdater.conf"
		ewarn "Please compare the settings from antivir.conf with those in avupdater.conf,"
		ewarn "modify those in avupdater.conf as needed and remove antivir.conf when done."
		ewarn
	fi

}

pkg_postinst() {

	#
	# Config
	#

	echo
	einfo ""
	einfo "Configuration"
	einfo "============="
	einfo ""
	einfo "Please run..."
	einfo ""
	einfo "\tebuild /var/db/pkg/${CATEGORY}/${PF}/${PF}.ebuild config"
	einfo ""
	einfo "...to configure the package!"

	echo

}

pkg_config () {

	#
	# Automatic updates
	# Generate a random number between 1 and 59 for the crontab
	#

	rand="$$$(date +%s)"
	min="$[ ($rand % 59) + 1 ]"
	echo
	einfo ""
	einfo "Using the internet updater"
	einfo "=========================="
	einfo ""
	einfo "Add the following line to your /etc/crontab or a new file"
	einfo "in /etc/cron.d/ to make AntiVir check for updates"
	einfo "${min} minutes after every full hour:"
	einfo ""
	einfo "\t${min} * * * * root exec ${AVHOMEDIR}/antivir --update >/dev/null"
	einfo ""
	echo

	## TODO: mirror script
}