all messages for Guix-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
From: "Ludovic Courtès" <ludo@gnu.org>
To: Maxim Cournoyer <maxim.cournoyer@gmail.com>
Cc: Josselin Poiret <dev@jpoiret.xyz>,
	Christopher Baines <mail@cbaines.net>,
	Simon Tournier <zimon.toutoune@gmail.com>,
	Mathieu Othacehe <othacehe@gnu.org>,
	Tobias Geerinckx-Rice <me@tobias.gr>,
	Ricardo Wurmus <rekado@elephly.net>,
	61255@debbugs.gnu.org
Subject: [bug#61255] [PATCH 0/5] Add support for the RPM format to "guix pack"
Date: Sun, 12 Feb 2023 19:52:08 +0100	[thread overview]
Message-ID: <87edquk97r.fsf_-_@gnu.org> (raw)
In-Reply-To: <20230203221409.15886-6-maxim.cournoyer@gmail.com> (Maxim Cournoyer's message of "Fri, 3 Feb 2023 17:14:08 -0500")

Hey!

Maxim Cournoyer <maxim.cournoyer@gmail.com> skribis:

> * guix/rpm.scm: New file.
> * guix/scripts/pack.scm (rpm-archive): New procedure.
> (%formats): Register it.
> (show-formats): Add it.
> (guix-pack): Register supported extra-options for the rpm format.
> * tests/pack.scm (rpm-for-tests): New variable.
> ("rpm archive can be installed/uninstalled"): New test.
> * tests/rpm.scm: New test.
> * doc/guix.texi (Invoking guix pack): Document it.

(‘Makefile.am’ changes are missing here.)

Woow, there’s a lot of fun stuff in here!  :-)  Nice work!

Perhaps we’ll soon see Guix-generated RPMs for, say, Jami?  :-)

Overall it looks great to me.

Perhaps you should submit an ‘etc/news.scm’ entry here so that
translators can work on it before it’s eventually pushed (I think that’s
the workflow Julien proposed).

Some comments follow:

> +@cindex Debian, build a .deb package with guix pack

@file{.deb} and @command{guix pack}

> +The RPM format supports relocatable packages via the @option{--prefix}
> +option of the @command{rpm} command, which can be handy to install an
> +RPM package to a specific prefix, making installing multiple
> +Guix-produced RPM packages side by side possible.
> +
> +@example
> +guix pack -f rpm -R -C xz -S /usr/bin/hello=bin/hello hello
> +sudo rpm --install --prefix=/opt /gnu/store/...-hello.rpm
> +@end example

Perhaps use two different @example boxes to distinguish between the Guix
machine that produces the RPM, and the RPM-based system that installs
it?

> +@quotation Note
> +Similarly to Debian packages, two RPM packages with conflicting files
> +cannot be installed simultaneously.  Contrary to Debian packages, RPM
> +supports relocatable packages, so file conflicts can be avoided by
> +installing the RPM packages under different installation prefixes, as
> +shown in the above example.

So for relocatable packages, one really needs ‘guix pack -R’ IIUC.
Interesting.

