From: Timmy Douglas <mail@timmydouglas.com>
To: Leo Famulari <leo@famulari.name>,
help-guix@gnu.org,
Katherine Cox-Buday <cox.katherine.e@gmail.com>,
Helio Machado <0x2b3bfa0@gmail.com>
Subject: Re: packaging a golang package
Date: Sat, 09 Jan 2021 16:32:45 -0800 [thread overview]
Message-ID: <87a6thtyvm.fsf@timmydouglas.com> (raw)
In-Reply-To: <4bdbc469-ad45-4739-b001-739ad3a60adc@www.fastmail.com>
"Leo Famulari" <leo@famulari.name> writes:
> On Fri, Jan 8, 2021, at 02:01, Timmy Douglas wrote:
>>
>> I recently installed guix for the first time and I wanted to try to
>> package my first program. The one I decided to try is written in go and
>> uses go.mod (https://github.com/coredns/coredns/blob/master/go.mod) for
>> modules. Running `go build` would normally download those if they don't
>> exist.
>>
>> I took a look at a couple of other packages, and it looks like the right
>> way to do it would be to package the individual modules as seen in
>> guix/gnu/packages/golang.scm. Has anyone tried automating this sort of
>> thing? There are almost 40 dependencies...
>
> Thanks for working on this!
>
> It's true, Go programs usually have a dependency graph that is
> uncomfortably large — although not impossibly large like Rust.
>
> There is a work-in-progress implementation of a Go package importer
> that I believe should make it easier:
>
> https://issues.guix.gnu.org/issue/44178
>
> You could try it out and, if it works for you, send those patches, and
> give feedback on the importer as well :)
Thanks for the pointer!
I tried both Katherine's patch (with dftxbs3e's mini fix for
recursive-import) and Helio's patch (with a git remote add/cherry-pick)
and had trouble with both of them. I spent a little more time with
Katherine's patch so I'll go into that more below.
Part of the issue is that I haven't used Scheme in like 15 years (and
when I did, it wasn't for anything non-trivial). But I'm also really
struggling to debug what's going on:
I run `make && ./pre-inst-env guix import go -r github.com/coredns/coredns`:
Starting download of /tmp/guix-file.pZqXNO
From https://proxy.golang.org/k8s.io/klog/@v/v1.0.0.mod...
v1.0.0.mod 68B 88KiB/s 00:00 [##################] 100.0%
metadata#f
Backtrace:
In ice-9/boot-9.scm:
1736:10 13 (with-exception-handler _ _ #:unwind? _ # _)
In unknown file:
12 (apply-smob/0 #<thunk 7f98846a3740>)
In ice-9/boot-9.scm:
718:2 11 (call-with-prompt _ _ #<procedure default-prompt-handle?>)
In ice-9/eval.scm:
619:8 10 (_ #(#(#<directory (guile-user) 7f98842e0f00>)))
In guix/ui.scm:
2154:12 9 (run-guix-command _ . _)
In guix/scripts/import.scm:
120:11 8 (guix-import . _)
In ice-9/eval.scm:
159:9 7 (_ _)
In guix/import/utils.scm:
468:27 6 (recursive-import _ #:repo->guix-package _ #:guix-name _ ?)
In srfi/srfi-1.scm:
586:17 5 (map1 (("k8s.io/klog" #f) ("k8s.io/client-go" #f) (?) ?))
In guix/import/utils.scm:
457:33 4 (lookup-node "k8s.io/klog" #f)
In guix/utils.scm:
703:8 3 (call-with-temporary-output-file #<procedure 7f9871b8c7?>)
In ice-9/eval.scm:
293:34 2 (_ #(#(#(#(#(#(#(#(#<directory ?> ?) ?) ?) ?) ?) ?) ?) ?))
155:9 1 (_ #(#(#<directory (guix import go) 7f9882267f00>) #f))
In unknown file:
0 (list-ref #f 1)
ERROR: In procedure list-ref:
In procedure list-ref: Wrong type argument in position 1: #f
I understand that (list-ref #f 1) won't work, but I can't figure out
where that code is based on the information in the backtrace. Seems like
the variables/symbols/filenames are missing everywhere where it counts.
I loaded the code up with #'display and found that I needed to add
another git scs/vcs entry for k8s.io, and that the
fetch-module-meta-data method tries to use regexes to parse html:
root-module-path= k8s.io/klog
line=
line= <html><head>
line= <meta name="go-import"
line= content="k8s.io/klog
line= git https://github.com/kubernetes/klog">
line= <meta name="go-source"
line= content="k8s.io/klog
line= https://github.com/kubernetes/klog
line= https://github.com/kubernetes/klog/tree/master{/dir}
line= https://github.com/kubernetes/klog/blob/master{/dir}/{file}#L{line}">
line= </head></html>
line=
(define (fetch-module-meta-data module-path)
"Fetches module meta-data from a module's landing page. This is necessary
because goproxy servers don't currently provide all the information needed to
build a package."
(let* ((port (http-fetch (string->uri (format #f "https://~a?go-get=1" module-path))))
(module-metadata #f)
(meta-tag-prefix "<meta name=\"go-import\" content=\"")
(meta-tag-prefix-length (string-length meta-tag-prefix)))
(do ((line (read-line port) (read-line port)))
((or (eof-object? line)
module-metadata))
(let ((meta-tag-index (string-contains line meta-tag-prefix)))
(display "line=")
(display line)
(newline)
(when meta-tag-index
(let* ((start (+ meta-tag-index meta-tag-prefix-length))
(end (string-index line #\" start)))
(set! module-metadata
(string-split (substring/shared line start end) #\space))))))
(close-port port)
module-metadata))
I don't think the regex would match due to content="" being put on
another line--so #f is returned and causes a type exception later. I'm
a little more used to statically typed languages so tracing it back to
there took longer than I would have liked.
Maybe I need to find a video tutorial on writing Scheme for Guix or
similiar? I felt like I was doing the wrong thing with
printf/make/pre-inst-env guix. I tried starting geiser in emacs, but
didn't really know what I should evaluate. It also added an unbearable
lag to typing in the scheme buffer and didn't provide auto-completion or
symbol lookup, so I didn't go too far with it...
Would be interested if Katherine or Helio have any more updates.
next prev parent reply other threads:[~2021-01-10 0:33 UTC|newest]
Thread overview: 16+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-01-08 7:01 packaging a golang package Timmy Douglas
2021-01-08 18:33 ` raingloom
2021-01-08 19:01 ` Leo Famulari
2021-01-10 0:32 ` Timmy Douglas [this message]
2021-01-11 6:09 ` Timmy Douglas
2021-01-17 13:31 ` Helio Machado
2021-01-25 7:18 ` Timmy Douglas
2021-01-25 20:49 ` Francois.JOULAUD--- via
2021-01-25 23:38 ` Helio Machado
2021-01-27 14:31 ` Katherine Cox-Buday
2021-01-28 8:18 ` Timmy Douglas
2021-01-28 10:32 ` adfeno--- via
2021-01-28 16:03 ` Ludovic Courtès
2021-01-28 21:10 ` adfeno--- via
2021-01-29 20:57 ` Elais Player
-- strict thread matches above, loose matches on Subject: below --
2021-01-20 3:27 jgart
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
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=87a6thtyvm.fsf@timmydouglas.com \
--to=mail@timmydouglas.com \
--cc=0x2b3bfa0@gmail.com \
--cc=cox.katherine.e@gmail.com \
--cc=help-guix@gnu.org \
--cc=leo@famulari.name \
/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 external index
https://git.savannah.gnu.org/cgit/guix.git
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.