From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mp1 ([2001:41d0:2:bcc0::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by ms0.migadu.com with LMTPS id cOpKFGMp4WDMPwAAgWs5BA (envelope-from ) for ; Sun, 04 Jul 2021 05:22:11 +0200 Received: from aspmx1.migadu.com ([2001:41d0:2:bcc0::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by mp1 with LMTPS id aIv8D2Mp4WBbHAAAbx9fmQ (envelope-from ) for ; Sun, 04 Jul 2021 03:22:11 +0000 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 829531A40F for ; Sun, 4 Jul 2021 05:22:10 +0200 (CEST) Received: from localhost ([::1]:58020 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1lzsht-00021h-Fb for larch@yhetil.org; Sat, 03 Jul 2021 23:22:09 -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 Content-Type: multipart/mixed; boundary="=-=-=" 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" X-Migadu-Flow: FLOW_IN ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=yhetil.org; s=key1; t=1625368931; h=from:from:sender:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type:resent-cc:resent-from:resent-sender: resent-message-id:in-reply-to:in-reply-to:references:references: list-id:list-help:list-unsubscribe:list-subscribe:list-post: dkim-signature; bh=3LW5qOIQzLoOmwa5CsdRAvMhJB46amBkS8GFCcCKk+U=; b=PjKSl3HE6LMez2D1ya42qWIhkBQelbaEtZqEMSHsMB1hnU4r80tmzw9CzQIGagn2lqdng9 RsaUpCH3BVg6h8THO5pSzbekAv5rQ57ul5/Xiglckx0V4+b5C5uYa408V1BG+fEe3AAIql hDUUvCBwM+yzyhhpueXkYpMjNBezc4f3xm43Db8B8FlczQcVNhAWxTR75SSEUxYCQ8pcSb 591fWUQFlsRFFOI1Unb1M874EXLmBHlFNgEkoqbulIoTEP75cUBXsd8OhLDkDlrEToxXAS G6eeXLKpcoNCIUJKzOkV6ZmUgHRTX4l5p9NecCfG8Vl6mcd/SYXkI3Riz0jXcg== ARC-Seal: i=1; s=key1; d=yhetil.org; t=1625368931; a=rsa-sha256; cv=none; b=Rx5BPcbT/bL4Jhr2Lz5u029sE302Cxl/gvLPlPlna31oWrh3wg06PkP3QeW/eqZEEp2sa3 FZ/+vX+HhSA2bakgCcD/FOJx+Cac4cyeAYV7zmPVxSEp20IzvjsIXSel75rE0yd8ZYgz90 KymNyFeWQfBT5txZY1pZOOrtVOStF6fpTWlcvnAysPJ93qj54zOPcpNdV5eVB/BZDNQ8dG 5IGkhrS5EY4vGi0KHI3snepNBmh3waqhI18FMgqGv9ngHPdiTCjlTlQS7r20Xx/ntUl6Eu u7tJd7PYRYdzCqDE8fCOTnHORzZGPVLUuQPEOtud/ZCNJ5l22qcUZj9kxlBgLw== ARC-Authentication-Results: i=1; aspmx1.migadu.com; dkim=fail ("headers rsa verify failed") header.d=gmail.com header.s=20161025 header.b=fa5exlur; dmarc=fail reason="SPF not aligned (relaxed)" header.from=gmail.com (policy=none); spf=pass (aspmx1.migadu.com: domain of guix-patches-bounces@gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=guix-patches-bounces@gnu.org X-Migadu-Spam-Score: -1.31 Authentication-Results: aspmx1.migadu.com; dkim=fail ("headers rsa verify failed") header.d=gmail.com header.s=20161025 header.b=fa5exlur; dmarc=fail reason="SPF not aligned (relaxed)" header.from=gmail.com (policy=none); spf=pass (aspmx1.migadu.com: domain of guix-patches-bounces@gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=guix-patches-bounces@gnu.org X-Migadu-Queue-Id: 829531A40F X-Spam-Score: -1.31 X-Migadu-Scanner: scn0.migadu.com X-TUID: QJkj3z7EuyPQ --=-=-= Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable Hi! Ludovic Court=C3=A8s writes: > Hi, > > Maxim Cournoyer skribis: > >> Ludovic Court=C3=A8s writes: >> >>> Maxim Cournoyer skribis: >>> >>>> Instead of just naming them by their pack type, add information from t= he >>>> 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 REP= OSITORY >>>> argument value accordingly. >>>> (guix-pack): Derive NAME using MANIFEST->FRIENDLY-NAME. >>> >>> [...] >>> >>>> - (define tag >>>> - ;; Compute a meaningful "repository" name, which will s= how 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 e= ntry >>> >>> 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=E2=80=99s 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=E2=80=99s a case where factorization isn=E2=80=99t beneficial. = Even if there=E2=80=99s > a similar procedure used in a different context, it=E2=80=99s still a dif= ferent > context with different constraints. My 2=C2=A2! 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 --=-=-= Content-Type: text/x-patch; charset=utf-8 Content-Disposition: attachment; filename=0001-guix-docker-Ensure-repository-name-length-limits-are.patch Content-Transfer-Encoding: quoted-printable >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=3DUTF-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=C3=A8s --- 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 =C2=A9 2017 Ricardo Wurmus ;;; Copyright =C2=A9 2017, 2018, 2019, 2021 Ludovic Court=C3=A8s ;;; Copyright =C2=A9 2018 Chris Marusich +;;; Copyright =C2=A9 2021 Maxim Cournoyer ;;; ;;; This file is part of GNU Guix. ;;; @@ -59,8 +60,13 @@ (container_config . #nil))) =20 (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")) =20 @@ -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)) =20 - (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)))) =20 (define* (manifest path id #:optional (tag "guix")) "Generate a simple image manifest." --=20 2.32.0 --=-=-=--