diff mbox series

[bug#60250] gnu: Add bees.

Message ID 87k02j4zq8.wl-hako@ultrarare.space
State New
Headers show
Series [bug#60250] gnu: Add bees. | expand

Commit Message

Hilton Chain Dec. 22, 2022, 8:19 a.m. UTC
* gnu/packages/file-systems.scm (bees): New variable.
---
 gnu/packages/file-systems.scm | 39 +++++++++++++++++++++++++++++++++++
 1 file changed, 39 insertions(+)


base-commit: 0744540d09ddef8dbf25cc5d65da9d029dab338c

Comments

Adam Faiz Dec. 22, 2022, 6:52 p.m. UTC | #1
Hi,

> #~(list (string-append "CC=" #$(cc-for-target))
> +                   (string-append "DESTDIR=" #$output)
> +                   (string-append "BEES_VERSION=" #$version)
> +                   "PREFIX=''"
> +                   "LIBEXEC_PREFIX=/lib/bees"
The LIBEXEC_PREFIX shouldn't be set to this, this is actually a bug with 
beesd.in and also the sed invocation(or $TEMPLATE_COMPILER which is what 
it's called in the Makefile).

> #~(modify-phases %standard-phases
> +               (delete 'configure)
> +               (add-after 'install 'fix-path
> +                 (lambda _
> +                   (substitute* (string-append #$output "/sbin/beesd")
> +                     (("/lib/bees/bees" all)
> +                      (string-append #$output all))))))))
The 'fix-path phase isn't necessary, and the LIBEXEC_PREFIX doesn't need 
to be set. The snippet below fixes the bug in bees:

>               (modules '((guix build utils)))
>               (snippet
>                #~(begin
>                    (substitute* "Defines.mk"
>                      (("^sed.*" all)
>                       (string-append all
>                                      "\t\t-e's#@DESTDIR@#$(DESTDIR)#' \\\n")))
>                    (substitute* "scripts/beesd.in"
>                      (("@LIBEXEC_PREFIX@") "@DESTDIR@/@LIBEXEC_PREFIX@"))))))

The files lib/city.cc and include/crucible/city.h need to be unbundled 
and the cityhash included in guix used instead. The cityhash package 
needs to be in the inputs, and these files need to be deleted as part of 
the snippet above:>                    (for-each delete-file
>                              '("lib/city.cc" "include/crucible/city.h"))

It appears that bees hasn't been built on a non-systemd distribution, 
because an optional feature hard fails. This fixes it, the systemd unit 
files are installed conditionally anyways:
>                    (substitute* "Makefile"
>                      (("pkg-config systemd --variable=systemdsystemunitdir" all)
>                       (string-append all " || true")))

>                    (substitute* "lib/Makefile"
>                      (("city.o.*") ""))
>                    (substitute* "src/bees-hash.cc"
>                      (("#include .crucible/city.h.") "#include <city.h>"))
These substitutions remove references to the bundled cityhash(which is 
11 years old!)

Native inputs and inputs for bees:
>     (native-inputs
>      (list pkg-config markdown))
>     (inputs
>      (list cityhash))

All the modifications made as part of the snippet should definitely be 
upstreamed, could you do that for me?
Adam Faiz Dec. 22, 2022, 7:22 p.m. UTC | #2
From the docs/install.md, it looks like btrfs-progs and 
util-linux(needed for the blkid program) are used at runtime. References 
to those programs in the source should probably just be substituted in a 
phase.
Hilton Chain Dec. 23, 2022, 6:25 a.m. UTC | #3
Hi Adam,

On Fri, 23 Dec 2022 02:52:38 +0800,
Adam Faiz wrote:
>
> Hi,
>
> > #~(list (string-append "CC=" #$(cc-for-target))
> > +                   (string-append "DESTDIR=" #$output)
> > +                   (string-append "BEES_VERSION=" #$version)
> > +                   "PREFIX=''"
> > +                   "LIBEXEC_PREFIX=/lib/bees"
> The LIBEXEC_PREFIX shouldn't be set to this, this is actually a bug with beesd.in and also the sed
> invocation(or $TEMPLATE_COMPILER which is what it's called in the Makefile).
>
> > #~(modify-phases %standard-phases
> > +               (delete 'configure)
> > +               (add-after 'install 'fix-path
> > +                 (lambda _
> > +                   (substitute* (string-append #$output "/sbin/beesd")
> > +                     (("/lib/bees/bees" all)
> > +                      (string-append #$output all))))))))
> The 'fix-path phase isn't necessary, and the LIBEXEC_PREFIX doesn't need to be set. The snippet
> below fixes the bug in bees:
>
> >               (modules '((guix build utils)))
> >               (snippet
> >                #~(begin
> >                    (substitute* "Defines.mk"
> >                      (("^sed.*" all)
> >                       (string-append all
> >                                      "\t\t-e's#@DESTDIR@#$(DESTDIR)#' \\\n")))
> >                    (substitute* "scripts/beesd.in"
> >                      (("@LIBEXEC_PREFIX@") "@DESTDIR@/@LIBEXEC_PREFIX@"))))))
>
> The files lib/city.cc and include/crucible/city.h need to be unbundled and the cityhash included in
> guix used instead. The cityhash package needs to be in the inputs, and these files need to be
> deleted as part of the snippet above:>                    (for-each delete-file
> >                              '("lib/city.cc" "include/crucible/city.h"))
>
> It appears that bees hasn't been built on a non-systemd distribution, because an optional feature
> hard fails. This fixes it, the systemd unit files are installed conditionally anyways:
> >                    (substitute* "Makefile"
> >                      (("pkg-config systemd --variable=systemdsystemunitdir" all)
> >                       (string-append all " || true")))
>
> >                    (substitute* "lib/Makefile"
> >                      (("city.o.*") ""))
> >                    (substitute* "src/bees-hash.cc"
> >                      (("#include .crucible/city.h.") "#include <city.h>"))
> These substitutions remove references to the bundled cityhash(which is 11 years old!)
>
> Native inputs and inputs for bees:
> >     (native-inputs
> >      (list pkg-config markdown))
> >     (inputs
> >      (list cityhash))
>
> All the modifications made as part of the snippet should definitely be upstreamed, could you do that
> for me?

Thank you for the snippet and explanation!

I've made a pull request (of the beesd part) to the upstream:
<https://github.com/Zygo/bees/pull/241>

(And it's merged before I send the mail XDDD)

However I'm not sure about the systemd part, could you explain more about which optional feature
hard fails?  And I get same binaries whether-ever this part is used.

As pkg-config is only used for systemd, and markdown for documentations that won't be installed,
I'd rather remove them from native-inputs, WDYT?
Adam Faiz Dec. 23, 2022, 7:57 a.m. UTC | #4
On 12/23/22 14:25, Hilton Chain wrote:
> Hi Adam,
> 
> On Fri, 23 Dec 2022 02:52:38 +0800,
> Adam Faiz wrote:
>>
>> Hi,
>>
>> It appears that bees hasn't been built on a non-systemd distribution, because an optional feature
>> hard fails. This fixes it, the systemd unit files are installed conditionally anyways:
>>>                     (substitute* "Makefile"
>>>                       (("pkg-config systemd --variable=systemdsystemunitdir" all)
>>>                        (string-append all " || true")))
> Thank you for the snippet and explanation!
> 
> I've made a pull request (of the beesd part) to the upstream:
> <https://github.com/Zygo/bees/pull/241>
> 
> (And it's merged before I send the mail XDDD)
> 
> However I'm not sure about the systemd part, could you explain more about which optional feature
> hard fails?  And I get same binaries whether-ever this part is used.
I had a problem earlier, but I can't reproduce it now. You can remove 
this one.

> As pkg-config is only used for systemd, and markdown for documentations that won't be installed,
> I'd rather remove them from native-inputs, WDYT?
I agree that it should be done, but it's a shame that there's no 
install_docs rule in the Makefile. That should be a feature request/patch.

I already have a bees-remove-bundled-cityhash.patch and 
bees-add-cityhash-to-install.md.patch to send upstream. Should I email 
them to you?
Hilton Chain Dec. 24, 2022, 11:34 a.m. UTC | #5
On Fri, 23 Dec 2022 15:57:53 +0800,
Adam Faiz wrote:
> > As pkg-config is only used for systemd, and markdown for documentations that won't be installed,
> > I'd rather remove them from native-inputs, WDYT?
> I agree that it should be done, but it's a shame that there's no install_docs rule in the
> Makefile. That should be a feature request/patch.
>
> I already have a bees-remove-bundled-cityhash.patch and bees-add-cityhash-to-install.md.patch to
> send upstream. Should I email them to you?

As v2 has unbundled cityhash, there's no need to send the patches to me.

One thing to mention is that, according to Repology[1], cityhash is not widely packaged, as a
result, it might be better to implement the unbundle as an option.

[1]: <https://repology.org/project/cityhash/versions>
Adam Faiz Dec. 24, 2022, 4:31 p.m. UTC | #6
On 12/24/22 19:34, Hilton Chain wrote:
> On Fri, 23 Dec 2022 15:57:53 +0800,
> Adam Faiz wrote:
>>> As pkg-config is only used for systemd, and markdown for documentations that won't be installed,
>>> I'd rather remove them from native-inputs, WDYT?
>> I agree that it should be done, but it's a shame that there's no install_docs rule in the
>> Makefile. That should be a feature request/patch.
>>
>> I already have a bees-remove-bundled-cityhash.patch and bees-add-cityhash-to-install.md.patch to
>> send upstream. Should I email them to you?
> 
> As v2 has unbundled cityhash, there's no need to send the patches to me.
> 
> One thing to mention is that, according to Repology[1], cityhash is not widely packaged, as a
> result, it might be better to implement the unbundle as an option.
> 
> [1]: <https://repology.org/project/cityhash/versions>
I don't think that should be done. It's all the more reason these 
distributions need cityhash packaged and people to help them.

If they need a reference, they can always look at the cityhash package 
in guix or other distributions and how they do it.
diff mbox series

Patch

diff --git a/gnu/packages/file-systems.scm b/gnu/packages/file-systems.scm
index 57a25a0d90..cce406a01d 100644
--- a/gnu/packages/file-systems.scm
+++ b/gnu/packages/file-systems.scm
@@ -1766,3 +1766,42 @@  (define-public udftools
 and other optical media.  It supports read-only media (DVD/CD-R)
 and rewritable media that wears out (DVD/CD-RW).")
     (license license:gpl2+)))
+
+(define-public bees
+  (package
+    (name "bees")
+    (version "0.8")
+    (source (origin
+              (method git-fetch)
+              (uri (git-reference
+                    (url "https://github.com/Zygo/bees")
+                    (commit (string-append "v" version))))
+              (file-name (git-file-name name version))
+              (sha256
+               (base32
+                "1kxpz1p9k5ir385kpvmfjawki5vg22hlx768k7835w6n5z5a65y4"))))
+    (build-system gnu-build-system)
+    (arguments
+     (list #:test-target "test"
+           #:make-flags
+           #~(list (string-append "CC=" #$(cc-for-target))
+                   (string-append "DESTDIR=" #$output)
+                   (string-append "BEES_VERSION=" #$version)
+                   "PREFIX=''"
+                   "LIBEXEC_PREFIX=/lib/bees")
+           #:phases
+           #~(modify-phases %standard-phases
+               (delete 'configure)
+               (add-after 'install 'fix-path
+                 (lambda _
+                   (substitute* (string-append #$output "/sbin/beesd")
+                     (("/lib/bees/bees" all)
+                      (string-append #$output all))))))))
+    (home-page "https://github.com/Zygo/bees")
+    (synopsis "Best-Effort Extent-Same, a btrfs dedupe agent")
+    (description
+     "@code{bees} is a block-oriented userspace deduplication agent designed
+for large btrfs filesystems.  It is an offline dedupe combined with an
+incremental data scan capability to minimize time data spends on disk from
+write to dedupe.")
+    (license license:gpl3+)))