Wrong result of package-name->name+version

  • Open
  • quality assurance status badge
Details
4 participants
  • Guillaume Le Vaillant
  • Leo Prikler
  • Ludovic Courtès
  • Sharlatan Hellseher
Owner
unassigned
Submitted by
Guillaume Le Vaillant
Severity
normal
G
G
Guillaume Le Vaillant wrote on 4 May 2021 15:35
(address . bug-guix@gnu.org)
87o8dqy636.fsf@yamatai
Hi,

The 'package-name->name+version' function defined in
"guix/build/utils.scm" returns a wrong result if there is a '-'
followed by a number in the package name:

Toggle snippet (7 lines)
(use-modules ((guix build utils)))
(package-name->name+version "sbcl-3d-vectors-3.1.0-1.29bb968")

$1 = "sbcl"
$2 = "3d-vectors-3.1.0-1.29bb968"

It should be:

Toggle snippet (4 lines)
$1 = "sbcl-3d-vectors"
$2 = "3.1.0-1.29bb968"

Can someone think of an elegant modification for
'package-name->name+version' so that it finds where the version is
even if there are several hyphens before of after it (as in
"sbcl-3d-vectors-3.1.0-1.29bb968" or "nyxt-2-pre-release-6")?

This is related to issue #48208, and also probably to issue #41437.
L
L
Leo Prikler wrote on 4 May 2021 21:39
240d6f2933bcf78ef7d08eb2003d562b10cca2bc.camel@student.tugraz.at
Am Dienstag, den 04.05.2021, 13:35 +0000 schrieb Guillaume Le Vaillant:
Toggle quote (27 lines)
> Hi,
>
> The 'package-name->name+version' function defined in
> "guix/build/utils.scm" returns a wrong result if there is a '-'
> followed by a number in the package name:
>
> --8<---------------cut here---------------start------------->8---
> (use-modules ((guix build utils)))
> (package-name->name+version "sbcl-3d-vectors-3.1.0-1.29bb968")
>
> $1 = "sbcl"
> $2 = "3d-vectors-3.1.0-1.29bb968"
> --8<---------------cut here---------------end--------------->8---
>
> It should be:
>
> --8<---------------cut here---------------start------------->8---
> $1 = "sbcl-3d-vectors"
> $2 = "3.1.0-1.29bb968"
> --8<---------------cut here---------------end--------------->8---
>
> Can someone think of an elegant modification for
> 'package-name->name+version' so that it finds where the version is
> even if there are several hyphens before of after it (as in
> "sbcl-3d-vectors-3.1.0-1.29bb968" or "nyxt-2-pre-release-6")?
>
> This is related to issue #48208, and also probably to issue #41437.
I don't think there's any way to cleverly match this. For all we know,
3d could be a version, we have 2019c, 2021a, 1a, 9d, 9100h and 063a
already. Perhaps we should forward name and version as keyword
arguments, so that we don't have to reconstruct them, or alternatively
use a different delimiter (e.g. @)

I'm honestly surprised, that many other stuff "works fine" despite the
fact, that they'd probably also suffer from this bug. Can anyone tell
me why emacs-2048-game builds?
L
L
Ludovic Courtès wrote on 4 May 2021 22:08
Re: bug#48225: Wrong result of package-name->name+version
(name . Guillaume Le Vaillant)(address . glv@posteo.net)(address . 48225@debbugs.gnu.org)
87pmy6l0su.fsf@gnu.org
Hi Guillaume,

Guillaume Le Vaillant <glv@posteo.net> skribis:

Toggle quote (21 lines)
> The 'package-name->name+version' function defined in
> "guix/build/utils.scm" returns a wrong result if there is a '-'
> followed by a number in the package name:
>
> (use-modules ((guix build utils)))
> (package-name->name+version "sbcl-3d-vectors-3.1.0-1.29bb968")
>
> $1 = "sbcl"
> $2 = "3d-vectors-3.1.0-1.29bb968"
>
>
> It should be:
>
> $1 = "sbcl-3d-vectors"
> $2 = "3.1.0-1.29bb968"
>
> Can someone think of an elegant modification for
> 'package-name->name+version' so that it finds where the version is
> even if there are several hyphens before of after it (as in
> "sbcl-3d-vectors-3.1.0-1.29bb968" or "nyxt-2-pre-release-6")?

