sharlatan pushed a commit to branch go-team
in repository guix.

commit eec79b558e5e6e5a36388942339daf6cbac9fd59
Author: Sharlatan Hellseher <sharlata...@gmail.com>
AuthorDate: Thu Feb 20 13:50:10 2025 +0000

    gnu: go-github-com-libp2p-go-libp2p-asn-util: Generate network list.
    
    * gnu/packages/golang-web.scm (go-github-com-libp2p-go-libp2p-asn-util)
    [source] <snippet>: Delete generated network list file.
    [arguments] <phases>: Add 'generate-sorted-network-list.
    [native-inputs]: Add specification-ip2asn-v6.
    
    Change-Id: Iab9e3c4329fd9a894bafab98d2f274d7f9bb0dad
---
 gnu/packages/golang-web.scm | 23 ++++++++++++++++++++---
 1 file changed, 20 insertions(+), 3 deletions(-)

diff --git a/gnu/packages/golang-web.scm b/gnu/packages/golang-web.scm
index 1db0a344f8..36e54dfcf7 100644
--- a/gnu/packages/golang-web.scm
+++ b/gnu/packages/golang-web.scm
@@ -73,6 +73,7 @@
   #:use-module (gnu packages golang-xyz)
   #:use-module (gnu packages ipfs)
   #:use-module (gnu packages prometheus)
+  #:use-module (gnu packages specifications)
   #:use-module (gnu packages tls)
   #:use-module (gnu packages web))
 
@@ -5030,13 +5031,29 @@ faster (and only does simple bandwidth metrics).")
              (commit (string-append "v" version))))
        (file-name (git-file-name name version))
        (sha256
-        (base32 "1c94sq43bl1kp04lllcfrfyiy5z3zcfz0s65sm1vgb2s40zrwpr7"))))
+        (base32 "1c94sq43bl1kp04lllcfrfyiy5z3zcfz0s65sm1vgb2s40zrwpr7"))
+       (modules '((guix build utils)))
+       (snippet
+        #~(begin
+            ;; Delete generated binary file.
+            (delete-file "sorted-network-list.bin")))))
     (build-system go-build-system)
     (arguments
      (list
-      #:import-path "github.com/libp2p/go-libp2p-asn-util"))
+      #:import-path "github.com/libp2p/go-libp2p-asn-util"
+      #:phases
+      #~(modify-phases %standard-phases
+          (add-after 'unpack 'generate-sorted-network-list
+            (lambda* (#:key import-path #:allow-other-keys)
+              (with-directory-excursion (string-append "src/" import-path)
+                (setenv "ASN_IPV6_FILE"
+                        (string-append
+                         #$(this-package-native-input 
"specification-ip2asn-v6")
+                         "/share/data/ip2asn-v6.tsv"))
+                (invoke "go" "run" "./generate/")))))))
     (native-inputs
-     (list go-github-com-stretchr-testify))
+     (list go-github-com-stretchr-testify
+           specification-ip2asn-v6))
     (propagated-inputs
      (list go-golang-org-x-exp))
     (home-page "https://github.com/libp2p/go-libp2p-asn-util";)

Reply via email to