2463d104a9e6b4bb08a0fa6d6047a975b402e48f
[gentoo.git] / sys-libs / cracklib / cracklib-2.9.7.ebuild
1 # Copyright 1999-2020 Gentoo Authors
2 # Distributed under the terms of the GNU General Public License v2
3
4 EAPI=6
5
6 PYTHON_COMPAT=( python{2_7,3_{6,7,8}} )
7 DISTUTILS_OPTIONAL=1
8
9 inherit distutils-r1 libtool multilib-minimal toolchain-funcs usr-ldscript
10
11 MY_P=${P/_}
12 DESCRIPTION="Password Checking Library"
13 HOMEPAGE="https://github.com/cracklib/cracklib/"
14 SRC_URI="https://github.com/${PN}/${PN}/releases/download/v${PV}/${P}.tar.bz2"
15
16 LICENSE="LGPL-2.1"
17 SLOT="0"
18 KEYWORDS="~alpha amd64 arm arm64 hppa ~ia64 m68k ~mips ppc ppc64 ~riscv s390 sparc x86 ~amd64-linux ~x86-linux ~ppc-macos ~x86-macos ~m68k-mint"
19 IUSE="nls python static-libs zlib"
20 REQUIRED_USE="python? ( ${PYTHON_REQUIRED_USE} )"
21
22 RDEPEND="python? ( ${PYTHON_DEPS} )
23         zlib? ( >=sys-libs/zlib-1.2.8-r1:=[${MULTILIB_USEDEP}] )"
24 DEPEND="${RDEPEND}
25         python? (
26                 dev-python/setuptools[${PYTHON_USEDEP}]
27         )"
28
29 S="${WORKDIR}/${MY_P}"
30
31 do_python() {
32         multilib_is_native_abi || return 0
33         use python || return 0
34         pushd python > /dev/null || die
35         distutils-r1_src_${EBUILD_PHASE}
36         popd > /dev/null
37 }
38
39 pkg_setup() {
40         # workaround #195017
41         if has unmerge-orphans ${FEATURES} && has_version "<${CATEGORY}/${PN}-2.8.10" ; then
42                 eerror "Upgrade path is broken with FEATURES=unmerge-orphans"
43                 eerror "Please run: FEATURES=-unmerge-orphans emerge cracklib"
44                 die "Please run: FEATURES=-unmerge-orphans emerge cracklib"
45         fi
46 }
47
48 src_prepare() {
49         eapply_user
50         elibtoolize #269003
51         do_python
52 }
53
54 multilib_src_configure() {
55         local myeconfargs=(
56                 # use /usr/lib so that the dictionary is shared between ABIs
57                 --with-default-dict='/usr/lib/cracklib_dict'
58                 --without-python
59                 $(use_enable nls)
60                 $(use_enable static-libs static)
61         )
62         export ac_cv_header_zlib_h=$(usex zlib)
63         export ac_cv_search_gzopen=$(usex zlib -lz no)
64         ECONF_SOURCE="${S}" econf "${myeconfargs[@]}"
65 }
66
67 multilib_src_compile() {
68         default
69         do_python
70 }
71
72 multilib_src_test() {
73         # Make sure we load the freshly built library
74         LD_LIBRARY_PATH="${BUILD_DIR}/lib/.libs" do_python
75 }
76
77 python_test() {
78         ${EPYTHON} -m unittest test_cracklib || die "Tests fail with ${EPYTHON}"
79 }
80
81 multilib_src_install() {
82         default
83         # move shared libs to /
84         gen_usr_ldscript -a crack
85
86         do_python
87 }
88
89 multilib_src_install_all() {
90         einstalldocs
91         find "${ED}" -name "*.la" -delete || die
92         rm -r "${ED%/}"/usr/share/cracklib || die
93
94         insinto /usr/share/dict
95         doins dicts/cracklib-small
96 }
97
98 pkg_postinst() {
99         if [[ ${ROOT} == "/" ]] ; then
100                 ebegin "Regenerating cracklib dictionary"
101                 create-cracklib-dict "${EPREFIX}"/usr/share/dict/* > /dev/null
102                 eend $?
103         fi
104 }