It’s implements a heuristic meant to work for most packages. It’s hard
to tweak that without breaking something else instead. (Plus,
“nyxt-2-pre-release-6” looks really bogus to me.)

A better fix would be to not guess and instead pass #:name and #:version
to all the build phases, with the value taken from the <package> object.
(That’s a world-rebuild fix though.)

WDYT?

Toggle quote (2 lines)
> This is related to issue #48208, and also probably to issue #41437.

Perhaps we can find a workaround for these?

Thanks,
Ludo’.
S
S
Sharlatan Hellseher wrote on 5 May 2021 23:27
Simple workaround
(address . 48225@debbugs.gnu.org)
CAO+9K5rF6hte3U=cga27p9K7uou8B_=csjXZb0QHc_DjxyOhsg@mail.gmail.com
Hi,
If chaining `package-name->name+version` function may affect a large
layer of infrastructure here is could a quick adhoc workaround:
sbcl-3d-vectors -> sbcl-cl3d-vectors
sbcl-3d-vectors -> sbcl-three-d-vectors
sbcl-3d-vectors -> sbcl-iiid-vectors
Or use any predictable common prefix which could be use and replaced
after the function is reviewed.
--
… ??? ????? - ???????????? ?????????????? ?????? ??????? ????????
????? ????? ????? ? ??? ??????, ??????????? ????? ???????, ??
?????????? ?? ? ????????? ??????? ????? ? ?????????????????.
G
G
Guillaume Le Vaillant wrote on 6 May 2021 11:10
Re: bug#48225: Wrong result of package-name->name+version
(name . Sharlatan Hellseher)(address . sharlatanus@gmail.com)
8735v0b53e.fsf@yamatai
Ludovic Courtès <ludo@gnu.org> skribis:

Toggle quote (11 lines)
> [...]
> A better fix would be to not guess and instead pass #:name and #:version
> to all the build phases, with the value taken from the <package> object.
> (That’s a world-rebuild fix though.)
>
> WDYT?
>
>> This is related to issue #48208, and also probably to issue #41437.
>
> Perhaps we can find a workaround for these?

Sharlatan Hellseher <sharlatanus@gmail.com> skribis:

Toggle quote (10 lines)
> If chaining `package-name->name+version` function may affect a large
> layer of infrastructure here is could a quick adhoc workaround:
>
> sbcl-3d-vectors -> sbcl-cl3d-vectors
> sbcl-3d-vectors -> sbcl-three-d-vectors
> sbcl-3d-vectors -> sbcl-iiid-vectors
>
> Or use any predictable common prefix which could be use and replaced
> after the function is reviewed.

I agree that having '#:name' and '#:version' available in the build
phases would be ideal.
Meanwhile I found a workaround for the asdf-build-system that fixes
bug#41437 and allows building the 'sbcl-3d-vectors' and
'sbcl-3d-matrices' packages of bug#48208 without having to mangle the
package names. It rebuilds all the Common Lisp packages, but that
doesn't take too much time.
WDYT?
From 1e37a89b943a818b5274c1d5f31143ca48bad40a Mon Sep 17 00:00:00 2001
From: Guillaume Le Vaillant <glv@posteo.net>
Date: Thu, 6 May 2021 10:32:56 +0200
Subject: [PATCH] build-system: asdf: Work around package-name->name+version
bug.

This patch modifies how the name of the main Common Lisp system is extracted
from the full Guix package name to work around bug#48225 concerning the
'package-name->name+version' function.


* guix/build-system/asdf.scm (asdf-build): Fix 'systems' function.
* guix/build/asdf-build-system.scm (main-system-name): Fix it.
---
guix/build-system/asdf.scm | 15 +++++++--------
guix/build/asdf-build-system.scm | 12 ++++++------
2 files changed, 13 insertions(+), 14 deletions(-)

