dev-qt/qtpositioning: stable 5.14.2 for ppc, bug #719732
[gentoo.git] / sys-fs / zfs / zfs-0.8.3-r1.ebuild
1 # Copyright 1999-2020 Gentoo Authors
2 # Distributed under the terms of the GNU General Public License v2
3
4 EAPI=7
5
6 DISTUTILS_OPTIONAL=1
7 PYTHON_COMPAT=( python3_{6,7} )
8
9 inherit bash-completion-r1 flag-o-matic linux-info distutils-r1 systemd toolchain-funcs udev usr-ldscript
10
11 DESCRIPTION="Userland utilities for ZFS Linux kernel module"
12 HOMEPAGE="https://zfsonlinux.org/"
13
14 if [[ ${PV} == "9999" ]] ; then
15         inherit autotools git-r3 linux-mod
16         EGIT_REPO_URI="https://github.com/zfsonlinux/zfs.git"
17 else
18         SRC_URI="https://github.com/zfsonlinux/${PN}/releases/download/${P}/${P}.tar.gz"
19         KEYWORDS="amd64 ~arm64 ~ppc64"
20 fi
21
22 LICENSE="BSD-2 CDDL MIT"
23 SLOT="0"
24 IUSE="custom-cflags debug kernel-builtin libressl python +rootfs test-suite static-libs"
25
26 DEPEND="
27         ${PYTHON_DEPS}
28         net-libs/libtirpc[static-libs?]
29         sys-apps/util-linux[static-libs?]
30         sys-libs/zlib[static-libs(+)?]
31         virtual/awk
32         virtual/libudev[static-libs(-)?]
33         libressl? ( dev-libs/libressl:0=[static-libs?] )
34         !libressl? ( dev-libs/openssl:0=[static-libs?] )
35         python? (
36                 virtual/python-cffi[${PYTHON_USEDEP}]
37         )
38 "
39
40 BDEPEND="virtual/awk
41         virtual/pkgconfig
42         python? (
43                 dev-python/setuptools[${PYTHON_USEDEP}]
44         )
45 "
46
47 RDEPEND="${DEPEND}
48         !kernel-builtin? ( ~sys-fs/zfs-kmod-${PV} )
49         !prefix? ( virtual/udev )
50         sys-fs/udev-init-scripts
51         rootfs? (
52                 app-arch/cpio
53                 app-misc/pax-utils
54                 !<sys-kernel/genkernel-3.5.1.1
55         )
56         test-suite? (
57                 sys-apps/util-linux
58                 sys-devel/bc
59                 sys-block/parted
60                 sys-fs/lsscsi
61                 sys-fs/mdadm
62                 sys-process/procps
63                 virtual/modutils
64         )
65 "
66
67 REQUIRED_USE="${PYTHON_REQUIRED_USE}"
68
69 RESTRICT="test"
70
71 PATCHES=(
72         "${FILESDIR}/bash-completion-sudo.patch"
73         "${FILESDIR}/${PV}-fno-common.patch"
74         "${FILESDIR}/${PV}-zfs-functions.patch"
75 )
76
77 pkg_setup() {
78         if use kernel_linux && use test-suite; then
79                 linux-info_pkg_setup
80
81                 if  ! linux_config_exists; then
82                         ewarn "Cannot check the linux kernel configuration."
83                 else
84                         if use test-suite; then
85                                 if linux_chkconfig_present BLK_DEV_LOOP; then
86                                         eerror "The ZFS test suite requires loop device support enabled."
87                                         eerror "Please enable it:"
88                                         eerror "    CONFIG_BLK_DEV_LOOP=y"
89                                         eerror "in /usr/src/linux/.config or"
90                                         eerror "    Device Drivers --->"
91                                         eerror "        Block devices --->"
92                                         eerror "            [X] Loopback device support"
93                                 fi
94                         fi
95                 fi
96         fi
97 }
98
99 src_prepare() {
100         default
101
102         if [[ ${PV} == "9999" ]]; then
103                 eautoreconf
104         else
105                 # Set revision number
106                 sed -i "s/\(Release:\)\(.*\)1/\1\2${PR}-gentoo/" META || die "Could not set Gentoo release"
107         fi
108
109         if use python; then
110                 pushd contrib/pyzfs >/dev/null || die
111                 distutils-r1_src_prepare
112                 popd >/dev/null || die
113         fi
114
115         # prevent errors showing up on zfs-mount stop, #647688
116         # openrc will unmount all filesystems anyway.
117         sed -i "/^ZFS_UNMOUNT=/ s/yes/no/" etc/init.d/zfs.in || die
118
119         # needed to get files regenerated
120         # https://github.com/zfsonlinux/zfs/issues/9443
121         rm -v etc/init.d/zfs{,-functions} || die
122 }
123
124 src_configure() {
125         use custom-cflags || strip-flags
126         python_setup
127
128         local myconf=(
129                 --bindir="${EPREFIX}/bin"
130                 --enable-shared
131                 --enable-systemd
132                 --enable-sysvinit
133                 --localstatedir="${EPREFIX}/var"
134                 --sbindir="${EPREFIX}/sbin"
135                 --with-config=user
136                 --with-dracutdir="${EPREFIX}/usr/lib/dracut"
137                 --with-linux="${KV_DIR}"
138                 --with-linux-obj="${KV_OUT_DIR}"
139                 --with-udevdir="$(get_udevdir)"
140                 --with-python="${EPYTHON}"
141                 --with-systemdunitdir="$(systemd_get_systemunitdir)"
142                 --with-systemdpresetdir="${EPREFIX}/lib/systemd/system-preset"
143                 $(use_enable debug)
144                 $(use_enable python pyzfs)
145                 $(use_enable static-libs static)
146         )
147
148         econf "${myconf[@]}"
149 }
150
151 src_compile() {
152         default
153         if use python; then
154                 pushd contrib/pyzfs >/dev/null || die
155                 distutils-r1_src_compile
156                 popd >/dev/null || die
157         fi
158 }
159
160 src_install() {
161         default
162
163         gen_usr_ldscript -a uutil nvpair zpool zfs zfs_core
164
165         use test-suite || rm -rf "${ED}/usr/share/zfs"
166
167         if ! use static-libs; then
168                 find "${ED}/" -name '*.la' -delete || die
169         fi
170
171         dobashcomp contrib/bash_completion.d/zfs
172         bashcomp_alias zfs zpool
173
174         # strip executable bit from conf.d file
175         fperms 0644 /etc/conf.d/zfs
176
177         if use python; then
178                 pushd contrib/pyzfs >/dev/null || die
179                 distutils-r1_src_install
180                 popd >/dev/null || die
181         fi
182
183         # enforce best available python implementation
184         python_fix_shebang "${ED}/bin"
185
186 }
187
188 pkg_postinst() {
189         if use rootfs; then
190                 if ! has_version sys-kernel/genkernel && ! has_version sys-kernel/dracut; then
191                         elog "root on zfs requires initramfs to boot"
192                         elog "the following packages known to provide one and tested on regular basis:"
193                         elog "  sys-kernel/dracut"
194                         elog "  sys-kernel/genkernel"
195                 fi
196
197                 if has_version "<=sys-kernel/genkernel-3.5.3.3"; then
198                         einfo "genkernel version 3.5.3.3 and earlier does NOT support"
199                         einfo " unlocking pools with native zfs encryption enabled at boot"
200                         einfo " use dracut or >=genkernel-4 if you requre this functionality"
201                 fi
202         fi
203
204         if ! use kernel-builtin && [[ ${PV} = "9999" ]]; then
205                 einfo "Adding ${P} to the module database to ensure that the"
206                 einfo "kernel modules and userland utilities stay in sync."
207                 update_moduledb
208         fi
209
210         [[ -e "${EROOT}/etc/runlevels/boot/zfs-import" ]] || \
211                 einfo "You should add zfs-import to the boot runlevel."
212         [[ -e "${EROOT}/etc/runlevels/boot/zfs-mount" ]]|| \
213                 einfo "You should add zfs-mount to the boot runlevel."
214         [[ -e "${EROOT}/etc/runlevels/default/zfs-share" ]] || \
215                 einfo "You should add zfs-share to the default runlevel."
216         [[ -e "${EROOT}/etc/runlevels/default/zfs-zed" ]] || \
217                 einfo "You should add zfs-zed to the default runlevel."
218 }
219
220 pkg_postrm() {
221         if ! use kernel-builtin && [[ ${PV} == "9999" ]]; then
222                 remove_moduledb
223         fi
224 }