Subject: [bug#48369] [PATCH] gnu: Add rset.

From: Sarah Morgensen <[email-masked]>
Date: Sun, 08 Aug 2021 17:26:26 -0700

Hello Stefan,

Thanks for the patch.  Sorry it's taken so long for someone to take a
look at this!  This utility certainly looks interesting.

I'm not a committer, but I tested out this patch.  It doesn't apply on
master anymore, so I manually applied it and was able to build it.
However, it looks like it expects a number of utilities to be in
specific places, such as /usr/bin/install (which caused rinstall to
just... do nothing).

It could also be problematic if it's attempting to invoke such absolute
paths on a remote machine.  I'm not sure exactly how rset works, though.

I was able to enable and pass tests with the modifications in the patch
attached below.  I don't know rset itself though, so I don't know if
there might be other hardcoded things that need to be substituted.  I
also bumped it to 2.2 and made a few minor tweaks to the description.

I noticed you didn't add a copyright line, but I wasn't sure whether the
omission was intentional, so I didn't add one for you. Go ahead and send
an updated patch to this bug number ([email-masked]) if you'd
like to add one, or make any other changes :)

The following is after the modifications I've made:

* Package review checklist (WIP - comments welcome!)
  A check indicates that I've verified the item.

1. [X] Package builds (guix build package)
     [X] x86_64  [ ] aarch64  [ ] armhf     [ ] powerpc64le
     [ ] i686    [ ] i586     [ ] mips64le
2. [X] Build is reproducible (guix build --rounds=n package)
3. [X] Tests enabled (if available) or disabled with in-source comment
4. [X] No extraneous dependencies (guix size package)
5. [X] No unnecessary pre-built binaries/blobs
6. [X] Dependencies unvendored when available in Guix
7. [X] Cross-compile friendly (cc-for-target, patches with inputs)
8. [X] License matches source
9. [X] No problematic lints (guix lint package)
10. [X] Formatting follows guidelines
    - [X] Lines wrap at 80 characters
    - [X] Indentation passes etc/indent-code.el
    - [X] Two spaces used between sentences

New packages:
11. [X] Source url is robust
    * mirror:// used with url-fetch when possible
    * No auto-generated archives from source repo (prefer cloning)
12. [X] Synopsis is short, descriptive, and meaningful to a wide audience
13. [X] Description is objective, takes 5-10 lines, uses full sentences,
    and provides the information users need to decide whether the
    software fits their needs.

Stefan Reichör <[email-masked]> writes:

