Skip to contentSkip to conversation

package/pkg-hare: refactor build command

PATCH Applied Thomas Petazzoni via buildroot 3 participants 12 messages Oct 20 – Oct 30

lore
Share & tools
lore
#0 lore raw

PATCH 1/2 package/pkg-hare: refactor build command

In order to avoid duplicating the build command, use an intermediate "target" shell variable to store the make target to be invoked for the build. This is in preparation to extending the build command.

---
 package/pkg-hare.mk | 7 +++----
 1 file changed, 3 insertions(+), 4 deletions(-)
package/pkg-hare.mk +3 -4
index 14e0cfce5a..15dc769311 100644
@@ -49,10 +49,9 @@ ifndef $(2)_BUILD_CMDS
 # but in real world, the target "all" is not always the default one
 define $(2)_BUILD_CMDS
 	if grep "^all:" $$($(2)_SRCDIR)Makefile > /dev/null; then \
-		$(MAKE) -C $$($(2)_SRCDIR) HARE="$$(HARE_RUN_CMD)" HAREFLAGS="$$(HARE_ARCH_OPT) $$(HARE_LIBDIR_OPT)" all; \
-	else \
-		$(MAKE) -C $$($(2)_SRCDIR) HARE="$$(HARE_RUN_CMD)" HAREFLAGS="$$(HARE_ARCH_OPT) $$(HARE_LIBDIR_OPT)"; \
-	fi
+		target=all ; \
+	fi ; \
+	$(MAKE) -C $$($(2)_SRCDIR) HARE="$$(HARE_RUN_CMD)" HAREFLAGS="$$(HARE_ARCH_OPT) $$(HARE_LIBDIR_OPT)" $${target}
 endef
 endif
 
Signature · 6 lines
2.56.0

_______________________________________________
buildroot mailing list
[email protected]
https://lists.buildroot.org/mailman/listinfo/buildroot
#1 lore raw

PATCH 2/2 package/pkg-hare: move cache directory outside of $(HOME)

By default, hare will store its cache directory in $(HOME)/.cache, which is a problem as we don't want a Buildroot build to write outside of its output directory (to the exception of DL_DIR, of course). The build of hare-package packages currently fails with:

Error creating /home/br-user/.cache/hare: Permission denied make[2]: *** [Makefile:15: dbus-introspector] Error 255 Error creating make[2]: *** Waiting for unfinished jobs.... /home/br-user/.cache/hare: Permission denied make[2]: *** [Makefile:19: dbus-scanner] Error 255

due to this issue.

We fix this by passing XDG_CACHE_HOME when building hare-package packages.

Fixes 44d38432343e65ec7a6d898cf982985cc2bc1e88 ("package/pkg-hare.mk: new infrastructure")
---
 package/pkg-hare.mk | 6 +++++-
 1 file changed, 5 insertions(+), 1 deletion(-)
package/pkg-hare.mk +5 -1
index 15dc769311..6494d2651c 100644
@@ -51,7 +51,11 @@ define $(2)_BUILD_CMDS
 	if grep "^all:" $$($(2)_SRCDIR)Makefile > /dev/null; then \
 		target=all ; \
 	fi ; \
-	$(MAKE) -C $$($(2)_SRCDIR) HARE="$$(HARE_RUN_CMD)" HAREFLAGS="$$(HARE_ARCH_OPT) $$(HARE_LIBDIR_OPT)" $${target}
+	$(MAKE) -C $$($(2)_SRCDIR) \
+		HARE="$$(HARE_RUN_CMD)" \
+		HAREFLAGS="$$(HARE_ARCH_OPT) $$(HARE_LIBDIR_OPT)" \
+		XDG_CACHE_HOME="$$($(2)_SRCDIR)/.cache" \
+		$${target}
 endef
 endif
 
Signature · 6 lines
2.56.0

_______________________________________________
buildroot mailing list
[email protected]
https://lists.buildroot.org/mailman/listinfo/buildroot
#2 lore raw

