+ `(("libuuid" ,util-linux "lib")))))
+
+(define-public f2fs-tools/static
+ (static-package
+ (package
+ (inherit f2fs-tools)
+ (name "f2fs-tools-static")
+ (arguments
+ `(#:configure-flags
+ (let ((libuuid-static (assoc-ref %build-inputs "libuuid:static"))
+ (libuuid (assoc-ref %build-inputs "libuuid")))
+ (list
+ (string-append "libuuid_CFLAGS=-I" libuuid "/include")
+ (string-append "libuuid_LIBS=-L" libuuid-static "/lib -luuid")
+ (string-append "libblkid_CFLAGS=-I" libuuid "/include")
+ (string-append "libblkid_LIBS=-L" libuuid-static "/lib -lblkid")))
+ #:disallowed-references (,util-linux)
+ #:phases
+ (modify-phases %standard-phases ; TODO: f2fs phases.
+ (add-after 'unpack 'make-static
+ (lambda _
+ (define (append-to-file name body)
+ (let ((file (open-file name "a")))
+ (display body file)
+ (close-port file)))
+ (append-to-file "mkfs/Makefile.am" "\nmkfs_f2fs_LDFLAGS = -all-static\n")
+ (append-to-file "fsck/Makefile.am" "\nfsck_f2fs_LDFLAGS = -all-static\n")
+ (append-to-file "tools/Makefile.am" "\nf2fscrypt_LDFLAGS = -all-static -luuid\n")
+ #t))
+ (add-after 'install 'remove-store-references
+ (lambda* (#:key outputs #:allow-other-keys)
+ ;; Work around bug in our util-linux.
+ ;; <https://debbugs.gnu.org/cgi/bugreport.cgi?bug=41019>.
+ (remove-store-references (string-append (assoc-ref outputs "out")
+ "/sbin/mkfs.f2fs"))
+ #t)))))
+ (inputs
+ `(("libuuid:static" ,util-linux "static")
+ ("libuuid" ,util-linux "lib")))))) ; for include files
+
+(define-public f2fs-fsck/static
+ (package
+ (name "f2fs-fsck-static")
+ (version (package-version f2fs-tools/static))
+ (source #f)
+ (build-system trivial-build-system)
+ (arguments
+ `(#:modules ((guix build utils))
+ #:builder
+ (begin
+ (use-modules (guix build utils)
+ (ice-9 ftw)
+ (srfi srfi-26))
+ (let* ((f2fs-tools (assoc-ref %build-inputs "f2fs-tools-static"))
+ (fsck "fsck.f2fs")
+ (out (assoc-ref %outputs "out"))
+ (sbin (string-append out "/sbin")))
+ (mkdir-p sbin)
+ (with-directory-excursion sbin
+ (install-file (string-append f2fs-tools "/sbin/" fsck)
+ ".")
+ (remove-store-references fsck)
+ (chmod fsck #o555))
+ #t))))
+ (inputs
+ `(("f2fs-tools-static" ,f2fs-tools/static)))
+ (home-page (package-home-page f2fs-tools/static))
+ (synopsis "Statically-linked fsck.f2fs command from f2fs-tools")
+ (description "This package provides statically-linked fsck.f2fs command taken
+from the f2fs-tools package. It is meant to be used in initrds.")
+ (license (package-license f2fs-tools/static))))