From 703fe789c88c5e89cd1012ef35719a14613b176f Mon Sep 17 00:00:00 2001 From: Justin Wind Date: Sat, 5 Sep 2020 15:03:38 -0700 Subject: [PATCH] add zfs 0.7 snapshot --- sys-fs/zfs-kmod/Manifest | 3 + sys-fs/zfs-kmod/metadata.xml | 18 + sys-fs/zfs-kmod/zfs-kmod-0.7.13.ebuild | 147 +++++++ sys-fs/zfs/Manifest | 11 + .../0.7.13-ZPOOL_IMPORT_UDEV_TIMEOUT_MS.patch | 70 ++++ sys-fs/zfs/files/0.8.3-fno-common.patch | 83 ++++ sys-fs/zfs/files/0.8.3-zfs-functions.patch | 51 +++ sys-fs/zfs/files/bash-completion-r1 | 391 ++++++++++++++++++ sys-fs/zfs/files/bash-completion-sudo.patch | 35 ++ sys-fs/zfs/files/zfs-init.sh.in | 29 ++ sys-fs/zfs/files/zfs.service.in | 16 + sys-fs/zfs/metadata.xml | 20 + sys-fs/zfs/zfs-0.7.13-r1.ebuild | 218 ++++++++++ sys-fs/zfs/zfs-0.7.13-r2.ebuild | 220 ++++++++++ sys-kernel/spl/Manifest | 3 + sys-kernel/spl/metadata.xml | 15 + sys-kernel/spl/spl-0.7.13.ebuild | 119 ++++++ 17 files changed, 1449 insertions(+) create mode 100644 sys-fs/zfs-kmod/Manifest create mode 100644 sys-fs/zfs-kmod/metadata.xml create mode 100644 sys-fs/zfs-kmod/zfs-kmod-0.7.13.ebuild create mode 100644 sys-fs/zfs/Manifest create mode 100644 sys-fs/zfs/files/0.7.13-ZPOOL_IMPORT_UDEV_TIMEOUT_MS.patch create mode 100644 sys-fs/zfs/files/0.8.3-fno-common.patch create mode 100644 sys-fs/zfs/files/0.8.3-zfs-functions.patch create mode 100644 sys-fs/zfs/files/bash-completion-r1 create mode 100644 sys-fs/zfs/files/bash-completion-sudo.patch create mode 100644 sys-fs/zfs/files/zfs-init.sh.in create mode 100644 sys-fs/zfs/files/zfs.service.in create mode 100644 sys-fs/zfs/metadata.xml create mode 100644 sys-fs/zfs/zfs-0.7.13-r1.ebuild create mode 100644 sys-fs/zfs/zfs-0.7.13-r2.ebuild create mode 100644 sys-kernel/spl/Manifest create mode 100644 sys-kernel/spl/metadata.xml create mode 100644 sys-kernel/spl/spl-0.7.13.ebuild diff --git a/sys-fs/zfs-kmod/Manifest b/sys-fs/zfs-kmod/Manifest new file mode 100644 index 0000000..668f3e3 --- /dev/null +++ b/sys-fs/zfs-kmod/Manifest @@ -0,0 +1,3 @@ +DIST zfs-0.7.13.tar.gz 6614047 BLAKE2B c59c46287715779eb04d69333b0a417fa9865eb0d61c642b043188c4c97d4eed369f76a48327326ed1d4dd608ff95d91d20d26c80ed0b120a8fcd5f83cea638f SHA512 457d8f110b68c9656194cd3738b216d5d807d680e5cfc6ed1f3cf5ebde67860476387c6b862ba3ba7f972d8945075963e6c325543ab84468e3eff5dbce68476e +EBUILD zfs-kmod-0.7.13.ebuild 4119 BLAKE2B f8d921251bc94644a7331762054935518bb9fb68425b404572876466bff118b9ae20cf297f34d9267c933d7ea28840c84fe8e4a867e9a9f191b627f29207798b SHA512 8e4eb43e5b4edd7dcb8b0ecb13a809340ee20247017e7cb141b8489dc4c9988b84b40e866028e8d3b73aea69981a923e4fc4b237389115fb8e72d8b6ed450340 +MISC metadata.xml 551 BLAKE2B c8dc35c8f884d3f5d8720ad838c34ae5be7dc3b3cc63ab7713330a5611bca2829942eeb640b7e00ef285af9b52dd2d134cd793a20baeecff2af56f6b60116e21 SHA512 1cfd4a6a6ec4a120c8e02d3dde831b1f73294a06b798388ff8d4e761ef986e625a56fa980f8d412fab082630f58932116cf795bc5e5728c6485dd9ad54e22a7a diff --git a/sys-fs/zfs-kmod/metadata.xml b/sys-fs/zfs-kmod/metadata.xml new file mode 100644 index 0000000..f47155e --- /dev/null +++ b/sys-fs/zfs-kmod/metadata.xml @@ -0,0 +1,18 @@ + + + + + ryao@gentoo.org + Richard Yao + + + gyakovlev@gentoo.org + Georgy Yakovlev + + + Install zfs-shutdown script to support exporting a pool containing rootfs + + + zfsonlinux/zfs + + diff --git a/sys-fs/zfs-kmod/zfs-kmod-0.7.13.ebuild b/sys-fs/zfs-kmod/zfs-kmod-0.7.13.ebuild new file mode 100644 index 0000000..250c19a --- /dev/null +++ b/sys-fs/zfs-kmod/zfs-kmod-0.7.13.ebuild @@ -0,0 +1,147 @@ +# Copyright 1999-2019 Gentoo Authors +# Distributed under the terms of the GNU General Public License v2 + +EAPI="5" + +if [ ${PV} == "9999" ]; then + AUTOTOOLS_AUTORECONF="1" + EGIT_REPO_URI="https://github.com/zfsonlinux/zfs.git" + inherit git-r3 +else + SRC_URI="https://github.com/zfsonlinux/zfs/releases/download/zfs-${PV}/zfs-${PV}.tar.gz" + S="${WORKDIR}/zfs-${PV}" + KEYWORDS="amd64" +fi + +inherit flag-o-matic linux-info linux-mod toolchain-funcs autotools-utils + +DESCRIPTION="Linux ZFS kernel module for sys-fs/zfs" +HOMEPAGE="https://zfsonlinux.org/" + +LICENSE="CDDL debug? ( GPL-2+ )" +SLOT="0" +IUSE="custom-cflags debug +rootfs" +RESTRICT="debug? ( strip ) test" + +DEPEND=" + =sys-kernel/spl-${PV}* + dev-lang/perl + virtual/awk +" + +RDEPEND="${DEPEND} + !sys-fs/zfs-fuse +" + +AT_M4DIR="config" +AUTOTOOLS_IN_SOURCE_BUILD="1" + +DOCS=( AUTHORS COPYRIGHT DISCLAIMER README.markdown ) + +pkg_setup() { + linux-info_pkg_setup + CONFIG_CHECK=" + !DEBUG_LOCK_ALLOC + EFI_PARTITION + MODULES + !PAX_KERNEXEC_PLUGIN_METHOD_OR + !TRIM_UNUSED_KSYMS + ZLIB_DEFLATE + ZLIB_INFLATE + " + + use debug && CONFIG_CHECK="${CONFIG_CHECK} + FRAME_POINTER + DEBUG_INFO + !DEBUG_INFO_REDUCED + " + + use rootfs && \ + CONFIG_CHECK="${CONFIG_CHECK} + BLK_DEV_INITRD + DEVTMPFS + " + + kernel_is lt 5 && CONFIG_CHECK="${CONFIG_CHECK} IOSCHED_NOOP" + + kernel_is ge 2 6 32 || die "Linux 2.6.32 or newer required" + + [ ${PV} != "9999" ] && \ + { kernel_is le 5 0 || die "Linux 5.0 is the latest supported version."; } + + check_extra_config +} + +src_prepare() { + # Remove GPLv2-licensed ZPIOS unless we are debugging + use debug || sed -e 's/^subdir-m += zpios$//' -i "${S}/module/Makefile.in" + + # Set module revision number + [ ${PV} != "9999" ] && \ + { sed -i "s/\(Release:\)\(.*\)1/\1\2${PR}-gentoo/" "${S}/META" || die "Could not set Gentoo release"; } + + autotools-utils_src_prepare +} + +src_configure() { + local SPL_PATH="$(basename $(echo "${EROOT}usr/src/spl-"*))" + use custom-cflags || strip-flags + filter-ldflags -Wl,* + + set_arch_to_kernel + local myeconfargs=(${myeconfargs} + --bindir="${EPREFIX}/bin" + --sbindir="${EPREFIX}/sbin" + --with-config=kernel + --with-linux="${KV_DIR}" + --with-linux-obj="${KV_OUT_DIR}" + --with-spl="${EROOT}usr/src/${SPL_PATH}" + --with-spl-obj="${EROOT}usr/src/${SPL_PATH}/${KV_FULL}" + $(use_enable debug) + ) + + autotools-utils_src_configure +} + +src_install() { + autotools-utils_src_install INSTALL_MOD_PATH="${INSTALL_MOD_PATH:-$EROOT}" +} + +pkg_postinst() { + linux-mod_pkg_postinst + + # Remove old modules + if [ -d "${EROOT}lib/modules/${KV_FULL}/addon/zfs" ] + then + ewarn "${PN} now installs modules in ${EROOT}lib/modules/${KV_FULL}/extra/zfs" + ewarn "Old modules were detected in ${EROOT}lib/modules/${KV_FULL}/addon/zfs" + ewarn "Automatically removing old modules to avoid problems." + rm -r "${EROOT}lib/modules/${KV_FULL}/addon/zfs" || die "Cannot remove modules" + rmdir --ignore-fail-on-non-empty "${EROOT}lib/modules/${KV_FULL}/addon" + fi + + if use x86 || use arm + then + ewarn "32-bit kernels will likely require increasing vmalloc to" + ewarn "at least 256M and decreasing zfs_arc_max to some value less than that." + fi + + ewarn "This version of ZFSOnLinux includes support for new feature flags" + ewarn "that are incompatible with previous versions. GRUB2 support for" + ewarn "/boot with the new feature flags is not yet available." + ewarn "Do *NOT* upgrade root pools to use the new feature flags." + ewarn "Any new pools will be created with the new feature flags by default" + ewarn "and will not be compatible with older versions of ZFSOnLinux. To" + ewarn "create a newpool that is backward compatible wih GRUB2, use " + ewarn + ewarn "zpool create -d -o feature@async_destroy=enabled " + ewarn " -o feature@empty_bpobj=enabled -o feature@lz4_compress=enabled" + ewarn " -o feature@spacemap_histogram=enabled" + ewarn " -o feature@enabled_txg=enabled " + ewarn " -o feature@extensible_dataset=enabled -o feature@bookmarks=enabled" + ewarn " ..." + ewarn + ewarn "GRUB2 support will be updated as soon as either the GRUB2" + ewarn "developers do a tag or the Gentoo developers find time to backport" + ewarn "support from GRUB2 HEAD." +} diff --git a/sys-fs/zfs/Manifest b/sys-fs/zfs/Manifest new file mode 100644 index 0000000..14df7dd --- /dev/null +++ b/sys-fs/zfs/Manifest @@ -0,0 +1,11 @@ +AUX 0.7.13-ZPOOL_IMPORT_UDEV_TIMEOUT_MS.patch 1945 BLAKE2B db5d094bcac52a3b53bae9df4b0444f656858dd83f21994cbefe4900554a2579c67b5058d149d226ca354bd45d9e24c12244186da3232064233b74ec590187dc SHA512 71a009336fdcac8e5813001fd6741f4310c3e792b20650ebad73ba0049730acb5188587dc8e706846e886bf9ac241d2163b9558150eb389c99d7910a730542d0 +AUX 0.8.3-fno-common.patch 2377 BLAKE2B 61390e1c64b212b94060777154f5cf18942d4c22ba845f85ae91e81cdb6978e6d01cc9f90b1739bf3503bc40f26a98389659dbc0f83d3cedc954b802792b3b55 SHA512 7b2b066d0f4def5950c031ef87626ef68e0eccfe388f451dd6e5a36874674020ed2e4658bf24ab3977673b77aa7631822ef12318381f7785f310a0b24a61dfbc +AUX 0.8.3-zfs-functions.patch 1707 BLAKE2B 6ead7415be7dbeff6377b8d4074bb4e1cf6b154cf145e77b876e514c57d05cc041c5a66cfd6ab4c0bbb4931fa2553680c5749c4e06810ebd5658941088f9e7cf SHA512 cda47f5ef47ab86b2fda87e9ac2ab26d08431b2bd7420ecdd8ab9625a283c48278caa794b2aaa4c5f9341e08a2751b5b4a7b93a3b53491ccbdf2f085a0cb86ec +AUX bash-completion-r1 11310 BLAKE2B f6c105fef1737d4be0e76967fdec62aa52fa7665bfc1e9aa4c944dd6442d64d7d31b8af54f92f5db25542f968ecf83da46db8c2a8f978577526bf9f90d8bccf3 SHA512 03be521e2c646196766d5fd049f241cb97f290abf0409881ea6ba709934984deda402c8513009e62a5787e0648023b55c040e5f99baef27709e81c3bc9c8f56e +AUX bash-completion-sudo.patch 905 BLAKE2B 92e58ff097893436d589f7df0134e09d2e0699ae82618c4c14caf4b26cb466367a5372d7e0a030aa857d024e3db0faef4bb5fa32c54f41f0d4766693a95ba5ab SHA512 e53c79401f4c634a94af27b2f88a40440b68a4c192fd1944668786650aaa0f1f08dff851dca5b9666ce8bba1f0e2b7cb195314cd9d1314c9bab1194d03122319 +AUX zfs-init.sh.in 582 BLAKE2B 27e5c1aff398c42178b3d7c005e91a1f8f3afa303a22e49c93a2cd7134016a8d07d68483126d60e46ed4ff5cbaeb87f050e9c9fb5bff5352d5dc32b4d94db7b4 SHA512 bed7eae5f902f13489241782d3d560b53a5a3258de492763b7b25783ca9417975afb9000f68f58be5c2057e1db50a569374ed0ff572140aa65e401e20e646461 +AUX zfs.service.in 335 BLAKE2B a18ad1d70975df98cfb7b5196ad17b7197d5eb59cac2ccb3b9243f111c6c882c3480eb6396e347eac91670e3a67d7f122953d6fa82ec61a6467163b788b31858 SHA512 7a167b389723e5f55fea6956e5546e46c89ebf3e2d1c25f6b56c357e6d3ffc765226549d78cdeb79b4dc90c798ec6326a13996215b40eb49179376e32c3c3287 +DIST zfs-0.7.13.tar.gz 6614047 BLAKE2B c59c46287715779eb04d69333b0a417fa9865eb0d61c642b043188c4c97d4eed369f76a48327326ed1d4dd608ff95d91d20d26c80ed0b120a8fcd5f83cea638f SHA512 457d8f110b68c9656194cd3738b216d5d807d680e5cfc6ed1f3cf5ebde67860476387c6b862ba3ba7f972d8945075963e6c325543ab84468e3eff5dbce68476e +EBUILD zfs-0.7.13-r1.ebuild 6276 BLAKE2B b2aafe81b97e72249710bbed0282afe8e03aaf5029236d5b12d3089ef58458b9615f1f60f89b1473097321b8182704a5ba2964fb94b86f03a20d269029351264 SHA512 3547d9918e2b082299dbbaf39310ecaa780f44c2c7ece907b6149b3cff98ce68fc73846c303d579112453aaa6763bd029ccd24ab330c1578432a44da73a0d816 +EBUILD zfs-0.7.13-r2.ebuild 6340 BLAKE2B a351568c54fecd31574471e164f41e1909fe6096ac68211664ef6a90435c59c4189a5ed9a1356867a81941a17874c8580b6a27ec0caef49976afdda655bb8571 SHA512 4a17ca33411e286f19ae8d4c6eaee42cad9a2db024a83b6355f0f33db0fcbd83ca138f3e4b88a2b14cc3fded942edf4bd22f4588afc6082e608e02ced2d59b10 +MISC metadata.xml 751 BLAKE2B 84331bb699e48773412c2b3a26786e746428a111b64d1a309d0acd6f2454220e917a6650b2a35e88269f77c725f848493f46516adf72a0deb149dbb1e0275bf3 SHA512 a16f2fff439157fa1910926bd5b90ccfc3cab262fe7b41e5565b645f29774b14f1d9ac11aceaee57b8685ec1c782d826e08715559fb0b2e06031a165ca5f6295 diff --git a/sys-fs/zfs/files/0.7.13-ZPOOL_IMPORT_UDEV_TIMEOUT_MS.patch b/sys-fs/zfs/files/0.7.13-ZPOOL_IMPORT_UDEV_TIMEOUT_MS.patch new file mode 100644 index 0000000..922e595 --- /dev/null +++ b/sys-fs/zfs/files/0.7.13-ZPOOL_IMPORT_UDEV_TIMEOUT_MS.patch @@ -0,0 +1,70 @@ +From a0767672aac01f41516550e3808ff72da893102f Mon Sep 17 00:00:00 2001 +From: Georgy Yakovlev +Date: Tue, 26 Nov 2019 12:07:36 -0800 +Subject: [PATCH] backport udev timeout patch + +https://github.com/zfsonlinux/zfs/commit/803884217f9b9b5fb235d7c5e78a809d271f6387 +--- + lib/libzfs/libzfs_import.c | 11 ++++++++++- + man/man8/zpool.8 | 6 ++++++ + 2 files changed, 16 insertions(+), 1 deletion(-) + +diff --git a/lib/libzfs/libzfs_import.c b/lib/libzfs/libzfs_import.c +index 9dbf207..cd08806 100644 +--- a/lib/libzfs/libzfs_import.c ++++ b/lib/libzfs/libzfs_import.c +@@ -53,6 +53,7 @@ + #endif + #include + #include ++#include + #include + #include + #include +@@ -1594,17 +1595,25 @@ zpool_open_func(void *arg) + if (rn->rn_labelpaths) { + char *path = NULL; + char *devid = NULL; ++ char *env = NULL; + rdsk_node_t *slice; + avl_index_t where; ++ int timeout; + int error; + + if (label_paths(rn->rn_hdl, rn->rn_config, &path, &devid)) + return; + ++ env = getenv("ZPOOL_IMPORT_UDEV_TIMEOUT_MS"); ++ if ((env == NULL) || sscanf(env, "%d", &timeout) != 1 || ++ timeout < 0) { ++ timeout = DISK_LABEL_WAIT; ++ } ++ + /* + * Allow devlinks to stabilize so all paths are available. + */ +- zpool_label_disk_wait(rn->rn_name, DISK_LABEL_WAIT); ++ zpool_label_disk_wait(rn->rn_name, timeout); + + if (path != NULL) { + slice = zfs_alloc(hdl, sizeof (rdsk_node_t)); +diff --git a/man/man8/zpool.8 b/man/man8/zpool.8 +index 46e531e..10a19b5 100644 +--- a/man/man8/zpool.8 ++++ b/man/man8/zpool.8 +@@ -2291,6 +2291,12 @@ Similar to the + option in + .Nm zpool import . + .El ++.Bl -tag -width "ZPOOL_IMPORT_UDEV_TIMEOUT_MS" ++.It Ev ZPOOL_IMPORT_UDEV_TIMEOUT_MS ++The maximum time in milliseconds that ++.Nm zpool import ++will wait for an expected device to be available. ++.El + .Bl -tag -width "ZPOOL_VDEV_NAME_GUID" + .It Ev ZPOOL_VDEV_NAME_GUID + Cause +-- +2.24.0 + diff --git a/sys-fs/zfs/files/0.8.3-fno-common.patch b/sys-fs/zfs/files/0.8.3-fno-common.patch new file mode 100644 index 0000000..3b09d8b --- /dev/null +++ b/sys-fs/zfs/files/0.8.3-fno-common.patch @@ -0,0 +1,83 @@ +From af09c050e95bebbaeca52156218f3f91e8c9951a Mon Sep 17 00:00:00 2001 +From: Romain Dolbeau +Date: Thu, 6 Feb 2020 18:25:29 +0100 +Subject: [PATCH] Fix static data to link with -fno-common + +-fno-common is the new default in GCC 10, replacing -fcommon in +GCC <= 9, so static data must only be allocated once. + +Reviewed-by: Brian Behlendorf +Signed-off-by: Romain Dolbeau +Closes #9943 +--- + cmd/zfs/zfs_util.h | 2 +- + cmd/zpool/zpool_main.c | 2 ++ + cmd/zpool/zpool_util.h | 2 +- + lib/libshare/smb.c | 2 ++ + lib/libshare/smb.h | 2 +- + 5 files changed, 7 insertions(+), 3 deletions(-) + +diff --git a/cmd/zfs/zfs_util.h b/cmd/zfs/zfs_util.h +index 3ddff9e22d7..a56af59adb1 100644 +--- a/cmd/zfs/zfs_util.h ++++ b/cmd/zfs/zfs_util.h +@@ -33,7 +33,7 @@ extern "C" { + + void * safe_malloc(size_t size); + void nomem(void); +-libzfs_handle_t *g_zfs; ++extern libzfs_handle_t *g_zfs; + + #ifdef __cplusplus + } +diff --git a/cmd/zpool/zpool_main.c b/cmd/zpool/zpool_main.c +index ae5e8a370fc..ff4f44d4652 100644 +--- a/cmd/zpool/zpool_main.c ++++ b/cmd/zpool/zpool_main.c +@@ -76,6 +76,8 @@ + + #include "statcommon.h" + ++libzfs_handle_t *g_zfs; ++ + static int zpool_do_create(int, char **); + static int zpool_do_destroy(int, char **); + +diff --git a/cmd/zpool/zpool_util.h b/cmd/zpool/zpool_util.h +index ce760df723c..1f23f61aaa4 100644 +--- a/cmd/zpool/zpool_util.h ++++ b/cmd/zpool/zpool_util.h +@@ -79,7 +79,7 @@ void pool_list_free(zpool_list_t *); + int pool_list_count(zpool_list_t *); + void pool_list_remove(zpool_list_t *, zpool_handle_t *); + +-libzfs_handle_t *g_zfs; ++extern libzfs_handle_t *g_zfs; + + + typedef struct vdev_cmd_data +diff --git a/lib/libshare/smb.c b/lib/libshare/smb.c +index a95607ee032..f567f7c49d7 100644 +--- a/lib/libshare/smb.c ++++ b/lib/libshare/smb.c +@@ -65,6 +65,8 @@ static boolean_t smb_available(void); + + static sa_fstype_t *smb_fstype; + ++smb_share_t *smb_shares; ++ + /* + * Retrieve the list of SMB shares. + */ +diff --git a/lib/libshare/smb.h b/lib/libshare/smb.h +index 7a0c0fd162d..8ea44677f9a 100644 +--- a/lib/libshare/smb.h ++++ b/lib/libshare/smb.h +@@ -44,6 +44,6 @@ typedef struct smb_share_s { + struct smb_share_s *next; + } smb_share_t; + +-smb_share_t *smb_shares; ++extern smb_share_t *smb_shares; + + void libshare_smb_init(void); diff --git a/sys-fs/zfs/files/0.8.3-zfs-functions.patch b/sys-fs/zfs/files/0.8.3-zfs-functions.patch new file mode 100644 index 0000000..9cce3e1 --- /dev/null +++ b/sys-fs/zfs/files/0.8.3-zfs-functions.patch @@ -0,0 +1,51 @@ +From 00478e1b5141f8b6ceaf14c173382d1aa11878b9 Mon Sep 17 00:00:00 2001 +From: Tony Hutter +Date: Thu, 6 Feb 2020 09:28:20 -0800 +Subject: [PATCH] Fix zfs-functions packaging bug + +This fixes a bug where the generated zfs-functions was being included along +with original zfs-functions.in in the make dist tarball. This caused an +unfortunate series of events during build/packaging that resulted in the +RPM-installed /etc/zfs/zfs-functions listing the paths as: + +ZFS="/usr/local/sbin/zfs" +ZED="/usr/local/sbin/zed" +ZPOOL="/usr/local/sbin/zpool" + +When they should have been: + +ZFS="/sbin/zfs" +ZED="/sbin/zed" +ZPOOL="/sbin/zpool" + +This affects init.d (non-systemd) distros like CentOS 6. + +Fixes: #9443 + +Signed-off-by: Tony Hutter +--- + contrib/initramfs/Makefile.am | 7 ++----- + 1 file changed, 2 insertions(+), 5 deletions(-) + +diff --git a/contrib/initramfs/Makefile.am b/contrib/initramfs/Makefile.am +index 52bdeb2afe5..4e52e8ea5e9 100644 +--- a/contrib/initramfs/Makefile.am ++++ b/contrib/initramfs/Makefile.am +@@ -6,15 +6,12 @@ initrd_SCRIPTS = \ + SUBDIRS = hooks scripts + + EXTRA_DIST = \ +- $(top_srcdir)/etc/init.d/zfs \ +- $(top_srcdir)/etc/init.d/zfs-functions \ ++ $(top_srcdir)/etc/init.d/zfs.in \ ++ $(top_srcdir)/etc/init.d/zfs-functions.in \ + $(top_srcdir)/contrib/initramfs/conf.d/zfs \ + $(top_srcdir)/contrib/initramfs/conf-hooks.d/zfs \ + $(top_srcdir)/contrib/initramfs/README.initramfs.markdown + +-$(top_srcdir)/etc/init.d/zfs $(top_srcdir)/etc/init.d/zfs-functions: +- $(MAKE) -C $(top_srcdir)/etc/init.d zfs zfs-functions +- + install-initrdSCRIPTS: $(EXTRA_DIST) + for d in conf.d conf-hooks.d scripts/local-top; do \ + $(MKDIR_P) $(DESTDIR)$(initrddir)/$$d; \ diff --git a/sys-fs/zfs/files/bash-completion-r1 b/sys-fs/zfs/files/bash-completion-r1 new file mode 100644 index 0000000..b1aded3 --- /dev/null +++ b/sys-fs/zfs/files/bash-completion-r1 @@ -0,0 +1,391 @@ +# Copyright (c) 2013, Aneurin Price + +# Permission is hereby granted, free of charge, to any person +# obtaining a copy of this software and associated documentation +# files (the "Software"), to deal in the Software without +# restriction, including without limitation the rights to use, +# copy, modify, merge, publish, distribute, sublicense, and/or sell +# copies of the Software, and to permit persons to whom the +# Software is furnished to do so, subject to the following +# conditions: + +# The above copyright notice and this permission notice shall be +# included in all copies or substantial portions of the Software. + +# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, +# EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES +# OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND +# NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT +# HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, +# WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING +# FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR +# OTHER DEALINGS IN THE SOFTWARE. + +#if [[ -w /dev/zfs ]]; then + __ZFS_CMD="zfs" + __ZPOOL_CMD="zpool" +#else +# __ZFS_CMD="sudo zfs" +# __ZPOOL_CMD="sudo zpool" +#fi + +__zfs_get_commands() +{ + $__ZFS_CMD 2>&1 | awk '/^\t[a-z]/ {print $1}' | cut -f1 -d '|' | uniq +} + +__zfs_get_properties() +{ + $__ZFS_CMD get 2>&1 | awk '$2 == "YES" || $2 == "NO" {print $1}'; echo all name space +} + +__zfs_get_editable_properties() +{ + $__ZFS_CMD get 2>&1 | awk '$2 == "YES" {print $1"="}' +} + +__zfs_get_inheritable_properties() +{ + $__ZFS_CMD get 2>&1 | awk '$3 == "YES" {print $1}' +} + +__zfs_list_datasets() +{ + $__ZFS_CMD list -H -o name -t filesystem,volume +} + +__zfs_list_filesystems() +{ + $__ZFS_CMD list -H -o name -t filesystem +} + +__zfs_match_snapshot() +{ + local base_dataset=${cur%@*} + if [[ $base_dataset != $cur ]] + then + $__ZFS_CMD list -H -o name -t snapshot -d 1 $base_dataset + else + $__ZFS_CMD list -H -o name -t filesystem,volume | awk '{print $1"@"}' + fi +} + +__zfs_match_explicit_snapshot() +{ + local base_dataset=${cur%@*} + if [[ $base_dataset != $cur ]] + then + $__ZFS_CMD list -H -o name -t snapshot -d 1 $base_dataset + fi +} + +__zfs_match_multiple_snapshots() +{ + local existing_opts=$(expr "$cur" : '\(.*\)[%,]') + if [[ $existing_opts ]] + then + local base_dataset=${cur%@*} + if [[ $base_dataset != $cur ]] + then + local cur=${cur##*,} + if [[ $cur =~ ^%|%.*% ]] + then + # correct range syntax is start%end + return 1 + fi + local range_start=$(expr "$cur" : '\(.*%\)') + $__ZFS_CMD list -H -o name -t snapshot -d 1 $base_dataset | sed 's$.*@$'$range_start'$g' + fi + else + __zfs_match_explicit_snapshot; __zfs_list_datasets + fi +} + +__zfs_list_volumes() +{ + $__ZFS_CMD list -H -o name -t volume +} + +__zfs_argument_chosen() +{ + local word property + for word in $(seq $((COMP_CWORD-1)) -1 2) + do + local prev="${COMP_WORDS[$word]}" + if [[ ${COMP_WORDS[$word-1]} != -[tos] ]] + then + if [[ "$prev" == [^,]*,* ]] || [[ "$prev" == *[@:]* ]] + then + return 0 + fi + for property in $@ + do + if [[ $prev == "$property" ]] + then + return 0 + fi + done + fi + done + return 1 +} + +__zfs_complete_ordered_arguments() +{ + local list1=$1 + local list2=$2 + local cur=$3 + local extra=$4 + if __zfs_argument_chosen $list1 + then + COMPREPLY=($(compgen -W "$list2 $extra" -- "$cur")) + else + COMPREPLY=($(compgen -W "$list1 $extra" -- "$cur")) + fi +} + +__zfs_complete_multiple_options() +{ + local options=$1 + local cur=$2 + + COMPREPLY=($(compgen -W "$options" -- "${cur##*,}")) + local existing_opts=$(expr "$cur" : '\(.*,\)') + if [[ $existing_opts ]] + then + COMPREPLY=( "${COMPREPLY[@]/#/${existing_opts}}" ) + fi +} + +__zfs_complete_switch() +{ + local options=$1 + if [[ ${cur:0:1} == - ]] + then + COMPREPLY=($(compgen -W "-{$options}" -- "$cur")) + return 0 + else + return 1 + fi +} + +__zfs_complete() +{ + local cur prev cmd cmds + COMPREPLY=() + # Don't split on colon + _get_comp_words_by_ref -n : -c cur -p prev -w COMP_WORDS -i COMP_CWORD + cmd="${COMP_WORDS[1]}" + + if [[ ${prev##*/} == zfs ]] + then + cmds=$(__zfs_get_commands) + COMPREPLY=($(compgen -W "$cmds -?" -- "$cur")) + return 0 + fi + + case "${cmd}" in + clone) + case "${prev}" in + -o) + COMPREPLY=($(compgen -W "$(__zfs_get_editable_properties)" -- "$cur")) + ;; + *) + if ! __zfs_complete_switch "o,p" + then + if __zfs_argument_chosen + then + COMPREPLY=($(compgen -W "$(__zfs_list_datasets)" -- "$cur")) + else + COMPREPLY=($(compgen -W "$(__zfs_match_snapshot)" -- "$cur")) + fi + fi + ;; + esac + ;; + get) + case "${prev}" in + -d) + COMPREPLY=($(compgen -W "" -- "$cur")) + ;; + -t) + __zfs_complete_multiple_options "filesystem volume snapshot all" "$cur" + ;; + -s) + __zfs_complete_multiple_options "local default inherited temporary none" "$cur" + ;; + -o) + __zfs_complete_multiple_options "name property value source received all" "$cur" + ;; + *) + if ! __zfs_complete_switch "H,r,p,d,o,t,s" + then + if __zfs_argument_chosen $(__zfs_get_properties) + then + COMPREPLY=($(compgen -W "$(__zfs_match_explicit_snapshot) $(__zfs_list_datasets)" -- "$cur")) + else + __zfs_complete_multiple_options "$(__zfs_get_properties)" "$cur" + fi + fi + ;; + esac + ;; + inherit) + if ! __zfs_complete_switch "r" + then + __zfs_complete_ordered_arguments "$(__zfs_get_inheritable_properties)" "$(__zfs_match_explicit_snapshot) $(__zfs_list_datasets)" $cur + fi + ;; + list) + case "${prev}" in + -d) + COMPREPLY=($(compgen -W "" -- "$cur")) + ;; + -t) + __zfs_complete_multiple_options "filesystem volume snapshot all" "$cur" + ;; + -o) + __zfs_complete_multiple_options "$(__zfs_get_properties)" "$cur" + ;; + -s|-S) + COMPREPLY=($(compgen -W "$(__zfs_get_properties)" -- "$cur")) + ;; + *) + if ! __zfs_complete_switch "H,r,d,o,t,s,S" + then + COMPREPLY=($(compgen -W "$(__zfs_match_explicit_snapshot) $(__zfs_list_datasets)" -- "$cur")) + fi + ;; + esac + ;; + promote) + COMPREPLY=($(compgen -W "$(__zfs_list_filesystems)" -- "$cur")) + ;; + rollback) + if ! __zfs_complete_switch "r,R,f" + then + COMPREPLY=($(compgen -W "$(__zfs_match_snapshot)" -- "$cur")) + fi + ;; + send) + if ! __zfs_complete_switch "d,n,P,p,R,v,i,I" + then + COMPREPLY=($(compgen -W "$(__zfs_match_snapshot)" -- "$cur")) + fi + ;; + snapshot) + case "${prev}" in + -o) + COMPREPLY=($(compgen -W "$(__zfs_get_editable_properties)" -- "$cur")) + ;; + *) + if ! __zfs_complete_switch "o,r" + then + COMPREPLY=($(compgen -W "$(__zfs_list_datasets | awk '{print $1"@"}')" -- "$cur")) + fi + ;; + esac + ;; + set) + __zfs_complete_ordered_arguments "$(__zfs_get_editable_properties)" "$(__zfs_match_explicit_snapshot) $(__zfs_list_datasets)" $cur + ;; + upgrade) + case "${prev}" in + -a|-V|-v) + COMPREPLY=($(compgen -W "" -- "$cur")) + ;; + *) + if ! __zfs_complete_switch "a,V,v,r" + then + COMPREPLY=($(compgen -W "$(__zfs_list_filesystems)" -- "$cur")) + fi + ;; + esac + ;; + destroy) + if ! __zfs_complete_switch "d,f,n,p,R,r,v" + then + __zfs_complete_multiple_options "$(__zfs_match_multiple_snapshots)" $cur + fi + ;; + *) + COMPREPLY=($(compgen -W "$(__zfs_match_explicit_snapshot) $(__zfs_list_datasets)" -- "$cur")) + ;; + esac + __ltrim_colon_completions "$cur" + return 0 +} + +__zpool_get_commands() +{ + $__ZPOOL_CMD 2>&1 | awk '/^\t[a-z]/ {print $1}' | uniq +} + +__zpool_get_properties() +{ + $__ZPOOL_CMD get 2>&1 | awk '$2 == "YES" || $2 == "NO" {print $1}'; echo all +} + +__zpool_get_editable_properties() +{ + $__ZPOOL_CMD get 2>&1 | awk '$2 == "YES" {print $1"="}' +} + +__zpool_list_pools() +{ + $__ZPOOL_CMD list -H -o name +} + +__zpool_complete() +{ + local cur prev cmd cmds + COMPREPLY=() + cur="${COMP_WORDS[COMP_CWORD]}" + prev="${COMP_WORDS[COMP_CWORD-1]}" + cmd="${COMP_WORDS[1]}" + + if [[ ${prev##*/} == zpool ]] + then + cmds=$(__zpool_get_commands) + COMPREPLY=($(compgen -W "$cmds" -- "$cur")) + return 0 + fi + + case "${cmd}" in + get) + __zfs_complete_ordered_arguments "$(__zpool_get_properties)" "$(__zpool_list_pools)" $cur + return 0 + ;; + import) + if [[ $prev == -d ]] + then + _filedir -d + else + COMPREPLY=($(compgen -W "$(__zpool_list_pools) -d" -- "$cur")) + fi + return 0 + ;; + set) + __zfs_complete_ordered_arguments "$(__zpool_get_editable_properties)" "$(__zpool_list_pools)" $cur + return 0 + ;; + add|attach|clear|create|detach|offline|online|remove|replace) + local pools="$(__zpool_list_pools)" + if __zfs_argument_chosen $pools + then + _filedir + else + COMPREPLY=($(compgen -W "$pools" -- "$cur")) + fi + return 0 + ;; + *) + COMPREPLY=($(compgen -W "$(__zpool_list_pools)" -- "$cur")) + return 0 + ;; + esac + +} + +complete -F __zfs_complete zfs +complete -F __zpool_complete zpool diff --git a/sys-fs/zfs/files/bash-completion-sudo.patch b/sys-fs/zfs/files/bash-completion-sudo.patch new file mode 100644 index 0000000..8ae9d25 --- /dev/null +++ b/sys-fs/zfs/files/bash-completion-sudo.patch @@ -0,0 +1,35 @@ +From 3829d0b867f6aa4bde8798147dee74a86435d12c Mon Sep 17 00:00:00 2001 +From: Georgy Yakovlev +Date: Fri, 22 Mar 2019 22:04:40 -0700 +Subject: [PATCH] contrib/bash_completion.d/zfs: remove sudo reference + +--- + contrib/bash_completion.d/zfs | 10 +++++----- + 1 file changed, 5 insertions(+), 5 deletions(-) + +diff --git a/contrib/bash_completion.d/zfs b/contrib/bash_completion.d/zfs +index 914db43c..b1aded36 100644 +--- a/contrib/bash_completion.d/zfs ++++ b/contrib/bash_completion.d/zfs +@@ -21,13 +21,13 @@ + # FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR + # OTHER DEALINGS IN THE SOFTWARE. + +-if [[ -w /dev/zfs ]]; then ++#if [[ -w /dev/zfs ]]; then + __ZFS_CMD="zfs" + __ZPOOL_CMD="zpool" +-else +- __ZFS_CMD="sudo zfs" +- __ZPOOL_CMD="sudo zpool" +-fi ++#else ++# __ZFS_CMD="sudo zfs" ++# __ZPOOL_CMD="sudo zpool" ++#fi + + __zfs_get_commands() + { +-- +2.21.0 + diff --git a/sys-fs/zfs/files/zfs-init.sh.in b/sys-fs/zfs/files/zfs-init.sh.in new file mode 100644 index 0000000..ed84585 --- /dev/null +++ b/sys-fs/zfs/files/zfs-init.sh.in @@ -0,0 +1,29 @@ +#!/bin/sh + +ZFS="@sbindir@/zfs" +ZPOOL="@sbindir@/zpool" +ZPOOL_CACHE="@sysconfdir@/zfs/zpool.cache" + +if [ -f "${ZPOOL_CACHE}" ]; then + "${ZPOOL}" import -c "${ZPOOL_CACHE}" -aN 2>/dev/null + if [ "${?}" != "0" ]; then + echo "Failed to import not-yet imported pools." >&2 + fi +fi + +echo "Mounting ZFS filesystems" +"${ZFS}" mount -a +if [ "${?}" != "0" ]; then + echo "Failed to mount ZFS filesystems." >&2 + exit 1 +fi + +echo "Exporting ZFS filesystems" +"${ZFS}" share -a +if [ "${?}" != "0" ]; then + echo "Failed to export ZFS filesystems." >&2 + exit 1 +fi + +exit 0 + diff --git a/sys-fs/zfs/files/zfs.service.in b/sys-fs/zfs/files/zfs.service.in new file mode 100644 index 0000000..ae2eff1 --- /dev/null +++ b/sys-fs/zfs/files/zfs.service.in @@ -0,0 +1,16 @@ +[Unit] +Description=ZFS filesystems setup +Before=network.target +After=systemd-udev-settle.target local-fs.target + +[Service] +Type=oneshot +RemainAfterExit=yes +ExecStartPre=-/sbin/modprobe zfs +ExecStartPre=/usr/bin/test -c /dev/zfs +ExecStart=/usr/libexec/zfs-init.sh +ExecStop=@sbindir@/zfs umount -a + +[Install] +WantedBy=multi-user.target + diff --git a/sys-fs/zfs/metadata.xml b/sys-fs/zfs/metadata.xml new file mode 100644 index 0000000..0b1da3a --- /dev/null +++ b/sys-fs/zfs/metadata.xml @@ -0,0 +1,20 @@ + + + + + ryao@gentoo.org + Richard Yao + + + gyakovlev@gentoo.org + Georgy Yakovlev + + + Disable dependency on sys-fs/zfs-kmod under the assumption that ZFS is part of the kernel source tree + Enable dependencies required for booting off a pool containing a rootfs + Install regression test suite + + + zfsonlinux/zfs + + diff --git a/sys-fs/zfs/zfs-0.7.13-r1.ebuild b/sys-fs/zfs/zfs-0.7.13-r1.ebuild new file mode 100644 index 0000000..e7978fd --- /dev/null +++ b/sys-fs/zfs/zfs-0.7.13-r1.ebuild @@ -0,0 +1,218 @@ +# Copyright 1999-2020 Gentoo Authors +# Distributed under the terms of the GNU General Public License v2 + +EAPI="5" +PYTHON_COMPAT=( python3_6 ) + +if [ ${PV} == "9999" ] ; then + inherit git-r3 linux-mod + AUTOTOOLS_AUTORECONF="1" + EGIT_REPO_URI="git://github.com/zfsonlinux/${PN}.git" +else + SRC_URI="https://github.com/zfsonlinux/${PN}/releases/download/${P}/${P}.tar.gz" + KEYWORDS="amd64" +fi + +inherit autotools-utils bash-completion-r1 flag-o-matic linux-info python-single-r1 systemd toolchain-funcs udev usr-ldscript + +DESCRIPTION="Userland utilities for ZFS Linux kernel module" +HOMEPAGE="https://zfsonlinux.org/" + +LICENSE="BSD-2 CDDL MIT" +SLOT="0" +IUSE="custom-cflags debug kernel-builtin +rootfs systemd test-suite static-libs" +RESTRICT="test" + +COMMON_DEPEND=" + net-libs/libtirpc + sys-apps/util-linux[static-libs?] + sys-libs/zlib[static-libs(+)?] + virtual/awk +" +DEPEND="${COMMON_DEPEND} + virtual/pkgconfig +" + +RDEPEND="${COMMON_DEPEND} + ${PYTHON_DEPS} + !=sys-apps/grep-2.13* + !kernel-builtin? ( =sys-fs/zfs-kmod-${PV}* ) + !sys-fs/zfs-fuse + !prefix? ( virtual/udev ) + test-suite? ( + sys-apps/util-linux + sys-devel/bc + sys-block/parted + sys-fs/lsscsi + sys-fs/mdadm + sys-process/procps + virtual/modutils + ) + rootfs? ( + app-arch/cpio + app-misc/pax-utils + !" + eerror " Block devices --->" + eerror " [ ] Loopback device support" + fi + fi + fi + fi +} + +src_prepare() { + # Update paths + sed -e "s|/sbin/lsmod|/bin/lsmod|" \ + -e "s|/usr/bin/scsi-rescan|/usr/sbin/rescan-scsi-bus|" \ + -e "s|/sbin/parted|/usr/sbin/parted|" \ + -i scripts/common.sh.in || die + + autotools-utils_src_prepare +} + +src_configure() { + use custom-cflags || strip-flags + local myeconfargs=( + --bindir="${EPREFIX}/bin" + --sbindir="${EPREFIX}/sbin" + --with-config=user + --with-dracutdir="${EPREFIX}/usr/lib/dracut" + --with-linux="${KV_DIR}" + --with-linux-obj="${KV_OUT_DIR}" + --with-udevdir="$(get_udevdir)" + --with-systemdunitdir="$(systemd_get_systemunitdir)" + --with-systemdpresetdir="${EPREFIX}/lib/systemd/system-preset" + $(use_enable debug) + $(use_enable systemd) + ) + autotools-utils_src_configure + + # prepare systemd unit and helper script + cat "${FILESDIR}/zfs.service.in" | \ + sed -e "s:@sbindir@:${EPREFIX}/sbin:g" \ + -e "s:@sysconfdir@:${EPREFIX}/etc:g" \ + > "${T}/zfs.service" || die + cat "${FILESDIR}/zfs-init.sh.in" | \ + sed -e "s:@sbindir@:${EPREFIX}/sbin:g" \ + -e "s:@sysconfdir@:${EPREFIX}/etc:g" \ + > "${T}/zfs-init.sh" || die +} + +src_install() { + autotools-utils_src_install + gen_usr_ldscript -a uutil nvpair zpool zfs zfs_core + use test-suite || rm -rf "${ED}usr/share/zfs" + + newbashcomp "${FILESDIR}/bash-completion-r1" zfs + bashcomp_alias zfs zpool + + exeinto /usr/libexec + doexe "${T}/zfs-init.sh" + systemd_dounit "${T}/zfs.service" + + # enforce selected python implementation + python_fix_shebang "${ED}/bin" +} + +pkg_postinst() { + if ! use kernel-builtin && [ ${PV} = "9999" ] + then + einfo "Adding ${P} to the module database to ensure that the" + einfo "kernel modules and userland utilities stay in sync." + update_moduledb + fi + + if [ -e "${EROOT}etc/runlevels/boot/zfs" ] + then + einfo 'The zfs boot script has been split into the zfs-import,' + einfo 'zfs-mount and zfs-share scripts.' + einfo + einfo 'You had the zfs script in your boot runlevel. For your' + einfo 'convenience, it has been automatically removed and the three' + einfo 'scripts that replace it have been configured to start.' + einfo 'The zfs-import and zfs-mount scripts have been added to the boot' + einfo 'runlevel while the zfs-share script is in the default runlevel.' + + rm "${EROOT}etc/runlevels/boot/zfs" + ln -snf "${EROOT}etc/init.d/zfs-import" \ + "${EROOT}etc/runlevels/boot/zfs-import" + ln -snf "${EROOT}etc/init.d/zfs-mount" \ + "${EROOT}etc/runlevels/boot/zfs-mount" + ln -snf "${EROOT}etc/init.d/zfs-share" \ + "${EROOT}etc/runlevels/default/zfs-share" + else + [ -e "${EROOT}etc/runlevels/boot/zfs-import" ] || \ + einfo "You should add zfs-import to the boot runlevel." + [ -e "${EROOT}etc/runlevels/boot/zfs-mount" ] || \ + einfo "You should add zfs-mount to the boot runlevel." + [ -e "${EROOT}etc/runlevels/default/zfs-share" ] || \ + einfo "You should add zfs-share to the default runlevel." + fi + + if [ -e "${EROOT}etc/runlevels/default/zed" ] + then + einfo 'The downstream OpenRC zed script has replaced by the upstream' + einfo 'OpenRC zfs-zed script.' + einfo + einfo 'You had the zed script in your default runlevel. For your' + einfo 'convenience, it has been automatically removed and the zfs-zed' + einfo 'script that replaced it has been configured to start.' + + rm "${EROOT}etc/runlevels/boot/zed" + ln -snf "${EROOT}etc/init.d/zfs-sed" \ + "${EROOT}etc/runlevels/default/zfs-zed" + else + [ -e "${EROOT}etc/runlevels/default/zfs-zed" ] || \ + einfo "You should add zfs-zed to the default runlevel." + fi + + if [ -e "${EROOT}etc/runlevels/shutdown/zfs-shutdown" ] + then + einfo "The zfs-shutdown script is obsolete. Removing it from runlevel." + rm "${EROOT}etc/runlevels/shutdown/zfs-shutdown" + fi + + systemd_reenable zfs-zed.service + systemd_reenable zfs-import-cache.service + systemd_reenable zfs-import-scan.service + systemd_reenable zfs-mount.service + systemd_reenable zfs-share.service + systemd_reenable zfs-import.target + systemd_reenable zfs.target + systemd_reenable zfs.service +} + +pkg_postrm() { + if ! use kernel-builtin && [ ${PV} = "9999" ] + then + remove_moduledb + fi +} diff --git a/sys-fs/zfs/zfs-0.7.13-r2.ebuild b/sys-fs/zfs/zfs-0.7.13-r2.ebuild new file mode 100644 index 0000000..2362e5c --- /dev/null +++ b/sys-fs/zfs/zfs-0.7.13-r2.ebuild @@ -0,0 +1,220 @@ +# Copyright 1999-2020 Gentoo Authors +# Distributed under the terms of the GNU General Public License v2 + +EAPI="5" +PYTHON_COMPAT=( python3_6 ) + +if [ ${PV} == "9999" ] ; then + inherit git-r3 linux-mod + AUTOTOOLS_AUTORECONF="1" + EGIT_REPO_URI="git://github.com/zfsonlinux/${PN}.git" +else + SRC_URI="https://github.com/zfsonlinux/${PN}/releases/download/${P}/${P}.tar.gz" + KEYWORDS="" +fi + +inherit autotools-utils bash-completion-r1 flag-o-matic linux-info python-single-r1 systemd toolchain-funcs udev usr-ldscript + +DESCRIPTION="Userland utilities for ZFS Linux kernel module" +HOMEPAGE="https://zfsonlinux.org/" + +LICENSE="BSD-2 CDDL MIT" +SLOT="0" +IUSE="custom-cflags debug kernel-builtin +rootfs systemd test-suite static-libs" +RESTRICT="test" + +COMMON_DEPEND=" + net-libs/libtirpc + sys-apps/util-linux[static-libs?] + sys-libs/zlib[static-libs(+)?] + virtual/awk +" +DEPEND="${COMMON_DEPEND} + virtual/pkgconfig +" + +RDEPEND="${COMMON_DEPEND} + ${PYTHON_DEPS} + !=sys-apps/grep-2.13* + !kernel-builtin? ( =sys-fs/zfs-kmod-${PV}* ) + !sys-fs/zfs-fuse + !prefix? ( virtual/udev ) + test-suite? ( + sys-apps/util-linux + sys-devel/bc + sys-block/parted + sys-fs/lsscsi + sys-fs/mdadm + sys-process/procps + virtual/modutils + ) + rootfs? ( + app-arch/cpio + app-misc/pax-utils + !" + eerror " Block devices --->" + eerror " [ ] Loopback device support" + fi + fi + fi + fi +} + +src_prepare() { + # Update paths + sed -e "s|/sbin/lsmod|/bin/lsmod|" \ + -e "s|/usr/bin/scsi-rescan|/usr/sbin/rescan-scsi-bus|" \ + -e "s|/sbin/parted|/usr/sbin/parted|" \ + -i scripts/common.sh.in || die + + autotools-utils_src_prepare +} + +src_configure() { + use custom-cflags || strip-flags + local myeconfargs=( + --bindir="${EPREFIX}/bin" + --sbindir="${EPREFIX}/sbin" + --with-config=user + --with-dracutdir="${EPREFIX}/usr/lib/dracut" + --with-linux="${KV_DIR}" + --with-linux-obj="${KV_OUT_DIR}" + --with-udevdir="$(get_udevdir)" + --with-systemdunitdir="$(systemd_get_systemunitdir)" + --with-systemdpresetdir="${EPREFIX}/lib/systemd/system-preset" + $(use_enable debug) + $(use_enable systemd) + ) + autotools-utils_src_configure + + # prepare systemd unit and helper script + cat "${FILESDIR}/zfs.service.in" | \ + sed -e "s:@sbindir@:${EPREFIX}/sbin:g" \ + -e "s:@sysconfdir@:${EPREFIX}/etc:g" \ + > "${T}/zfs.service" || die + cat "${FILESDIR}/zfs-init.sh.in" | \ + sed -e "s:@sbindir@:${EPREFIX}/sbin:g" \ + -e "s:@sysconfdir@:${EPREFIX}/etc:g" \ + > "${T}/zfs-init.sh" || die +} + +src_install() { + autotools-utils_src_install + gen_usr_ldscript -a uutil nvpair zpool zfs zfs_core + use test-suite || rm -rf "${ED}usr/share/zfs" + + newbashcomp "${FILESDIR}/bash-completion-r1" zfs + bashcomp_alias zfs zpool + + exeinto /usr/libexec + doexe "${T}/zfs-init.sh" + systemd_dounit "${T}/zfs.service" + + # enforce selected python implementation + python_fix_shebang "${ED}/bin" +} + +pkg_postinst() { + if ! use kernel-builtin && [ ${PV} = "9999" ] + then + einfo "Adding ${P} to the module database to ensure that the" + einfo "kernel modules and userland utilities stay in sync." + update_moduledb + fi + + if [ -e "${EROOT}etc/runlevels/boot/zfs" ] + then + einfo 'The zfs boot script has been split into the zfs-import,' + einfo 'zfs-mount and zfs-share scripts.' + einfo + einfo 'You had the zfs script in your boot runlevel. For your' + einfo 'convenience, it has been automatically removed and the three' + einfo 'scripts that replace it have been configured to start.' + einfo 'The zfs-import and zfs-mount scripts have been added to the boot' + einfo 'runlevel while the zfs-share script is in the default runlevel.' + + rm "${EROOT}etc/runlevels/boot/zfs" + ln -snf "${EROOT}etc/init.d/zfs-import" \ + "${EROOT}etc/runlevels/boot/zfs-import" + ln -snf "${EROOT}etc/init.d/zfs-mount" \ + "${EROOT}etc/runlevels/boot/zfs-mount" + ln -snf "${EROOT}etc/init.d/zfs-share" \ + "${EROOT}etc/runlevels/default/zfs-share" + else + [ -e "${EROOT}etc/runlevels/boot/zfs-import" ] || \ + einfo "You should add zfs-import to the boot runlevel." + [ -e "${EROOT}etc/runlevels/boot/zfs-mount" ] || \ + einfo "You should add zfs-mount to the boot runlevel." + [ -e "${EROOT}etc/runlevels/default/zfs-share" ] || \ + einfo "You should add zfs-share to the default runlevel." + fi + + if [ -e "${EROOT}etc/runlevels/default/zed" ] + then + einfo 'The downstream OpenRC zed script has replaced by the upstream' + einfo 'OpenRC zfs-zed script.' + einfo + einfo 'You had the zed script in your default runlevel. For your' + einfo 'convenience, it has been automatically removed and the zfs-zed' + einfo 'script that replaced it has been configured to start.' + + rm "${EROOT}etc/runlevels/boot/zed" + ln -snf "${EROOT}etc/init.d/zfs-sed" \ + "${EROOT}etc/runlevels/default/zfs-zed" + else + [ -e "${EROOT}etc/runlevels/default/zfs-zed" ] || \ + einfo "You should add zfs-zed to the default runlevel." + fi + + if [ -e "${EROOT}etc/runlevels/shutdown/zfs-shutdown" ] + then + einfo "The zfs-shutdown script is obsolete. Removing it from runlevel." + rm "${EROOT}etc/runlevels/shutdown/zfs-shutdown" + fi + + systemd_reenable zfs-zed.service + systemd_reenable zfs-import-cache.service + systemd_reenable zfs-import-scan.service + systemd_reenable zfs-mount.service + systemd_reenable zfs-share.service + systemd_reenable zfs-import.target + systemd_reenable zfs.target + systemd_reenable zfs.service +} + +pkg_postrm() { + if ! use kernel-builtin && [ ${PV} = "9999" ] + then + remove_moduledb + fi +} diff --git a/sys-kernel/spl/Manifest b/sys-kernel/spl/Manifest new file mode 100644 index 0000000..1a9e5be --- /dev/null +++ b/sys-kernel/spl/Manifest @@ -0,0 +1,3 @@ +DIST spl-0.7.13.tar.gz 554211 BLAKE2B 7c1c95beb23b9725b3552a5bdb2260743c72fbc96cbdda8353893b9b13299b8a30c64d22400bc37d35ee21389eec809ee6d7b85a181ce44f0065dff81cb2e2a4 SHA512 31b67dc2f88f5028b5994aef886e05aeb9e65661895bffa29c5a1ac84df5f1c8e9c715f8cd7b63cf271d651ab7278aa63f51c78000f333ff7a75f0f8eedb5998 +EBUILD spl-0.7.13.ebuild 2905 BLAKE2B 61131b975242186caae6a25fcf20df905d0969dff31fc138ee645a020c969aaaa280285cdd966ccaa8397e115be26d8b86db19b3f5354fc73db9542829eafdc8 SHA512 d726ed506c15a528daeb25aad18919223c6a2a4d617f4e2a8d10ba1969c21598348be7698e80f3260a5020748616a003acf9d5bf28d06fc9c06091433f20234e +MISC metadata.xml 433 BLAKE2B d911e255347ea6ddf13c56903332d32a5acaa1fd6c66302aab9f70431ffbd681a37fb1829335ff6892ca8dc2c08fd653e5119ccf46516a23e8ce5c8bc8840fcc SHA512 7b31d40c8c2a87c9aab15c67503540d0e6ce6b149c7d69f1f6f92402ab5f9ff5795aea77f20e63af593e53b9e43a370cbc764d8586b5bf1f47647e413461dc6e diff --git a/sys-kernel/spl/metadata.xml b/sys-kernel/spl/metadata.xml new file mode 100644 index 0000000..b51664d --- /dev/null +++ b/sys-kernel/spl/metadata.xml @@ -0,0 +1,15 @@ + + + + + ryao@gentoo.org + Richard Yao + + + gyakovlev@gentoo.org + Georgy Yakovlev + + + zfsonlinux/spl + + diff --git a/sys-kernel/spl/spl-0.7.13.ebuild b/sys-kernel/spl/spl-0.7.13.ebuild new file mode 100644 index 0000000..3c81647 --- /dev/null +++ b/sys-kernel/spl/spl-0.7.13.ebuild @@ -0,0 +1,119 @@ +# Copyright 1999-2020 Gentoo Authors +# Distributed under the terms of the GNU General Public License v2 + +EAPI="5" +PYTHON_COMPAT=( python3_6 ) + +if [[ ${PV} == "9999" ]] ; then + AUTOTOOLS_AUTORECONF="1" + EGIT_REPO_URI="https://github.com/zfsonlinux/${PN}.git" + inherit git-r3 +else + SRC_URI="https://github.com/zfsonlinux/zfs/releases/download/zfs-${PV}/${P}.tar.gz" + KEYWORDS="amd64" +fi + +inherit flag-o-matic linux-info linux-mod python-single-r1 autotools-utils + +DESCRIPTION="The Solaris Porting Layer provides many of the Solaris kernel APIs" +HOMEPAGE="https://zfsonlinux.org/" + +LICENSE="GPL-2" +SLOT="0" +IUSE="custom-cflags debug" +RESTRICT="debug? ( strip ) test" + +COMMON_DEPEND=" + dev-lang/perl + virtual/awk" + +DEPEND="${COMMON_DEPEND}" + +RDEPEND="${COMMON_DEPEND} + ${PYTHON_DEPS} + !sys-devel/spl" + +REQUIRED_USE="${PYTHON_REQUIRED_USE}" + +AT_M4DIR="config" +AUTOTOOLS_IN_SOURCE_BUILD="1" +DOCS=( AUTHORS DISCLAIMER ) + +pkg_setup() { + python-single-r1_pkg_setup + linux-info_pkg_setup + CONFIG_CHECK=" + !DEBUG_LOCK_ALLOC + MODULES + KALLSYMS + !PAX_KERNEXEC_PLUGIN_METHOD_OR + !PAX_SIZE_OVERFLOW + !TRIM_UNUSED_KSYMS + ZLIB_DEFLATE + ZLIB_INFLATE + " + + use debug && CONFIG_CHECK="${CONFIG_CHECK} + FRAME_POINTER + DEBUG_INFO + !DEBUG_INFO_REDUCED + " + + kernel_is ge 2 6 32 || die "Linux 2.6.32 or newer required" + + [ ${PV} != "9999" ] && \ + { kernel_is le 5 0 || die "Linux 5.0 is the latest supported version."; } + + check_extra_config +} + +src_prepare() { + # Workaround for hard coded path + sed -i "s|/sbin/lsmod|/bin/lsmod|" "${S}/scripts/check.sh" || \ + die "Cannot patch check.sh" + + # splat is unnecessary unless we are debugging + use debug || { sed -e 's/^subdir-m += splat$//' -i "${S}/module/Makefile.in" || die ; } + + # Set module revision number + [ ${PV} != "9999" ] && \ + { sed -i "s/\(Release:\)\(.*\)1/\1\2${PR}-gentoo/" "${S}/META" || die "Could not set Gentoo release"; } + + autotools-utils_src_prepare +} + +src_configure() { + use custom-cflags || strip-flags + filter-ldflags -Wl,* + + set_arch_to_kernel + local myeconfargs=( + --bindir="${EPREFIX}/bin" + --sbindir="${EPREFIX}/sbin" + --with-config=all + --with-linux="${KV_DIR}" + --with-linux-obj="${KV_OUT_DIR}" + $(use_enable debug) + ) + autotools-utils_src_configure +} + +src_install() { + autotools-utils_src_install INSTALL_MOD_PATH="${INSTALL_MOD_PATH:-$EROOT}" + # enforce selected python implementation + python_fix_shebang "${ED}/bin" +} + +pkg_postinst() { + linux-mod_pkg_postinst + + # Remove old modules + if [ -d "${EROOT}lib/modules/${KV_FULL}/addon/spl" ] + then + ewarn "${PN} now installs modules in ${EROOT}lib/modules/${KV_FULL}/extra/spl" + ewarn "Old modules were detected in ${EROOT}lib/modules/${KV_FULL}/addon/spl" + ewarn "Automatically removing old modules to avoid problems." + rm -r "${EROOT}lib/modules/${KV_FULL}/addon/spl" || die "Cannot remove modules" + rmdir --ignore-fail-on-non-empty "${EROOT}lib/modules/${KV_FULL}/addon" + fi +} -- 2.45.2