Toggle diff (53 lines)
diff --git a/guix/build-system/asdf.scm b/guix/build-system/asdf.scm
index 28403a1960..8f9d63337f 100644
--- a/guix/build-system/asdf.scm
+++ b/guix/build-system/asdf.scm
@@ -291,16 +291,15 @@ set up using CL source package conventions."
(imported-modules %asdf-build-system-modules)
(modules %asdf-build-modules))
- ;; FIXME: The definition of 'systems' is pretty hacky.
- ;; Is there a more elegant way to do it?
(define systems
(if (null? (cadr asd-systems))
- `(quote
- ,(list
- (string-drop
- ;; NAME is the value returned from `package-full-name'.
- (hyphen-separated-name->name+version name)
- (1+ (string-length lisp-type))))) ; drop the "<lisp>-" prefix.
+ (let* ((lisp-prefix (string-append lisp-type "-"))
+ (package-name (hyphen-separated-name->name+version
+ (if (string-prefix? lisp-prefix name)
+ (string-drop name
+ (string-length lisp-prefix))
+ name))))
+ `(quote ,(list package-name)))
asd-systems))
(define builder
diff --git a/guix/build/asdf-build-system.scm b/guix/build/asdf-build-system.scm
index 6ad855cab2..5a4fc44aef 100644
--- a/guix/build/asdf-build-system.scm
+++ b/guix/build/asdf-build-system.scm
@@ -52,12 +52,12 @@
(string-append %source-install-prefix "/systems"))
(define (main-system-name output)
- (let ((package-name (package-name->name+version
- (strip-store-file-name output)))
- (lisp-prefix (string-append (%lisp-type) "-")))
- (if (string-prefix? lisp-prefix package-name)
- (string-drop package-name (string-length lisp-prefix))
- package-name)))
+ (let* ((full-name (strip-store-file-name output))
+ (lisp-prefix (string-append (%lisp-type) "-"))
+ (package-name (if (string-prefix? lisp-prefix full-name)
+ (string-drop full-name (string-length lisp-prefix))
+ full-name)))
+ (package-name->name+version package-name)))
(define (lisp-source-directory output name)
(string-append output (%lisp-source-install-prefix) "/" name))
--
2.31.1
-----BEGIN PGP SIGNATURE-----

iIUEAREKAC0WIQTLxZxm7Ce5cXlAaz5r6CCK3yH+PwUCYJOydQ8cZ2x2QHBvc3Rl
by5uZXQACgkQa+ggit8h/j82kgD/eEaXWTxKV/UFOUDeOPSe0b46+I0jAIyDAu5x
0aRyvxgBAJZHbQ4n9rEnP3BeGJi1H0/V0uNF+ipQ/q9QfKLnjoJ/
=LsaU
-----END PGP SIGNATURE-----

L
L
Ludovic Courtès wrote on 8 May 2021 12:27
(name . Guillaume Le Vaillant)(address . glv@posteo.net)
87v97t8qrc.fsf@gnu.org
Hi Guillaume,

Guillaume Le Vaillant <glv@posteo.net> skribis:

Toggle quote (15 lines)
> From 1e37a89b943a818b5274c1d5f31143ca48bad40a Mon Sep 17 00:00:00 2001
> From: Guillaume Le Vaillant <glv@posteo.net>
> Date: Thu, 6 May 2021 10:32:56 +0200
> Subject: [PATCH] build-system: asdf: Work around package-name->name+version
> bug.
>
> This patch modifies how the name of the main Common Lisp system is extracted
> from the full Guix package name to work around bug#48225 concerning the
> 'package-name->name+version' function.
>
> Fixes <https://issues.guix.gnu.org/41437>.
>
> * guix/build-system/asdf.scm (asdf-build): Fix 'systems' function.
> * guix/build/asdf-build-system.scm (main-system-name): Fix it.

If it works for you, sounds good to me. Please do rebuild as many CL
packages, with different CL implementations, to make sure we do not
overlook any corner case.

Toggle quote (8 lines)
> + (let* ((lisp-prefix (string-append lisp-type "-"))
> + (package-name (hyphen-separated-name->name+version
> + (if (string-prefix? lisp-prefix name)
> + (string-drop name
> + (string-length lisp-prefix))
> + name))))
> + `(quote ,(list package-name)))

