1 # Copyright 1999-2020 Gentoo Authors
2 # Distributed under the terms of the GNU General Public License v2
7 PYTHON_COMPAT=( python{3_6,3_7} )
9 inherit autotools distutils-r1 linux-info libtool ltprune eutils versionator
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"
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
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(+)] )
32 !libressl? ( dev-libs/openssl:0=[static-libs(+)] )
33 libressl? ( dev-libs/libressl:=[static-libs(+)] )
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} )"
46 static? ( ${LIB_DEPEND} )"
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"
60 sed -i '/^LOOPDEV=/s:$: || exit 0:' tests/{compat,mode}-test || die
61 #epatch "${PATCHES[@]}"
62 epatch_user && eautoreconf
66 cp "${FILESDIR}"/setup-1.7.0.py setup.py || die
67 distutils-r1_src_prepare
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."
78 # We disable autotool python integration so we can use eclasses
79 # for proper integration with multiple python versions.
84 $(use_enable static static-cryptsetup) \
85 $(use_enable static-libs static) \
87 $(use_enable pwquality) \
88 $(use_enable reencrypt cryptsetup-reencrypt) \
90 $(use_enable !urandom dev-random) \
91 --with-crypto_backend=$(for x in ${CRYPTO_BACKENDS//+/} ; do usev ${x} ; done)
93 use python && cd python && distutils-r1_src_configure
98 use python && cd python && distutils-r1_src_compile
102 if [[ ! -e /dev/mapper/control ]] ; then
103 ewarn "No /dev/mapper/control found -- skipping tests"
107 for p in /dev/mapper /dev/loop* ; do
116 mv "${ED}"/sbin/cryptsetup{.static,} || die
117 mv "${ED}"/sbin/veritysetup{.static,} || die
118 use reencrypt && { mv "${ED}"/sbin/cryptsetup-reencrypt{.static,} || die ; }
120 prune_libtool_files --modules
122 newconfd "${FILESDIR}"/1.6.7-dmcrypt.confd dmcrypt
123 newinitd "${FILESDIR}"/1.6.7-dmcrypt.rc dmcrypt
125 use python && cd python && distutils-r1_src_install