devshell: Fix wrong PATH value if disabled ccache

Message ID 20250108152256.851757-1-amikan@ilbers.de
State Accepted, archived
Headers show
Series devshell: Fix wrong PATH value if disabled ccache | expand

Commit Message

Anton Mikanovich Jan. 8, 2025, 3:22 p.m. UTC
In case USE_CCACHE is set to 0 the value of PATH_PREPEND env variable
will be empty. This makes PATH in devshell looks like:

:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin

If building the packages having directories named the same as some
binaries used during the build (like dh-python with dh directory inside
its sources), it will fail with the following error:

...
 debian/rules binary
dh binary
make: dh: Permission denied
make: *** [debian/rules:4: binary] Error 127

Make devshell expand PATH only if PATH_PREPEND is non-empty.

Signed-off-by: Anton Mikanovich <amikan@ilbers.de>
---
 meta/classes/dpkg-base.bbclass | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

Comments

Uladzimir Bely Jan. 16, 2025, 7:02 a.m. UTC | #1
On Wed, 2025-01-08 at 17:22 +0200, Anton Mikanovich wrote:
> In case USE_CCACHE is set to 0 the value of PATH_PREPEND env variable
> will be empty. This makes PATH in devshell looks like:
> 
> :/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin
> 
> If building the packages having directories named the same as some
> binaries used during the build (like dh-python with dh directory
> inside
> its sources), it will fail with the following error:
> 
> ...
>  debian/rules binary
> dh binary
> make: dh: Permission denied
> make: *** [debian/rules:4: binary] Error 127
> 
> Make devshell expand PATH only if PATH_PREPEND is non-empty.
> 
> Signed-off-by: Anton Mikanovich <amikan@ilbers.de>
> ---
>  meta/classes/dpkg-base.bbclass | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/meta/classes/dpkg-base.bbclass b/meta/classes/dpkg-
> base.bbclass
> index c02c07a8..4468a49a 100644
> --- a/meta/classes/dpkg-base.bbclass
> +++ b/meta/classes/dpkg-base.bbclass
> @@ -258,7 +258,7 @@ python do_devshell() {
>          apt-get -y -q update -o
> Dir::Etc::SourceList=\"sources.list.d/isar-apt.list\" -o
> Dir::Etc::SourceParts=\"-\" -o APT::Get::List-Cleanup=\"0\"; \
>          apt-get -y upgrade; \
>          {2}; \
> -        export PATH=$PATH_PREPEND:$PATH; \
> +        if [ -n \"$PATH_PREPEND\" ]; then export
> PATH=$PATH_PREPEND:$PATH; fi; \
>          $SHELL -i \
>      '"
>      oe_terminal(termcmd.format(schroot, pp_pps, install_deps), "Isar
> devshell", d)
> -- 
> 2.34.1
> 

Applied to next.

Patch

diff --git a/meta/classes/dpkg-base.bbclass b/meta/classes/dpkg-base.bbclass
index c02c07a8..4468a49a 100644
--- a/meta/classes/dpkg-base.bbclass
+++ b/meta/classes/dpkg-base.bbclass
@@ -258,7 +258,7 @@  python do_devshell() {
         apt-get -y -q update -o Dir::Etc::SourceList=\"sources.list.d/isar-apt.list\" -o Dir::Etc::SourceParts=\"-\" -o APT::Get::List-Cleanup=\"0\"; \
         apt-get -y upgrade; \
         {2}; \
-        export PATH=$PATH_PREPEND:$PATH; \
+        if [ -n \"$PATH_PREPEND\" ]; then export PATH=$PATH_PREPEND:$PATH; fi; \
         $SHELL -i \
     '"
     oe_terminal(termcmd.format(schroot, pp_pps, install_deps), "Isar devshell", d)