Print hint if build fails due to invalid character in package source base name

  • Open
  • quality assurance status badge
Details
2 participants
  • Hartmut Goebel
  • zimoun
Owner
unassigned
Submitted by
Hartmut Goebel
Severity
normal
H
H
Hartmut Goebel wrote on 26 Sep 2019 18:01
(name . bug-guix)(address . bug-guix@gnu.org)
80714a9a-b70d-8810-0f1b-606b8a6b8743@crazy-compilers.com

guix shall print a hint if building fails due to the package source base
name containing a character invalid in a store filename (e.g. "@" or "%").

Currently, when building such a package, one gets an error message like:

guix build: error: invalid character `@' in name
`kde-l10n-ca@valencia-14.11.80.tar.xz.drv'

guix build should catch this error and print a hint like:

You may add a ‘file-name’ field to the package source to work around this.


Ludovic Courtès wrote on Sun Sep 08 22:07:10+0200 2019

Toggle quote (5 lines)
> Unfortunately it cannot really be caught. I mean, you could catch
> ‘&store-protocol-error’ error conditions, but then the error message is
> just a string, there’s no error code you can compare against.


Example package raising this error:

(use-modules (guix packages) (guix download) (guix build-system gnu))

(package
  (name "kde-l10n-ca-valencia")
  (version "14.11.80")
  (source
   (origin
     (method url-fetch)
     (uri (string-append "mirror://kde//Attic/applications/"
                         version "/src/kde-l10n/"
                         "kde-l10n-ca@valencia-" version ".tar.xz"))
     (sha256 (base32
"1mqadassxcm0m9r1l02m5vr4bbandn48xz8gifvxmb4wiz8i8d0w"))))
  (build-system gnu-build-system)
  (synopsis "") (description "") (license "") (home-page ""))

--
Regards
Hartmut Goebel

| Hartmut Goebel | h.goebel@crazy-compilers.com |
| www.crazy-compilers.com | compilers which you thought are impossible |
Z
Z
zimoun wrote on 21 Dec 2020 14:37
(name . Hartmut Goebel)(address . h.goebel@crazy-compilers.com)(address . 37523@debbugs.gnu.org)
86lfdr9t67.fsf@gmail.com
Hi,

On Thu, 26 Sep 2019 at 18:01, Hartmut Goebel <h.goebel@crazy-compilers.com> wrote:

Toggle quote (20 lines)
> guix shall print a hint if building fails due to the package source base
> name containing a character invalid in a store filename (e.g. "@" or "%").
>
> Currently, when building such a package, one gets an error message like:
>
> guix build: error: invalid character `@' in name `kde-l10n-ca@valencia-14.11.80.tar.xz.drv'
>
>
> guix build should catch this error and print a hint like:
>
> You may add a ‘file-name’ field to the package source to work around
> this.
>
>
> Ludovic Courtès wrote on Sun Sep 08 22:07:10+0200 2019
>
>> Unfortunately it cannot really be caught. I mean, you could catch
>> ‘&store-protocol-error’ error conditions, but then the error message is
>> just a string, there’s no error code you can compare against.

If I read correctly, the error is raised by nix/libstore/store-api.cc:

Toggle snippet (19 lines)
void checkStoreName(const string & name)
{
string validChars = "+-._?=";
/* Disallow names starting with a dot for possible security
reasons (e.g., "." and ".."). */
if (string(name, 0, 1) == ".")
throw Error(format("invalid name: `%1%'") % name);
foreach (string::const_iterator, i, name)
if (!((*i >= 'A' && *i <= 'Z') ||
(*i >= 'a' && *i <= 'z') ||
(*i >= '0' && *i <= '9') ||
validChars.find(*i) != string::npos))
{
throw Error(format("invalid character `%1%' in name `%2%'")
% *i % name);
}
}

Therefore, I am missing if this message “invalid character” should be
improved or if the check of the name should be done before on the Scheme
side. Well, I am missing what could be the path to improve the
situation, if it needs.


All the best,
simon
H
H
Hartmut Goebel wrote on 21 Dec 2020 15:16
(name . zimoun)(address . zimon.toutoune@gmail.com)(address . 37523@debbugs.gnu.org)
2f806ed7-dc2c-ee67-76ff-4483b5515f31@crazy-compilers.com
Hi,,

thanks for picking this up.

Toggle quote (5 lines)
> Therefore, I am missing if this message “invalid character” should be
> improved or if the check of the name should be done before on the Scheme
> side. Well, I am missing what could be the path to improve the
> situation, if it needs.

Since this check is done also for other store-items, I assume it does
not make much sense to change the message in the C-code.

So I assume the patch to improve this is to check the name on the Scheme
side. (Or to make the da)emon return some meaningful error object.
Anyhow I assume this is much more complicated and not a solution for now.

--
Regards
Hartmut Goebel

| Hartmut Goebel | h.goebel@crazy-compilers.com |
| www.crazy-compilers.com | compilers which you thought are impossible |
?
Your comment

Commenting via the web interface is currently disabled.

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

To respond to this issue using the mumi CLI, first switch to it
mumi current 37523
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