sys-fs/simple-mtpfs: new version 0.3.0.
[gentoo.git] / sys-fs / zfs / zfs-0.6.2-r5.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} )
6
7 inherit python-r1
8
9 AT_M4DIR="config"
10 AUTOTOOLS_AUTORECONF="1"
11 AUTOTOOLS_IN_SOURCE_BUILD="1"
12
13 if [ ${PV} == "9999" ] ; then
14         inherit git-2 linux-mod
15         EGIT_REPO_URI="git://github.com/zfsonlinux/${PN}.git"
16 else
17         inherit eutils versionator
18         MY_PV=$(replace_version_separator 3 '-')
19         SRC_URI="https://github.com/zfsonlinux/${PN}/archive/${PN}-${MY_PV}.tar.gz
20                 https://dev.gentoo.org/~ryao/dist/${PN}-kmod-${MY_PV}-p4.tar.xz"
21         S="${WORKDIR}/${PN}-${PN}-${MY_PV}"
22         KEYWORDS="~amd64 ~arm ~ppc ~ppc64"
23 fi
24
25 inherit bash-completion-r1 flag-o-matic toolchain-funcs autotools-utils udev systemd
26
27 DESCRIPTION="Userland utilities for ZFS Linux kernel module"
28 HOMEPAGE="http://zfsonlinux.org/"
29
30 LICENSE="BSD-2 CDDL bash-completion? ( MIT )"
31 SLOT="0"
32 IUSE="bash-completion custom-cflags debug kernel-builtin +rootfs selinux test-suite static-libs"
33 RESTRICT="test"
34
35 COMMON_DEPEND="
36         selinux? ( sys-libs/libselinux )
37         sys-apps/util-linux[static-libs?]
38         sys-libs/zlib[static-libs(+)?]
39         virtual/awk
40 "
41 DEPEND="${COMMON_DEPEND}
42         virtual/pkgconfig
43 "
44
45 RDEPEND="${COMMON_DEPEND}
46         !=sys-apps/grep-2.13*
47         !kernel-builtin? ( =sys-fs/zfs-kmod-${PV}* )
48         !sys-fs/zfs-fuse
49         !prefix? ( virtual/udev )
50         test-suite? (
51                 sys-apps/util-linux
52                 sys-devel/bc
53                 sys-block/parted
54                 sys-fs/lsscsi
55                 sys-fs/mdadm
56                 sys-process/procps
57                 virtual/modutils
58                 )
59         rootfs? (
60                 app-arch/cpio
61                 app-misc/pax-utils
62                 !<sys-boot/grub-2.00-r2:2
63                 )
64 "
65
66 pkg_setup() {
67         :
68 }
69
70 src_prepare() {
71         if [ ${PV} != "9999" ]
72         then
73                 # Apply patch set
74                 EPATCH_SUFFIX="patch" \
75                 EPATCH_FORCE="yes" \
76                 epatch "${WORKDIR}/${PN}-kmod-${MY_PV}-patches"
77         fi
78
79         # Update paths
80         sed -e "s|/sbin/lsmod|/bin/lsmod|" \
81                 -e "s|/usr/bin/scsi-rescan|/usr/sbin/rescan-scsi-bus|" \
82                 -e "s|/sbin/parted|/usr/sbin/parted|" \
83                 -i scripts/common.sh.in
84
85         autotools-utils_src_prepare
86 }
87
88 src_configure() {
89         use custom-cflags || strip-flags
90         local myeconfargs=(
91                 --bindir="${EPREFIX}/bin"
92                 --sbindir="${EPREFIX}/sbin"
93                 --with-config=user
94                 --with-linux="${KV_DIR}"
95                 --with-linux-obj="${KV_OUT_DIR}"
96                 --with-udevdir="$(get_udevdir)"
97                 --with-blkid
98                 $(use_enable debug)
99                 $(use_with selinux)
100         )
101         autotools-utils_src_configure
102
103         # prepare systemd unit and helper script
104         cat "${FILESDIR}/zfs.service.in" | \
105                 sed -e "s:@sbindir@:${EPREFIX}/sbin:g" \
106                         -e "s:@sysconfdir@:${EPREFIX}/etc:g" \
107                 > "${T}/zfs.service" || die
108         cat "${FILESDIR}/zfs-init.sh.in" | \
109                 sed -e "s:@sbindir@:${EPREFIX}/sbin:g" \
110                         -e "s:@sysconfdir@:${EPREFIX}/etc:g" \
111                 > "${T}/zfs-init.sh" || die
112 }
113
114 src_install() {
115         autotools-utils_src_install
116         gen_usr_ldscript -a uutil nvpair zpool zfs
117         rm -rf "${ED}usr/lib/dracut"
118         use test-suite || rm -rf "${ED}usr/share/zfs"
119
120         use bash-completion && newbashcomp "${FILESDIR}/bash-completion-r1" zfs
121
122         exeinto /usr/libexec
123         doexe "${T}/zfs-init.sh"
124         systemd_dounit "${T}/zfs.service"
125 }
126
127 pkg_postinst() {
128
129         if ! use kernel-builtin && [ ${PV} = "9999" ]
130         then
131                 einfo "Adding ${P} to the module database to ensure that the"
132                 einfo "kernel modules and userland utilities stay in sync."
133                 update_moduledb
134         fi
135
136         [ -e "${EROOT}etc/runlevels/boot/zfs" ] \
137                 || ewarn 'You should add zfs to the boot runlevel.'
138
139         if [ -e "${EROOT}etc/runlevels/shutdown/zfs-shutdown" ]
140         then
141                 einfo "The zfs-shutdown script is obsolete. Removing it from runlevel."
142                 rm "${EROOT}etc/runlevels/shutdown/zfs-shutdown"
143         fi
144
145 }
146
147 pkg_postrm() {
148         if ! use kernel-builtin && [ ${PV} = "9999" ]
149         then
150                 remove_moduledb
151         fi
152 }