From debbugs-submit-bounces@debbugs.gnu.org Mon Jun 21 02:12:51 2021 Received: (at 49149) by debbugs.gnu.org; 21 Jun 2021 06:12:51 +0000 Received: from localhost ([127.0.0.1]:35198 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1lvDAx-0006bN-Gw for submit@debbugs.gnu.org; Mon, 21 Jun 2021 02:12:51 -0400 Received: from mail-qk1-f171.google.com ([209.85.222.171]:35488) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1lvDAv-0006aX-QZ for 49149@debbugs.gnu.org; Mon, 21 Jun 2021 02:12:50 -0400 Received: by mail-qk1-f171.google.com with SMTP id q190so24939267qkd.2 for <49149@debbugs.gnu.org>; Sun, 20 Jun 2021 23:12:49 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=v/TsY7TUeHjjKKjuzsJGN8fmXHrFAsNNkILKEI0FWYI=; b=psYIXNjXvH5cb+0EF/NWbr4FsWM9hxGZtBWYR7uOi1B35tkfUaSjAZXFWKLuFzLsel qtD9Oo39SCICdu3OdDUMmjLu0J5VaDwUS1yJwDi1i0VD0u8hNNPYz+aeYPawpiySTmck gpffgNAyuxZXGMsKN3nZlfz9gtuUDDzYY0Q4sz2DsGaAZlz/SGdcB5vvTeVe5ylnmnM9 2mOPtzaoi4jmF3879rEqkIuK9fMufbdCAKSy/I6h9M3JNECmE9M0+Dtek6UUDUpxVbDO 8EWgq0OGnpASysqFKnyr5gvbWcPRr31UP1Pdq7sKtdO0MociXU2iAZlj3oqvUyjZ7Kiy nhRg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=v/TsY7TUeHjjKKjuzsJGN8fmXHrFAsNNkILKEI0FWYI=; b=hA1ZlTMMIGi5WCY0kYsmKFbcOLu91dk+1fskjEDB2aIZ+GmtipeF6UpT8eXi8kAoDW KJOyxdl20gHd3LlmLS2ggoSxwNiPa5ItiwolS/opd+OIWcKjnsaBltCAXAOKzWLNfYo4 zfvytCer1sfcn6h7dpBIs3TENhMQmX4PlFpZMU8brm43UqEG2fE7OXlOtiH83A6u9h71 UeM4ZUSpToAK52WBD0kgAqch/tQkLKCNSKEjWjouC/KUGb51L90V/7Z7/TvImK25iSTR 0O3l9+VQd4o0FBDKXDfFPoMmPsqxCvCuEAwCTJK5Qx6a0NzF+SLWKMcZi010RDedVsd6 v7oA== X-Gm-Message-State: AOAM532VOpkz029g2eZxwWrNBFBWbytR8geNsRohhVQLOuGCNY0vCaqR HDK6QccmmhT0GnEtCXhRejk5J5CEp+B2Jw== X-Google-Smtp-Source: ABdhPJzbtxaphj68wsORpAEvS4vDRtmaaEqjsmZG3TITxky8WVa0EdK3ORNaU1OUejpORE+NrW0/qA== X-Received: by 2002:a37:b881:: with SMTP id i123mr21390929qkf.207.1624255964252; Sun, 20 Jun 2021 23:12:44 -0700 (PDT) Received: from localhost.localdomain (dsl-148-219.b2b2c.ca. [66.158.148.219]) by smtp.gmail.com with ESMTPSA id i11sm8478663qke.74.2021.06.20.23.12.43 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 20 Jun 2021 23:12:44 -0700 (PDT) From: Maxim Cournoyer To: 49149@debbugs.gnu.org Subject: [PATCH 4/7] pack: Improve naming of the packs store file names. Date: Mon, 21 Jun 2021 02:12:02 -0400 Message-Id: <20210621061205.31878-5-maxim.cournoyer@gmail.com> X-Mailer: git-send-email 2.32.0 In-Reply-To: <20210621061205.31878-1-maxim.cournoyer@gmail.com> References: <20210621061205.31878-1-maxim.cournoyer@gmail.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Spam-Score: 0.0 (/) X-Debbugs-Envelope-To: 49149 Cc: Maxim Cournoyer X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -1.0 (-) Instead of just naming them by their pack type, add information from the package(s) they contain to make it easier to differentiate them. * guix/scripts/pack.scm (manifest->friendly-name): Extract procedure from ... (docker-image): ... here. Adjust REPOSITORY argument value accordingly. (guix-pack): Derive NAME using MANIFEST->FRIENDLY-NAME. --- guix/scripts/pack.scm | 44 +++++++++++++++++++++++++------------------ 1 file changed, 26 insertions(+), 18 deletions(-) diff --git a/guix/scripts/pack.scm b/guix/scripts/pack.scm index 7ea97a4b7a..9d4bb9f497 100644 --- a/guix/scripts/pack.scm +++ b/guix/scripts/pack.scm @@ -172,6 +172,23 @@ dependencies are registered." (computed-file "store-database" build #:options `(#:references-graphs ,(zip labels items)))) +;;; XXX: The following procedure has to *also* be used in the build side +;;; G-Exp, because PROFILE is passed as a derivation in the tests. +(define define-manifest->friendly-name + '(define (manifest->friendly-name manifest) + "Return a friendly name computed from the entries in MANIFEST, a + object." + (let loop ((names (map manifest-entry-name + (manifest-entries manifest)))) + (define str (string-join names "-")) + (if (< (string-length str) 40) + str + (match names + ((_) str) + ((names ... _) (loop names))))))) ;drop one entry + +(eval define-manifest->friendly-name (current-module)) + ;;; ;;; Tarball format. @@ -540,7 +557,7 @@ the image." (file-append (store-database (list profile)) "/db/db.sqlite"))) - (define defmod 'define-module) ;trick Geiser + (define defmod 'define-module) ;trick Geiser (define build ;; Guile-JSON and Guile-Gcrypt are required by (guix docker). @@ -558,6 +575,8 @@ the image." (srfi srfi-1) (srfi srfi-19) (ice-9 match)) + #$define-manifest->friendly-name + (define environment (map (match-lambda ((spec . value) @@ -581,19 +600,6 @@ the image." `((directory "/tmp" ,(getuid) ,(getgid) #o1777) ,@(append-map symlink->directives '#$symlinks))) - (define tag - ;; Compute a meaningful "repository" name, which will show up in - ;; the output of "docker images". - (let ((manifest (profile-manifest #$profile))) - (let loop ((names (map manifest-entry-name - (manifest-entries manifest)))) - (define str (string-join names "-")) - (if (< (string-length str) 40) - str - (match names - ((_) str) - ((names ... _) (loop names))))))) ;drop one entry - (setenv "PATH" #+(file-append archiver "/bin")) (build-docker-image #$output @@ -601,7 +607,8 @@ the image." (call-with-input-file "profile" read-reference-graph)) #$profile - #:repository tag + #:repository (manifest->friendly-name + (profile-manifest #$profile)) #:database #+database #:system (or #$target %host-type) #:environment environment @@ -1209,8 +1216,6 @@ Create a bundle of PACKAGE.\n")) manifest) manifest))) (pack-format (assoc-ref opts 'format)) - (name (string-append (symbol->string pack-format) - "-pack")) (target (assoc-ref opts 'target)) (bootstrap? (assoc-ref opts 'bootstrap?)) (compressor (if bootstrap? @@ -1244,7 +1249,10 @@ Create a bundle of PACKAGE.\n")) (hooks (if bootstrap? '() %default-profile-hooks)) - (locales? (not bootstrap?))))) + (locales? (not bootstrap?)))) + (name (string-append (manifest->friendly-name manifest) + "-" (symbol->string pack-format) + "-pack"))) (define (lookup-package package) (manifest-lookup manifest (manifest-pattern (name package)))) -- 2.32.0