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