From: Denis 'GNUtoo' Carikli <GNUtoo@cyberdimension.org>
To: Simon Tournier <zimon.toutoune@gmail.com>
Cc: Adrien 'neox' Bourmault <neox@gnu.org>, help-guix@gnu.org
Subject: Re: License compliance when redistributing images built with 'guix system'.
Date: Sat, 23 Nov 2024 00:56:06 +0100 [thread overview]
Message-ID: <20241123005606.6ab10a76@primary_laptop> (raw)
In-Reply-To: <20241118133843.2f1787b7@primary_laptop>
[-- Attachment #1: Type: text/plain, Size: 2930 bytes --]
On Mon, 18 Nov 2024 13:38:43 +0100
Denis 'GNUtoo' Carikli <GNUtoo@cyberdimension.org> wrote:
> On Mon, 18 Nov 2024 09:41:41 +0100
> Denis 'GNUtoo' Carikli <GNUtoo@cyberdimension.org> wrote:
> > But now I have another problem: some of the paths don't exist. For
> > instance the code above lists
> > /gnu/[...]-ath9k-htc-firmware-1.4.0-checkout which doesn't exist.
> I've found an idea for working around that: I can get the file name
> and loop over all the packages, match a package's
> origin-actual-file-name against the name above, and once we have the
> package we can simply run guix build --sources=transitive with it.
This turned out to take way too long.
I've talked again to Simon Tournier in a Guix even and he pointed to me
the missing part: guix build can build a lot of things, including
derivations and all, all I needed to do was to pass the right path to
guix build and it would figure out what it is and build it (if it can).
So at the end this gave this small source code:
;;; Copyright © 2024 Denis 'GNUtoo' Carikli <GNUtoo@cyberdimension.org>
;;;
;;; GNU Guix is free software; you can redistribute it and/or modify it
;;; under the terms of the GNU General Public License as published by
;;; the Free Software Foundation; either version 3 of the License, or (at
;;; your option) any later version.
;;;
;;; GNU Guix is distributed in the hope that it will be useful, but
;;; WITHOUT ANY WARRANTY; without even the implied warranty of
;;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
;;; GNU General Public License for more details.
(use-modules (guix build utils)
(guix derivations)
(guix scripts build))
(let ((drv-from-file
(read-derivation-from-file (list-ref (program-arguments) 1))))
(map
(lambda (drv-prerequisite)
(map
(lambda (drv-output)
(if (derivation-output-hash (cdr drv-output))
((lambda _
(let ((source-path (derivation-output-path (cdr drv-output))))
(if (not (file-exists? source-path))
(guix-build source-path))
(if (not (elf-file? source-path))
(display (string-append source-path "\n"))))))))
(derivation-outputs (derivation-input-derivation drv-prerequisite))))
(derivation-prerequisites drv-from-file)))
It can be used with something like that:
$ cp $(guix gc --derivers $(guix system image minimal-system.scm)) image.drv
$ tar cf sources.tar $(guix repl get-sources.scm image.drv)
There might still be room for testing and improvements though but we
now at least have something that can be used to easily publish complete
and corresponding source code of images in a safe and easy way.
Thanks a lot to Simon for all the help as this help has been extremely
useful in pointing me in the right direction multiple times.
Denis.
[-- Attachment #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 833 bytes --]
prev parent reply other threads:[~2024-11-22 23:58 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-05-23 0:09 License compliance when redistributing images built with 'guix system' Denis 'GNUtoo' Carikli
2024-07-17 17:26 ` Simon Tournier
2024-07-28 17:20 ` Denis 'GNUtoo' Carikli
2024-09-30 20:11 ` Denis 'GNUtoo' Carikli
2024-11-18 8:41 ` Denis 'GNUtoo' Carikli
2024-11-18 12:38 ` Denis 'GNUtoo' Carikli
2024-11-22 23:56 ` Denis 'GNUtoo' Carikli [this message]
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
List information: https://guix.gnu.org/
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20241123005606.6ab10a76@primary_laptop \
--to=gnutoo@cyberdimension.org \
--cc=help-guix@gnu.org \
--cc=neox@gnu.org \
--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.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).