lvm2-2.02.116.ebuild 9.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272
  1. # Copyright 1999-2016 Gentoo Foundation
  2. # Distributed under the terms of the GNU General Public License v2
  3. EAPI=5
  4. inherit autotools eutils linux-info multilib systemd toolchain-funcs udev flag-o-matic
  5. DESCRIPTION="User-land utilities for LVM2 (device-mapper) software"
  6. HOMEPAGE="https://sourceware.org/lvm2/"
  7. SRC_URI="ftp://sourceware.org/pub/lvm2/${PN/lvm/LVM}.${PV}.tgz
  8. ftp://sourceware.org/pub/lvm2/old/${PN/lvm/LVM}.${PV}.tgz"
  9. LICENSE="GPL-2"
  10. SLOT="0"
  11. KEYWORDS="alpha amd64 arm arm64 hppa ia64 ~mips ppc ppc64 s390 sh sparc x86 ~amd64-linux ~x86-linux"
  12. IUSE="readline static static-libs systemd clvm cman lvm1 lvm2create_initrd selinux +udev +thin device-mapper-only"
  13. REQUIRED_USE="device-mapper-only? ( !clvm !cman !lvm1 !lvm2create_initrd !thin )
  14. systemd? ( udev )
  15. static? ( !udev )" #520450
  16. DEPEND_COMMON="clvm? ( cman? ( =sys-cluster/cman-3* ) =sys-cluster/libdlm-3* )
  17. readline? ( sys-libs/readline:0= )
  18. udev? ( >=virtual/libudev-208:=[static-libs?] )"
  19. # /run is now required for locking during early boot. /var cannot be assumed to
  20. # be available -- thus, pull in recent enough baselayout for /run.
  21. # This version of LVM is incompatible with cryptsetup <1.1.2.
  22. RDEPEND="${DEPEND_COMMON}
  23. >=sys-apps/baselayout-2.2
  24. !<sys-apps/openrc-0.11
  25. !<sys-fs/cryptsetup-1.1.2
  26. !!sys-fs/clvm
  27. !!sys-fs/lvm-user
  28. >=sys-apps/util-linux-2.16
  29. lvm2create_initrd? ( sys-apps/makedev )
  30. thin? ( >=sys-block/thin-provisioning-tools-0.3.0 )"
  31. # note: thin- 0.3.0 is required to avoid --disable-thin_check_needs_check
  32. DEPEND="${DEPEND_COMMON}
  33. virtual/pkgconfig
  34. >=sys-devel/binutils-2.20.1-r1
  35. static? (
  36. selinux? ( sys-libs/libselinux[static-libs] )
  37. udev? ( >=virtual/libudev-208:=[static-libs] )
  38. >=sys-apps/util-linux-2.16[static-libs]
  39. )"
  40. S=${WORKDIR}/${PN/lvm/LVM}.${PV}
  41. pkg_setup() {
  42. local CONFIG_CHECK="~SYSVIPC"
  43. if use udev; then
  44. local WARNING_SYSVIPC="CONFIG_SYSVIPC:\tis not set (required for udev sync)\n"
  45. if linux_config_exists; then
  46. local uevent_helper_path=$(linux_chkconfig_string UEVENT_HELPER_PATH)
  47. if [ -n "${uevent_helper_path}" ] && [ "${uevent_helper_path}" != '""' ]; then
  48. ewarn "It's recommended to set an empty value to the following kernel config option:"
  49. ewarn "CONFIG_UEVENT_HELPER_PATH=${uevent_helper_path}"
  50. fi
  51. fi
  52. fi
  53. check_extra_config
  54. # 1. Genkernel no longer copies /sbin/lvm blindly.
  55. if use static; then
  56. elog "Warning, we no longer overwrite /sbin/lvm and /sbin/dmsetup with"
  57. elog "their static versions. If you need the static binaries,"
  58. elog "you must append .static to the filename!"
  59. fi
  60. }
  61. src_prepare() {
  62. # Gentoo specific modification(s):
  63. epatch "${FILESDIR}"/${PN}-2.02.108-example.conf.in.patch
  64. sed -i \
  65. -e "1iAR = $(tc-getAR)" \
  66. -e "s:CC ?= @CC@:CC = $(tc-getCC):" \
  67. make.tmpl.in || die #444082
  68. sed -i -e '/FLAG/s:-O2::' configure{.in,} || die #480212
  69. if use udev && ! use device-mapper-only; then
  70. sed -i -e '/use_lvmetad =/s:0:1:' conf/example.conf.in || die #514196
  71. elog "Notice that \"use_lvmetad\" setting is enabled with USE=\"udev\" in"
  72. elog "/etc/lvm/lvm.conf, which will require restart of udev, lvm, and lvmetad"
  73. elog "if it was previously disabled."
  74. fi
  75. sed -i -e "s:/usr/bin/true:$(type -P true):" scripts/blk_availability_systemd_red_hat.service.in || die #517514
  76. # For upstream -- review and forward:
  77. epatch "${FILESDIR}"/${PN}-2.02.63-always-make-static-libdm.patch
  78. epatch "${FILESDIR}"/${PN}-2.02.56-lvm2create_initrd.patch
  79. epatch "${FILESDIR}"/${PN}-2.02.67-createinitrd.patch #301331
  80. epatch "${FILESDIR}"/${PN}-2.02.99-locale-muck.patch #330373
  81. epatch "${FILESDIR}"/${PN}-2.02.70-asneeded.patch # -Wl,--as-needed
  82. epatch "${FILESDIR}"/${PN}-2.02.92-dynamic-static-ldflags.patch #332905
  83. epatch "${FILESDIR}"/${PN}-2.02.108-static-pkgconfig-libs.patch #370217, #439414 + blkid
  84. epatch "${FILESDIR}"/${PN}-2.02.106-pthread-pkgconfig.patch #492450
  85. # Without thin-privision-tools, there is nothing to install for target install_man7:
  86. use thin || { sed -i -e '/^install_lvm2/s:install_man7::' man/Makefile.in || die; }
  87. eautoreconf
  88. }
  89. src_configure() {
  90. filter-flags -flto
  91. local myconf
  92. local buildmode
  93. myconf="${myconf} $(use_enable !device-mapper-only dmeventd)"
  94. myconf="${myconf} $(use_enable !device-mapper-only cmdlib)"
  95. myconf="${myconf} $(use_enable !device-mapper-only applib)"
  96. myconf="${myconf} $(use_enable !device-mapper-only fsadm)"
  97. myconf="${myconf} $(use_enable !device-mapper-only lvmetad)"
  98. use device-mapper-only && myconf="${myconf} --disable-udev-systemd-background-jobs"
  99. # Most of this package does weird stuff.
  100. # The build options are tristate, and --without is NOT supported
  101. # options: 'none', 'internal', 'shared'
  102. if use static; then
  103. buildmode="internal"
  104. # This only causes the .static versions to become available
  105. myconf="${myconf} --enable-static_link"
  106. else
  107. buildmode="shared"
  108. fi
  109. dmbuildmode=$(use !device-mapper-only && echo internal || echo none)
  110. # dmeventd requires mirrors to be internal, and snapshot available
  111. # so we cannot disable them
  112. myconf="${myconf} --with-mirrors=${dmbuildmode}"
  113. myconf="${myconf} --with-snapshots=${dmbuildmode}"
  114. if use thin; then
  115. myconf="${myconf} --with-thin=internal --with-cache=internal"
  116. local texec
  117. for texec in check dump repair restore; do
  118. myconf="${myconf} --with-thin-${texec}=${EPREFIX}/sbin/thin_${texec}"
  119. myconf="${myconf} --with-cache-${texec}=${EPREFIX}/sbin/cache_${texec}"
  120. done
  121. else
  122. myconf="${myconf} --with-thin=none --with-cache=none"
  123. fi
  124. if use lvm1; then
  125. myconf="${myconf} --with-lvm1=${buildmode}"
  126. else
  127. myconf="${myconf} --with-lvm1=none"
  128. fi
  129. # disable O_DIRECT support on hppa, breaks pv detection (#99532)
  130. use hppa && myconf="${myconf} --disable-o_direct"
  131. if use clvm; then
  132. myconf="${myconf} --with-cluster=${buildmode}"
  133. # 4-state! Make sure we get it right, per bug 210879
  134. # Valid options are: none, cman, gulm, all
  135. #
  136. # 2009/02:
  137. # gulm is removed now, now dual-state:
  138. # cman, none
  139. # all still exists, but is not needed
  140. #
  141. # 2009/07:
  142. # TODO: add corosync and re-enable ALL
  143. local clvmd=""
  144. use cman && clvmd="cman"
  145. #clvmd="${clvmd/cmangulm/all}"
  146. [ -z "${clvmd}" ] && clvmd="none"
  147. myconf="${myconf} --with-clvmd=${clvmd}"
  148. myconf="${myconf} --with-pool=${buildmode}"
  149. else
  150. myconf="${myconf} --with-clvmd=none --with-cluster=none"
  151. fi
  152. econf \
  153. $(use_enable readline) \
  154. $(use_enable selinux) \
  155. --enable-pkgconfig \
  156. --with-confdir="${EPREFIX}"/etc \
  157. --exec-prefix="${EPREFIX}" \
  158. --sbindir="${EPREFIX}/sbin" \
  159. --with-staticdir="${EPREFIX}"/sbin \
  160. --libdir="${EPREFIX}/$(get_libdir)" \
  161. --with-usrlibdir="${EPREFIX}/usr/$(get_libdir)" \
  162. --with-default-dm-run-dir=/run \
  163. --with-default-run-dir=/run/lvm \
  164. --with-default-locking-dir=/run/lock/lvm \
  165. --with-default-pid-dir=/run \
  166. $(use_enable udev udev_rules) \
  167. $(use_enable udev udev_sync) \
  168. $(use_with udev udevdir "$(get_udevdir)"/rules.d) \
  169. $(use_enable systemd udev-systemd-background-jobs) \
  170. "$(systemd_with_unitdir)" \
  171. ${myconf} \
  172. CLDFLAGS="${LDFLAGS}"
  173. }
  174. src_compile() {
  175. pushd include >/dev/null
  176. emake
  177. popd >/dev/null
  178. if use device-mapper-only ; then
  179. emake device-mapper
  180. else
  181. emake
  182. emake CC="$(tc-getCC)" -C scripts lvm2_activation_generator_systemd_red_hat
  183. fi
  184. }
  185. src_install() {
  186. local inst
  187. INSTALL_TARGETS="install install_systemd_units install_systemd_generators install_tmpfiles_configuration"
  188. use device-mapper-only && INSTALL_TARGETS="install_device-mapper"
  189. for inst in ${INSTALL_TARGETS}; do
  190. emake DESTDIR="${D}" ${inst}
  191. done
  192. newinitd "${FILESDIR}"/device-mapper.rc-2.02.105-r2 device-mapper
  193. newconfd "${FILESDIR}"/device-mapper.conf-1.02.22-r3 device-mapper
  194. if use !device-mapper-only ; then
  195. newinitd "${FILESDIR}"/dmeventd.initd-2.02.67-r1 dmeventd
  196. newinitd "${FILESDIR}"/lvm.rc-2.02.105-r2 lvm
  197. newconfd "${FILESDIR}"/lvm.confd-2.02.28-r2 lvm
  198. newinitd "${FILESDIR}"/lvm-monitoring.initd-2.02.105-r2 lvm-monitoring
  199. newinitd "${FILESDIR}"/lvmetad.initd-2.02.105-r2 lvmetad
  200. fi
  201. if use clvm; then
  202. newinitd "${FILESDIR}"/clvmd.rc-2.02.39 clvmd
  203. newconfd "${FILESDIR}"/clvmd.confd-2.02.39 clvmd
  204. fi
  205. if use static-libs; then
  206. dolib.a libdm/ioctl/libdevmapper.a
  207. dolib.a libdaemon/client/libdaemonclient.a #462908
  208. #gen_usr_ldscript libdevmapper.so
  209. dolib.a daemons/dmeventd/libdevmapper-event.a
  210. #gen_usr_ldscript libdevmapper-event.so
  211. else
  212. rm -f "${ED}"usr/$(get_libdir)/{libdevmapper-event,liblvm2cmd,liblvm2app,libdevmapper}.a
  213. fi
  214. if use lvm2create_initrd; then
  215. dosbin scripts/lvm2create_initrd/lvm2create_initrd
  216. doman scripts/lvm2create_initrd/lvm2create_initrd.8
  217. newdoc scripts/lvm2create_initrd/README README.lvm2create_initrd
  218. fi
  219. insinto /etc
  220. doins "${FILESDIR}"/dmtab
  221. dodoc README VERSION* WHATS_NEW WHATS_NEW_DM doc/*.{c,txt} conf/*.conf
  222. }
  223. pkg_postinst() {
  224. ewarn "Make sure the \"lvm\" init script is in the runlevels:"
  225. ewarn "# rc-update add lvm boot"
  226. ewarn
  227. ewarn "Make sure to enable lvmetad in /etc/lvm/lvm.conf if you want"
  228. ewarn "to enable lvm autoactivation and metadata caching."
  229. }
  230. src_test() {
  231. einfo "Tests are disabled because of device-node mucking, if you want to"
  232. einfo "run tests, compile the package and see ${S}/tests"
  233. }