GNU logs - #36662, boring messages


Message sent to guix-patches@HIDDEN:


X-Loop: help-debbugs@HIDDEN
Subject: [bug#36662] [PATCH] guix import: Add proper guix-hash-url
Resent-From: Robert Vollmert <rob@HIDDEN>
Original-Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org>
Resent-CC: guix-patches@HIDDEN
Resent-Date: Mon, 15 Jul 2019 11:00:03 +0000
Resent-Message-ID: <handler.36662.B.15631883972738 <at> debbugs.gnu.org>
Resent-Sender: help-debbugs@HIDDEN
X-GNU-PR-Message: report 36662
X-GNU-PR-Package: guix-patches
X-GNU-PR-Keywords: patch
To: 36662 <at> debbugs.gnu.org
Cc: Robert Vollmert <rob@HIDDEN>
X-Debbugs-Original-To: guix-patches@HIDDEN
Received: via spool by submit <at> debbugs.gnu.org id=B.15631883972738
          (code B ref -1); Mon, 15 Jul 2019 11:00:03 +0000
Received: (at submit) by debbugs.gnu.org; 15 Jul 2019 10:59:57 +0000
Received: from localhost ([127.0.0.1]:46583 helo=debbugs.gnu.org)
	by debbugs.gnu.org with esmtp (Exim 4.84_2)
	(envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>)
	id 1hmyi5-0000i4-BY
	for submit <at> debbugs.gnu.org; Mon, 15 Jul 2019 06:59:57 -0400
Received: from lists.gnu.org ([209.51.188.17]:40451)
 by debbugs.gnu.org with esmtp (Exim 4.84_2)
 (envelope-from <rob@HIDDEN>) id 1hmyi1-0000ht-0Z
 for submit <at> debbugs.gnu.org; Mon, 15 Jul 2019 06:59:53 -0400
Received: from eggs.gnu.org ([2001:470:142:3::10]:43475)
 by lists.gnu.org with esmtp (Exim 4.86_2)
 (envelope-from <rob@HIDDEN>) id 1hmyhz-0007vw-4z
 for guix-patches@HIDDEN; Mon, 15 Jul 2019 06:59:52 -0400
X-Spam-Checker-Version: SpamAssassin 3.3.2 (2011-06-06) on eggs.gnu.org
X-Spam-Level: 
X-Spam-Status: No, score=0.1 required=5.0 tests=BAYES_50,RCVD_IN_DNSWL_LOW
 autolearn=disabled version=3.3.2
Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71)
 (envelope-from <rob@HIDDEN>) id 1hmyhx-0000ml-Jo
 for guix-patches@HIDDEN; Mon, 15 Jul 2019 06:59:51 -0400
Received: from mx2.mailbox.org ([80.241.60.215]:47000)
 by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_256_CBC_SHA1:32)
 (Exim 4.71) (envelope-from <rob@HIDDEN>) id 1hmyhx-0000mQ-AV
 for guix-patches@HIDDEN; Mon, 15 Jul 2019 06:59:49 -0400
Received: from smtp2.mailbox.org (smtp2.mailbox.org [80.241.60.241])
 (using TLSv1.2 with cipher ECDHE-RSA-CHACHA20-POLY1305 (256/256 bits))
 (No client certificate requested)
 by mx2.mailbox.org (Postfix) with ESMTPS id 2A481A1069;
 Mon, 15 Jul 2019 12:59:47 +0200 (CEST)
X-Virus-Scanned: amavisd-new at heinlein-support.de
Received: from smtp2.mailbox.org ([80.241.60.241])
 by hefe.heinlein-support.de (hefe.heinlein-support.de [91.198.250.172])
 (amavisd-new, port 10030)
 with ESMTP id 1WRBg0s7Mt1n; Mon, 15 Jul 2019 12:59:45 +0200 (CEST)
