mbox series

[bug#50072,WIP,0/4] Add upstream updater for git-fetch origins.

Message ID cover.1629068119.git.iskarian@mgsn.dev
Headers show
Series Add upstream updater for git-fetch origins. | expand

Message

Sarah Morgensen Aug. 15, 2021, 11:16 p.m. UTC
Hello Guix,

This is a proof-of-concept for extending `guix refresh -u` to support packages
with git-fetch origins.  The potential impact is large: approximately 4.5k
packages use git-fetch, although only some fraction would be supported.

Currently, this enables update support for (at least) any package where

* github-updater finds an update,
* origin-method is 'git-fetch', and
* the package version is a suffix of the 'commit' field.

Drawbacks currently include the fact that libgit2 doesn't (yet) support
shallow checkouts [0], so the entire repository must be cloned. There is also
no support for verifying commits.

There should probably also be a few tests added.

WDYT?

[0] https://github.com/libgit2/libgit2/issues/3058

--
Sarah Morgensen (4):
  guix hash: Extract file hashing procedures.
  import: Factorize file hashing.
  refresh: Support non-tarball sources.
  upstream: Support updating git-fetch origins.

 guix/git-download.scm    | 18 +++++++++++++-
 guix/hash.scm            | 51 ++++++++++++++++++++++++++++++++++++++++
 guix/import/cran.scm     | 32 +++----------------------
 guix/import/elpa.scm     | 28 ++++------------------
 guix/import/go.scm       | 26 +++-----------------
 guix/scripts/hash.scm    | 29 ++++++-----------------
 guix/scripts/refresh.scm | 10 ++++----
 guix/upstream.scm        | 41 +++++++++++++++++++++++++++++++-
 8 files changed, 130 insertions(+), 105 deletions(-)
 create mode 100644 guix/hash.scm


base-commit: 12099eac1b161d364be923451d27d7d739d0f14d

Comments

M Jan. 1, 2022, 5:35 p.m. UTC | #1
Hi,

I'm currently unifying the patches of Sarah and me, changing the
minetest and generic-git updater so "guix refresh -u" works. I'll
send them when they are tested.

Greetings,
Maxime.
M Jan. 1, 2022, 8:39 p.m. UTC | #2
Hi,

This is a combination of Sarah's patches and the patch I wrote.

Some differences:

'guix/hash.scm' is added to Makefile.am.
I modified the 'generic-git' and 'minetest' updater to return
'git-reference' objects.

There's no guess-version-transform procedure. Due to letting updaters
return git-reference objects, guessing isn't necessary.
This also allows using commits.

In contrast to my original version, it not only supports commits,
but also tags (using 'tag-or-commit'), like in Sarah's version.

I didn't use checkout-to-store, because it is used in only a single
location and is only a basic wrapper around latest-repository-commit.

I didn't look at testing if (let ((commit ...) (revision ...)) (package ...))
works. If it doesn't, that could be implemented in a separate patch.

'--with-latest' with a git source fails with a nice error message.

Some tests:

$ make check # no failures
$ ./pre-inst-env guix refresh minetest-mobs-animal -u --type=generic-git
  The result seems largely reasonable: the version changed, and the commit
  changed to a new tag.

  However, the URL changed from mixed case to lowercase. Maybe a todo for later:
  use the original URL if it only changed in case.

  Also, the version switched from YYYY-MM-DD to YYYY.MM.DD. Maybe change the
  minetest importer to use the latter, to keep minetest and generic-git
  consistent? TODO for later!

  A bug: the sha256 hash isn't updated. I don't know why.
  I investigated a little, and it turns out that 'latest-repository-commit' is called
  with the new tag, but the store item corresponds the old commit. Weird!
$ # undo the update
$ ./pre-inst-env guix refresh minetest-mobs-animal -u --type=minetest

  No problems at all (except the mixed case -> lowercase). The commit and sha256/base32
  are updated!
$ ./pre-inst-env guix build minetest-mobs-animal

  This builds successfully.
$ # undo changes
$ ./pre-inst-env guix build minetest-mobs-animal --with-latest=minetest-mobs-animal
It fails gracefully with:

guix build: error: git origins are unsupported by --with-latest

Also, do tarball origins still function? They do:

$ # move GNU "hello" to an earlier version, then do
$ ./pre-inst-env guix build hello --with-latest=hello

  This build hello@2.10 -- the output path is the same as before moving 'hello'
  to an earlier version.

$ ./pre-inst-env guix refresh -u hello

  The version is updated to @2.10, but sha256 isn't changed?
  Seems like a bug, but it doesn't appear to be a regression.

Sarah Morgensen (4):
  guix hash: Extract file hashing procedures.
  import: Factorize file hashing.
  refresh: Support non-tarball sources.
  upstream: Support updating 'git-fetch' origins.

 Makefile.am              |  1 +
 guix/hash.scm            | 51 ++++++++++++++++++++++++++++++++++
 guix/import/cran.scm     | 32 ++-------------------
 guix/import/elpa.scm     | 29 +++----------------
 guix/import/git.scm      | 22 +++++++++------
 guix/import/go.scm       | 25 ++---------------
 guix/import/minetest.scm | 24 +++++++---------
 guix/scripts/hash.scm    | 18 ++----------
 guix/scripts/refresh.scm | 10 +++----
 guix/upstream.scm        | 60 ++++++++++++++++++++++++++++++++++++----
 tests/minetest.scm       |  7 ++---
 11 files changed, 151 insertions(+), 128 deletions(-)
 create mode 100644 guix/hash.scm


base-commit: 9708681f1a9f221ae6cad64625ba8309b6742653
M Jan. 4, 2022, 3:09 p.m. UTC | #3
The following changes were made since v2:

  * file-hash* has been modified to, by default, only compute nar hash if the
    file is a directory.
  * Most uses of file-hash* have been modified to explicitely set #:recursive?
    #false or #:recursive? #true
  * the compiler <upstream-source> has been modified to support git-fetch
    origins.

    However, it is broken, and I don't know how to resolve the issue.
    (Except perhaps by using latest-repository-commit directly but that
    shouldn't be necessary, since <git-checkout> objects are lowerable?)
  * 'guess-version-transform' has been removed, since it is unused.

Checklist:

 - [x] make check

  There's one test failure: FAIL: tests/guix-pack-relocatable.sh

guix pack: error: profile contains conflicting entries for python-numpy
guix pack: error:   first entry: python-numpy@1.21.3 /gnu/store/9dd0zkkwl45rmsa7b6vjb1747l57aw4y-python-numpy-1.21.3R
guix pack: error:   second entry: python-numpy@1.20.3 /gnu/store/mlccgh05bf8cdinq0ilpvpdmsspq36pv-python-numpy-1.20.3R
guix pack: error:    ... propagated from python-matplotlib@3.4.3
guix pack: error:    ... propagated from python-scipy@1.7.3

guix/build/syscalls.scm:2271:8: In procedure terminal-window-size:
In procedure terminal-window-size: Inappropriate ioctl for device

   (This is from within Emacs.) It seems unrelated to this patch series;

 - [ ] guix build --source minetest-unified-inventory --with-latest=minetest-unified-inventory

      This causes

      Wrong type to apply: #<<git-checkout> url: "https://github.com/minetest-mods/unified_inventory" branch: #f commit: "d6688872c84417d2f61d6f5e607aea39d78920aa" recursive?: #f>

      but I don't know how to resolve this.

 - [x] guix refresh minetest-unified-inventory -t minetest
 - [x] guix refresh -t minetest -u minetest-unified-inventory
       Version, hash and commit seem ok.
 - [x] move "hello" to earlier version, do "guix refresh hello"
      An update '2.9' -> '2.10' is available.
 - [ ] guix refresh -u hello

  gpgv: Signature made Sun Nov 16 12:08:37 2014 UTC
  gpgv:                using RSA key A9553245FDE9B739
  gpgv: Can't check signature: No public key
  Would you like to add this key to keyring '$HOME/.config/guix/upstream/trustedkeys.kbx'?
  yes
  gpg: key A9553245FDE9B739: new key but contains no user ID - skipped
  gpg: Total number processed: 1
  gpg:           w/o user IDs: 1
  gpgv: Signature made Sun Nov 16 12:08:37 2014 UTC
  gpgv:                using RSA key A9553245FDE9B739
  gpgv: Can't check signature: No public key
  guix refresh: warning: signature verification failed for 'mirror://gnu/hello/hello-2.10.tar.gz' (key: A9553245FDE9B739)
  guix refresh: warning: hello: version 2.10 could not be downloaded and authenticated; not updating

  Failure seems unrelated to patch series.

 - [x] "./pre-inst-env guix download mirror://gnu/hello/hello-2.10.tar.gz" and "./pre-inst-env guix hash /gnu/store/STUFF" return the same hash

 - [x] ./pre-inst-env guix hash -r $(./pre-inst-env guix build --source minetest-mesecons)
      returns the hash in the minetest-mesecons package

      Also a warning: ‘--recursive is deprecated, use --serializer' instead,
      but 'guix hash --help' doesn't tell what the argument of '--serializer'
      can be so I think I'll stick with '-r' for now.

Sarah Morgensen (4):
  guix hash: Extract file hashing procedures.
  import: Factorize file hashing.
  refresh: Support non-tarball sources.
  upstream: Support updating and fetching 'git-fetch' origins.

 Makefile.am              |  1 +
 guix/git.scm             | 14 ++++++++-
 guix/hash.scm            | 68 ++++++++++++++++++++++++++++++++++++++++
 guix/import/cran.scm     | 32 ++-----------------
 guix/import/elpa.scm     | 29 +++--------------
 guix/import/git.scm      | 22 +++++++------
 guix/import/go.scm       | 25 ++-------------
 guix/import/minetest.scm | 25 +++++++--------
 guix/scripts/hash.scm    | 22 +++----------
 guix/scripts/refresh.scm | 10 +++---
 guix/upstream.scm        | 68 +++++++++++++++++++++++++++++++++++-----
 tests/minetest.scm       |  7 ++---
 12 files changed, 190 insertions(+), 133 deletions(-)
 create mode 100644 guix/hash.scm


base-commit: 9708681f1a9f221ae6cad64625ba8309b6742653
M Jan. 4, 2022, 8:06 p.m. UTC | #4
I've found a solution to the upstream-source-compiler/git-fetch
problem: returning the result of git-fetch like
upstream-source-compiler/url-fetch returns the result of url-fetch.

The following now works:
$ ./pre-inst-env guix build --source minetest-unified-inventory --with-latest=minetest-unified-inventory

Unrelated change: I let (guix git) be autoloaded, to avoid loading
guile-git when not necessary.

I think this patch series is ready now?

Sarah Morgensen (4):
  guix hash: Extract file hashing procedures.
  import: Factorize file hashing.
  refresh: Support non-tarball sources.
  upstream: Support updating and fetching 'git-fetch' origins.

 Makefile.am              |  1 +
 guix/git.scm             | 14 +++++++-
 guix/hash.scm            | 68 +++++++++++++++++++++++++++++++++++++
 guix/import/cran.scm     | 32 ++----------------
 guix/import/elpa.scm     | 29 +++-------------
 guix/import/git.scm      | 22 +++++++-----
 guix/import/go.scm       | 25 ++------------
 guix/import/minetest.scm | 25 ++++++--------
 guix/scripts/hash.scm    | 22 +++---------
 guix/scripts/refresh.scm | 10 +++---
 guix/upstream.scm        | 73 ++++++++++++++++++++++++++++++++++++----
 tests/minetest.scm       |  7 ++--
 12 files changed, 195 insertions(+), 133 deletions(-)
 create mode 100644 guix/hash.scm


base-commit: 9708681f1a9f221ae6cad64625ba8309b6742653