From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mp2 ([2001:41d0:2:4a6f::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by ms11 with LMTPS id YBHeI/1ZCmCSYQAA0tVLHw (envelope-from ) for ; Fri, 22 Jan 2021 04:52:13 +0000 Received: from aspmx1.migadu.com ([2001:41d0:2:4a6f::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by mp2 with LMTPS id xbSxH/1ZCmALcgAAB5/wlQ (envelope-from ) for ; Fri, 22 Jan 2021 04:52:13 +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 9F613940415 for ; Fri, 22 Jan 2021 04:52:11 +0000 (UTC) Received: from localhost ([::1]:50410 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1l2oQc-0001m5-KN for larch@yhetil.org; Thu, 21 Jan 2021 23:52:10 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:49662) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1l2oQU-0001l4-FF for guix-patches@gnu.org; Thu, 21 Jan 2021 23:52:02 -0500 Received: from debbugs.gnu.org ([209.51.188.43]:48342) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1l2oQU-0003Ze-7V for guix-patches@gnu.org; Thu, 21 Jan 2021 23:52:02 -0500 Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1l2oQU-0004VW-6W for guix-patches@gnu.org; Thu, 21 Jan 2021 23:52:02 -0500 X-Loop: help-debbugs@gnu.org Subject: [bug#46028] [PATCH core-updates 1/2] utils: Add a version-minor procedure. References: <20210122044816.30058-1-maxim.cournoyer@gmail.com> In-Reply-To: <20210122044816.30058-1-maxim.cournoyer@gmail.com> Resent-From: Maxim Cournoyer Original-Sender: "Debbugs-submit" Resent-CC: guix-patches@gnu.org Resent-Date: Fri, 22 Jan 2021 04:52:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 46028 X-GNU-PR-Package: guix-patches X-GNU-PR-Keywords: patch To: 46028@debbugs.gnu.org Received: via spool by 46028-submit@debbugs.gnu.org id=B46028.161129108417268 (code B ref 46028); Fri, 22 Jan 2021 04:52:02 +0000 Received: (at 46028) by debbugs.gnu.org; 22 Jan 2021 04:51:24 +0000 Received: from localhost ([127.0.0.1]:59885 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1l2oPs-0004US-3F for submit@debbugs.gnu.org; Thu, 21 Jan 2021 23:51:24 -0500 Received: from mail-qt1-f172.google.com ([209.85.160.172]:41855) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1l2oPr-0004UE-6t for 46028@debbugs.gnu.org; Thu, 21 Jan 2021 23:51:23 -0500 Received: by mail-qt1-f172.google.com with SMTP id j26so3312590qtq.8 for <46028@debbugs.gnu.org>; Thu, 21 Jan 2021 20:51:23 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=BnUvdc6F7dARSUrR/n00PIxJaMIUGiN35ztDYge8pag=; b=sdaEQ0n8HnNiPdT+8imHMxddgJ4bMNTWiEEa6lHVO5CMtoz+eAHl4yhvzCif++rr7N Y2nHH8mdMdClgMFqN0KwbaCcWqa0u+olvfC/dsF7c/5NHUtkyFUMeDJWy5V+j1ejEOFt dCCB9wr7/aZmhEhs4MkP3HYep6vT7LvZXRdlEt1/9fhaE+Tem3rg2p8hZJTtR0rcPJvF gfJo0SaBWMuFWuAmiqb7M6HEq3Y8Tu0OGkBAHNmhQBL99a8hJkBCAjA4Be2XTvdZchvE 1B3W1l+M7MxpL0iqW7jzx9duoJHr5zHZWQUm0uavexbj7roLJt/hM7xF5Wb7ybNpZ62c /SVQ== 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:mime-version :content-transfer-encoding; bh=BnUvdc6F7dARSUrR/n00PIxJaMIUGiN35ztDYge8pag=; b=m7NLBQ8/MWixIS3lZEuvSAytt5RPuFRRf8IAILgNri3zVbiIYOBDPar8c6OSmPPulw lj7dcvI13td6cBov4RB2LFVl2RT0kCLfksttvSpLu9jLiYUSCBI7Wgv7lGD8Gqiarue6 Xyrn0SgFeJfYE5NDhFwYrCQ+fsAPR1MVd0rPTEkqZhY93sjnEGyhGG2bkxrldt7IJgbJ hzx7DzKWwnxBFoSUnilqBp/yI07zlK8MjIFKO9gKNq/hOp+25aNfX/ZLF2zBLzXpgr2Q gntCzp1EAUR8j2f77CvKGlEKOMG4CH7F2oRDjJKIerK/f1pIsBFWsrFjWguYGhmULzkV GatQ== X-Gm-Message-State: AOAM5328hMxHk+7oCCdmJxzBBQlBvx1HaIY3vDkQFITZzgzDbwED/C+r HSKiRFkA2Gfb6wn7fQ+I4j4caEJkgsM= X-Google-Smtp-Source: ABdhPJxiMBa2JLKH60R7QTj7Oh6PkfKBDUMUyWvhgWAVHpeJKqqR1IuMqDJS3X5VjEKPGu0LZLeQ/g== X-Received: by 2002:ac8:782:: with SMTP id l2mr2813930qth.271.1611291077360; Thu, 21 Jan 2021 20:51:17 -0800 (PST) Received: from localhost.localdomain (dsl-152-143.b2b2c.ca. [66.158.152.143]) by smtp.gmail.com with ESMTPSA id h8sm5162004qtm.5.2021.01.21.20.51.16 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 21 Jan 2021 20:51:16 -0800 (PST) From: Maxim Cournoyer Date: Thu, 21 Jan 2021 23:51:03 -0500 Message-Id: <20210122045104.30229-1-maxim.cournoyer@gmail.com> X-Mailer: git-send-email 2.29.2 MIME-Version: 1.0 Content-Type: text/plain; charset=yes Content-Transfer-Encoding: 8bit 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 X-Migadu-Spam-Score: -1.25 Authentication-Results: aspmx1.migadu.com; dkim=fail ("headers rsa verify failed") header.d=gmail.com header.s=20161025 header.b=sdaEQ0n8; 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: 9F613940415 X-Spam-Score: -1.25 X-Migadu-Scanner: scn0.migadu.com X-TUID: OARQZIRwi9Dv * guix/utils.scm (version-components): New procedure. (version-prefix): Use it. (version-major): Likewise. (version-minor): New procedure. --- guix/utils.scm | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) diff --git a/guix/utils.scm b/guix/utils.scm index 678954dbfa..cd4e595f7e 100644 --- a/guix/utils.scm +++ b/guix/utils.scm @@ -8,7 +8,7 @@ ;;; Copyright © 2017 Mathieu Othacehe ;;; Copyright © 2018, 2020 Marius Bakke ;;; Copyright © 2020 Efraim Flashner -;;; Copyright © 2020 Maxim Cournoyer +;;; Copyright © 2020, 2021 Maxim Cournoyer ;;; ;;; This file is part of GNU Guix. ;;; @@ -93,6 +93,7 @@ version-major+minor+point version-major+minor version-major + version-minor guile-version>? version-prefix? string-replace-substring @@ -573,10 +574,14 @@ or '= when they denote equal versions." ((negative? result) '<) (else '=)))))) +(define (version-components version-string) + "Return the dot-separated version components as a list." + (string-split version-string #\.)) + (define (version-prefix version-string num-parts) "Truncate version-string to the first num-parts components of the version. For example, (version-prefix \"2.1.47.4.23\" 3) returns \"2.1.47\"" - (string-join (take (string-split version-string #\.) num-parts) ".")) + (string-join (take (version-components version-string) num-parts) ".")) (define (version-major+minor+point version-string) "Return \"major>..\", where major, minor and point are the @@ -595,7 +600,11 @@ minor version numbers from version-string." (define (version-major version-string) "Return the major version number as string from the version-string." - (version-prefix version-string 1)) + (first (version-components version-string))) + +(define (version-minor version-string) + "Return the minor version number as string from the version-string." + (second (version-components version-string))) (define (version>? a b) "Return #t when A denotes a version strictly newer than B." -- 2.29.2