From patchwork Sat Jun 5 19:18:26 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Xinglu Chen X-Patchwork-Id: 29945 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 029A427BC81; Sat, 5 Jun 2021 21:04:09 +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_SIGNED, MAILING_LIST_MULTI,RCVD_IN_MSPIKE_H4,RCVD_IN_MSPIKE_WL,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 BA46327BC78 for ; Sat, 5 Jun 2021 21:04:08 +0100 (BST) Received: from localhost ([::1]:56220 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1lpcWd-00056D-QW for patchwork@mira.cbaines.net; Sat, 05 Jun 2021 16:04:07 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:49224) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1lpcWX-00055u-T0 for guix-patches@gnu.org; Sat, 05 Jun 2021 16:04:01 -0400 Received: from debbugs.gnu.org ([209.51.188.43]:38531) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1lpcWX-0004hg-Mk for guix-patches@gnu.org; Sat, 05 Jun 2021 16:04:01 -0400 Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1lpcWX-00079f-Mw for guix-patches@gnu.org; Sat, 05 Jun 2021 16:04:01 -0400 X-Loop: help-debbugs@gnu.org Subject: [bug#48852] [PATCH] hg-download: Add helpers for defining packages. Resent-From: Xinglu Chen Original-Sender: "Debbugs-submit" Resent-CC: guix-patches@gnu.org Resent-Date: Sat, 05 Jun 2021 20:04:01 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: report 48852 X-GNU-PR-Package: guix-patches X-GNU-PR-Keywords: patch To: 48852@debbugs.gnu.org X-Debbugs-Original-To: guix-patches@gnu.org Received: via spool by submit@debbugs.gnu.org id=B.162292342027434 (code B ref -1); Sat, 05 Jun 2021 20:04:01 +0000 Received: (at submit) by debbugs.gnu.org; 5 Jun 2021 20:03:40 +0000 Received: from localhost ([127.0.0.1]:50061 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1lpcWC-00078J-2g for submit@debbugs.gnu.org; Sat, 05 Jun 2021 16:03:40 -0400 Received: from lists.gnu.org ([209.51.188.17]:43686) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1lpcW9-00077d-5t for submit@debbugs.gnu.org; Sat, 05 Jun 2021 16:03:38 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:43778) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1lpboa-0005WC-Gm for guix-patches@gnu.org; Sat, 05 Jun 2021 15:18:36 -0400 Received: from h87-96-130-155.cust.a3fiber.se ([87.96.130.155]:53300 helo=mail.yoctocell.xyz) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1lpboY-0001DM-AB for guix-patches@gnu.org; Sat, 05 Jun 2021 15:18:36 -0400 From: Xinglu Chen DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=yoctocell.xyz; s=mail; t=1622920706; bh=q5fEmA04psi8qgMkGf8y88kSAPQlU28W6vnFwH7OnhE=; h=From:To:Subject:Date; b=TFCuSObIAPyy4GTTr9MR9HLrPxIxPDEBJ8Frlv+9hbWmMSACQES9cHyNjLIH25KKj uTA0wd8eJBb/0azJ0AGasUiLzqF6zfhSwLP+Z0r64M8VcEYVaqtAsvP6py0J5EgEov oSKEsw658fEHKpzn/3ldl/I3izZZ7hDkCDGlWsiE= Message-Id: Date: Sat, 05 Jun 2021 21:18:26 +0200 MIME-Version: 1.0 Received-SPF: pass client-ip=87.96.130.155; envelope-from=public@yoctocell.xyz; helo=mail.yoctocell.xyz X-Spam_score_int: 30 X-Spam_score: 3.0 X-Spam_bar: +++ X-Spam_report: (3.0 / 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, FROM_SUSPICIOUS_NTLD=0.498, FROM_SUSPICIOUS_NTLD_FP=1.599, PDS_OTHER_BAD_TLD=1.997, RDNS_DYNAMIC=0.982, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=no 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+patchwork=mira.cbaines.net@gnu.org Sender: "Guix-patches" X-getmail-retrieved-from-mailbox: Patches Hg followup to commit ee17a9e06e636400e3354796a42ac445dbcc8f96. * hg-download.scm (hg-version, hg-file-name): New procedures. --- guix/hg-download.scm | 22 +++++++++++++++++++++- 1 file changed, 21 insertions(+), 1 deletion(-) base-commit: 9da90938c63208b7721276f8cefcdac82ba765f2 diff --git a/guix/hg-download.scm b/guix/hg-download.scm index c6cee2dbb8..9f23e4c40d 100644 --- a/guix/hg-download.scm +++ b/guix/hg-download.scm @@ -1,6 +1,7 @@ ;;; GNU Guix --- Functional package management for GNU ;;; Copyright © 2014, 2015, 2016, 2017, 2019 Ludovic Courtès ;;; Copyright © 2016 Ricardo Wurmus +;;; Copyright © 2021 Xinglu Chen ;;; ;;; This file is part of GNU Guix. ;;; @@ -34,7 +35,9 @@ hg-reference-changeset hg-reference-recursive? hg-predicate - hg-fetch)) + hg-fetch + hg-version + hg-file-name)) ;;; Commentary: ;;; @@ -102,6 +105,23 @@ HASH-ALGO (a symbol). Use NAME as the file name, or a generic name if #f." #:recursive? #t #:guile-for-build guile))) +(define (hg-version version revision changeset) + "Return the version string for packages using hg-download." + ;; hg-version is almost exclusively executed while modules are being loaded. + ;; This makes any errors hide their backtrace. Avoid the mysterious error + ;; "Value out of range 0 to N: 7" when the commit ID is too short, which + ;; can happen, for example, when the user swapped the revision and commit + ;; arguments by mistake. + (when (< (string-length changeset) 7) + (raise + (condition + (&message (message "hg-version: changeset ID unexpectedly short"))))) + (string-append version "-" revision "." (string-take changeset 7))) + +(define (hg-file-name name version) + "Return the file-name for packages using hg-download." + (string-append name "-" version "-checkout")) + (define (hg-file-list directory) "Evaluates to a list of files contained in the repository at path @var{directory}"