Re: [Buildroot] [PATCH 2/2] package/pkg-hare: move cache directory outside of $(HOME)

Am 20.10.26 um 14:06 schrieb Thomas Petazzoni via buildroot:

Quoted 3 lines

By default, hare will store its cache directory in $(HOME)/.cache, which is a problem as we don't want a Buildroot build to write outside of its output directory (to the exception of DL_DIR, of course). The

And CCACHE_DIR, if enabled. Not really critical, but might give someone who's new to Buildroot a wrong idea. ;-)

Quoted 8 lines

build of hare-package packages currently fails with:

Error creating /home/br-user/.cache/hare: Permission denied make[2]: *** [Makefile:15: dbus-introspector] Error 255 Error creating make[2]: *** Waiting for unfinished jobs.... /home/br-user/.cache/hare: Permission denied make[2]: *** [Makefile:19: dbus-scanner] Error 255

Quoted 4 lines

due to this issue.

We fix this by passing XDG_CACHE_HOME when building hare-package packages.

I'm not familiar with Hare, what does it store in its cache dir? The default path suggests it's intended as a global cache, so I'm wondering if something like $(BUILD_DIR)/.hare-cache might be better than a per-package cache. But of course that depends on what goes in there.

Best regards,
Fiona

Quoted 13 lines
Fixes 44d38432343e65ec7a6d898cf982985cc2bc1e88 ("package/pkg-hare.mk: new infrastructure")
---
  package/pkg-hare.mk | 6 +++++-
  1 file changed, 5 insertions(+), 1 deletion(-)
package/pkg-hare.mk +0 -0
index 15dc769311..6494d2651c 100644
@@ -51,7 +51,11 @@ define $(2)_BUILD_CMDS
  	if grep "^all:" $$($(2)_SRCDIR)Makefile > /dev/null; then \
  		target=all ; \

package/pkg-hare.mk define $(2)_BUILD_CMDS · line 61

Quoted 10 lines
package/pkg-hare.mk +5 -1
  	fi ; \
-	$(MAKE) -C $$($(2)_SRCDIR) HARE="$$(HARE_RUN_CMD)" HAREFLAGS="$$(HARE_ARCH_OPT) $$(HARE_LIBDIR_OPT)" $${target}
+	$(MAKE) -C $$($(2)_SRCDIR) \
+		HARE="$$(HARE_RUN_CMD)" \
+		HAREFLAGS="$$(HARE_ARCH_OPT) $$(HARE_LIBDIR_OPT)" \
+		XDG_CACHE_HOME="$$($(2)_SRCDIR)/.cache" \
+		$${target}
  endef
  endif
 

_______________________________________________
buildroot mailing list
[email protected]
https://lists.buildroot.org/mailman/listinfo/buildroot

#3 lore raw

Re: [Buildroot] [PATCH 2/2] package/pkg-hare: move cache directory outside of $(HOME)

Quoted 7 lines · Fiona Klute

Am 20.10.26 um 14:06 schrieb Thomas Petazzoni via buildroot:

Quoted 3 lines

By default, hare will store its cache directory in $(HOME)/.cache, which is a problem as we don't want a Buildroot build to write outside of its output directory (to the exception of DL_DIR, of course). The

And CCACHE_DIR, if enabled. Not really critical, but might give someone who's new to Buildroot a wrong idea. ;-)

True.

Quoted 4 lines

I'm not familiar with Hare, what does it store in its cache dir? The default path suggests it's intended as a global cache, so I'm wondering if something like $(BUILD_DIR)/.hare-cache might be better than a per-package cache. But of course that depends on what goes in there.

I must say I'm not sure. On the package/hare patch, I asked the feedback from François Perrad precisely for this reason. For what I can see, it contains "object files" for each source file that has been compiled, along with a bunch of other things.

See:

https://paste.ack.tf/3839b9@raw

