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