lvm2-2.02.145.ebuild 9.4 KB

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