From patchwork Sun Jul 4 03:21:05 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Maxim Cournoyer X-Patchwork-Id: 31123 Return-Path: X-Original-To: patchwork@mira.cbaines.net Delivered-To: patchwork@mira.cbaines.net Received: by mira.cbaines.net (Postfix, from userid 113) id 3CEC727BC81; Sun, 4 Jul 2021 04:22:10 +0100 (BST) X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on mira.cbaines.net X-Spam-Level: X-Spam-Status: No, score=-2.8 required=5.0 tests=BAYES_00,DKIM_ADSP_CUSTOM_MED, DKIM_SIGNED,FREEMAIL_FROM,MAILING_LIST_MULTI,SPF_HELO_PASS, T_DKIM_INVALID,URIBL_BLOCKED autolearn=unavailable autolearn_force=no version=3.4.2 Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mira.cbaines.net (Postfix) with ESMTPS id ADD3227BC78 for ; Sun, 4 Jul 2021 04:22:09 +0100 (BST) Received: from localhost ([::1]:58020 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1lzshs-00021h-NM for patchwork@mira.cbaines.net; Sat, 03 Jul 2021 23:22:08 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:35310) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1lzshm-00021D-Vc for guix-patches@gnu.org; Sat, 03 Jul 2021 23:22:03 -0400 Received: from debbugs.gnu.org ([209.51.188.43]:56958) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1lzshm-0002MV-KZ for guix-patches@gnu.org; Sat, 03 Jul 2021 23:22:02 -0400 Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1lzshm-00016J-FL for guix-patches@gnu.org; Sat, 03 Jul 2021 23:22:02 -0400 X-Loop: help-debbugs@gnu.org Subject: [bug#49149] [PATCH 0/7] Add deb format for guix pack. Resent-From: Maxim Cournoyer Original-Sender: "Debbugs-submit" Resent-CC: guix-patches@gnu.org Resent-Date: Sun, 04 Jul 2021 03:22:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 49149 X-GNU-PR-Package: guix-patches X-GNU-PR-Keywords: patch To: Ludovic =?utf-8?q?Court=C3=A8s?= Cc: 49149@debbugs.gnu.org Received: via spool by 49149-submit@debbugs.gnu.org id=B49149.16253688934197 (code B ref 49149); Sun, 04 Jul 2021 03:22:02 +0000 Received: (at 49149) by debbugs.gnu.org; 4 Jul 2021 03:21:33 +0000 Received: from localhost ([127.0.0.1]:40271 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1lzshI-00015c-Na for submit@debbugs.gnu.org; Sat, 03 Jul 2021 23:21:33 -0400 Received: from mail-qt1-f180.google.com ([209.85.160.180]:42710) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1lzshG-00015O-V0 for 49149@debbugs.gnu.org; Sat, 03 Jul 2021 23:21:31 -0400 Received: by mail-qt1-f180.google.com with SMTP id y9so9805779qtx.9 for <49149@debbugs.gnu.org>; Sat, 03 Jul 2021 20:21:30 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:references:date:in-reply-to:message-id :user-agent:mime-version; bh=3LW5qOIQzLoOmwa5CsdRAvMhJB46amBkS8GFCcCKk+U=; b=fa5exlurQP6ecQ3PtMBh1EM4vo2OfVO+F9qIb2v/a0aR6umEuo0FOw9lF4+sLVncps VBbSWWYs5pr/dLmLsqqbA/wZj9lBXhg6jsvBCwW2kPx37hhNXGY1vnU7C71kgN6yQ6R+ 0FbSuniUVRJhLtljB9Hi4gKQbbU5HVdOOeg/RTzwlTmtcJ+n9xzWlz5djJG0ULKAmWz5 AnDSpaikQMSetDswbYJQuVDFmhnyVw5hepzXaFbJama79WuUwO2CdQmuJ86uTiir4yBI uDJxTCGqToUFka/rxJIQ3sUwzOJw5JaaamLsBnvW0frFaNUe4XehuDsbbtJxfqIQgaVJ nxuQ== 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:references:date:in-reply-to :message-id:user-agent:mime-version; bh=3LW5qOIQzLoOmwa5CsdRAvMhJB46amBkS8GFCcCKk+U=; b=sCZpxz9UiEXknAS5bBxykRCuPJJpjLeMJI0snUirTef1NoNVR5sGGVpNbw7Abnl+fQ sv3ScymDRXYNkNgjHqwKgyxs5vO/VyUwQ3C6JX8zvMA7NBvC+N9LXalU9PC5D3AWpMRt M5KwpyqaxKywFu+WCXFEUdxPRwwWWfJyhpXBuWNHUreCB5+uc6Jdh/6PTFkcyCEuowIU iSQdyVrj75uz38RHTNsC6rRtECfqNyZjey4I7M01Ji6Jg//dzW3m6vaOC5dbpcx/CBjI 9IdbNy6IXhSsbpKNxzeuZDzEZaE6UiQNr994SlXByuZ/zEETgiVuBj8ftNkf4aife/cb knbw== X-Gm-Message-State: AOAM5338HGwcsVsDXUCHhADNpHoUEWZTYesfVJXaheqsrjyvYLW5nFY1 I9ZVwriA9fJnsSUfbW96vQpTw9UDxbEOHg== X-Google-Smtp-Source: ABdhPJysELW56Bz5X1ys3vdMShYTtR82qu9hRT8Prl7ua85Z+4SC8DUmMvDbO1QRoDPXUOZycNI9+A== X-Received: by 2002:ac8:5813:: with SMTP id g19mr6922879qtg.383.1625368884111; Sat, 03 Jul 2021 20:21:24 -0700 (PDT) Received: from hurd (dsl-10-132-56.b2b2c.ca. [72.10.132.56]) by smtp.gmail.com with ESMTPSA id e1sm3117211qti.27.2021.07.03.20.21.22 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 03 Jul 2021 20:21:23 -0700 (PDT) From: Maxim Cournoyer References: <20210624044049.17906-1-maxim.cournoyer@gmail.com> <20210624044049.17906-4-maxim.cournoyer@gmail.com> <87lf6roe32.fsf_-_@gnu.org> <8735sz42tc.fsf@gmail.com> <87bl7mkvvu.fsf@gnu.org> Date: Sat, 03 Jul 2021 23:21:05 -0400 In-Reply-To: <87bl7mkvvu.fsf@gnu.org> ("Ludovic =?utf-8?q?Court=C3=A8s?= "'s message of "Thu, 01 Jul 2021 15:26:45 +0200") Message-ID: <87zgv2228u.fsf@gmail.com> User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/27.2 (gnu/linux) MIME-Version: 1.0 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+patchwork=mira.cbaines.net@gnu.org Sender: "Guix-patches" X-getmail-retrieved-from-mailbox: Patches Hi! Ludovic Courtès writes: > Hi, > > Maxim Cournoyer skribis: > >> Ludovic Courtès writes: >> >>> Maxim Cournoyer skribis: >>> >>>> 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 (define-with-source): New macro. >>>> (manifest->friendly-name): Extract procedure from ... >>>> (docker-image): ... here, now defined via the above macro. Adjust REPOSITORY >>>> argument value accordingly. >>>> (guix-pack): Derive NAME using MANIFEST->FRIENDLY-NAME. >>> >>> [...] >>> >>>> - (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 >>> >>> I think this should not be factorized because the requirements are very >>> Docker-dependent. Once factorized, it becomes easy to overlook this. >> >> Hmm, I'm not a docker format expert, but my quick reading about it >> turned no restrictions about what a docker image label should look like? >> So perhaps it is not specially Docker-dependent. > > It’s a hack specifically written with Docker repository names in mind, > and the 40-or-so character limit, for instance. The actual name length requirement for a Docker repository name seems to be that it must be between 2 and 255 characters [0]; the attached patch ensure that this is respected. > To me it’s a case where factorization isn’t beneficial. Even if there’s > a similar procedure used in a different context, it’s still a different > context with different constraints. My 2¢! It seems to me that with the attached patch we get to share what used to be a Docker-specific abstraction without any added risk (have our cake and it eat to!). What do you think? Thanks, Maxim From f3dc90213423bf0a087245bd4bfc8c4a828d4df1 Mon Sep 17 00:00:00 2001 From: Maxim Cournoyer Date: Sat, 3 Jul 2021 23:08:15 -0400 Subject: [PATCH] guix: docker: Ensure repository name length limits are met. MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * guix/docker.scm (canonicalize-repository-name): Fix typo in doc. Capture repository name length limits and ensure they are met, by either truncating or padding the normalized name. Reported-by: Ludovic Courtès --- guix/docker.scm | 28 ++++++++++++++++++++++------ 1 file changed, 22 insertions(+), 6 deletions(-) diff --git a/guix/docker.scm b/guix/docker.scm index bd952e45ec..4239ccdf9c 100644 --- a/guix/docker.scm +++ b/guix/docker.scm @@ -2,6 +2,7 @@ ;;; Copyright © 2017 Ricardo Wurmus ;;; Copyright © 2017, 2018, 2019, 2021 Ludovic Courtès ;;; Copyright © 2018 Chris Marusich +;;; Copyright © 2021 Maxim Cournoyer ;;; ;;; This file is part of GNU Guix. ;;; @@ -59,8 +60,13 @@ (container_config . #nil))) (define (canonicalize-repository-name name) - "\"Repository\" names are restricted to roughtl [a-z0-9_.-]. + "\"Repository\" names are restricted to roughly [a-z0-9_.-]. Return a version of TAG that follows these rules." + ;; Refer to https://docs.docker.com/docker-hub/repos/. + (define min-length 2) + (define padding-character #\a) + (define max-length 255) + (define ascii-letters (string->char-set "abcdefghijklmnopqrstuvwxyz")) @@ -70,11 +76,21 @@ Return a version of TAG that follows these rules." (define repo-char-set (char-set-union char-set:digit ascii-letters separators)) - (string-map (lambda (chr) - (if (char-set-contains? repo-char-set chr) - chr - #\.)) - (string-trim (string-downcase name) separators))) + (define normalized-name + (string-map (lambda (chr) + (if (char-set-contains? repo-char-set chr) + chr + #\.)) + (string-trim (string-downcase name) separators))) + + (let ((l (string-length normalized-name))) + (match l + ((? (cut > <> max-length)) + (string-take normalized-name max-length)) + ((? (cut < <> min-length )) + (string-append normalized-name + (make-string (- min-length l) padding-character))) + (_ normalized-name)))) (define* (manifest path id #:optional (tag "guix")) "Generate a simple image manifest." -- 2.32.0