1
0

cryptsetup-2.7.1.ebuild 4.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154
  1. # Copyright 1999-2023 Gentoo Authors
  2. # Distributed under the terms of the GNU General Public License v2
  3. EAPI=8
  4. inherit autotools linux-info tmpfiles
  5. DESCRIPTION="Tool to setup encrypted devices with dm-crypt"
  6. HOMEPAGE="https://gitlab.com/cryptsetup/cryptsetup"
  7. SRC_URI="https://www.kernel.org/pub/linux/utils/${PN}/v$(ver_cut 1-2)/${P/_/-}.tar.xz"
  8. S="${WORKDIR}"/${P/_/-}
  9. LICENSE="GPL-2+"
  10. SLOT="0/12" # libcryptsetup.so version
  11. if [[ ${PV} != *_rc* ]] ; then
  12. KEYWORDS="~alpha amd64 arm arm64 hppa ~ia64 ~loong ~mips ppc ppc64 ~riscv ~s390 sparc x86"
  13. fi
  14. CRYPTO_BACKENDS="gcrypt kernel nettle +openssl"
  15. # we don't support nss since it doesn't allow cryptsetup to be built statically
  16. # and it's missing ripemd160 support so it can't provide full backward compatibility
  17. IUSE="${CRYPTO_BACKENDS} +argon2 +hwopal fips gcryptargon2 nls pwquality ssh static static-libs test +udev urandom"
  18. RESTRICT="!test? ( test )"
  19. # bug #496612, bug #832711, bug #843863
  20. REQUIRED_USE="
  21. ^^ ( ${CRYPTO_BACKENDS//+/} )
  22. static? ( !gcrypt !ssh !udev !fips )
  23. fips? ( !kernel !nettle )
  24. gcryptargon2? ( gcrypt !argon2 )
  25. "
  26. LIB_DEPEND="
  27. dev-libs/json-c:=[static-libs(+)]
  28. dev-libs/popt[static-libs(+)]
  29. >=sys-apps/util-linux-2.31-r1[static-libs(+)]
  30. argon2? ( app-crypt/argon2:=[static-libs(+)] )
  31. hwopal? ( >=sys-kernel/linux-headers-6.4 )
  32. gcrypt? (
  33. dev-libs/libgcrypt:0=[static-libs(+)]
  34. dev-libs/libgpg-error[static-libs(+)]
  35. )
  36. gcryptargon2? ( >=dev-libs/libgcrypt-1.11:0=[static-libs(+)] )
  37. nettle? ( >=dev-libs/nettle-2.4[static-libs(+)] )
  38. openssl? ( dev-libs/openssl:0=[static-libs(+)] )
  39. pwquality? ( dev-libs/libpwquality[static-libs(+)] )
  40. ssh? ( net-libs/libssh[static-libs(+)] )
  41. sys-fs/lvm2[static-libs(+)]
  42. "
  43. # We have to always depend on ${LIB_DEPEND} rather than put behind
  44. # !static? () because we provide a shared library which links against
  45. # these other packages. bug #414665
  46. RDEPEND="
  47. static-libs? ( ${LIB_DEPEND} )
  48. ${LIB_DEPEND//\[static-libs\([+-]\)\]}
  49. udev? ( virtual/libudev:= )
  50. "
  51. DEPEND="
  52. ${RDEPEND}
  53. static? ( ${LIB_DEPEND} )
  54. "
  55. # vim-core needed for xxd in tests
  56. BDEPEND="
  57. virtual/pkgconfig
  58. test? ( app-editors/vim-core )
  59. "
  60. pkg_setup() {
  61. local CONFIG_CHECK="~DM_CRYPT ~CRYPTO ~CRYPTO_CBC ~CRYPTO_SHA256"
  62. local WARNING_DM_CRYPT="CONFIG_DM_CRYPT:\tis not set (required for cryptsetup)\n"
  63. local WARNING_CRYPTO_SHA256="CONFIG_CRYPTO_SHA256:\tis not set (required for cryptsetup)\n"
  64. local WARNING_CRYPTO_CBC="CONFIG_CRYPTO_CBC:\tis not set (required for kernel 2.6.19)\n"
  65. local WARNING_CRYPTO="CONFIG_CRYPTO:\tis not set (required for cryptsetup)\n"
  66. check_extra_config
  67. }
  68. src_prepare() {
  69. default
  70. sed -i '/^LOOPDEV=/s:$: || exit 0:' tests/{compat,mode}-test || die
  71. eautoreconf
  72. }
  73. src_configure() {
  74. local myeconfargs=(
  75. --disable-internal-argon2
  76. --disable-asciidoc
  77. --enable-shared
  78. --sbindir="${EPREFIX}"/sbin
  79. # for later use
  80. --with-default-luks-format=LUKS2
  81. --with-tmpfilesdir="${EPREFIX}/usr/lib/tmpfiles.d"
  82. --with-crypto_backend=$(for x in ${CRYPTO_BACKENDS//+/} ; do usev ${x} ; done)
  83. $(use_enable argon2 libargon2)
  84. $(use_enable gcryptargon2 gcrypt-argon2)
  85. $(use_enable hwopal hw-opal)
  86. $(use_enable nls)
  87. $(use_enable pwquality)
  88. $(use_enable !static external-tokens)
  89. $(use_enable static static-cryptsetup)
  90. $(use_enable static-libs static)
  91. $(use_enable udev)
  92. $(use_enable !urandom dev-random)
  93. $(use_enable ssh ssh-token)
  94. $(usev !argon2 '--with-luks2-pbkdf=pbkdf2')
  95. $(use_enable fips)
  96. )
  97. econf "${myeconfargs[@]}"
  98. }
  99. src_test() {
  100. if [[ ! -e /dev/mapper/control ]] ; then
  101. ewarn "No /dev/mapper/control found -- skipping tests"
  102. return 0
  103. fi
  104. local p
  105. for p in /dev/mapper /dev/loop* ; do
  106. addwrite ${p}
  107. done
  108. default
  109. }
  110. src_install() {
  111. default
  112. if use static ; then
  113. mv "${ED}"/sbin/cryptsetup{.static,} || die
  114. mv "${ED}"/sbin/veritysetup{.static,} || die
  115. mv "${ED}"/sbin/integritysetup{.static,} || die
  116. if use ssh ; then
  117. mv "${ED}"/sbin/cryptsetup-ssh{.static,} || die
  118. fi
  119. fi
  120. find "${ED}" -type f -name "*.la" -delete || die
  121. dodoc docs/v*ReleaseNotes
  122. newconfd "${FILESDIR}"/2.4.3-dmcrypt.confd dmcrypt
  123. newinitd "${FILESDIR}"/2.4.3-dmcrypt.rc dmcrypt
  124. }
  125. pkg_postinst() {
  126. tmpfiles_process cryptsetup.conf
  127. if use kernel ; then
  128. ewarn "Note that kernel backend is very slow for this type of operation"
  129. ewarn "and is provided mainly for embedded systems wanting to avoid"
  130. ewarn "userspace crypto libraries."
  131. fi
  132. }