unofficial mirror of guix-devel@gnu.org 
 help / color / mirror / code / Atom feed
From: ericbavier@openmailbox.org
To: guix-devel@gnu.org
Cc: Eric Bavier <bavier@member.fsf.org>
Subject: [PATCH 2/3] import: hackage: Factorize url synthesis.
Date: Tue, 22 Mar 2016 22:54:28 -0500	[thread overview]
Message-ID: <1458705269-31766-2-git-send-email-ericbavier@openmailbox.org> (raw)
In-Reply-To: <1458705269-31766-1-git-send-email-ericbavier@openmailbox.org>

From: Eric Bavier <bavier@member.fsf.org>

* guix/import/hackage.scm (hackage-source-url, hackage-cabal-url): New
  procedures.
  (hackage-fetch, hackage-module->sexp): Use them.
---
 guix/import/hackage.scm | 27 +++++++++++++++++++--------
 1 file changed, 19 insertions(+), 8 deletions(-)

diff --git a/guix/import/hackage.scm b/guix/import/hackage.scm
index 9401830..3e9df63 100644
--- a/guix/import/hackage.scm
+++ b/guix/import/hackage.scm
@@ -1,5 +1,6 @@
 ;;; GNU Guix --- Functional package management for GNU
 ;;; Copyright © 2015 Federico Beffa <beffa@fbengineering.ch>
+;;; Copyright © 2016 Eric Bavier <bavier@member.fsf.org>
 ;;;
 ;;; This file is part of GNU Guix.
 ;;;
@@ -65,6 +66,22 @@
 
 (define package-name-prefix "ghc-")
 
+(define (hackage-source-url name version)
+  "Given a Hackage package NAME and VERSION, return a url to the source
+tarball."
+  (string-append "http://hackage.haskell.org/package/" name
+                 "/" name "-" version ".tar.gz"))
+
+(define* (hackage-cabal-url name #:optional version)
+  "Given a Hackage package NAME and VERSION, return a url to the corresponding
+.cabal file on Hackage.  If VERSION is #f or missing, the url for the latest
+version is returned."
+  (if version
+      (string-append "http://hackage.haskell.org/package/"
+                     name "-" version "/" name ".cabal")
+      (string-append "http://hackage.haskell.org/package/"
+                     name "/" name ".cabal")))
+
 (define (hackage-name->package-name name)
   "Given the NAME of a Cabal package, return the corresponding Guix name."
   (if (string-prefix? package-name-prefix name)
@@ -76,12 +93,7 @@
 the version part is omitted from the package name, then return the latest
 version."
   (let*-values (((name version) (package-name->name+version name-version))
-                ((url)
-                 (if version
-                     (string-append "http://hackage.haskell.org/package/"
-                                    name "-" version "/" name ".cabal")
-                     (string-append "http://hackage.haskell.org/package/"
-                                    name "/" name ".cabal"))))
+                ((url) (hackage-cabal-url name version)))
     ;; XXX: We want to silence the download progress report, which is
     ;; especially annoying for 'guix refresh', but we have to use a file port.
     (call-with-temporary-output-file
@@ -159,8 +171,7 @@ representation of a Cabal file as produced by 'read-cabal'."
     (cabal-package-version cabal))
   
   (define source-url
-    (string-append "http://hackage.haskell.org/package/" name
-                   "/" name "-" version ".tar.gz"))
+    (hackage-source-url name version))
 
   (define dependencies
     (let ((names
-- 
2.7.3

  reply	other threads:[~2016-03-23  3:54 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-03-23  3:54 [PATCH 1/3] import: hackage: Silence download output ericbavier
2016-03-23  3:54 ` ericbavier [this message]
2016-03-28 16:08   ` [PATCH 2/3] import: hackage: Factorize url synthesis Ludovic Courtès
2016-03-23  3:54 ` [PATCH 3/3] import: Add Hackage updater ericbavier
2016-03-28 16:12   ` Ludovic Courtès
2016-03-30  1:53     ` Eric Bavier
2016-03-30 21:16       ` Ludovic Courtès
2016-03-28 16:07 ` [PATCH 1/3] import: hackage: Silence download output Ludovic Courtès

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://guix.gnu.org/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1458705269-31766-2-git-send-email-ericbavier@openmailbox.org \
    --to=ericbavier@openmailbox.org \
    --cc=bavier@member.fsf.org \
    --cc=guix-devel@gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/guix.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).