From patchwork Thu Dec 19 09:49:56 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Efraim Flashner X-Patchwork-Id: 16563 Return-Path: X-Original-To: patchwork@mira.cbaines.net Delivered-To: patchwork@mira.cbaines.net Received: by mira.cbaines.net (Postfix, from userid 113) id 0EE5717941; Thu, 19 Dec 2019 09:51:12 +0000 (GMT) X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on mira.cbaines.net X-Spam-Level: X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00,URIBL_BLOCKED autolearn=unavailable autolearn_force=no version=3.4.0 Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mira.cbaines.net (Postfix) with ESMTP id 57CA817940 for ; Thu, 19 Dec 2019 09:51:11 +0000 (GMT) Received: from localhost ([::1]:37888 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1ihsSc-0006Yp-OZ for patchwork@mira.cbaines.net; Thu, 19 Dec 2019 04:51:10 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:48707) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1ihsSW-0006Yh-Jq for guix-patches@gnu.org; Thu, 19 Dec 2019 04:51:06 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ihsSU-000282-Tb for guix-patches@gnu.org; Thu, 19 Dec 2019 04:51:04 -0500 Received: from debbugs.gnu.org ([209.51.188.43]:38316) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1ihsSU-000273-Nw for guix-patches@gnu.org; Thu, 19 Dec 2019 04:51:02 -0500 Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1ihsSU-0008Nr-Me for guix-patches@gnu.org; Thu, 19 Dec 2019 04:51:02 -0500 X-Loop: help-debbugs@gnu.org Subject: [bug#38669] [PATCH] gnu: Add zfs. Resent-From: Efraim Flashner Original-Sender: "Debbugs-submit" Resent-CC: guix-patches@gnu.org Resent-Date: Thu, 19 Dec 2019 09:51:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: report 38669 X-GNU-PR-Package: guix-patches X-GNU-PR-Keywords: patch To: 38669@debbugs.gnu.org X-Debbugs-Original-To: guix-patches@gnu.org Received: via spool by submit@debbugs.gnu.org id=B.157674904132194 (code B ref -1); Thu, 19 Dec 2019 09:51:02 +0000 Received: (at submit) by debbugs.gnu.org; 19 Dec 2019 09:50:41 +0000 Received: from localhost ([127.0.0.1]:44289 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1ihsS3-0008N7-P2 for submit@debbugs.gnu.org; Thu, 19 Dec 2019 04:50:41 -0500 Received: from lists.gnu.org ([209.51.188.17]:42353) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1ihsS1-0008Mv-So for submit@debbugs.gnu.org; Thu, 19 Dec 2019 04:50:34 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:43310) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1ihsRz-0006UZ-3r for guix-patches@gnu.org; Thu, 19 Dec 2019 04:50:33 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ihsRx-00087Z-C9 for guix-patches@gnu.org; Thu, 19 Dec 2019 04:50:30 -0500 Received: from flashner.co.il ([178.62.234.194]:55932) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ihsRx-00081h-0q for guix-patches@gnu.org; Thu, 19 Dec 2019 04:50:29 -0500 Received: from localhost (unknown [141.226.13.108]) by flashner.co.il (Postfix) with ESMTPSA id B683C40116 for ; Thu, 19 Dec 2019 09:50:27 +0000 (UTC) Date: Thu, 19 Dec 2019 11:49:56 +0200 From: Efraim Flashner Message-ID: <20191219094956.GG917@E5400> MIME-Version: 1.0 Content-Disposition: inline X-PGP-Key-ID: 0x41AAE7DCCA3D8351 X-PGP-Key: https://flashner.co.il/~efraim/efraim_flashner.asc X-PGP-Fingerprint: A28B F40C 3E55 1372 662D 14F7 41AA E7DC CA3D 8351 User-Agent: Mutt/1.12.2 (2019-09-21) X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 209.51.188.43 X-BeenThere: guix-patches@gnu.org List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: guix-patches-bounces+patchwork=mira.cbaines.net@gnu.org Sender: "Guix-patches" X-getmail-retrieved-from-mailbox: Patches I don't actually have a use case for this patch myself but I know there are others who are interested in using ZFS. I found the Nix implementation¹ to be very helpful when I was working on it. ¹ https://github.com/NixOS/nixpkgs/blob/master/pkgs/os-specific/linux/zfs/default.nix¬ diff --git a/gnu/packages/file-systems.scm b/gnu/packages/file-systems.scm index fd62bf29ed..a820c159da 100644 --- a/gnu/packages/file-systems.scm +++ b/gnu/packages/file-systems.scm @@ -3,6 +3,7 @@ ;;; Copyright © 2017 Gábor Boskovits ;;; Copyright © 2017, 2018 Ricardo Wurmus ;;; Copyright © 2018 Leo Famulari +;;; Copyright © 2019 Efraim Flashner ;;; ;;; This file is part of GNU Guix. ;;; @@ -26,6 +27,7 @@ #:use-module (guix git-download) #:use-module (guix build-system cmake) #:use-module (guix build-system gnu) + #:use-module (guix build-system linux-module) #:use-module (guix utils) #:use-module (gnu packages) #:use-module (gnu packages acl) @@ -40,7 +42,9 @@ #:use-module (gnu packages docbook) #:use-module (gnu packages flex) #:use-module (gnu packages glib) + #:use-module (gnu packages libffi) #:use-module (gnu packages linux) + #:use-module (gnu packages nfs) #:use-module (gnu packages onc-rpc) #:use-module (gnu packages pkg-config) #:use-module (gnu packages python) @@ -322,3 +326,113 @@ to read all files, and it does not support all the compression methods in APFS.") (home-page "https://github.com/sgan81/apfs-fuse") (license license:gpl2+)))) + +(define-public zfs + (package + (name "zfs") + (version "0.8.2") + (outputs '("out" "module" "src")) + (source + (origin + (method url-fetch) + (uri (string-append "https://github.com/zfsonlinux/zfs/releases" + "/download/zfs-" version + "/zfs-" version ".tar.gz")) + (sha256 + (base32 + "1f7aig15q3z832pr2n48j3clafic2yk1vvqlh28vpklfghjqwq27")))) + (build-system linux-module-build-system) + (arguments + `(;; The ZFS kernel module should not be downloaded since the license + ;; terms don't allow for distributing it, only building it locally. + ;#:substitutable? #f ; Unrecognized with the linux-module-build-system. + ;; Tests cannot run in an unprivileged build environment. + #:tests? #f + #:phases + (modify-phases %standard-phases + (add-after 'configure 'really-configure + (lambda* (#:key outputs inputs #:allow-other-keys) + (let ((out (assoc-ref outputs "out"))) + (substitute* "configure" + (("-/bin/sh") (string-append "-" (which "sh"))) + ((" /bin/sh") (string-append " " (which "sh")))) + (invoke "./configure" + "--with-config=all" + (string-append "--prefix=" out) + (string-append "--with-dracutdir=" out "/lib/dracut") + (string-append "--with-udevdir=" out "/lib/udev") + (string-append "--with-mounthelperdir=" out "/sbin") + (string-append "--with-linux=" + (assoc-ref inputs "linux-module-builder") + "/lib/modules/build"))))) + (add-after 'unpack 'patch-source + (lambda* (#:key inputs outputs #:allow-other-keys) + (let ((out (assoc-ref outputs "out")) + (src (assoc-ref outputs "src")) + (util-linux (assoc-ref inputs "util-linux")) + (nfs-utils (assoc-ref inputs "nfs-utils"))) + (substitute* "module/zfs/zfs_ctldir.c" + (("/usr/bin/env\", \"umount") + (string-append util-linux "/bin/umount\", \"-n")) + (("/usr/bin/env\", \"mount") + (string-append util-linux "/bin/mount\", \"-n"))) + (substitute* "lib/libzfs/libzfs_mount.c" + (("/bin/mount") (string-append util-linux "/bin/mount")) + (("/bin/umount") (string-append util-linux "/bin/umount"))) + (substitute* "lib/libshare/nfs.c" + (("/usr/sbin/exportfs") + (string-append nfs-utils "/sbin/exportfs"))) + (substitute* "config/zfs-build.m4" + (("\\$sysconfdir/init.d") (string-append out "/etc/init.d"))) + (substitute* '("etc/zfs/Makefile.am" + "cmd/zed/Makefile.am") + (("\\$\\(sysconfdir)") (string-append out "/etc"))) + (substitute* "cmd/vdev_id/vdev_id" + (("PATH=/bin:/sbin:/usr/bin:/usr/sbin") + (string-append "PATH=" + (dirname (which "chmod")) ":" + (dirname (which "grep")) ":" + (dirname (which "sed")) ":" + (dirname (which "gawk"))))) + (substitute* "contrib/pyzfs/Makefile.in" + ((".*install-lib.*") "")) + (substitute* '("Makefile.am" "Makefile.in") + (("\\$\\(prefix)/src") (string-append src "/src")))) + #t)) + (replace 'build + (lambda _ (invoke "make"))) + (replace 'install + (lambda* (#:key outputs inputs native-inputs #:allow-other-keys) + (let* ((out (assoc-ref outputs "out")) + (moddir (assoc-ref outputs "module")) + (kmod (assoc-ref (or native-inputs inputs) "kmod"))) + (invoke "make" "install" + (string-append "DEFAULT_INITCONF_DIR=" out "/etc/default") + (string-append "DEPMOD=" kmod "/bin/depmod") + (string-append "INSTALL_PATH=" out) + (string-append "INSTALL_MOD_PATH=" moddir) + "INSTALL_MOD_STRIP=1") + (install-file "contrib/bash_completion.d/zfs" + (string-append out "/share/bash-completion/completions")) + (symlink "../share/pkgconfig/" (string-append out "/lib/pkgconfig")) + #t)))))) + (native-inputs + `(("attr" ,attr) + ("pkg-config" ,pkg-config))) + (inputs + `(("eudev" ,eudev) + ("libaio" ,libaio) + ("libtirpc" ,libtirpc) + ("nfs-utils" ,nfs-utils) + ("openssl" ,openssl) + ("python" ,python) + ("python-cffi" ,python-cffi) + ("util-linux" ,util-linux) + ("zlib" ,zlib))) + (home-page "https://zfsonlinux.org/") + (synopsis "Native ZFS on Linux") + (description + "ZFS on Linux is an advanced file system and volume manager which was +originally developed for Solaris and is now maintained by the OpenZFS +community.") + (license license:cddl1.0)))