I’d like to see a FIXME in there: this is all guesswork and we should
eventually replace guesses with known-good info.

What would it take to pass the right package name and implementation
name upfront from the package?

Thanks,
Ludo’.
G
G
Guillaume Le Vaillant wrote on 8 May 2021 14:41
(name . Ludovic Courtès)(address . ludo@gnu.org)
87r1ihieje.fsf@kitej
Ludovic Courtès <ludo@gnu.org> skribis:

Toggle quote (40 lines)
> Hi Guillaume,
>
> Guillaume Le Vaillant <glv@posteo.net> skribis:
>
>> From 1e37a89b943a818b5274c1d5f31143ca48bad40a Mon Sep 17 00:00:00 2001
>> From: Guillaume Le Vaillant <glv@posteo.net>
>> Date: Thu, 6 May 2021 10:32:56 +0200
>> Subject: [PATCH] build-system: asdf: Work around package-name->name+version
>> bug.
>>
>> This patch modifies how the name of the main Common Lisp system is extracted
>> from the full Guix package name to work around bug#48225 concerning the
>> 'package-name->name+version' function.
>>
>> Fixes <https://issues.guix.gnu.org/41437>.
>>
>> * guix/build-system/asdf.scm (asdf-build): Fix 'systems' function.
>> * guix/build/asdf-build-system.scm (main-system-name): Fix it.
>
> If it works for you, sounds good to me. Please do rebuild as many CL
> packages, with different CL implementations, to make sure we do not
> overlook any corner case.
>
>> + (let* ((lisp-prefix (string-append lisp-type "-"))
>> + (package-name (hyphen-separated-name->name+version
>> + (if (string-prefix? lisp-prefix name)
>> + (string-drop name
>> + (string-length lisp-prefix))
>> + name))))
>> + `(quote ,(list package-name)))
>
> I’d like to see a FIXME in there: this is all guesswork and we should
> eventually replace guesses with known-good info.
>
> What would it take to pass the right package name and implementation
> name upfront from the package?
>
> Thanks,
> Ludo’.

I tried rebuilding all the sbcl-*, cl-* and ecl-* packages, as well as
stumpwm, uglify-js and nyxt, and I didn't see new failures.
I pushed the patch as 2fa8fd4af59af0de392352915fa50fc21a4cf98a.

When 'package-name->name+version' returns a bad result leading to an
incorrect default Lisp system name being computed, it can be overridden
using the '#:asd-systems' parameter of 'asdf-build-system', which should
work around the problem in almost all cases.

However I suppose other build systems could have issues if they make use
of 'package-name->name+version' on a package with a name like
"abc-123-def-1.2.3" (depending how they use the result).
-----BEGIN PGP SIGNATURE-----

iIUEAREKAC0WIQTLxZxm7Ce5cXlAaz5r6CCK3yH+PwUCYJaG5Q8cZ2x2QHBvc3Rl
by5uZXQACgkQa+ggit8h/j9xigD/U6jKF9r1pA36vLz2ylC/jR55bxg/UjOys3lz
MipayOQBAJRyhM74/cziP6bpAzuhap7LEB+tCWrL9qXbp0yZSXGv
=DUq0
-----END PGP SIGNATURE-----

?
Your comment

Commenting via the web interface is currently disabled.

To comment on this conversation send an email to 48225@debbugs.gnu.org

To respond to this issue using the mumi CLI, first switch to it
mumi current 48225
Then, you may apply the latest patchset in this issue (with sign off)
mumi am -- -s
Or, compose a reply to this issue
mumi compose
Or, send patches to this issue
mumi send-email *.patch