summaryrefslogtreecommitdiff
blob: 452bd4ae9b87175ecf02cb98251875ad076e26b9 (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
# Copyright 1999-2023 Gentoo Authors
# Distributed under the terms of the GNU General Public License v2

EAPI=7

inherit cmake

DESCRIPTION="Set of scripts to manage google-auth setup on Gentoo Infra"
HOMEPAGE="https://github.com/projg2/google-authenticator-wrappers"
SRC_URI="https://github.com/projg2/google-authenticator-wrappers/archive/v${PV}.tar.gz -> ${P}.tar.gz"

LICENSE="BSD-2"
SLOT="0"
KEYWORDS="~amd64 ~x86"

DEPEND="
	acct-group/gauth
	acct-user/gauth
"
RDEPEND="
	${DEPEND}
	sys-auth/google-authenticator
"

pkg_pretend() {
	if [[ ${MERGE_TYPE} != buildonly ]]; then
		local v
		for v in ${REPLACING_VERSIONS}; do
			if ver_test "${v}" -lt 3; then
				ewarn "google-authenticator-wrappers v3 switches the secret store mechanism"
				ewarn "from user-owned files to /var/lib/gauth.  To migrate secrets, move"
				ewarn "and chown, e.g.:"
				ewarn
				ewarn "  mv /home/myuser/.google_authenticator /var/lib/gauth/myuser"
				ewarn "  chown gauth /var/lib/gauth/myuser"
				ewarn
				ewarn "If you do not migrate or reset secrets, second step authentication"
				ewarn "will be disabled after the upgrade."
				break
			fi
		done
	fi
}

src_configure() {
	local mycmakeargs=(
		-DGAUTH_USERNAME=gauth
	)

	cmake_src_configure
}

pkg_preinst() {
	fowners gauth:gauth /var/lib/gauth /usr/bin/gauthctl /usr/bin/gauth-test
	fperms ug+s /usr/bin/gauthctl /usr/bin/gauth-test
}