summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorZheng Junjie <z572@z572.online>2025-06-19 23:24:30 +0800
committerSharlatan Hellseher <sharlatanus@gmail.com>2025-07-01 08:48:47 +0100
commitd8a61d2b0b81d17e9183a0e0124f2fd3d1aa0a86 (patch)
tree4c55c338904f707da671cf7f9e43f0d13a4755e2
parent8b38fb8fa7dd030b58aa545e60cccedf72e25f18 (diff)
import: nuget: use xml->sxml's namespaces keyword.
* guix/import/nuget.scm (%nuget-nuspec): New variable. (fetch-repo-info-from-snupkg): use xml->sxml's namespaces keyword. reindentation. Do not use square brackets. Change-Id: Ic86a12ab6557e0a7d627864c9ec39245f9cea892 Reviewed-by: Danny Milosavljevic <dannym@friendly-machines.com> Signed-off-by: Sharlatan Hellseher <sharlatanus@gmail.com>
-rw-r--r--guix/import/nuget.scm34
1 files changed, 19 insertions, 15 deletions
diff --git a/guix/import/nuget.scm b/guix/import/nuget.scm
index 3e5d815a00..8a16525b2d 100644
--- a/guix/import/nuget.scm
+++ b/guix/import/nuget.scm
@@ -80,6 +80,7 @@
(define %nuget-v3-package-versions-url "https://api.nuget.org/v3-flatcontainer/")
(define %nuget-symbol-packages-url "https://globalcdn.nuget.org/symbol-packages/")
+(define %nuget-nuspec "http://schemas.microsoft.com/packaging/2013/05/nuspec.xsd")
;;; Version index https://api.nuget.org/v3-flatcontainer/{id-lower}/index.json
;;; nupkg download url https://api.nuget.org/v3-flatcontainer/{id-lower}/{version-lower}/{id-lower}.{version-lower}.nupkg
;;; nuspec url https://api.nuget.org/v3-flatcontainer/{id-lower}/{version-lower}/{id-lower}.nuspec
@@ -273,25 +274,28 @@ success, or #f on failure."
#f)
(call-with-input-file (car nuspec-files)
(lambda (port)
- (let* ((sxml (xml->sxml port #:trim-whitespace? #t)))
+ (let* ((sxml
+ (xml->sxml
+ port
+ #:trim-whitespace? #t
+ #:namespaces `((#f . ,%nuget-nuspec)))))
(car-safe
(filter-map
(lambda (node)
(sxml-match node
- [(http://schemas.microsoft.com/packaging/2013/05/nuspec.xsd:repository
- (@ . ,attrs-raw)
- . ,_)
- (let ((attrs (map (lambda (attr)
- (cons (symbol->string (car attr))
- (cadr attr)))
- attrs-raw)))
- (if (or (assoc-ref attrs "url")
- (assoc-ref attrs "commit"))
- attrs
- #f))]
- [,otherwise #f]))
- ((sxpath '(// http://schemas.microsoft.com/packaging/2013/05/nuspec.xsd:metadata
- http://schemas.microsoft.com/packaging/2013/05/nuspec.xsd:repository))
+ ((repository
+ (@ . ,attrs-raw)
+ . ,_)
+ (let ((attrs (map (lambda (attr)
+ (cons (symbol->string (car attr))
+ (cadr attr)))
+ attrs-raw)))
+ (if (or (assoc-ref attrs "url")
+ (assoc-ref attrs "commit"))
+ attrs
+ #f)))
+ (,otherwise #f)))
+ ((sxpath '(// metadata repository))
sxml)))))))))))))
(lambda (key . args)
(warning (G_ "Failed to fetch or process snupkg file: ~a (Reason: ~a ~s)~%")