sys-fs/simple-mtpfs: new version 0.3.0.
[gentoo.git] / sys-fs / zfs / zfs-0.6.5.3-r3.ebuild
1 # Copyright 1999-2015 Gentoo Foundation
2 # Distributed under the terms of the GNU General Public License v2
3
4 EAPI="5"
5 PYTHON_COMPAT=( python{2_7,3_4,3_5} )
6
7 AT_M4DIR="config"
8 AUTOTOOLS_AUTORECONF="1"
9 AUTOTOOLS_IN_SOURCE_BUILD="1"
10
11 if [ ${PV} == "9999" ] ; then
12         inherit git-r3 linux-mod
13         AUTOTOOLS_AUTORECONF="1"
14         EGIT_REPO_URI="git://github.com/zfsonlinux/${PN}.git"
15 else
16         SRC_URI="https://github.com/zfsonlinux/${PN}/releases/download/${P}/${P}.tar.gz
17                 https://dev.gentoo.org/~ryao/dist/${P}-patches-p2.tar.xz"
18         KEYWORDS="~amd64 ~arm ~ppc ~ppc64"
19 fi
20
21 inherit autotools-utils bash-completion-r1 flag-o-matic linux-info python-r1 systemd toolchain-funcs udev
22
23 DESCRIPTION="Userland utilities for ZFS Linux kernel module"
24 HOMEPAGE="http://zfsonlinux.org/"
25
26 LICENSE="BSD-2 CDDL MIT"
27 SLOT="0"
28 IUSE="custom-cflags debug kernel-builtin +rootfs test-suite static-libs"
29 RESTRICT="test"
30
31 COMMON_DEPEND="
32         sys-apps/util-linux[static-libs?]
33         sys-libs/zlib[static-libs(+)?]
34         virtual/awk
35 "
36 DEPEND="${COMMON_DEPEND}
37         virtual/pkgconfig
38 "
39
40 RDEPEND="${COMMON_DEPEND}
41         !=sys-apps/grep-2.13*
42         !kernel-builtin? (
43                 =sys-fs/zfs-kmod-${PV}*
44                 !<sys-fs/zfs-kmod-0.6.5.3-r1
45                 )
46         !sys-fs/zfs-fuse
47         !prefix? ( virtual/udev )
48         test-suite? (
49                 sys-apps/util-linux
50                 sys-devel/bc
51                 sys-block/parted
52                 sys-fs/lsscsi
53                 sys-fs/mdadm
54                 sys-process/procps
55                 virtual/modutils
56                 )
57         rootfs? (
58                 app-arch/cpio
59                 app-misc/pax-utils
60                 !<sys-boot/grub-2.00-r2:2
61                 )
62         !>=sys-fs/udev-init-scripts-28
63 "
64
65 AT_M4DIR="config"
66 AUTOTOOLS_IN_SOURCE_BUILD="1"
67
68 pkg_setup() {
69         if use kernel_linux && use test-suite; then
70                 linux-info_pkg_setup
71                 if  ! linux_config_exists; then
72                         ewarn "Cannot check the linux kernel configuration."
73                 else
74                         # recheck that we don't have usblp to collide with libusb
75                         if use test-suite; then
76                                 if linux_chkconfig_present BLK_DEV_LOOP; then
77                                         eerror "The ZFS test suite requires loop device support enabled."
78                                         eerror "Please enable it:"
79                                         eerror "    CONFIG_BLK_DEV_LOOP=y"
80                                         eerror "in /usr/src/linux/.config or"
81                                         eerror "    Device Drivers --->"
82                                         eerror "        Block devices --->"
83                                         eerror "            [ ] Loopback device support"
84                                 fi
85                         fi
86                 fi
87         fi
88
89 }
90
91 src_prepare() {
92         if [ ${PV} != "9999" ]
93         then
94                 # Apply patch set
95                 EPATCH_SUFFIX="patch" \
96                 EPATCH_FORCE="yes" \
97                 epatch "${WORKDIR}/${P}-patches"
98         fi
99
100         # Update paths
101         sed -e "s|/sbin/lsmod|/bin/lsmod|" \
102                 -e "s|/usr/bin/scsi-rescan|/usr/sbin/rescan-scsi-bus|" \
103                 -e "s|/sbin/parted|/usr/sbin/parted|" \
104                 -i scripts/common.sh.in
105
106         autotools-utils_src_prepare
107 }
108
109 src_configure() {
110         use custom-cflags || strip-flags
111         local myeconfargs=(
112                 --bindir="${EPREFIX}/bin"
113                 --sbindir="${EPREFIX}/sbin"
114                 --with-config=user
115                 --with-dracutdir="/usr/$(get_libdir)/dracut"
116                 --with-linux="${KV_DIR}"
117                 --with-linux-obj="${KV_OUT_DIR}"
118                 --with-udevdir="$(get_udevdir)"
119                 --with-blkid
120                 $(use_enable debug)
121         )
122         autotools-utils_src_configure
123
124         # prepare systemd unit and helper script
125         cat "${FILESDIR}/zfs.service.in" | \
126                 sed -e "s:@sbindir@:${EPREFIX}/sbin:g" \
127                         -e "s:@sysconfdir@:${EPREFIX}/etc:g" \
128                 > "${T}/zfs.service" || die
129         cat "${FILESDIR}/zfs-init.sh.in" | \
130                 sed -e "s:@sbindir@:${EPREFIX}/sbin:g" \
131                         -e "s:@sysconfdir@:${EPREFIX}/etc:g" \
132                 > "${T}/zfs-init.sh" || die
133 }
134
135 src_install() {
136         autotools-utils_src_install
137         gen_usr_ldscript -a uutil nvpair zpool zfs zfs_core
138         use test-suite || rm -rf "${ED}usr/share/zfs"
139
140         newbashcomp "${FILESDIR}/bash-completion-r1" zfs
141         bashcomp_alias zfs zpool
142
143         exeinto /usr/libexec
144         doexe "${T}/zfs-init.sh"
145         systemd_dounit "${T}/zfs.service"
146 }
147
148 pkg_postinst() {
149         if ! use kernel-builtin && [ ${PV} = "9999" ]
150         then
151                 einfo "Adding ${P} to the module database to ensure that the"
152                 einfo "kernel modules and userland utilities stay in sync."
153                 update_moduledb
154         fi
155
156         if [ -e "${EROOT}etc/runlevels/boot/zfs" ]
157         then
158                 einfo 'The zfs boot script has been split into the zfs-import,'
159                 einfo 'zfs-mount and zfs-share scripts.'
160                 einfo
161                 einfo 'You had the zfs script in your boot runlevel. For your'
162                 einfo 'convenience, it has been automatically removed and the three'
163                 einfo 'scripts that replace it have been configured to start.'
164                 einfo 'The zfs-import and zfs-mount scripts have been added to the boot'
165                 einfo 'runlevel while the zfs-share script is in the default runlevel.'
166
167                 rm "${EROOT}etc/runlevels/boot/zfs"
168                 ln -snf "${EROOT}etc/init.d/zfs-import" \
169                         "${EROOT}etc/runlevels/boot/zfs-import"
170                 ln -snf "${EROOT}etc/init.d/zfs-mount" \
171                         "${EROOT}etc/runlevels/boot/zfs-mount"
172                 ln -snf "${EROOT}etc/init.d/zfs-share" \
173                         "${EROOT}etc/runlevels/default/zfs-share"
174         else
175                 [ -e "${EROOT}etc/runlevels/boot/zfs-import" ] || \
176                         einfo "You should add zfs-import to the boot runlevel."
177                 [ -e "${EROOT}etc/runlevels/boot/zfs-mount" ] || \
178                         einfo "You should add zfs-mount to the boot runlevel."
179                 [ -e "${EROOT}etc/runlevels/default/zfs-share" ] || \
180                         einfo "You should add zfs-share to the default runlevel."
181         fi
182
183         if [ -e "${EROOT}etc/runlevels/default/zed" ]
184         then
185                 einfo 'The downstream OpenRC zed script has replaced by the upstream'
186                 einfo 'OpenRC zfs-zed script.'
187                 einfo
188                 einfo 'You had the zed script in your default runlevel. For your'
189                 einfo 'convenience, it has been automatically removed and the zfs-zed'
190                 einfo 'script that replaced it has been configured to start.'
191
192                 rm "${EROOT}etc/runlevels/boot/zed"
193                 ln -snf "${EROOT}etc/init.d/zfs-sed" \
194                         "${EROOT}etc/runlevels/default/zfs-zed"
195         else
196                 [ -e "${EROOT}etc/runlevels/default/zfs-zed" ] || \
197                         einfo "You should add zfs-zed to the default runlevel."
198         fi
199
200         if [ -e "${EROOT}etc/runlevels/shutdown/zfs-shutdown" ]
201         then
202                 einfo "The zfs-shutdown script is obsolete. Removing it from runlevel."
203                 rm "${EROOT}etc/runlevels/shutdown/zfs-shutdown"
204         fi
205
206         einfo "sys-kernel/spl-0.6.5.3-r1, sys-fs/zfs-kmod-0.6.5.3-r1 and "
207         einfo "sys-fs/zfs-0.6.5.3-r1 have introduced a partial stable "
208         einfo "/dev/zfs API developed by ClusterHQ. This means that situations "
209         einfo "arising from the kernel modules and userland tools being "
210         einfo "mismatched on future updates will not cause problems."
211         einfo
212         einfo "In specific, this should solve the failure to mount filesystems when "
213         einfo "old modules are cached in an old initramfs provided that those "
214         einfo "modules support this API"
215         if use rootfs
216         then
217                 einfo
218                 ewarn "The older modules will *NOT* work with the new userland code."
219                 ewarn "It is very important that you update your initramfs after this "
220                 ewarn "update."
221         fi
222 }
223
224 pkg_postrm() {
225         if ! use kernel-builtin && [ ${PV} = "9999" ]
226         then
227                 remove_moduledb
228         fi
229 }