lvm2-2.03.22-r2.ebuild 8.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307
  1. # Copyright 1999-2023 Gentoo Authors
  2. # Distributed under the terms of the GNU General Public License v2
  3. EAPI=8
  4. TMPFILES_OPTIONAL=1
  5. inherit autotools linux-info systemd toolchain-funcs tmpfiles udev flag-o-matic
  6. DESCRIPTION="User-land utilities for LVM2 (device-mapper) software"
  7. HOMEPAGE="https://sourceware.org/lvm2/"
  8. SRC_URI="https://sourceware.org/ftp/lvm2/${PN^^}.${PV}.tgz"
  9. S="${WORKDIR}/${PN^^}.${PV}"
  10. LICENSE="GPL-2"
  11. SLOT="0"
  12. KEYWORDS="~amd64 ~arm arm64 ~loong ~mips ppc64 ~riscv ~s390 ~sparc x86 ~amd64-linux ~x86-linux"
  13. IUSE="dbus lvm readline sanlock selinux static static-libs systemd thin +udev valgrind"
  14. REQUIRED_USE="
  15. static? ( !systemd !udev )
  16. static-libs? ( static !udev )
  17. systemd? ( udev )
  18. thin? ( lvm )
  19. "
  20. DEPEND_COMMON="
  21. udev? ( virtual/libudev:= )
  22. lvm? (
  23. dev-libs/libaio
  24. sys-apps/util-linux
  25. readline? ( sys-libs/readline:= )
  26. sanlock? ( sys-cluster/sanlock )
  27. systemd? ( sys-apps/systemd:= )
  28. )
  29. "
  30. # /run is now required for locking during early boot. /var cannot be assumed to
  31. # be available -- thus, pull in recent enough baselayout for /run.
  32. # This version of LVM is incompatible with cryptsetup <1.1.2.
  33. RDEPEND="
  34. ${DEPEND_COMMON}
  35. >=sys-apps/baselayout-2.2
  36. lvm? (
  37. virtual/tmpfiles
  38. thin? ( >=sys-block/thin-provisioning-tools-1.0.6 )
  39. )
  40. "
  41. # note: thin-0.3.0 is required to avoid --disable-thin_check_needs_check
  42. DEPEND="
  43. ${DEPEND_COMMON}
  44. static? (
  45. sys-apps/util-linux[static-libs]
  46. lvm? (
  47. dev-libs/libaio[static-libs]
  48. readline? ( sys-libs/readline[static-libs] )
  49. )
  50. selinux? ( sys-libs/libselinux[static-libs] )
  51. )
  52. valgrind? ( >=dev-util/valgrind-3.6 )
  53. "
  54. BDEPEND="
  55. sys-devel/autoconf-archive
  56. virtual/pkgconfig
  57. "
  58. PATCHES=(
  59. # Gentoo specific modification(s):
  60. "${FILESDIR}"/${PN}-2.03.20-example.conf.in.patch
  61. # For upstream -- review and forward:
  62. "${FILESDIR}"/${PN}-2.03.20-dmeventd-no-idle-exit.patch
  63. "${FILESDIR}"/${PN}-2.03.20-freopen-musl.patch
  64. "${FILESDIR}"/${PN}-2.03.22-mkdir-lockfile.patch
  65. )
  66. pkg_setup() {
  67. local CONFIG_CHECK="~SYSVIPC"
  68. if use udev; then
  69. local WARNING_SYSVIPC="CONFIG_SYSVIPC:\tis not set (required for udev sync)\n"
  70. if linux_config_exists; then
  71. local uevent_helper_path=$(linux_chkconfig_string UEVENT_HELPER_PATH)
  72. if [[ -n "${uevent_helper_path}" ]] && [[ "${uevent_helper_path}" != '""' ]]; then
  73. ewarn "It's recommended to set an empty value to the following kernel config option:"
  74. ewarn "CONFIG_UEVENT_HELPER_PATH=${uevent_helper_path}"
  75. fi
  76. fi
  77. fi
  78. check_extra_config
  79. # 1. Genkernel no longer copies /sbin/lvm blindly.
  80. if use static; then
  81. elog "Warning, we no longer overwrite /sbin/lvm and /sbin/dmsetup with"
  82. elog "their static versions. If you need the static binaries,"
  83. elog "you must append .static to the filename!"
  84. fi
  85. }
  86. src_prepare() {
  87. default
  88. # Users without systemd get no auto-activation of any logical volume
  89. if ! use systemd ; then
  90. eapply "${FILESDIR}"/${PN}-2.03.20-dm_lvm_rules_no_systemd.patch
  91. fi
  92. eautoreconf
  93. }
  94. src_configure() {
  95. filter-lto
  96. # Workaround for bug #822210
  97. tc-ld-disable-gold
  98. # Most of this package does weird stuff.
  99. # The build options are tristate, and --without is NOT supported
  100. # options: 'none', 'internal', 'shared'
  101. local myeconfargs=(
  102. $(use_enable lvm dmfilemapd)
  103. $(use_enable lvm dmeventd)
  104. $(use_enable lvm cmdlib)
  105. $(use_enable lvm fsadm)
  106. $(use_enable lvm lvmpolld)
  107. # This only causes the .static versions to become available
  108. $(usev static --enable-static_link)
  109. # dmeventd requires mirrors to be internal, and snapshot available
  110. # so we cannot disable them
  111. --with-mirrors="$(usex lvm internal none)"
  112. --with-snapshots="$(usex lvm internal none)"
  113. )
  114. if use lvm && use thin; then
  115. myeconfargs+=( --with-thin=internal --with-cache=internal )
  116. local texec
  117. for texec in check dump repair restore; do
  118. myeconfargs+=( --with-thin-${texec}="${EPREFIX}"/sbin/thin_${texec} )
  119. myeconfargs+=( --with-cache-${texec}="${EPREFIX}"/sbin/cache_${texec} )
  120. done
  121. else
  122. myeconfargs+=( --with-thin=none --with-cache=none )
  123. fi
  124. myeconfargs+=(
  125. # musl doesn't do symbol versioning so can end up with
  126. # runtime breakage.
  127. --with-symvers=$(usex elibc_glibc 'gnu' 'no')
  128. $(use_enable readline)
  129. $(use_enable selinux)
  130. --enable-pkgconfig
  131. --with-confdir="${EPREFIX}"/etc
  132. --exec-prefix="${EPREFIX}"
  133. --sbindir="${EPREFIX}/sbin"
  134. --with-staticdir="${EPREFIX}"/sbin
  135. --libdir="${EPREFIX}/$(get_libdir)"
  136. --with-usrlibdir="${EPREFIX}/usr/$(get_libdir)"
  137. --with-default-dm-run-dir=/run
  138. --with-default-run-dir=/run/lvm
  139. --with-default-locking-dir=/run/lock/lvm
  140. --with-default-pid-dir=/run
  141. $(use_enable dbus dbus-service)
  142. $(use_enable udev udev_rules)
  143. $(use_enable udev udev_sync)
  144. $(use_with udev udevdir "${EPREFIX}$(get_udevdir)"/rules.d)
  145. # USE=sanlock requires USE=lvm
  146. $(use_enable $(usex lvm sanlock lvm) lvmlockd-sanlock)
  147. $(use_enable systemd notify-dbus)
  148. $(use_enable systemd app-machineid)
  149. $(use_enable systemd systemd-journal)
  150. $(use_with systemd systemd-run "/usr/bin/systemd-run")
  151. $(use_enable valgrind valgrind-pool)
  152. --with-systemdsystemunitdir="$(systemd_get_systemunitdir)"
  153. CLDFLAGS="${LDFLAGS}"
  154. )
  155. econf "${myeconfargs[@]}"
  156. }
  157. src_compile() {
  158. emake V=1 -C include
  159. if use lvm ; then
  160. emake V=1
  161. emake V=1 CC="$(tc-getCC)" -C scripts
  162. else
  163. emake V=1 device-mapper
  164. # https://bugs.gentoo.org/878131
  165. emake V=1 -C libdm/dm-tools device-mapper
  166. fi
  167. }
  168. src_test() {
  169. einfo "Tests are disabled because of device-node mucking, if you want to"
  170. einfo "run tests, compile the package and see ${S}/tests"
  171. }
  172. src_install() {
  173. local targets=()
  174. if use lvm; then
  175. targets+=( install install_tmpfiles_configuration )
  176. if use systemd; then
  177. # install systemd related files only when requested, bug #522430
  178. targets+=( install_systemd_units )
  179. fi
  180. else
  181. targets+=( install_device-mapper )
  182. fi
  183. # -j1 for bug #918125
  184. emake -j1 V=1 DESTDIR="${D}" "${targets[@]}"
  185. newinitd "${FILESDIR}"/device-mapper.rc-r3 device-mapper
  186. newconfd "${FILESDIR}"/device-mapper.conf-r4 device-mapper
  187. if use lvm ; then
  188. newinitd "${FILESDIR}"/dmeventd.initd-r3 dmeventd
  189. newinitd "${FILESDIR}"/lvm.rc-r1 lvm
  190. newconfd "${FILESDIR}"/lvm.confd-r4 lvm
  191. if ! use udev ; then
  192. # We keep the variable but remove udev from it.
  193. sed -r -i \
  194. -e '/^rc_need=/s/\<udev\>//g' \
  195. "${ED}"/etc/conf.d/lvm || die "Could not drop udev from rc_need"
  196. fi
  197. newinitd "${FILESDIR}"/lvm-monitoring.initd-r3 lvm-monitoring
  198. newinitd "${FILESDIR}"/lvmpolld.initd-r1 lvmpolld
  199. if use sanlock; then
  200. newinitd "${FILESDIR}"/lvmlockd.initd-r2 lvmlockd
  201. fi
  202. fi
  203. if use static-libs; then
  204. dolib.a libdm/ioctl/libdevmapper.a
  205. if use lvm; then
  206. # depends on lvmetad
  207. dolib.a libdaemon/client/libdaemonclient.a #462908
  208. # depends on dmeventd
  209. dolib.a daemons/dmeventd/libdevmapper-event.a
  210. fi
  211. else
  212. rm -f "${ED}"/usr/$(get_libdir)/{libdevmapper-event,liblvm2cmd,liblvm2app,libdevmapper}.a || die
  213. fi
  214. insinto /etc
  215. doins "${FILESDIR}"/dmtab
  216. dodoc README VERSION* WHATS_NEW WHATS_NEW_DM doc/*.{c,txt} conf/*.conf
  217. }
  218. pkg_preinst() {
  219. HAD_LVM=0
  220. if has_version 'sys-fs/lvm2[lvm(+)]' ; then
  221. HAD_LVM=1
  222. fi
  223. }
  224. pkg_postinst() {
  225. use lvm && tmpfiles_process lvm2.conf
  226. use udev && udev_reload
  227. # This is a new installation
  228. if [[ -z "${REPLACING_VERSIONS}" ]]; then
  229. if use lvm ; then
  230. ewarn "Make sure the \"lvm\" init script is in the runlevels:"
  231. ewarn "# rc-update add lvm boot"
  232. ewarn
  233. ewarn "Make sure to enable lvmetad in ${EROOT}/etc/lvm/lvm.conf if you want"
  234. ewarn "to enable lvm autoactivation and metadata caching."
  235. else
  236. ewarn "Please enable USE=lvm if you need the LVM daemon and"
  237. ewarn "tools like 'lvchange', 'vgchange', etc!"
  238. fi
  239. else
  240. if ! use lvm && [[ ${HAD_LVM} -eq 1 ]] ; then
  241. ewarn "LVM was previously enabled but is now disabled."
  242. ewarn "Please enable USE=lvm if you need the LVM daemon and"
  243. ewarn "tools like 'lvchange', 'vgchange', etc!"
  244. ewarn "See the 2022-11-19-lvm2-default-USE-flags news item for more details."
  245. fi
  246. fi
  247. if use udev && [[ -d /run ]] ; then
  248. local permission_run_expected="drwxr-xr-x"
  249. local permission_run=$(stat -c "%A" /run)
  250. if [[ "${permission_run}" != "${permission_run_expected}" ]] ; then
  251. ewarn "Found the following problematic permissions:"
  252. ewarn ""
  253. ewarn " ${permission_run} /run"
  254. ewarn ""
  255. ewarn "Expected:"
  256. ewarn ""
  257. ewarn " ${permission_run_expected} /run"
  258. ewarn ""
  259. ewarn "This is known to cause problems for udev-enabled LVM services."
  260. fi
  261. fi
  262. }
  263. pkg_postrm() {
  264. if use udev && [[ -z ${REPLACED_BY_VERSION} ]]; then
  265. udev_reload
  266. fi
  267. }