From b48b2bcf421b0a630e9b07378854e52618e8e773 Mon Sep 17 00:00:00 2001 From: Ray Miller Date: Sat, 24 May 2025 17:55:09 +0100 Subject: [PATCH] pack: Include store parent directories in the Docker layer. MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Fixes . 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/…-info-dir/" * guix/scripts/pack.scm (docker-image)[build]: Add store directory to the docker layer. * guix/docker.scm (build-docker-image): Change order of arguments to ‘tar’ so parent directories are added before their contents. Change-Id: I2b103c59981e828c965564ccc5d2415b00a7e52e Signed-off-by: Ludovic Courtès --- guix/docker.scm | 5 +++-- guix/scripts/pack.scm | 5 +++-- 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/guix/docker.scm b/guix/docker.scm index 60ce13cbde8..bb6d896a635 100644 --- a/guix/docker.scm +++ b/guix/docker.scm @@ -365,10 +365,11 @@ added to image as a layer." (apply invoke "tar" "-cf" "../layer.tar" `(,@transformation-options ,@(tar-base-options) - ,@(if max-layers '() paths) + ;; Add parent directories before their contents. ,@(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 7ab2c0d4475..857cb46af37 100644 --- a/guix/scripts/pack.scm +++ b/guix/scripts/pack.scm @@ -580,9 +580,10 @@ layers." (,source -> ,target)))))) (define directives - ;; Create a /tmp directory, as some programs expect it, and - ;; create SYMLINKS. + ;; Create the /tmp and %store-prefix directories, as some + ;; programs expect them, and create SYMLINKS. `((directory "/tmp" ,(getuid) ,(getgid) #o1777) + (directory #$(%store-prefix) ,(getuid) ,(getgid) #o755) ,@(append-map symlink->directives '#$symlinks))) (define (form-entry-point prefix entry-point entry-point-argument)