[PATCH] ebuild.sh: Fail on command-not-found in global scope

classic Classic list List threaded Threaded
3 messages Options
Reply | Threaded
Open this post in threaded view
|

[PATCH] ebuild.sh: Fail on command-not-found in global scope

Michał Górny-5
The PMS specifies that ebuilds must not call external commands in global
scope. We can not prevent that from happening at the moment since a few
ebuilds in Gentoo are still doing that.

Instead, start increasing strictness by explicitly failing if ebuilds
call external commands that are not found. This is not going to really
break any ebuilds that are not broken already (since command-not-found
usually indicates something is going wrong), and it will help noticing
typos and reliance on non-common external commands.

A similar change has been tested in pkgcore, and confirmed not to cause
any failures with the current state of the Gentoo repository.

Closes: https://github.com/gentoo/portage/pull/198
---
 bin/ebuild.sh | 4 ++++
 1 file changed, 4 insertions(+)

diff --git a/bin/ebuild.sh b/bin/ebuild.sh
index f1ac3f278..c23561651 100755
--- a/bin/ebuild.sh
+++ b/bin/ebuild.sh
@@ -79,6 +79,10 @@ else
  eval "${x}() { die \"\${FUNCNAME}() calls are not allowed in global scope\"; }"
  done
  unset funcs x
+
+ command_not_found_handle() {
+ die "Command not found while sourcing ebuild: ${*}"
+ }
 fi
 
 # Don't use sandbox's BASH_ENV for new shells because it does
--
2.14.1


Reply | Threaded
Open this post in threaded view
|

Re: [PATCH] ebuild.sh: Fail on command-not-found in global scope

Zac Medico-2
On 08/31/2017 07:56 AM, Michał Górny wrote:

> The PMS specifies that ebuilds must not call external commands in global
> scope. We can not prevent that from happening at the moment since a few
> ebuilds in Gentoo are still doing that.
>
> Instead, start increasing strictness by explicitly failing if ebuilds
> call external commands that are not found. This is not going to really
> break any ebuilds that are not broken already (since command-not-found
> usually indicates something is going wrong), and it will help noticing
> typos and reliance on non-common external commands.
>
> A similar change has been tested in pkgcore, and confirmed not to cause
> any failures with the current state of the Gentoo repository.
>
> Closes: https://github.com/gentoo/portage/pull/198
> ---
>  bin/ebuild.sh | 4 ++++
>  1 file changed, 4 insertions(+)
>
> diff --git a/bin/ebuild.sh b/bin/ebuild.sh
> index f1ac3f278..c23561651 100755
> --- a/bin/ebuild.sh
> +++ b/bin/ebuild.sh
> @@ -79,6 +79,10 @@ else
>   eval "${x}() { die \"\${FUNCNAME}() calls are not allowed in global scope\"; }"
>   done
>   unset funcs x
> +
> + command_not_found_handle() {
> + die "Command not found while sourcing ebuild: ${*}"
> + }
>  fi
>  
>  # Don't use sandbox's BASH_ENV for new shells because it does
>

Looks good. Please merge.
--
Thanks,
Zac

Reply | Threaded
Open this post in threaded view
|

Re: [PATCH] ebuild.sh: Fail on command-not-found in global scope

Michał Górny-5
W dniu czw, 31.08.2017 o godzinie 10∶42 -0700, użytkownik Zac Medico
napisał:

> On 08/31/2017 07:56 AM, Michał Górny wrote:
> > The PMS specifies that ebuilds must not call external commands in global
> > scope. We can not prevent that from happening at the moment since a few
> > ebuilds in Gentoo are still doing that.
> >
> > Instead, start increasing strictness by explicitly failing if ebuilds
> > call external commands that are not found. This is not going to really
> > break any ebuilds that are not broken already (since command-not-found
> > usually indicates something is going wrong), and it will help noticing
> > typos and reliance on non-common external commands.
> >
> > A similar change has been tested in pkgcore, and confirmed not to cause
> > any failures with the current state of the Gentoo repository.
> >
> > Closes: https://github.com/gentoo/portage/pull/198
> > ---
> >  bin/ebuild.sh | 4 ++++
> >  1 file changed, 4 insertions(+)
> >
> > diff --git a/bin/ebuild.sh b/bin/ebuild.sh
> > index f1ac3f278..c23561651 100755
> > --- a/bin/ebuild.sh
> > +++ b/bin/ebuild.sh
> > @@ -79,6 +79,10 @@ else
> >   eval "${x}() { die \"\${FUNCNAME}() calls are not allowed in global scope\"; }"
> >   done
> >   unset funcs x
> > +
> > + command_not_found_handle() {
> > + die "Command not found while sourcing ebuild: ${*}"
> > + }
> >  fi
> >  
> >  # Don't use sandbox's BASH_ENV for new shells because it does
> >
>
> Looks good. Please merge.

Merged.

--
Best regards,
Michał Górny