From: Robert Vollmert <rob@HIDDEN>
Date: Mon, 15 Jul 2019 12:59:33 +0200
Message-Id: <20190715105933.23964-1-rob@HIDDEN>
MIME-Version: 1.0
Content-Transfer-Encoding: quoted-printable
X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic]
X-Received-From: 80.241.60.215
X-Spam-Score: -1.6 (-)
X-BeenThere: debbugs-submit <at> debbugs.gnu.org
X-Mailman-Version: 2.1.18
Precedence: list
List-Id: <debbugs-submit.debbugs.gnu.org>
List-Unsubscribe: <https://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe>
List-Archive: <https://debbugs.gnu.org/cgi-bin/mailman/private/debbugs-submit/>
List-Post: <mailto:debbugs-submit <at> debbugs.gnu.org>
List-Help: <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=help>
List-Subscribe: <https://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=subscribe>
Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org
Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org>
X-Spam-Score: -2.6 (--)

* guix/import/utils.scm (guix-hash-url): Rename to...
(guix-hash-file): this.
(guix-hash-url): New function that does what it's called.
* guix/import/opam.scm (opam->guix-package): Use guix-hash-url.
* tests/opam.scm: Mock guix-hash-url instead.
---
 guix/import/opam.scm  | 65 +++++++++++++++--------------
 guix/import/utils.scm | 12 +++++-
 tests/opam.scm        | 95 ++++++++++++++++++++-----------------------
 3 files changed, 87 insertions(+), 85 deletions(-)

