summaryrefslogtreecommitdiff
path: root/guix/import/go.scm
AgeCommit message (Collapse)Author
2023-12-16guix: import: Report go version for go importer.Efraim Flashner
* guix/import/go.scm (go-package, go.mod-go-version): New procedures. (go-module->guix-package): Add the #:go keyword in the generated package definition if the required go is newer than the default go. * tests/go.scm (mock-http-get): Use gexps for package arguments. Change-Id: I8d005740a442330ac307a40a53764c803ceffc4f
2023-12-16guix: import: Don't include indirect dependencies in go.Efraim Flashner
* guix/import/go.scm (parse-go.mod)[define-peg-patern require]: Adjust the peg pattern to reject lines with the 'indirect' comment in them. Change-Id: I9618bbaa1cb8c6549ced875e3c8d32afc72c3b9b
2023-03-13guix: Strip #:use-module lists.Ludovic Courtès
This was obtained by setting up this environment: guix shell -D guix --with-input=guile@3.0.9=guile-next \ --with-commit=guile-next=e2ed33ef0445c867fe56c247054aa67e834861f2 -- make -j5 then adding 'unused-module' to (@@ (guix build compiler) %warnings), building, and checking all the "unused module" warnings and removing those that were definitely unused.
2022-12-31import/utils: Pass all arguments through to package builder.Lars-Dominik Braun
Individual importer may have additional arguments. * guix/import/utils.scm (recursive-import): Patch all keyword arguments through to repo->guix-package. * guix/import/cran.scm (cran->guix-package): Add #:allow-other-keys. * guix/import/crate.scm (crate->guix-package): Ditto. * guix/import/egg.scm (egg->guix-package): Ditto. * guix/import/elm.scm (elm->guix-package): Ditto. * guix/import/gem.scm (gem->guix-package): Ditto. * guix/import/gnu.scm (gnu->guix-package): Ditto. * guix/import/go.scm (go-module->guix-package): Ditto. (go-module-recursive-import): Ditto. * guix/import/hackage.scm (hackage->guix-package): Ditto. (hackage-recursive-import): Ditto. * guix/import/hexpm.scm (hexpm->guix-package): Ditto. * guix/import/minetest.scm (minetest->guix-package): Ditto. (minetest-recursive-import): Ditto. * guix/import/opam.scm (opam->guix-package): Ditto. * guix/import/pypi.scm (pypi->guix-package): Ditto. * guix/import/stackage.scm (stackage->guix-package): Ditto. (stackage-recursive-import): Ditto. * guix/import/texlive.scm (texlive->guix-package): Ditto.
2022-01-09import: go: Correctly report diagnostics upon version mismatch.Ludovic Courtès
* guix/import/go.scm (strip-v-prefix, ensure-v-prefix) (validate-version): New procedures. (go-module->guix-package): Use 'validate-version' when defining 'version*'. Remove 'else' clause in SRFI-34 guard.
2022-01-06import: Factorize file hashing.Sarah Morgensen
* guix/import/cran.scm (vcs-file?, file-hash): Remove procedures. (description->package): Use 'file-hash*' instead. * guix/import/elpa.scm (vcs-file?, file-hash): Remove procedures. (git-repository->origin, elpa-package->sexp): Use 'file-hash* instead'. * guix/import/go.scm (vcs-file?, file-hash): Remove procedures. (git-checkout-hash): Use 'file-hash*' instead. * guix/import/minetest.scm (file-hash): Remove procedure. (make-minetest-sexp): Use 'file-hash*' instead. Signed-off-by: Ludovic Courtès <ludo@gnu.org>
2021-10-04import: go: Recognize major version suffixes.Sarah Morgensen
Do not treat major version suffixes (such as "/v3") as repository subdirectories. See <https://golang.org/ref/mod#major-version-suffixes>. * guix/import/go.scm (go-module->guix-package): When determining the unpack path, compare 'root-module-path' to 'module-path-sans-suffix' instead of 'module-path'. Signed-off-by: Ludovic Courtès <ludo@gnu.org>
2021-10-04import: go: Handle extra whitespace in "go-import" meta tags.Sarah Morgensen
Some packages sites use extra whitespace in the content portion of <meta name="go-import" ...> tags, so handle that. Example: <https://k8s.io/api?go-get=1> * guix/import/go.scm (fetch-module-meta-data)[go-import->module-meta]: Use 'string-tokenize' instead of 'string-split'. Signed-off-by: Ludovic Courtès <ludo@gnu.org>
2021-09-18import: go: Match "go-import" meta tags anywhere.Sarah Morgensen
Some personal sites forget to put <meta name="go-import" ...> in a <head> element, so look anywhere for them. Partly fixes <https://issues.guix.gnu.org/50595>. Reported by Stephen Paul Weber <singpolyma@singpolyma.net>. * guix/import/go.scm (fetch-module-meta-data): Match "go-import" meta tags anywhere in the page. Signed-off-by: Ludovic Courtès <ludo@gnu.org>
2021-09-18import: go: Improve handling of modules in VCS subdirectories.Sarah Morgensen
Use the supplied module path (instead of the repository root) as the import path for everything except source and homepage URLs. For modules not in the root of a VCS repository, set #:unpack-path to the repository root by default. Partly fixes <https://issues.guix.gnu.org/50595>. Reported by Stephen Paul Weber <singpolyma@singpolyma.net>. * guix/import/go.scm (go-module->guix-package): Use 'module-path' instead of 'root-module-path' for #:import-path. Emit #:unpack-path when #:import-path is not equal to 'root-module-path'. Signed-off-by: Ludovic Courtès <ludo@gnu.org>
2021-09-07import: go: Fix import when import path redirects.Sarah Morgensen
* guix/import/go.scm (fetch-module-meta-data): If no meta entries have a matching import prefix, return the first entry instead of #f. Signed-off-by: Ludovic Courtès <ludo@gnu.org>
2021-09-01import: go: Improve error handling.zimoun
* guix/import/go.scm (go-module->guix-package*): Handle errors, remove memoize. (go-module-recursive-import): Remove 'guard', add memoize. * guix/scripts/import/go.scm (guix-import-go): Adjust. * tests/go.scm: Adjust. Signed-off-by: Ludovic Courtès <ludo@gnu.org>
2021-09-01import: go: Return false for package not found.Sarah Morgensen
* guix/import/go.scm (go-module-recursive-import): Explicitly return false when packages are not found. Signed-off-by: Ludovic Courtès <ludo@gnu.org>
2021-07-18import: go: Fix indentation.Maxim Cournoyer
* guix/import/go.scm: Fix indentation.
2021-07-18import: go: Upgrade go.mod parser.Sarah Morgensen
Upgrade the go.mod parser to handle the full go.mod spec, and to gracefully handle unexpected/malformed syntax. Restructure parser usage, making the parse tree available for other uses. guix/import/go.scm (parse-go.mod): Parse using (ice-9 peg) instead of regex matching for more robustness. Return a list of directives. (go.mod-directives): New procedure. (go.mod-requirements): Likewise. (go-module->guix-package): Use it. (%go.mod-replace-directive-rx): Remove unused variable. tests/go.scm (testing-parse-mod): Adjust accordingly. (go.mod-requirements) (fixture-go-mod-unparseable) (fixture-go-mod-retract) (fixture-go-mod-strings): New variables. ("parse-go.mod: simple") ("parse-go.mod: comments and unparseable lines") ("parse-go.mod: retract") ("parse-go.mod: raw strings and quoted strings") ("parse-go.mod: complete"): New tests. Signed-off-by: Maxim Cournoyer <maxim.cournoyer@gmail.com>
2021-07-17import: go: Handle multiple go-import meta tags.Sarah Morgensen via Guix-patches via
* guix/import/go.scm (fetch-module-meta-data): Parse all go-import meta tags and return the first 'module-meta' with a matching import prefix. [go-import->module-meta]: Extract parsing into new procedure. Signed-off-by: Maxim Cournoyer <maxim.cournoyer@gmail.com>
2021-07-17import: go: Fix parsing of pkg.go.dev licenses after site update.Sarah Morgensen via Guix-patches via
* guix/import/go.scm (go-package-licenses): Find license names in 'h2 // div // *text*' elements rather than 'h2 // *text*' elements. Signed-off-by: Maxim Cournoyer <maxim.cournoyer@gmail.com>
2021-07-05import: go: Replace tildes with hyphens in package names.Sarah Morgensen
Fixes <https://issues.guix.gnu.org/48111>. * guix/import/go.scm (go-module->guix-package-name): Replace tildes with hyphens. Signed-off-by: Leo Prikler <leo.prikler@student.tugraz.at>
2021-06-28import: go: Fix match-error in 'go-package-description'Sarah Morgensen via Guix-patches via
* guix/import/go.scm (go-package-description): Make sure description* is always a list, so the result is properly matched. Signed-off-by: Björn Höfling <bjoern.hoefling@bjoernhoefling.de>
2021-04-23import: go: Autoload (htmlprag).Ludovic Courtès
Fixes <https://bugs.gnu.org/47924>. Reported by Carl Dong <contact@carldong.me>. * guix/import/go.scm: Autoload (htmlprag).
2021-04-23import: go: Do not set '%strict-tokenizer?' from the top level.Ludovic Courtès
This avoids interference with other users of (htmlprag) and makes the intent clearer. * guix/import/go.scm <top level>: Remove call to '%strict-tokenizer?'. (go-package-licenses, go-package-description) (go-package-synopsis, fetch-module-meta-data): Pass #:strict? #t to 'html->sxml'.
2021-04-09import: go: Append version to symbol name in the pinned version mode.Maxim Cournoyer
This allows importing packages with complicated version specific dependency chains without the package symbol names colliding. * doc/guix.texi (Invoking guix import): Document the --pin-versions option. Mention that a specific version can be imported. Remove the experimental warning. * guix/import/go.scm (go-module->guix-package-name)[version]: Add optional argument. Rewrite the character translation in terms of string-map. (go-module->guix-package): Conditionally use dependencies whose symbol include their version, based no the value of the PIN-VERSIONS? argument. * guix/import/utils.scm (package->definition): Add a new case where the full version string is appended to the package symbol. * guix/scripts/import.scm (guix-import): Correctly print forms starting with '(define-public [...]'. * guix/scripts/import/go.scm (guix-import-go): Conditionally include the version in the package symbols defined.
2021-04-09import: go: Add an option to use pinned versions.Maxim Cournoyer
The ability to pin versions is handy when having to deal to packages that bootstrap themselves through a chain of former versions. Not using pinned versions in these case could introduce dependency cycles. * guix/build-system/go.scm (guix) (%go-version-rx): Rename to... (%go-pseudo-version-rx): ... this. Simplify the regular expression, which in turns makes it more robust. * guix/build-system/go.scm (go-version->git-ref): Adjust following the above rename. (go-pseudo-version?): New predicate. (go-module-latest-version): Rename to ... (go-module-version-string): ... this. Rename goproxy-url argument to just goproxy. Add a VERSION keyword argument, update docstring and adjust to have it used. (go-module-available-versions): New procedure. (%go.mod-require-directive-rx): Document regexp. (parse-go.mod): Harmonize the way dependencies are recorded to a list of lists rather than a list of pairs, as done for other importers. Rewrite to directly pass multiple values rather than a record object. Filter the replaced modules in a functional style. (go-module->guix-package): Add docstring. [version, pin-versions?]: New arguments. Rename the GOPROXY-URL argument to GOPROXY. Adjust to the new returned value of fetch-go.mod, which is a string. Fail when the provided version doesn't exist. Return a list dependencies and their versions when in pinned versions mode, else just the dependencies. (go-module-recursive-import)[version, pin-versions?]: New arguments. Honor the new arguments and guard against network errors. * guix/scripts/import/go.scm (%default-options): Register a default value for the goproxy argument. (show-help): Document that a version can be specified. Remove the --version argument and add a --pin-versions argument. (%options)[version]: Remove option. [pin-versions]: Add option. (guix-import-go): Adjust so the version provided from the module name is honored, along the new pin-versions? argument. * tests/go.scm: Adjust and add new tests.
2021-04-09import: go: Improve synopsis and description parsing.Maxim Cournoyer
* guix/import/go.scm (%strict-tokenizer?): Set parameter to #t. (go-path-escape): Redefine to prevent inlining. (http-get*): Replace by ... (http-fetch*): this ... (json-fetch*): New procedure. (go.pkg.dev-info): Use http-fetch*. (go-package-licenses): Rewrite in terms of go.pkg.dev-info. (go-package-description): Likewise. (go-package-synopsis): Likewise. (fetch-go.mod): Use the memoized http-fetch*. (parse-go.mod): Adjust to receive content as a string. (fetch-module-meta-data): Adjust to use http-fetch*. (go-module->guix-package): Adjust to the modified fetch-go.mod return value. [inputs]: Use propagated inputs, which is the most common situations for Go libraries. [description]: Beautify description. [licenses]: Do no check for #f. The result of the license parsing is always a list. * tests/go.scm: Adjust following above changes.
2021-04-04import: go: Replace underscores with hyphens in package names.Xinglu Chen
As per section '16.4.2 Package Naming' in the manual, use hypens instead of underscores in package names. * guix/import/go.scm (go-module->guix-package-name): Replace underscores with hyphens. Signed-off-by: Leo Famulari <leo@famulari.name>
2021-03-10import: go: Compute the hash of Git checkouts.Ludovic Courtès
* guix/import/go.scm (vcs-file?, file-hash, git-checkout-hash): New procedures. (vcs->origin): Use 'git-checkout-hash' in the 'git case.
2021-03-10import: Add Go importer.Katherine Cox-Buday
This patch adds a 'guix import go' command. * doc/guix.texi (Requirements): Mention Guile-Lib dependency. (Invoking guix import): Document 'guix import go'. * gnu/packages/package-management.scm (guix)[inputs, propagated-inputs]: Add GUILE-LIB. * guix/self.scm (compiled-guix)[guile-lib]: New variable. [dependencies]: Add it. (specification->package): Add "guile-lib". * guix/build-system/go.scm (go-version->git-ref): New procedure. * guix/import/go.scm, guix/scripts/import/go.scm, tests/go.scm: New files. * guix/scripts/import.scm: Declare subcommand guix import go * po/guix/POTFILES.in: Add 'guix/scripts/import/go.scm'. * Makefile.am (MODULES): Add 'guix/import/go.scm' and 'guix/scripts/import/go.scm'. (SCM_TESTS): Add 'tests/go.scm'. Co-Authored-By: Helio Machado <0x2b3bfa0@gmail.com> Co-Authored-By: Francois Joulaud <francois.joulaud@radiofrance.com> Co-Authored-By: Maxim Cournoyer <maxim.cournoyer@gmail.com> Co-Authored-by: Ludovic Courtès <ludo@gnu.org>