From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mp10.migadu.com ([2001:41d0:306:2d92::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by ms9.migadu.com with LMTPS id 8DY7OUlvGWXiBQEAG6o9tA:P1 (envelope-from ) for ; Sun, 01 Oct 2023 15:08:26 +0200 Received: from aspmx1.migadu.com ([2001:41d0:306:2d92::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by mp10.migadu.com with LMTPS id 8DY7OUlvGWXiBQEAG6o9tA (envelope-from ) for ; Sun, 01 Oct 2023 15:08:26 +0200 Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by aspmx1.migadu.com (Postfix) with ESMTPS id 8F21554EAC for ; Sun, 1 Oct 2023 15:08:25 +0200 (CEST) Authentication-Results: aspmx1.migadu.com; dkim=fail ("headers rsa verify failed") header.d=soeren-tempel.net header.s=opensmtpd header.b=fbg95GBX; spf=pass (aspmx1.migadu.com: domain of "guix-patches-bounces+larch=yhetil.org@gnu.org" designates 209.51.188.17 as permitted sender) smtp.mailfrom="guix-patches-bounces+larch=yhetil.org@gnu.org"; dmarc=fail reason="SPF not aligned (relaxed)" header.from=soeren-tempel.net (policy=none) ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=yhetil.org; s=key1; t=1696165705; h=from:from:sender:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding:resent-cc: resent-from:resent-sender:resent-message-id:list-id:list-help: list-unsubscribe:list-subscribe:list-post:dkim-signature; bh=48Fvv+GhPuVoHbokFJBHDn/LNeH98HLB9OhhRwjSChs=; b=pIb7tzCG700hl5aV8xd7ExSVRGl8VIWEc3fVFKm+REMkMxoL5PUk9/KKTNPdAjBHaOC00l YFeIHltd7GPvlHSzq+cLrgmEFBFsGdT8ykeS1ib8NroHkKw07+A744x5e49MGLf69bIPNu dLfpuVtCjlwjpgubPRb8cT7WXcaPDIGhDTZ3RmyAb4RO1VpzxQxiPMUnTViSpBeCDX0vFn P1zvNj4abePsjLtJFIss856QBEqqtubOBN+FdPN30ItMmPOXu1zT0xfS3nWqe2Q7kvnkwN dg6+hzcHzTc5ArbZ4ZYPylaLkelxvzmZmmY9719UmWRs0tA5nGPuhBHLVIWQcg== ARC-Authentication-Results: i=1; aspmx1.migadu.com; dkim=fail ("headers rsa verify failed") header.d=soeren-tempel.net header.s=opensmtpd header.b=fbg95GBX; spf=pass (aspmx1.migadu.com: domain of "guix-patches-bounces+larch=yhetil.org@gnu.org" designates 209.51.188.17 as permitted sender) smtp.mailfrom="guix-patches-bounces+larch=yhetil.org@gnu.org"; dmarc=fail reason="SPF not aligned (relaxed)" header.from=soeren-tempel.net (policy=none) ARC-Seal: i=1; s=key1; d=yhetil.org; t=1696165705; a=rsa-sha256; cv=none; b=GijcxsTScvwctwcocQ56mFvmAC7SH5Vgsmw3REl5NxH8ehaiA5SAY54LGA9Hwwo5cAR2QS L8/03Xv1u6oNC2CqMyYwqg+52MuFaR183Aht8Ao8VDRz/9Sxjr1ElNGGByDWS8LT6Wt8KJ OUDRjueQ6XGZxb3zP2iLjVqzyE/OTbmHJ3g45rDFlutoJxCs0HCSPKQnDgpISHpl/Eg5tb JDg0LprXdHPlpjph8E+G3UeU2J3gZXYLUjtBRGllbNAAFU/p/W8V7lDq9RX+xnzE7NmbWx dFgLj5WHPQflRcl6w6imPyicbZRx09M+0MleFOL0kkkx6UeVXKiBL5z92fxy5Q== Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1qmwBC-0007cr-Ck; Sun, 01 Oct 2023 09:08:16 -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 ) id 1qmwAm-0007VH-F2 for guix-patches@gnu.org; Sun, 01 Oct 2023 09:07:49 -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 ) id 1qmwAl-0007ls-5v for guix-patches@gnu.org; Sun, 01 Oct 2023 09:07:47 -0400 Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1qmwB0-0007y2-Q5 for guix-patches@gnu.org; Sun, 01 Oct 2023 09:08:02 -0400 X-Loop: help-debbugs@gnu.org Subject: [bug#66296] [PATCH] pack: Allow setting a custom image tag for Docker images Resent-From: soeren@soeren-tempel.net Original-Sender: "Debbugs-submit" Resent-CC: guix-patches@gnu.org Resent-Date: Sun, 01 Oct 2023 13:08:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: report 66296 X-GNU-PR-Package: guix-patches X-GNU-PR-Keywords: patch To: 66296@debbugs.gnu.org X-Debbugs-Original-To: guix-patches@gnu.org Received: via spool by submit@debbugs.gnu.org id=B.169616563230545 (code B ref -1); Sun, 01 Oct 2023 13:08:02 +0000 Received: (at submit) by debbugs.gnu.org; 1 Oct 2023 13:07:12 +0000 Received: from localhost ([127.0.0.1]:60868 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1qmwAB-0007wa-JJ for submit@debbugs.gnu.org; Sun, 01 Oct 2023 09:07:12 -0400 Received: from lists.gnu.org ([2001:470:142::17]:34544) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1qmwA9-0007w1-4p for submit@debbugs.gnu.org; Sun, 01 Oct 2023 09:07:09 -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 ) id 1qmw9k-0007MG-RC for guix-patches@gnu.org; Sun, 01 Oct 2023 09:06:45 -0400 Received: from magnesium.8pit.net ([45.76.88.171]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1qmw9i-0007aW-7z; Sun, 01 Oct 2023 09:06:44 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; s=opensmtpd; bh=k3De1y4apY c1PiMfD833NBP1dFa5SlGFLO/fnSY18qs=; h=date:subject:to:from; d=soeren-tempel.net; b=fbg95GBXDrtnuMN0VFuibu1ip++DY/vsr40EW4C95FlhDWh 9x+OHFcaSzPiQK4ipvkal6OdUKkw/Z+1JHeW4IBT0lqWj/E/ZdsFKIFzAH++9KIwCegLe1 RrkHzqYV6Ph1RcaYdU8rKOfcHB/Fds5iBAG3jycF2nGyveImUvv1AI= Received: from localhost (dynamic-2a02-3102-49da-001b-268f-6598-9e92-70b5.310.pool.telefonica.de [2a02:3102:49da:1b:268f:6598:9e92:70b5]) by magnesium.8pit.net (OpenSMTPD) with ESMTPSA id fffc4d4e (TLSv1.3:TLS_AES_256_GCM_SHA384:256:YES); Sun, 1 Oct 2023 15:06:35 +0200 (CEST) From: soeren@soeren-tempel.net Date: Sun, 1 Oct 2023 15:06:15 +0200 Message-ID: <20231001130615.18132-1-soeren@soeren-tempel.net> X-Mailer: git-send-email 2.42.0 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Received-SPF: pass client-ip=45.76.88.171; envelope-from=soeren@soeren-tempel.net; helo=magnesium.8pit.net X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 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, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list X-BeenThere: guix-patches@gnu.org List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: guix-patches-bounces+larch=yhetil.org@gnu.org Sender: guix-patches-bounces+larch=yhetil.org@gnu.org X-Migadu-Flow: FLOW_IN X-Migadu-Country: US X-Migadu-Spam-Score: -4.10 X-Migadu-Scanner: mx2.migadu.com X-Migadu-Queue-Id: 8F21554EAC X-Spam-Score: -4.10 X-TUID: uO5rLyhXE3xh From: Sören Tempel Previously, the image repository name was automatically computed from the packages in the manifest without allowing the user to set a custom one. As such, changing the packages in the manifest would result in a new image name. Thereby requiring updating documentation et cetera when using `docker load` directory on the resulting image. Inspired by `docker build -t`, this commit adds a new Docker-specific option to `guix pack` which allows setting a custom repository name for the resulting image. If this option is not specified, pack falls back to computing the name from the manifest. Therefore, this change is entirely backwards compatible. * guix/scripts/pack.scm (guix-pack): add --image-tag option * guix/scripts/pack.scm (%docker-format-options): new constant * guix/scripts/pack.scm (show-docker-format-options): new procedure * guix/scripts/pack.scm (show-docker-format-options/detailed): new procedure * guix/scripts/pack.scm (docker-image): allow setting a custom repository name for the created docker image via extra-options. Signed-off-by: Sören Tempel --- guix/scripts/pack.scm | 66 ++++++++++++++++++++++++++++++------------- 1 file changed, 46 insertions(+), 20 deletions(-) diff --git a/guix/scripts/pack.scm b/guix/scripts/pack.scm index 01995c48b7..e7005e7bc6 100644 --- a/guix/scripts/pack.scm +++ b/guix/scripts/pack.scm @@ -507,7 +507,7 @@ (define* (docker-image name profile image is a tarball conforming to the Docker Image Specification, compressed with COMPRESSOR. It can be passed to 'docker load'. If TARGET is true, it must a be a GNU triplet and it is used to derive the architecture metadata in -the image." +the image. EXTRA-OPTIONS may contain the IMAGE-TAG keyword argument." (define database (and localstatedir? (file-append (store-database (list profile)) @@ -531,7 +531,7 @@ (define build (guix build utils) (guix profiles) (guix search-paths) (srfi srfi-1) (srfi srfi-19) - (ice-9 match)) + (ice-9 match) (ice-9 optargs)) #$(procedure-source manifest->friendly-name) @@ -560,23 +560,26 @@ (define directives (setenv "PATH" #+(file-append archiver "/bin")) - (build-docker-image #$output - (map store-info-item - (call-with-input-file "profile" - read-reference-graph)) - #$profile - #:repository (manifest->friendly-name - (profile-manifest #$profile)) - #:database #+database - #:system (or #$target %host-type) - #:environment environment - #:entry-point - #$(and entry-point - #~(list (string-append #$profile "/" - #$entry-point))) - #:extra-files directives - #:compressor #+(compressor-command compressor) - #:creation-time (make-time time-utc 0 1)))))) + (let-keywords '#$extra-options #f + ((image-tag #f)) + (build-docker-image #$output + (map store-info-item + (call-with-input-file "profile" + read-reference-graph)) + #$profile + #:repository (or image-tag + (manifest->friendly-name + (profile-manifest #$profile))) + #:database #+database + #:system (or #$target %host-type) + #:environment environment + #:entry-point + #$(and entry-point + #~(list (string-append #$profile "/" + #$entry-point))) + #:extra-files directives + #:compressor #+(compressor-command compressor) + #:creation-time (make-time time-utc 0 1))))))) (gexp->derivation (string-append name ".tar" (compressor-extension compressor)) @@ -1287,6 +1290,20 @@ (define (required-option symbol) (alist-cons symbol arg result) rest)))) +(define %docker-format-options + (list (required-option 'image-tag))) + +(define (show-docker-format-options) + (display (G_ " + --help-docker-format list options specific to the docker format"))) + +(define (show-docker-format-options/detailed) + (display (G_ " + --image-tag=NAME + Use the given NAME for the Docker image repository")) + (newline) + (exit 0)) + (define %deb-format-options (list (required-option 'control-file) (required-option 'postinst-file) @@ -1407,6 +1424,10 @@ (define %options (lambda (opt name arg result) (alist-cons 'bootstrap? #t result))) + (option '("help-docker-format") #f #f + (lambda args + (show-docker-format-options/detailed))) + (option '("help-deb-format") #f #f (lambda args (show-deb-format-options/detailed))) @@ -1415,7 +1436,8 @@ (define %options (lambda args (show-rpm-format-options/detailed))) - (append %deb-format-options + (append %docker-format-options + %deb-format-options %rpm-format-options %transformation-options %standard-build-options @@ -1433,6 +1455,7 @@ (define (show-help) (newline) (show-transformation-options-help) (newline) + (show-docker-format-options) (show-deb-format-options) (show-rpm-format-options) (newline) @@ -1586,6 +1609,9 @@ (define (process-file-arg opts name) manifest))) (pack-format (assoc-ref opts 'format)) (extra-options (match pack-format + ('docker + (list #:image-tag + (assoc-ref opts 'image-tag))) ('deb (list #:control-file (process-file-arg opts 'control-file)