Issues with package/Makefile and home build

Hi! Not sure how long this has been happening, It doesn’t always result in a failure to build firmware, either. But I have this error in my home system openwrt build log:

bash: line 1: cd: /src/openwrt/bin/packages/aarch64_cortex-a53: No such file or directory

resulting from this call made in package/Makefile:

(cd /src/openwrt/bin/packages/aarch64_cortex-a53; find . -maxdepth 1 -type f -not -name 'sha256sums' -printf "%P\n" | sort | xargs -r /src/openwrt/staging_dir/host/bin/mkhash -n sha256 | sed -ne 's!^\(.*\) \(.*\)$!\1 *\2!p' > sha256sums)

from line 175 of package/Makefile:

        $(call sha256sums,$(OUTPUT_DIR)/packages/$(ARCH_PACKAGES),1)

and this definition in rules.mk:

define sha256sums
	(cd $(1); find . $(if $(2),,-maxdepth 1) -type f -not -name 'sha256sums' -printf "%P\n" | sort | \
		xargs -r $(MKHASH) -n sha256 | sed -ne 's!^\(.*\) \(.*\)$$!\1 *\2!p' > sha256sums)

Since the ‘cd’ to a non-existent directory fails, it does a mkhash of the entire /src/openwrt directory, raising errors when it finds a file with a space in the name (there are several in the cmake and meson utils).

First, why is the build system looking for a non-existent directory?

Second, can the definition of sha256sums be changed to the below in order to avoid errors for file names with spaces in them:

define sha256sums
        (cd $(1); find . $(if $(2),,-maxdepth 1) -type f -not -name 'sha256sums' -printf "%P\0" | sort -z | \
                xargs -0 -r $(MKHASH) -n sha256 | sed -ne 's!^\(.*\) \(.*\)$$!\1 *\2!p' > sha256sums)

Ideas on the non-existent directory?

Thanks much!

Sure looks like $OUTPUT_DIR is somehow not getting set properly. You might take a look in rules.mk and see if you can figure out what would break its definition.

rules.mk:OUTPUT_DIR:=$(if $(call qstrip,$(CONFIG_BINARY_FOLDER)),$(call qstrip,$(CONFIG_BINARY_FOLDER)),$(TOPDIR)/bin)