summaryrefslogtreecommitdiff
path: root/app-admin/pass-import/pass-import-3.5-r1.ebuild
blob: 81e5be159fbbe2a92b688a2bdcaf8c22662a3fad (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
# Copyright 2026 Gentoo Authors
# Distributed under the terms of the GNU General Public License v2

EAPI=8

PYTHON_COMPAT=( python3_{13..14} )
DISTUTILS_USE_PEP517=setuptools
PYPI_NO_NORMALIZE=1
VERIFY_SIG_OPENPGP_KEY_PATH=/usr/share/openpgp-keys/roddhjav.asc
inherit distutils-r1 optfeature shell-completion verify-sig xdg-utils

DESCRIPTION="pass extension for importing data from most existing password managers"
HOMEPAGE="
	https://github.com/roddhjav/pass-import/
	https://pypi.org/project/pass-import/
"
# lacking test files in sdist
SRC_URI="
	https://github.com/roddhjav/pass-import/releases/download/v${PV}/${P}.tar.gz
	verify-sig? (
		https://github.com/roddhjav/pass-import/releases/download/v${PV}/${P}.tar.gz.asc
	)
"

LICENSE="GPL-3+"
SLOT="0"
KEYWORDS="amd64"

# defusedxml is optional, it falls back to builtin, but then it's
# automagic, so just always depend on it.
RDEPEND="
	app-admin/pass
	dev-python/defusedxml[${PYTHON_USEDEP}]
	dev-python/pyaml[${PYTHON_USEDEP}]
	dev-python/requests[${PYTHON_USEDEP}]
	dev-python/zxcvbn[${PYTHON_USEDEP}]
"
BDEPEND="
	test? (
		sys-apps/dbus
	)
	verify-sig? (
		sec-keys/openpgp-keys-roddhjav
	)
"

EPYTEST_PLUGINS=()
distutils_enable_tests pytest

PATCHES=(
	"${FILESDIR}"/pass-import-3.5-dont-install-data.patch
	"${FILESDIR}"/pass-import-3.5-deal-with-zxcvbn-4.5.0-password-limit.patch
)

python_prepare_all() {
	distutils-r1_python_prepare_all

	xdg_environment_reset
	mkdir -p "${XDG_DATA_HOME}"/keyrings || die
	cp tests/assets/db/gnome-keyring.keyring "${XDG_DATA_HOME}"/keyrings/pass-import.keyring || die
}

python_test() {
	EPYTEST_DESELECT=(
		# Tries to touch system networkmanager
		tests/test_open.py::TestOpen::test_open_networkmanager

		# FIXME
		tests/imports/test_parse.py::TestParse::test_import_gnome_keyring
	)
	EPYTEST_IGNORE=()

	local usedep="python_targets_${EPYTHON/./_}(-)"

	if ! has_version "dev-python/pykeepass[${usedep}]"; then
		EPYTEST_DESELECT+=(
			tests/imports/test_parse.py::TestParse::test_import_keepass
		)
	fi

	if ! has_version "dev-python/jsonpath-ng[${usedep}]"; then
		EPYTEST_IGNORE+=(
			tests/filters/test_filter_jsonpath.py
		)
	fi

	local dbus_params=(
		$(dbus-daemon --session --print-address --fork --print-pid)
	)
	local -x DBUS_SESSION_BUS_ADDRESS=${dbus_params[0]}

	epytest

	kill "${dbus_params[1]}" || die
}

src_install() {
	distutils-r1_src_install

	exeinto /usr/lib/password-store/extensions
	doexe import.bash

	doman share/man/man1/pass-import.1 share/man/man1/pimport.1
	dobashcomp share/bash-completion/completions/pimport

	# bug #767871
	insinto /etc/bash_completion.d
	doins share/bash-completion/completions/pass-import

	dozshcomp share/zsh/site-functions/_pass-import \
		share/zsh/site-functions/_pimport
}

pkg_postinst() {
	#optfeature "Lastpass cli based import/export" app-admin/lpass
	optfeature "Keepass import from KDBX file" dev-python/pykeepass
	optfeature "Gnome Keyring import" dev-python/secretstorage
	optfeature "AndOTP or Aegis encrypted import" dev-python/cryptography
	#optfeature "Detection of file decryption" dev-python/file-magic
	optfeature "Filter exports" dev-python/jsonpath-ng
}