> +;;; Commentary:
> +;;;
> +;;; This module provides the building blocks required to construct RPM
> +;;; archives.  It is intended to be importable on the build side, so shouldn't
> +;;; depend on (guix diagnostics) or other host-side-only modules.
> +
> +(define-module (guix rpm)

The commentary should be followed by “Code:” and it should come after
the ‘define-module’ form.  That way, (ice-9 documentation) can find it.

> +(define (make-header-index+data entries)
> +  "Return the index and data sections as u8 number lists, via multiple values.
> +An index is composed of four u32 (16 bytes total) quantities, in order: tag,
> +type, offset and count."
> +  (match (fold (match-lambda*
> +                 ((entry (offset . (index . data)))
> +                  (let* ((tag (header-entry-tag entry))
> +                         (tag-number (rpm-tag-number tag))
> +                         (tag-type (rpm-tag-type tag))
> +                         (count (header-entry-count entry))
> +                         (data* (header-entry->data entry))
> +                         (alignment (entry-type->alignement tag-type))
> +                         (aligned-offset (next-aligned-offset offset alignment))
> +                         (padding (make-list (- aligned-offset offset) 0)))
> +                    (cons (+ aligned-offset (length data*))
> +                          (cons (append index
> +                                        (u32-number->u8-list tag-number)
> +                                        (u32-number->u8-list tag-type)
> +                                        (u32-number->u8-list aligned-offset)
> +                                        (u32-number->u8-list count))
> +                                (append data padding data*))))))

I think it would be possible (throughout the code) to avoid building
lists of bytes and instead directly produce bytevectors or, better,
produce procedures that write bytes directly to an output port (with
macros along the lines of ‘define-operation’ in (guix store) or
‘define-pack’ in (guix cpio)).

I don’t think it should be a blocker though, it’s okay to keep it this
way.

> +(define (files->md5-checksums files)
> +  "Return the MD5 checksums (formatted as hexadecimal strings) for FILES."

Does it have to be MD5?  If RPM supports SHA1 or SHA2*, it would be best
to pick one of these; MD5 is okay to detect unintended modifications,
but it’s useless if we care about malicious tampering.

> +            (define name (or (and=> single-entry manifest-entry-name)
> +                             (manifest->friendly-name manifest)))
> +
> +            (define version (or (and=> single-entry manifest-entry-version)
> +                                "0.0.0"))
> +
> +            (define lead (generate-lead (string-append name "-" version)
> +                                        #:target (or #$target %host-type)))
> +
> +            (define payload-digest (bytevector->hex-string
> +                                    (file-sha256 #$payload)))

Nitpick: the convention usually followed is to write the value, when
it’s long enough as is the case here, on the next line, as in:

  (define something
    value-thats-a-little-bit-long)

> +  (unless store (test-skip 1))
> +  (test-assertm "rpm archive can be installed/uninstalled" store

Really cool to have a full-blown test like this.

> +(define-module (test-rpm)
> +  #:use-module (guix rpm)

That too!

Thanks,
Ludo’.




  reply	other threads:[~2023-02-12 18:53 UTC|newest]

Thread overview: 45+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-02-03 16:19 [bug#61255] [PATCH 0/5] Add support for the RPM format to "guix pack" Maxim Cournoyer
2023-02-03 22:14 ` [bug#61255] [PATCH 1/5] pack: Extract keyword-ref procedure from debian-archive Maxim Cournoyer
2023-02-03 22:14   ` [bug#61255] [PATCH 2/5] gexp: computed-file: Honor %guile-for-build Maxim Cournoyer
2023-02-04  1:11     ` Ludovic Courtès
2023-02-04  3:43       ` Maxim Cournoyer
2023-02-12 18:14         ` [bug#61255] [PATCH 0/5] Add support for the RPM format to "guix pack" Ludovic Courtès
2023-02-16 15:12           ` Maxim Cournoyer
2023-02-23 15:44             ` [bug#61255] (%guile-for-build) default in ‘computed-file’ Ludovic Courtès
2023-02-24  2:38               ` Maxim Cournoyer
2023-02-27 15:10               ` bug#61841: bug#61255: [PATCH 0/5] Add support for the RPM format to "guix pack" Ludovic Courtès
2023-02-27 16:41                 ` Maxim Cournoyer
2023-02-27 21:08                   ` bug#61841: ‘guix shell’ computes different package derivation than ‘guix build’ Ludovic Courtès
2023-02-28  2:25                     ` Maxim Cournoyer
2023-02-03 22:14   ` [bug#61255] [PATCH 3/5] pack: Extract populate-profile-root from self-contained-tarball/builder Maxim Cournoyer
2023-02-03 22:14   ` [bug#61255] [PATCH 4/5] tests: pack: Fix indentation Maxim Cournoyer
2023-02-12 18:20     ` [bug#61255] [PATCH 0/5] Add support for the RPM format to "guix pack" Ludovic Courtès
2023-02-16 15:22       ` Maxim Cournoyer
2023-02-23 15:47         ` Ludovic Courtès
2023-02-23 22:20           ` Feedback on indentation rules (was: [PATCH 0/5] Add support for the RPM format to "guix pack") Maxim Cournoyer
2023-02-27 19:14             ` Efraim Flashner
2023-03-01 15:17               ` Feedback on indentation rules Maxim Cournoyer
2023-03-06 16:56                 ` Ludovic Courtès
2023-03-07 13:46                   ` Simon Tournier
2023-03-07 16:54                     ` Maxim Cournoyer
2023-03-07 17:29                       ` Simon Tournier
2023-03-09 13:55                         ` Maxim Cournoyer
2023-03-15 16:15                     ` Ludovic Courtès
2023-03-17 16:16                       ` Maxim Cournoyer
2023-02-03 22:14   ` [bug#61255] [PATCH 5/5] pack: Add RPM format Maxim Cournoyer
2023-02-12 18:52     ` Ludovic Courtès [this message]
2023-02-16 22:17       ` [bug#61255] [PATCH 0/5] Add support for the RPM format to "guix pack" Maxim Cournoyer
2023-02-12 18:57   ` Ludovic Courtès
2023-02-16 15:25     ` Maxim Cournoyer
2023-02-17  1:49 ` [bug#61255] [PATCH v2 0/8] " Maxim Cournoyer
2023-02-17  1:49   ` [bug#61255] [PATCH v2 1/8] .dir-locals: Add let-keywords indentation rules Maxim Cournoyer
2023-02-17  1:49   ` [bug#61255] [PATCH v2 2/8] pack: Use let-keywords instead of keyword-ref Maxim Cournoyer
2023-02-17  1:49   ` [bug#61255] [PATCH v2 3/8] gexp: computed-file: Honor %guile-for-build Maxim Cournoyer
2023-02-17  1:49   ` [bug#61255] [PATCH v2 4/8] pack: Extract populate-profile-root from self-contained-tarball/builder Maxim Cournoyer
2023-02-17  1:49   ` [bug#61255] [PATCH v2 5/8] tests: pack: Fix indentation Maxim Cournoyer
2023-02-17  1:49   ` [bug#61255] [PATCH v2 6/8] pack: Add RPM format Maxim Cournoyer
2023-02-17  1:49   ` [bug#61255] [PATCH v2 7/8] etc: Add a news entry snippet Maxim Cournoyer
2023-02-17  1:49   ` [bug#61255] [PATCH v2 8/8] news: Add entry for the new 'rpm' guix pack format Maxim Cournoyer
2023-02-17  6:34     ` Julien Lepiller
2023-02-17 17:32       ` Maxim Cournoyer
2023-02-17 15:12     ` pelzflorian (Florian Pelz)

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=87edquk97r.fsf_-_@gnu.org \
    --to=ludo@gnu.org \
    --cc=61255@debbugs.gnu.org \
    --cc=dev@jpoiret.xyz \
    --cc=mail@cbaines.net \
    --cc=maxim.cournoyer@gmail.com \
    --cc=me@tobias.gr \
    --cc=othacehe@gnu.org \
    --cc=rekado@elephly.net \
    --cc=zimon.toutoune@gmail.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this external index

	https://git.savannah.gnu.org/cgit/guix.git

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.