diff --git a/guix/import/opam.scm b/guix/import/opam.scm
index 5dcc0e97a3..724302d0c5 100644
--- a/guix/import/opam.scm
+++ b/guix/import/opam.scm
@@ -263,39 +263,38 @@ path to the repository."
         ;; If one of these are required at build time, it means we
         ;; can use the much nicer dune-build-system.
         (let ((use-dune? (or (member "dune" native-dependencies)
-                        (member "jbuilder" native-dependencies))))
-          (call-with-temporary-output-file
-            (lambda (temp port)
-              (and (url-fetch source-url temp)
-                   (values
-                    `(package
-                       (name ,(ocaml-name->guix-name name))
-                       (version ,(if (string-prefix? "v" version)
-                                   (substring version 1)
-                                   version))
-                       (source
-                         (origin
-                           (method url-fetch)
-                           (uri ,source-url)
-                           (sha256 (base32 ,(guix-hash-url temp)))))
-                       (build-system ,(if use-dune?
-                                          'dune-build-system
-                                          'ocaml-build-system))
-                       ,@(if (null? inputs)
-                           '()
-                           `((inputs ,(list 'quasiquote inputs))))
-                       ,@(if (null? native-inputs)
-                           '()
-                           `((native-inputs ,(list 'quasiquote native-in=
puts))))
-                       ,@(if (equal? name (guix-name->opam-name (ocaml-n=
ame->guix-name name)))
-                           '()
-                           `((properties
-                               ,(list 'quasiquote `((upstream-name . ,na=
me))))))
-                       (home-page ,(metadata-ref opam-content "homepage"=
))
-                       (synopsis ,(metadata-ref opam-content "synopsis")=
)
-                       (description ,(metadata-ref opam-content "descrip=
tion"))
-                       (license #f))
-                    dependencies)))))))
+                        (member "jbuilder" native-dependencies)))
+              (hash (guix-hash-url source-url)))
+          (and hash
+               (values
+                `(package
+                   (name ,(ocaml-name->guix-name name))
+                   (version ,(if (string-prefix? "v" version)
+                               (substring version 1)
+                               version))
+                   (source
+                     (origin
+                       (method url-fetch)
+                       (uri ,source-url)
+                       (sha256 (base32 ,hash))))
+                   (build-system ,(if use-dune?
+                                      'dune-build-system
+                                      'ocaml-build-system))
+                   ,@(if (null? inputs)
+                       '()
+                       `((inputs ,(list 'quasiquote inputs))))
+                   ,@(if (null? native-inputs)
+                       '()
+                       `((native-inputs ,(list 'quasiquote native-inputs=
))))
+                   ,@(if (equal? name (guix-name->opam-name (ocaml-name-=
>guix-name name)))
+                       '()
+                       `((properties
+                           ,(list 'quasiquote `((upstream-name . ,name))=
))))
+                   (home-page ,(metadata-ref opam-content "homepage"))
+                   (synopsis ,(metadata-ref opam-content "synopsis"))
+                   (description ,(metadata-ref opam-content "description=
"))
+                   (license #f))
+                dependencies)))))
=20
 (define (opam-recursive-import package-name)
   (recursive-import package-name #f
diff --git a/guix/import/utils.scm b/guix/import/utils.scm
index 0dfd4959a8..5eb8abbbed 100644
--- a/guix/import/utils.scm
+++ b/guix/import/utils.scm
@@ -50,6 +50,7 @@
             assoc-ref*
=20
             url-fetch
+            guix-hash-file
             guix-hash-url
=20
             package-names->package-inputs
@@ -137,10 +138,17 @@ recursively apply the procedure to the sub-list."
   (parameterize ((current-output-port (current-error-port)))
     (build:url-fetch url file-name)))
=20
-(define (guix-hash-url filename)
+(define (guix-hash-file filename)
   "Return the hash of FILENAME in nix-base32 format."
   (bytevector->nix-base32-string (file-sha256 filename)))
=20
+(define (guix-hash-url url)
+  "Return the hash of URL in nix-base32 format."
+  (call-with-temporary-output-file
+   (lambda (temp port)
+     (and (url-fetch url temp)
+          (guix-hash-file temp)))))
+
 (define (spdx-string->license str)
   "Convert STR, a SPDX formatted license identifier, to a license object=
.
    Return #f if STR does not match any known identifiers."
@@ -305,7 +313,7 @@ the expected fields of an <origin> object."
        (origin
          (method url-fetch)
          (uri source-url)
-         (sha256 (base32 (guix-hash-url tarball))))))
+         (sha256 (base32 (guix-hash-file tarball))))))
     (#f #f)
     (orig (let ((sha (match (assoc-ref orig "sha256")
                        ((("base32" . value))
diff --git a/tests/opam.scm b/tests/opam.scm
index e8c0d15198..6357758208 100644
--- a/tests/opam.scm
+++ b/tests/opam.scm
@@ -31,7 +31,7 @@
   #:use-module (ice-9 peg))
=20
 (define test-opam-file
-"opam-version: \"2.0\"
+  "opam-version: \"2.0\"
   version: \"1.0.0\"
 maintainer: \"Alice Doe\"
 authors: [
@@ -60,61 +60,56 @@ url {
   checksum: \"md5=3D74c6e897658e820006106f45f736381f\"
 }")
=20
-(define test-source-hash
-  "")
-
 (define test-repo
   (mkdtemp! "/tmp/opam-repo.XXXXXX"))
=20
+(define %test-hash
+  "0w83v9ylycsssyn47q8wnkfbvhn5vn10z6i35n5965i2m1r0mmcf")
+
 (test-begin "opam")
=20
 (test-assert "opam->guix-package"
-  (mock ((guix import utils) url-fetch
-         (lambda (url file-name)
-           (match url
-             ("https://example.org/foo-1.0.0.tar.gz"
-              (begin
-                (mkdir-p "foo-1.0.0")
-                (system* "tar" "czvf" file-name "foo-1.0.0/")
-                (delete-file-recursively "foo-1.0.0")
-                (set! test-source-hash
-                  (call-with-input-file file-name port-sha256))))
-             (_ (error "Unexpected URL: " url)))))
-      (let ((my-package (string-append test-repo "/packages/foo/foo.1.0.=
0")))
-        (mkdir-p my-package)
-        (with-output-to-file (string-append my-package "/opam")
-          (lambda _
-            (format #t "~a" test-opam-file))))
-      (mock ((guix import opam) get-opam-repository
-             (lambda _
-               test-repo))
-        (match (opam->guix-package "foo")
-          (('package
-             ('name "ocaml-foo")
-             ('version "1.0.0")
-             ('source ('origin
-                        ('method 'url-fetch)
-                        ('uri "https://example.org/foo-1.0.0.tar.gz")
-                        ('sha256
-                         ('base32
-                          (? string? hash)))))
-             ('build-system 'ocaml-build-system)
-             ('inputs
-              ('quasiquote
-               (("ocaml-zarith" ('unquote 'ocaml-zarith)))))
-             ('native-inputs
-              ('quasiquote
-               (("ocaml-alcotest" ('unquote 'ocaml-alcotest))
-                ("ocamlbuild" ('unquote 'ocamlbuild)))))
-             ('home-page "https://example.org/")
-             ('synopsis "Some example package")
-             ('description "This package is just an example.")
-             ('license #f))
-           (string=3D? (bytevector->nix-base32-string
-                      test-source-hash)
-                     hash))
-          (x
-           (pk 'fail x #f))))))
+  (begin
+    (let ((my-package (string-append test-repo "/packages/foo/foo.1.0.0"=
)))
+      (mkdir-p my-package)
+      (with-output-to-file (string-append my-package "/opam")
+        (lambda _
+          (format #t "~a" test-opam-file))))
+    (mock
+     ((guix import utils) guix-hash-url
+      (lambda (url)
+        (match url
+          ("https://example.org/foo-1.0.0.tar.gz" %test-hash)
+          (_ (error "Unexpected URL: " url)))))
+     (mock
+      ((guix import opam) get-opam-repository
+       (lambda _
+         test-repo))
+      (match (opam->guix-package "foo")
+        (('package
+           ('name "ocaml-foo")
+           ('version "1.0.0")
+           ('source ('origin
+                      ('method 'url-fetch)
+                      ('uri "https://example.org/foo-1.0.0.tar.gz")
+                      ('sha256
+                       ('base32
+                        (? string? hash)))))
+           ('build-system 'ocaml-build-system)
+           ('inputs
+            ('quasiquote
+             (("ocaml-zarith" ('unquote 'ocaml-zarith)))))
+           ('native-inputs
+            ('quasiquote
+             (("ocaml-alcotest" ('unquote 'ocaml-alcotest))
+              ("ocamlbuild" ('unquote 'ocamlbuild)))))
+           ('home-page "https://example.org/")
+           ('synopsis "Some example package")
+           ('description "This package is just an example.")
+           ('license #f))
+         (string=3D? hash %test-hash))
+        (x
+         (pk 'fail x #f)))))))
=20
 ;; Test the opam file parser
 ;; We fold over some test cases. Each case is a pair of the string to pa=
rse and the
--=20
2.20.1 (Apple Git-117)





Message sent:


Content-Disposition: inline
Content-Transfer-Encoding: quoted-printable
MIME-Version: 1.0
X-Mailer: MIME-tools 5.505 (Entity 5.505)
Content-Type: text/plain; charset=utf-8
X-Loop: help-debbugs@HIDDEN
From: help-debbugs@HIDDEN (GNU bug Tracking System)
To: Robert Vollmert <rob@HIDDEN>
Subject: bug#36662: Acknowledgement ([PATCH] guix import: Add proper
 guix-hash-url)
Message-ID: <handler.36662.B.15631883972738.ack <at> debbugs.gnu.org>
References: <20190715105933.23964-1-rob@HIDDEN>
X-Gnu-PR-Message: ack 36662
X-Gnu-PR-Package: guix-patches
X-Gnu-PR-Keywords: patch
Reply-To: 36662 <at> debbugs.gnu.org
Date: Mon, 15 Jul 2019 11:00:04 +0000

Thank you for filing a new bug report with debbugs.gnu.org.

This is an automatically generated reply to let you know your message
has been received.

Your message is being forwarded to the package maintainers and other
interested parties for their attention; they will reply in due course.

Your message has been sent to the package maintainer(s):
 guix-patches@HIDDEN

If you wish to submit further information on this problem, please
send it to 36662 <at> debbugs.gnu.org.

Please do not send mail to help-debbugs@HIDDEN unless you wish
to report a problem with the Bug-tracking system.

--=20
36662: http://debbugs.gnu.org/cgi/bugreport.cgi?bug=3D36662
GNU Bug Tracking System
Contact help-debbugs@HIDDEN with problems



Last modified: Mon, 25 Nov 2019 12:00:02 UTC

GNU bug tracking system
Copyright (C) 1999 Darren O. Benham, 1997 nCipher Corporation Ltd, 1994-97 Ian Jackson.