Message ID | c2da04d9-1509-4eec-8248-ffe484953154@1729.org.uk |
---|---|
State | New |
Headers |
Return-Path: <guix-patches-bounces+patchwork=mira.cbaines.net@gnu.org> X-Original-To: patchwork@mira.cbaines.net Delivered-To: patchwork@mira.cbaines.net Received: by mira.cbaines.net (Postfix, from userid 113) id B290527BC4B; Fri, 2 May 2025 14:16:22 +0100 (BST) X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on mira.cbaines.net X-Spam-Level: X-Spam-Status: No, score=0.0 required=5.0 tests=none autolearn=unavailable version=3.4.6 Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mira.cbaines.net (Postfix) with ESMTPS id 6982C27BC49 for <patchwork@mira.cbaines.net>; Fri, 2 May 2025 14:16:22 +0100 (BST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from <guix-patches-bounces@gnu.org>) id 1uAqFQ-0003a1-N7; Fri, 02 May 2025 09:16:13 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from <Debian-debbugs@debbugs.gnu.org>) id 1uAoqC-0007P5-Bg for guix-patches@gnu.org; Fri, 02 May 2025 07:46:06 -0400 Received: from debbugs.gnu.org ([2001:470:142:5::43]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from <Debian-debbugs@debbugs.gnu.org>) id 1uAoqB-0007Bf-TW for guix-patches@gnu.org; Fri, 02 May 2025 07:46:04 -0400 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=debbugs.gnu.org; s=debbugs-gnu-org; h=From:MIME-Version:Date:To:Subject; bh=mVWoCrjuXDWgv9Nrja+ZAIdKrvluwHKwfvLGGdJsUXQ=; b=NlldQZmxlsZOlgXJnmuaanqZxdC58K261r5jariN8spilM+H1GCU5w1D6C3CwyxrqUjC3DuNB53Gv4EhFI1GdVZPPp01RntOJ9pmYQGruaWvQQod/UVpNaqYH7rkSGsuNNs298dVFfQDPdbeNioWpuU7yGuifWqagt9R8iQ9kWKRy4oI9LbV8X5aWmAFqF6b/aCyRy7+ix4Qs0iCvc38UlFhr3O8BSgNixopiWQoK8rf8EY1txrBManakGFyvqCdvRHYMuBn2looiQo7MUCIuReKlD7+L0o6gXh8Plk5+bqnbitpxqBIShiDHTXs9CGMZuTAF6Um9FpP6fsNf8v9UQ==; Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from <Debian-debbugs@debbugs.gnu.org>) id 1uAoqB-0005aO-Lv for guix-patches@gnu.org; Fri, 02 May 2025 07:46:03 -0400 X-Loop: help-debbugs@gnu.org Subject: [bug#78210] [PATCH] guix: include store parent dirs in docker layer Resent-From: Ray Miller <ray@1729.org.uk> Original-Sender: "Debbugs-submit" <debbugs-submit-bounces@debbugs.gnu.org> Resent-CC: guix-patches@gnu.org Resent-Date: Fri, 02 May 2025 11:46:03 +0000 Resent-Message-ID: <handler.78210.B.174618634421409@debbugs.gnu.org> Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: report 78210 X-GNU-PR-Package: guix-patches X-GNU-PR-Keywords: patch To: 78210@debbugs.gnu.org X-Debbugs-Original-To: guix-patches@gnu.org Received: via spool by submit@debbugs.gnu.org id=B.174618634421409 (code B ref -1); Fri, 02 May 2025 11:46:03 +0000 Received: (at submit) by debbugs.gnu.org; 2 May 2025 11:45:44 +0000 Received: from localhost ([127.0.0.1]:57059 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from <debbugs-submit-bounces@debbugs.gnu.org>) id 1uAopr-0005ZD-Nz for submit@debbugs.gnu.org; Fri, 02 May 2025 07:45:44 -0400 Received: from lists.gnu.org ([2001:470:142::17]:43062) by debbugs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.84_2) (envelope-from <ray@1729.org.uk>) id 1uAnri-0007d0-SL for submit@debbugs.gnu.org; Fri, 02 May 2025 06:43:35 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from <ray@1729.org.uk>) id 1uAnra-0007vP-JF for guix-patches@gnu.org; Fri, 02 May 2025 06:43:27 -0400 Received: from mx1.mythic-beasts.com ([2a00:1098:0:86:1000:0:2:1]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from <ray@1729.org.uk>) id 1uAnrY-0002YN-0t for guix-patches@gnu.org; Fri, 02 May 2025 06:43:26 -0400 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=1729.org.uk ; s=mythic-beasts-k1; h=Subject:From:To:Date; bh=mVWoCrjuXDWgv9Nrja+ZAIdKrvluwHKwfvLGGdJsUXQ=; b=cZiqtOhmYyfR897Yuyko8Kj3vj 0Bhf92SuFd3j7IHKv3IQp2NT/oLXtqybzQ4cJG4VqUokV9M76BVZvqJ4fkScS404MsK3oiRnA6WMQ oOxss1VwpHDmxpu/DO8W2r8uHKwEJHiyeyjNonJJOyWjUOHNcWp0IIcCQSuPmr+Ia6AGvsTD0ZjiM i3tyZHAO2E6Yi/7DFVA80OnbnMOkSqrfId1r2fQX4PWGrt/Wbbp8lPVKyRScEObDX2KMpMu8+yk0K N4lMjVXVsAKI4Th56EVXUPgDb2Qz2RnmIZEKSljpRiNc6RrOX1udz/1BL/D4nisqfwGiE3nhmqWxv SWmpBBPQ==; Received: by mailhub-cam-d.mythic-beasts.com with esmtpsa (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from <ray@1729.org.uk>) id 1uAnrU-003pgR-WF for guix-patches@gnu.org; Fri, 02 May 2025 11:43:21 +0100 Message-ID: <c2da04d9-1509-4eec-8248-ffe484953154@1729.org.uk> Date: Fri, 2 May 2025 11:43:16 +0100 MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Content-Language: en-GB Autocrypt: addr=ray@1729.org.uk; keydata= xsDNBGEEGzEBDACd/xYfKYdNJwrAB3PJM3Z5Or3u5zaG3qSdkplIoiFWdKlI0RmKU2jxXNQ0 uEVzfQAm861ILeS58eyyc5G1EphHpmPNvBigA7dtPfs+dtbuIl6yj+rsHV691mRaAHiSkIB7 LexvzrJ/1cNxp+MqhB8/svKqdZgl081q6dZYPTWaU/NeOcNi8z2poo5HDGnjIhdj4y1GkKyI VoZnZ1nzKZJm0Z9oV+y4B2aKXQr89Dz2rS2tNbUraO+8bZTadztWlb/q9JZlqq7MmkgiaZ3N tJ/sn+UpF/hnStBDUtJbMkmbWke58+wcEyvATTXaV6ol8ow8vutC4Q75irs9FQULZtfRbbo1 59icl9y7M7UAvqvCMFv6qNuiAg4gc0+ru/W9D6URkYjM+IjL/torkskn8nr6iP7D64MbBbTw haoCuHxx23spDDlAg7p41I1F74IPAVVPt+/XG8T6a9sJjE5VatwQwA7OpdMMVGyfpPtYiQ7I ToWBQUAFSMf/DVWTSm24AhsAEQEAAc0cUmF5IE1pbGxlciA8cmF5QDE3Mjkub3JnLnVrPsLB FAQTAQoAPgIbAwULCQgHAgYVCgkICwIEFgIDAQIeAQIXgBYhBC4Zz4JVtqBNVVAfLAQ/eGxM 1oG4BQJj/MwsBQkMXrJ7AAoJEAQ/eGxM1oG48wcL/RKFFgJLfCcm3Nz/babpe3BlPSXS7rmY WUo1mGN1OgkIeW5DbW3hvrT6p8gP451cdwqBT56Iv7nJkzkXhegPUSO4V8L3WySJ7iK+fIxJ HwtZvxtX94WQ8XRQHP0UWwuAt/qF5jQBPF3fFLzhXmrQgY1H79ngncQFOlyObwyPT7EnMyFE mhdZKLgmI7LydwEgrxI8xIXfKJ1gU3FajfxzGxW3eN2JJ0luToxqEmBO6A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oO3+NiiSdsBAHK/kcmdijDYxVO UF4QyWXFCPi8sb+U1DHpIE1jy0QVdR/c8ANq9qGdwYUlpzZFfv9h7GE1XuFXUi4l+gFqBREc z9I0G00rXaoMkBCM9F26zVpZ+7FQ05kefr2QGbWzEt9vlcpDUwf60oidJLlAcTwUvM4Ev6Im UmoF4HNLvbNRpIqe0TQPjfdOyc4IdFJY+yPfbP3+Xdo2Tru+5WMie3UM5a/eMQXzwkS6C6fq 18xiP/dGWNKDD+pP4UStMVG1AHG/0WuykIioKYO6zamWZ7ezjIaAgyjdE7poQc7xYQetykUK 2t+Hmx6pMM4p4nZqbaVURAcyHvI= Content-Type: multipart/signed; micalg=pgp-sha256; protocol="application/pgp-signature"; boundary="------------Aj3p9FctUHFBmuF5zMUOHcV4" X-BlackCat-Spam-Score: -19 Received-SPF: pass client-ip=2a00:1098:0:86:1000:0:2:1; envelope-from=ray@1729.org.uk; helo=mx1.mythic-beasts.com X-Spam_score_int: -23 X-Spam_score: -2.4 X-Spam_bar: -- X-Spam_report: (-2.4 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, PDS_NAKED_TO_NUMERO=1.999, RCVD_IN_DNSWL_MED=-2.3, SPF_HELO_PASS=-0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-Mailman-Approved-At: Fri, 02 May 2025 07:45:40 -0400 X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list X-Mailman-Approved-At: Fri, 02 May 2025 09:15:59 -0400 X-BeenThere: guix-patches@gnu.org List-Id: <guix-patches.gnu.org> List-Unsubscribe: <https://lists.gnu.org/mailman/options/guix-patches>, <mailto:guix-patches-request@gnu.org?subject=unsubscribe> List-Archive: <https://lists.gnu.org/archive/html/guix-patches> List-Post: <mailto:guix-patches@gnu.org> List-Help: <mailto:guix-patches-request@gnu.org?subject=help> List-Subscribe: <https://lists.gnu.org/mailman/listinfo/guix-patches>, <mailto:guix-patches-request@gnu.org?subject=subscribe> Reply-to: Ray Miller <ray@1729.org.uk> X-ACL-Warn: , Ray Miller via Guix-patches <guix-patches@gnu.org> From: Ray Miller via Guix-patches via <guix-patches@gnu.org> Errors-To: guix-patches-bounces+patchwork=mira.cbaines.net@gnu.org Sender: guix-patches-bounces+patchwork=mira.cbaines.net@gnu.org X-getmail-retrieved-from-mailbox: Patches |
Series |
[bug#78210] guix: include store parent dirs in docker layer
|
|
Commit Message
Ray Miller
May 2, 2025, 10:43 a.m. UTC
This patch adds the /gnu and /gnu/store directories to the Docker layer created by `guix pack -f docker ...` which enables the Docker image to be used to create an AWS Lambda function. Without the patch, creating the AWS Lambda function fails with this error: "MissingParentDirectory: Parent directory does not exist for file: gnu/store/zic27jikg36d6wjj4cz8hyriyfl3ygiz-info-dir/" My first attempt to fix this was just to add the /gnu and /gnu/store directories to `directives` but the Docker image failed in AWS Lambda with the same error. These directories need to appear in the tarball for the layer *before* the packages, so the change to the order of the tar arguments is also needed. * guix/scripts/pack.scm: add /gnu and /gnu/store directories to the docker layer. * guix/docker.scm: change order of arguments to tar so parent directories are added before their contents. Change-Id: I2b103c59981e828c965564ccc5d2415b00a7e52e --- guix/docker.scm | 4 ++-- guix/scripts/pack.scm | 6 ++++-- 2 files changed, 6 insertions(+), 4 deletions(-) entry-point-argument) base-commit: 4fe4cf9fdd959126d3c53c3df4504d851e7b736a -- 2.47.1
Comments
Hi Ray, Ray Miller <ray@1729.org.uk> writes: > This patch adds the /gnu and /gnu/store directories to the Docker layer > created by `guix pack -f docker ...` which enables the Docker image to be > used to create an AWS Lambda function. Without the patch, creating the AWS > Lambda function fails with this error: > > "MissingParentDirectory: Parent directory does not exist for file: > gnu/store/zic27jikg36d6wjj4cz8hyriyfl3ygiz-info-dir/" > > My first attempt to fix this was just to add the /gnu and /gnu/store > directories > to `directives` but the Docker image failed in AWS Lambda with the same > error. These > directories need to appear in the tarball for the layer *before* the > packages, > so the change to the order of the tar arguments is also needed. > > * guix/scripts/pack.scm: add /gnu and /gnu/store directories to the > docker layer. > * guix/docker.scm: change order of arguments to tar so parent > directories are added before their contents. > > Change-Id: I2b103c59981e828c965564ccc5d2415b00a7e52e Neat! Could you include in the commit log a line like: Fixes <https://issues.guix.gnu.org/XYZ>. … so we can keep track of where this was reported and discussed? > +++ b/guix/scripts/pack.scm > @@ -580,9 +580,11 @@ (define* (docker-image name profile > (,source -> ,target)))))) > > (define directives > - ;; Create a /tmp directory, as some programs expect it, and > - ;; create SYMLINKS. > + ;; Create /tmp, /gnu, and /gnu/store directories, as some > + ;; programs expect them, and create SYMLINKS. > `((directory "/tmp" ,(getuid) ,(getgid) #o1777) > + (directory "/gnu" ,(getuid) ,(getgid) #o755) > + (directory "/gnu/store" ,(getuid) ,(getgid) #o755) It’s a bit trickier, because “/gnu/store” is not hardcoded. Instead, you need to recurse over the components of (%store-prefix), so something like: `((directory "/tmp" …) #$@(map (lambda (component) #~(directory #$component …)) (string-tokenize (%store-prefix) (char-set-complement (char-set #\/))))) But perhaps this should actually be done in (guix docker) so that ‘guix system image -t docker’ also benefits from it? Thanks, Ludo’.
Hi Ludo, Thank you for the feedback and suggestions. On 18/05/2025 21:34, Ludovic Courtès wrote: > Neat! > > Could you include in the commit log a line like: > > Fixes <https://issues.guix.gnu.org/XYZ>. > > … so we can keep track of where this was reported and discussed? > Done. >> +++ b/guix/scripts/pack.scm >> @@ -580,9 +580,11 @@ (define* (docker-image name profile >> (,source -> ,target)))))) >> >> (define directives >> - ;; Create a /tmp directory, as some programs expect it, and >> - ;; create SYMLINKS. >> + ;; Create /tmp, /gnu, and /gnu/store directories, as some >> + ;; programs expect them, and create SYMLINKS. >> `((directory "/tmp" ,(getuid) ,(getgid) #o1777) >> + (directory "/gnu" ,(getuid) ,(getgid) #o755) >> + (directory "/gnu/store" ,(getuid) ,(getgid) #o755) > It’s a bit trickier, because “/gnu/store” is not hardcoded. Ah, OK. Good catch! > Instead, you need to recurse over the components of (%store-prefix), so > something like: > > `((directory "/tmp" …) > #$@(map (lambda (component) > #~(directory #$component …)) > (string-tokenize (%store-prefix) > (char-set-complement (char-set #\/))))) It turns out to be a bit simpler because these directives are processed by evaluate-populate-directive which calls mkdir-p. (I discovered this after implementing a recursive solution then thinking "there must be a better way" and reading some source code...) > But perhaps this should actually be done in (guix docker) so that ‘guix > system image -t docker’ also benefits from it? I tested this by running 'guix systemimage -t docker' and inspecting the layer it generates. It turns out not to suffer from the same problem: the store directory is present in the layer. Updated patch to follow. Ray.
diff --git a/guix/docker.scm b/guix/docker.scm index 60ce13cbde..9911bb84bb 100644 --- a/guix/docker.scm +++ b/guix/docker.scm @@ -365,10 +365,10 @@ (define* (build-docker-image image paths prefix (apply invoke "tar" "-cf" "../layer.tar" `(,@transformation-options ,@(tar-base-options) - ,@(if max-layers '() paths) ,@(scandir "." (lambda (file) - (not (member file '("." "..")))))))) + (not (member file '("." ".."))))) + ,@(if max-layers '() paths)))) (delete-file-recursively "extra"))) ;; It is possible for "/" to show up in the archive, especially when diff --git a/guix/scripts/pack.scm b/guix/scripts/pack.scm index 7ab2c0d447..5cb9cd0b48 100644 --- a/guix/scripts/pack.scm +++ b/guix/scripts/pack.scm @@ -580,9 +580,11 @@ (define* (docker-image name profile (,source -> ,target)))))) (define directives - ;; Create a /tmp directory, as some programs expect it, and - ;; create SYMLINKS. + ;; Create /tmp, /gnu, and /gnu/store directories, as some + ;; programs expect them, and create SYMLINKS. `((directory "/tmp" ,(getuid) ,(getgid) #o1777) + (directory "/gnu" ,(getuid) ,(getgid) #o755) + (directory "/gnu/store" ,(getuid) ,(getgid) #o755) ,@(append-map symlink->directives '#$symlinks))) (define (form-entry-point prefix entry-point