(from this I can see the path within output/build/hare-dbus-e9a89f8bc5ce783fa25f0eb67d7d8932db90bcc2/.cache seems a bit crazy though.

Thomas

Signature · 7 lines
Thomas Petazzoni, co-owner and CEO, Bootlin
Embedded Linux and Kernel engineering and training
https://bootlin.com
_______________________________________________
buildroot mailing list
[email protected]
https://lists.buildroot.org/mailman/listinfo/buildroot
#4 lore raw

Re: [Buildroot] [PATCH 2/2] package/pkg-hare: move cache directory outside of $(HOME)

In reply to Thomas Petazzoni via buildroot
Quoted 13 lines
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line

"Thomas" == Thomas Petazzoni via buildroot <[email protected]> writes:

By default, hare will store its cache directory in $(HOME)/.cache, which is a problem as we don't want a Buildroot build to write outside of its output directory (to the exception of DL_DIR, of course). The build of hare-package packages currently fails with:

Error creating /home/br-user/.cache/hare: Permission denied make[2]: *** [Makefile:15: dbus-introspector] Error 255 Error creating make[2]: *** Waiting for unfinished jobs.... /home/br-user/.cache/hare: Permission denied make[2]: *** [Makefile:19: dbus-scanner] Error 255

Quoted 4 lines

due to this issue.

We fix this by passing XDG_CACHE_HOME when building hare-package packages.

Do we have reasons to think that this environment variable will only ever be used by hare packages? If not, then we should perhaps rather do it globally / in pkg-generic.mk, similar to E.G. how we set GIT_DIR=. ?

Signature · 5 lines
Bye, Peter Korsgaard
_______________________________________________
buildroot mailing list
[email protected]
https://lists.buildroot.org/mailman/listinfo/buildroot
#5 lore raw

Re: [Buildroot] [PATCH 2/2] package/pkg-hare: move cache directory outside of $(HOME)

Le mar. 20 oct. 2026 à 18:43, Peter Korsgaard <[email protected]> a écrit :

Quoted 14 lines
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line

"Thomas" == Thomas Petazzoni via buildroot <[email protected]>

Quoted 10 lines · writes:

By default, hare will store its cache directory in $(HOME)/.cache, which is a problem as we don't want a Buildroot build to write outside of its output directory (to the exception of DL_DIR, of course). The build of hare-package packages currently fails with:

Error creating /home/br-user/.cache/hare: Permission denied make[2]: *** [Makefile:15: dbus-introspector] Error 255 Error creating make[2]: *** Waiting for unfinished jobs.... /home/br-user/.cache/hare: Permission denied make[2]: *** [Makefile:19: dbus-scanner] Error 255

Quoted 10 lines
Quoted 4 lines

due to this issue.

We fix this by passing XDG_CACHE_HOME when building hare-package packages.

Do we have reasons to think that this environment variable will only ever be used by hare packages? If not, then we should perhaps rather do it globally / in pkg-generic.mk, similar to E.G. how we set GIT_DIR=. ?

in fact, hare has its own variable HARECACHE, see
https://manpages.ubuntu.com/manpages/stonking/man1/hare-build.1.html#environment

HARECACHE="$$($(2)_SRCDIR).cache" works fine.

no needs to set a desktop XDG environment variable.

François

Quoted 3 lines

--
Bye, Peter Korsgaard

_______________________________________________
buildroot mailing list
[email protected]
https://lists.buildroot.org/mailman/listinfo/buildroot

#6 lore raw

Re: [Buildroot] [PATCH 2/2] package/pkg-hare: move cache directory outside of $(HOME)

In reply to Peter Korsgaard
Quoted 3 lines · Peter Korsgaard

Do we have reasons to think that this environment variable will only ever be used by hare packages? If not, then we should perhaps rather do it globally / in pkg-generic.mk, similar to E.G. how we set GIT_DIR=. ?

That is certainly an option. Initially I only saw the problem on host-hare, but then I saw that the hare packages themselves can be affected as well. The question is of course whether there will be an impact on other packages, but if we decide that $HOME should be read-only, then it makes sense to divert XDG_CACHE_HOME to BUILD_DIR/.cache, and see whether it causes issues for some packages.

Should I respin a patch in that direction?

Independently from that I believe
https://patchwork.buildroot.org/project/buildroot/patch/[email protected]/
can still be a good small refactoring to merge.

Thanks!

Thomas

Signature · 7 lines
Thomas Petazzoni, co-owner and CEO, Bootlin
Embedded Linux and Kernel engineering and training
https://bootlin.com
_______________________________________________
buildroot mailing list
[email protected]
https://lists.buildroot.org/mailman/listinfo/buildroot
#7 lore raw

Re: [Buildroot] [PATCH 2/2] package/pkg-hare: move cache directory outside of $(HOME)

Quoted 7 lines
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line

"Thomas" == Thomas Petazzoni <[email protected]> writes:

Quoted 3 lines · Peter Korsgaard

Do we have reasons to think that this environment variable will only ever be used by hare packages? If not, then we should perhaps rather do it globally / in pkg-generic.mk, similar to E.G. how we set GIT_DIR=. ?

Quoted 8 lines

That is certainly an option. Initially I only saw the problem on host-hare, but then I saw that the hare packages themselves can be affected as well. The question is of course whether there will be an impact on other packages, but if we decide that $HOME should be read-only, then it makes sense to divert XDG_CACHE_HOME to BUILD_DIR/.cache, and see whether it causes issues for some packages.

Should I respin a patch in that direction?

I think that would be a good idea, yes.

Quoted 3 lines

Independently from that I believe
https://patchwork.buildroot.org/project/buildroot/patch/[email protected]/
can still be a good small refactoring to merge.

Sure, I will apply it now.

Signature · 5 lines
Bye, Peter Korsgaard
_______________________________________________
buildroot mailing list
[email protected]
https://lists.buildroot.org/mailman/listinfo/buildroot
Acked-by on v1 1/2
#8 lore raw
In reply to Thomas Petazzoni via buildroot
Quoted 30 lines · Thomas Petazzoni

In order to avoid duplicating the build command, use an intermediate "target" shell variable to store the make target to be invoked for the build. This is in preparation to extending the build command.

---
 package/pkg-hare.mk | 7 +++----
 1 file changed, 3 insertions(+), 4 deletions(-)
package/pkg-hare.mk +3 -4
index 14e0cfce5a..15dc769311 100644
@@ -49,10 +49,9 @@ ifndef $(2)_BUILD_CMDS
 # but in real world, the target "all" is not always the default one
 define $(2)_BUILD_CMDS
        if grep "^all:" $$($(2)_SRCDIR)Makefile > /dev/null; then \
-               $(MAKE) -C $$($(2)_SRCDIR) HARE="$$(HARE_RUN_CMD)"
 HAREFLAGS="$$(HARE_ARCH_OPT) $$(HARE_LIBDIR_OPT)" all; \
-       else \
-               $(MAKE) -C $$($(2)_SRCDIR) HARE="$$(HARE_RUN_CMD)"
 HAREFLAGS="$$(HARE_ARCH_OPT) $$(HARE_LIBDIR_OPT)"; \
-       fi
+               target=all ; \
+       fi ; \
+       $(MAKE) -C $$($(2)_SRCDIR) HARE="$$(HARE_RUN_CMD)"
 HAREFLAGS="$$(HARE_ARCH_OPT) $$(HARE_LIBDIR_OPT)" $${target}

endef
endif

Quoted 4 lines

--
2.56.0

_______________________________________________
buildroot mailing list
[email protected]
https://lists.buildroot.org/mailman/listinfo/buildroot

#9 lore raw
In reply to Thomas Petazzoni via buildroot
Quoted 7 lines
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line

"Thomas" == Thomas Petazzoni via buildroot <[email protected]> writes:

In order to avoid duplicating the build command, use an intermediate "target" shell variable to store the make target to be invoked for the build. This is in preparation to extending the build command.

Committed, thanks.

Signature · 5 lines
Bye, Peter Korsgaard
_______________________________________________
buildroot mailing list
[email protected]
https://lists.buildroot.org/mailman/listinfo/buildroot
#10 lore raw
In reply to Thomas Petazzoni via buildroot
Quoted 16 lines
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line

"Thomas" == Thomas Petazzoni via buildroot <[email protected]> writes:

In order to avoid duplicating the build command, use an intermediate "target" shell variable to store the make target to be invoked for the build. This is in preparation to extending the build command.

---
 package/pkg-hare.mk | 7 +++----
 1 file changed, 3 insertions(+), 4 deletions(-)
package/pkg-hare.mk +0 -0
index 14e0cfce5a..15dc769311 100644

package/pkg-hare.mk ifndef $(2)_BUILD_CMDS · line 54

Quoted 10 lines
package/pkg-hare.mk +3 -4
@@ -49,10 +49,9 @@ ifndef $(2)_BUILD_CMDS
 # but in real world, the target "all" is not always the default one
 define $(2)_BUILD_CMDS
 	if grep "^all:" $$($(2)_SRCDIR)Makefile > /dev/null; then \
-		$(MAKE) -C $$($(2)_SRCDIR) HARE="$$(HARE_RUN_CMD)" HAREFLAGS="$$(HARE_ARCH_OPT) $$(HARE_LIBDIR_OPT)" all; \
-	else \
-		$(MAKE) -C $$($(2)_SRCDIR) HARE="$$(HARE_RUN_CMD)" HAREFLAGS="$$(HARE_ARCH_OPT) $$(HARE_LIBDIR_OPT)"; \
-	fi
+		target=all ; \
+	fi ; \
+	$(MAKE) -C $$($(2)_SRCDIR) HARE="$$(HARE_RUN_CMD)" HAREFLAGS="$$(HARE_ARCH_OPT) $$(HARE_LIBDIR_OPT)" $${target}

I already pushed, but this presumably will break quite badly if someone has a 'target' environment variable set. Maybe we should explicitly set it to the empty string in the else clause?

Signature · 5 lines
Bye, Peter Korsgaard
_______________________________________________
buildroot mailing list
[email protected]
https://lists.buildroot.org/mailman/listinfo/buildroot
#11 lore raw
In reply to Thomas Petazzoni via buildroot

In reply of:

Quoted 6 lines

In order to avoid duplicating the build command, use an intermediate "target" shell variable to store the make target to be invoked for the build. This is in preparation to extending the build command.

Applied to 2026.08.x. Thanks

Quoted 12 lines
---
 package/pkg-hare.mk | 7 +++----
 1 file changed, 3 insertions(+), 4 deletions(-)
package/pkg-hare.mk +0 -0
index 14e0cfce5a..15dc769311 100644
@@ -49,10 +49,9 @@ ifndef $(2)_BUILD_CMDS
 # but in real world, the target "all" is not always the default one
 define $(2)_BUILD_CMDS
 	if grep "^all:" $$($(2)_SRCDIR)Makefile > /dev/null; then \

package/pkg-hare.mk ifndef $(2)_BUILD_CMDS · line 57

Quoted 10 lines
package/pkg-hare.mk +3 -4
-		$(MAKE) -C $$($(2)_SRCDIR) HARE="$$(HARE_RUN_CMD)" HAREFLAGS="$$(HARE_ARCH_OPT) $$(HARE_LIBDIR_OPT)" all; \
-	else \
-		$(MAKE) -C $$($(2)_SRCDIR) HARE="$$(HARE_RUN_CMD)" HAREFLAGS="$$(HARE_ARCH_OPT) $$(HARE_LIBDIR_OPT)"; \
-	fi
+		target=all ; \
+	fi ; \
+	$(MAKE) -C $$($(2)_SRCDIR) HARE="$$(HARE_RUN_CMD)" HAREFLAGS="$$(HARE_ARCH_OPT) $$(HARE_LIBDIR_OPT)" $${target}
 endef
 endif
 

_______________________________________________
buildroot mailing list
[email protected]
https://lists.buildroot.org/mailman/listinfo/buildroot