sys-fs/ntfs3g: x86 stable wrt bug #717640
[gentoo.git] / sys-fs / cryptsetup / cryptsetup-1.7.5-r1.ebuild
1 # Copyright 1999-2020 Gentoo Authors
2 # Distributed under the terms of the GNU General Public License v2
3
4 EAPI=5
5
6 DISTUTILS_OPTIONAL=1
7 PYTHON_COMPAT=( python{3_6,3_7} )
8
9 inherit autotools distutils-r1 linux-info libtool ltprune eutils versionator
10
11 DESCRIPTION="Tool to setup encrypted devices with dm-crypt"
12 HOMEPAGE="https://gitlab.com/cryptsetup/cryptsetup/blob/master/README.md"
13 SRC_URI="https://www.kernel.org/pub/linux/utils/${PN}/v$(get_version_component_range 1-2)/${P}.tar.xz"
14
15 LICENSE="GPL-2+"
16 SLOT="0"
17 KEYWORDS="~alpha amd64 arm ~arm64 hppa ~ia64 ~mips ppc ppc64 s390 sparc x86"
18 CRYPTO_BACKENDS="+gcrypt kernel nettle openssl"
19 # we don't support nss since it doesn't allow cryptsetup to be built statically
20 # and it's missing ripemd160 support so it can't provide full backward compatibility
21 IUSE="${CRYPTO_BACKENDS} libressl nls pwquality python reencrypt static static-libs +udev urandom"
22 REQUIRED_USE="^^ ( ${CRYPTO_BACKENDS//+/} )
23         python? ( ${PYTHON_REQUIRED_USE} )
24         static? ( !gcrypt )" #496612
25
26 LIB_DEPEND="dev-libs/libgpg-error[static-libs(+)]
27         dev-libs/popt[static-libs(+)]
28         sys-apps/util-linux[static-libs(+)]
29         gcrypt? ( dev-libs/libgcrypt:0=[static-libs(+)] )
30         nettle? ( >=dev-libs/nettle-2.4[static-libs(+)] )
31         openssl? (
32                 !libressl? ( dev-libs/openssl:0=[static-libs(+)] )
33                 libressl? ( dev-libs/libressl:=[static-libs(+)] )
34         )
35         pwquality? ( dev-libs/libpwquality[static-libs(+)] )
36         sys-fs/lvm2[static-libs(+)]
37         udev? ( virtual/libudev[static-libs(-)] )"
38 # We have to always depend on ${LIB_DEPEND} rather than put behind
39 # !static? () because we provide a shared library which links against
40 # these other packages. #414665
41 RDEPEND="static-libs? ( ${LIB_DEPEND} )
42         ${LIB_DEPEND//\[static-libs\([+-]\)\]}
43         python? ( ${PYTHON_DEPS} )"
44 DEPEND="${RDEPEND}
45         virtual/pkgconfig
46         static? ( ${LIB_DEPEND} )"
47
48 #PATCHES=( )
49
50 pkg_setup() {
51         local CONFIG_CHECK="~DM_CRYPT ~CRYPTO ~CRYPTO_CBC ~CRYPTO_SHA256"
52         local WARNING_DM_CRYPT="CONFIG_DM_CRYPT:\tis not set (required for cryptsetup)\n"
53         local WARNING_CRYPTO_SHA256="CONFIG_CRYPTO_SHA256:\tis not set (required for cryptsetup)\n"
54         local WARNING_CRYPTO_CBC="CONFIG_CRYPTO_CBC:\tis not set (required for kernel 2.6.19)\n"
55         local WARNING_CRYPTO="CONFIG_CRYPTO:\tis not set (required for cryptsetup)\n"
56         check_extra_config
57 }
58
59 src_prepare() {
60         sed -i '/^LOOPDEV=/s:$: || exit 0:' tests/{compat,mode}-test || die
61         #epatch "${PATCHES[@]}"
62         epatch_user && eautoreconf
63
64         if use python ; then
65                 cd python
66                 cp "${FILESDIR}"/setup-1.7.0.py setup.py || die
67                 distutils-r1_src_prepare
68         fi
69 }
70
71 src_configure() {
72         if use kernel ; then
73                 ewarn "Note that kernel backend is very slow for this type of operation"
74                 ewarn "and is provided mainly for embedded systems wanting to avoid"
75                 ewarn "userspace crypto libraries."
76         fi
77
78         # We disable autotool python integration so we can use eclasses
79         # for proper integration with multiple python versions.
80         econf \
81                 --sbindir=/sbin \
82                 --enable-shared \
83                 --disable-python \
84                 $(use_enable static static-cryptsetup) \
85                 $(use_enable static-libs static) \
86                 $(use_enable nls) \
87                 $(use_enable pwquality) \
88                 $(use_enable reencrypt cryptsetup-reencrypt) \
89                 $(use_enable udev) \
90                 $(use_enable !urandom dev-random) \
91                 --with-crypto_backend=$(for x in ${CRYPTO_BACKENDS//+/} ; do usev ${x} ; done)
92
93         use python && cd python && distutils-r1_src_configure
94 }
95
96 src_compile() {
97         default
98         use python && cd python && distutils-r1_src_compile
99 }
100
101 src_test() {
102         if [[ ! -e /dev/mapper/control ]] ; then
103                 ewarn "No /dev/mapper/control found -- skipping tests"
104                 return 0
105         fi
106         local p
107         for p in /dev/mapper /dev/loop* ; do
108                 addwrite ${p}
109         done
110         default
111 }
112
113 src_install() {
114         default
115         if use static ; then
116                 mv "${ED}"/sbin/cryptsetup{.static,} || die
117                 mv "${ED}"/sbin/veritysetup{.static,} || die
118                 use reencrypt && { mv "${ED}"/sbin/cryptsetup-reencrypt{.static,} || die ; }
119         fi
120         prune_libtool_files --modules
121
122         newconfd "${FILESDIR}"/1.6.7-dmcrypt.confd dmcrypt
123         newinitd "${FILESDIR}"/1.6.7-dmcrypt.rc dmcrypt
124
125         use python && cd python && distutils-r1_src_install
126 }