lvm2-2.02.116-r2.ebuild 9.2 KB

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