Re: Question about compiling the linux kernel
On Saturday, August 16th, 2025 at 9:41 AM, maria.shrivinski <maria.shrivinski@proton.me> wrote:
Hello,
> When compiling the kernel with make -j `getconf _NPROCESSORS_ONLN` deb-pkg the resulting .deb packages are generated in the parent directory.
> Is there a way to choose a specific directory where those packages will be placed?
>
> I have researched this issue and found partial answers about modifying scripts/package/debian/rules or various makefiles, but nothing has worked so far.
>
> Using environment variables like DESTDIR=/path/to/dir or OUTPUT_DIRECTORY=/path/to/dir with the make command also did not work.
>
> Starting to think that this might be impossible. Anyone have an idea?
I guess you're referring to the system found in the upstream kernel — a bit out of topic in this ML, isn't it? :P
Anyway, here is how I would do it.
First you need to patch scripts/package/debian/rules with the following:
diff --git a/scripts/package/debian/rules b/scripts/package/debian/rules
index a417a7f8bbc1..a9826a62c4f2 100755
--- a/scripts/package/debian/rules
+++ b/scripts/package/debian/rules
@@ -58,7 +58,7 @@ define binary
$(Q)dh_fixperms $(DH_OPTIONS)
$(Q)dh_gencontrol $(DH_OPTIONS) -- -f$(call mk-files,$@)
$(Q)dh_md5sums $(DH_OPTIONS)
- $(Q)dh_builddeb $(DH_OPTIONS) -- $(addprefix -Z,$(KDEB_COMPRESS))
+ $(Q)dh_builddeb $(DH_OPTIONS) --destdir=$(ARTIFACTS_DIR) -- $(addprefix -Z,$(KDEB_COMPRESS))
endef
.PHONY: $(binary-targets)
Then, you can build the package with the following command:
export ARTIFACTS_DIR=$(mktemp -d)
make DPKG_FLAGS="--buildinfo-file=${ARTIFACTS_DIR}/vanilla-image.buildinfo --buildinfo-option=-u${ARTIFACTS_DIR} --changes-option=-u${ARTIFACTS_DIR}" -j $(nproc --all) bindeb-pkg
Please note the DPKG_FLAGS.
Hope it helps
Best regards
Alessandro
Reply to: