import: launchpad: Use repository to retrieve releases.

* guix/import/launchpad.scm (latest-released-version): Use repository instead
of package name.
(latest-release): Pass repository to latest-released-version.

Signed-off-by: Brice Waegeneire <brice@waegenei.re>
This commit is contained in:
Matthew James Kraai 2021-06-19 03:07:39 -07:00 committed by Brice Waegeneire
parent 9fd9364492
commit 9171079e51
No known key found for this signature in database
GPG Key ID: A94903A166A18FAE

View File

@ -1,5 +1,6 @@
;;; GNU Guix --- Functional package management for GNU ;;; GNU Guix --- Functional package management for GNU
;;; Copyright © 2019, 2020 Arun Isaac <arunisaac@systemreboot.net> ;;; Copyright © 2019, 2020 Arun Isaac <arunisaac@systemreboot.net>
;;; Copyright © 2021 Matthew James Kraai <kraai@ftbfs.org>
;;; ;;;
;;; This file is part of GNU Guix. ;;; This file is part of GNU Guix.
;;; ;;;
@ -100,8 +101,8 @@ URL of the form
(match (string-split (uri-path (string->uri url)) #\/) (match (string-split (uri-path (string->uri url)) #\/)
((_ repo . rest) repo))) ((_ repo . rest) repo)))
(define (latest-released-version package-name) (define (latest-released-version repository)
"Return a string of the newest released version name given the PACKAGE-NAME, "Return a string of the newest released version name given the REPOSITORY,
for example, 'linuxdcpp'. Return #f if there is no releases." for example, 'linuxdcpp'. Return #f if there is no releases."
(define (pre-release? x) (define (pre-release? x)
;; Versions containing anything other than digit characters and "." (for ;; Versions containing anything other than digit characters and "." (for
@ -112,7 +113,7 @@ for example, 'linuxdcpp'. Return #f if there is no releases."
(match (json-fetch (match (json-fetch
(string-append "https://api.launchpad.net/1.0/" (string-append "https://api.launchpad.net/1.0/"
package-name "/releases")) repository "/releases"))
(#f #f) ;404 or similar (#f #f) ;404 or similar
(json (json
(assoc-ref (assoc-ref
@ -129,7 +130,8 @@ for example, 'linuxdcpp'. Return #f if there is no releases."
(let* ((source-uri (origin-github-uri (package-source pkg))) (let* ((source-uri (origin-github-uri (package-source pkg)))
(name (package-name pkg)) (name (package-name pkg))
(newest-version (latest-released-version name))) (repository (launchpad-repository source-uri))
(newest-version (latest-released-version repository)))
(if newest-version (if newest-version
(upstream-source (upstream-source
(package name) (package name)