> * gnu/packages/admin.scm (rset): New variable.
> ---
>  gnu/packages/admin.scm | 35 +++++++++++++++++++++++++++++++++++
>  1 file changed, 35 insertions(+)
>
> diff --git a/gnu/packages/admin.scm b/gnu/packages/admin.scm
> index fdcbf28a6a..c17609c442 100644
> --- a/gnu/packages/admin.scm
> +++ b/gnu/packages/admin.scm
> @@ -3371,6 +3371,41 @@ Intel DRM Driver.")
>      (supported-systems '("i686-linux" "x86_64-linux"))
>      (license license:expat)))
>  
> +(define-public rset
> +  (package
> +    (name "rset")
> +    (version "2.1")
> +    (source
> +     (origin
> +       (method git-fetch)
> +       (uri (git-reference
> +             (url "https://github.com/eradman/rset/")
> +             (commit version)))
> +       (file-name (git-file-name name version))
> +       (sha256
> +        (base32 "150my3lvql3m6jn1c12x81jx990nqh5g02v6r9a5j51ds39shr39"))))
> +    (build-system gnu-build-system)
> +    (arguments
> +     `(#:phases
> +       (modify-phases %standard-phases
> +         (replace 'configure
> +           (lambda* (#:key outputs #:allow-other-keys)
> +             (invoke "./configure"))))
> +       #:make-flags
> +       (list (string-append "PREFIX=" (assoc-ref %outputs "out"))
> +             ,(string-append "CC=" (cc-for-target)))
> +       #:tests? #f)) ; TODO: test target requires ruby, curl, uname
> +    (home-page "http://scriptedconfiguration.org")
> +    (synopsis "Configure systems using any scripting language")
> +    (description
> +     "rset(1) operates by staging files on a remote system, then executing
> +instructions embedded in the pln(5) files.  Any interpreter capable of running
> +scripts read over a pipe may be specified.  The bundled utilities rinstall(1)
> +and rsub(1) provide an easy means of installing and modifying configuration
> +files, and capabilities are added by writing utility scripts which are sent
> +along with configuration data.")
> +    (license license:isc)))
> +
>  (define-public fabric
>    (package
>      (name "fabric")

Subject: [PATCH] gnu: Add rset.

* gnu/packages/admin.scm (rset): New variable.
---
 gnu/packages/admin.scm | 79 ++++++++++++++++++++++++++++++++++++++++++
 1 file changed, 79 insertions(+)

diff --git a/gnu/packages/admin.scm b/gnu/packages/admin.scm
index eda269f148..4bf17d57e5 100644
--- a/gnu/packages/admin.scm
+++ b/gnu/packages/admin.scm
@@ -142,6 +142,7 @@
   #:use-module (gnu packages tls)
   #:use-module (gnu packages version-control)
   #:use-module (gnu packages web)
+  #:use-module (gnu packages wget)
   #:use-module (gnu packages xdisorg)
   #:use-module (gnu packages xml)
   #:use-module (gnu packages xorg))
@@ -3425,6 +3426,84 @@ Intel DRM Driver.")
     (supported-systems '("i686-linux" "x86_64-linux"))
     (license license:expat)))
 
+(define-public rset
+  (package
+    (name "rset")
+    (version "2.2")
+    (source
+     (origin
+       (method git-fetch)
+       (uri (git-reference
+             (url "https://github.com/eradman/rset/")
+             (commit version)))
+       (file-name (git-file-name name version))
+       (sha256
+        (base32 "0dk75an8axf4480lirwj1vyq1nd18kq5lwz6gdg6hgk3a4rwpv8j"))))
+    (build-system gnu-build-system)
+    (arguments
+     `(#:make-flags (list (string-append "PREFIX=" %output)
+                          (string-append "CC=" ,(cc-for-target)))
+       #:test-target "test"
+       #:phases
+       (modify-phases %standard-phases
+         (add-after 'unpack 'patch-paths
+           (lambda* (#:key inputs #:allow-other-keys)
+             (substitute* "rutils.c"
+               (("/usr/bin/install")
+                (string-append (assoc-ref inputs "coreutils") "/bin/install")))
+             (substitute* "config.h"
+               (("(LOCAL_INTERPRETER \")/bin/sh" _ start)
+                (string-append start (assoc-ref inputs "bash") "/bin/sh")))
+             ;; Paths on Guix tend to be much longer, so increase buffer size.
+             (substitute* "input.h"
+               (("#define PLN_OPTION_SIZE 64")
+                "#define PLN_OPTION_SIZE 128"))))
+         (add-after 'patch-paths 'patch-tests
+           (lambda _
+             ;; Input files must be writable for pipe tests.
+             (for-each make-file-writable (find-files "tests/input"))
+             (substitute* (find-files "tests")
+               (("(#!|local_interpreter=)/bin/sh" _ start)
+                (string-append start (which "sh"))))
+             (substitute* '("tests/stubs/ssh" "tests/stubs/tar")
+               (("/bin/echo") (which "echo")))
+             (substitute* "tests/test_miniquark.rb"
+               ;; Make sure the test can see PATH.
+               ((":unsetenv_others=>true") ":unsetenv_others=>false"))
+             (substitute* '("tests/cmd_pipe_stdin.c" "tests/test_rset.rb")
+               (("/bin/cat") (which "cat"))
+               ;; /bin/cat is in a fixed-size buffer, so increase the size.
+               (("char \\*cmd_argv\\[16\\];") "char *cmd_argv[256];"))
+             (substitute* "tests/test_rset.rb"
+               (("output_size: 20") "output_size: 66")
+               (("strlen: 20") "strlen: 66")
+               (("/usr/bin/env ruby") (which "ruby"))
+               (("\"/bin/sh") (string-append "\"" (which "sh")))
+               ;; Make the sure the test can see our PATH.
+               (("\\{\"PATH\"=>\"/bin:/usr/bin\"\\}, ") ""))))
+         (replace 'configure
+           (lambda* (#:key outputs #:allow-other-keys)
+             ;; ./configure must be called with no arguments, or it fails.
+             (invoke "./configure"))))))
+    (inputs
+     `(("coreutils" ,coreutils)
+       ("bash" ,bash-minimal)))
+    (native-inputs
+     `(("ruby" ,ruby)
+       ("wget" ,wget)
+       ("inetutils" ,inetutils)))
+    (home-page "http://scriptedconfiguration.org")
+    (synopsis "Configure systems using any scripting language")
+    (description
+     "@command{rset} operates by staging files on a remote system, then
+executing instructions embedded in the @code{pln(5)} (Progressive Language
+Notation) files.  Any interpreter capable of running scripts read over a pipe
+may be specified.  The bundled utilities @command{rinstall} and @command{rsub}
+provide a means of installing and modifying configuration files, and
+capabilities are added by writing utility scripts which are sent along
+with configuration data.")
+    (license license:isc)))
+
 (define-public neofetch
   (package
     (name "neofetch")

base-commit: c8e2be3b32fe784a9db52d8a1a12902ab12ae7cb
-- 
2.31.1

--
Sarah