[OpenWrt-Devel] [PATCH] build: fixes feeds with Makefile in root directory (#20392)

Ryan Lindeman rlindeman at caengineering.com
Thu Sep 24 10:43:09 EDT 2015


A kind reminder to please incorporate or comment on my patch. I think this
fix should also be backported to CC, BB, and possibly AA as well. Thank you
in advance for your consideration and thoughts/comments.

Best Regards,

Ryan Lindeman

On Fri, Aug 28, 2015 at 2:05 PM, Ryan Lindeman <rlindeman at caengineering.com>
wrote:

> This patch addresses an error caused by adding feeds that contain a
> Makefile
> in the root directory. The error is typically shown as follows:
> .../info/.files-packageinfo.mk:1: * target pattern contains no `%'. Stop.
> OR
> .../info/.files-targetinfo.mk:1: * target pattern contains no `%'. Stop.
>
> The root cause of the error is due to problems with the $(FILELIST): rule
> in
> the include/scan.mk file which attempts to strip off the $(SCAN_DIR)/ and
> /Makefile: ... contents of the lines provided by the FIND_L command. When a
> feed contains a single Makefile in the root directory the /Makefile: ...
> portion is not removed since the $(SCAN_DIR)/ has already removed the
> preceding / before the Makefile. This then causes extra characters to be
> evaluated by grep in the $(TMP_DIR)/info/.files-$(SCAN_TARGET).mk: rule
> which
> is where the above error is eventually reported by Make.
>
> The solution is to allow for a portion of the $(SCAN_DIR) to be included
> in the
> results produced by the $(FILELIST): rule. This patch creates a new
> variable
> called PREFIX_DIR which becomes the directory portion of $(SCAN_DIR)
> removed.
> This variable is specified by the update_index method of the scripts/feeds
> file. Since the include/scan.mk file is also used to scan the packages
> folder
> the default value for PREFIX_DIR must be empty (which is specified at the
> top
> of the include/scan.mk file). These changes results in the
> info/.files-$(SCAN_TARGET).mk files to include the remainder of the
> $(SCAN_DIR) path not removed so the $(SCAN_DIR) path information is removed
> from the PackageDir rule specified in include/scan.mk. This has the added
> benefit of simplifying the readability of this rule IMHO.
>
> Signed-off-by: Ryan Lindeman <rlindeman at caengineering.com>
> ---
>  include/scan.mk |   21 +++++++++++----------
>  scripts/feeds   |    4 ++--
>  2 files changed, 13 insertions(+), 12 deletions(-)
>
> diff --git a/include/scan.mk b/include/scan.mk
> index 5af0359..8561b30 100644
> --- a/include/scan.mk
> +++ b/include/scan.mk
> @@ -8,6 +8,7 @@ include $(TOPDIR)/include/host.mk
>  SCAN_TARGET ?= packageinfo
>  SCAN_NAME ?= package
>  SCAN_DIR ?= package
> +PREFIX_DIR ?=
>  TARGET_STAMP:=$(TMP_DIR)/info/.files-$(SCAN_TARGET).stamp
>  FILELIST:=$(TMP_DIR)/info/.files-$(SCAN_TARGET)-$(SCAN_COOKIE)
>  OVERRIDELIST:=$(TMP_DIR)/info/.overrides-$(SCAN_TARGET)-$(SCAN_COOKIE)
> @@ -28,15 +29,15 @@ endef
>
>  define PackageDir
>    $(TMP_DIR)/.$(SCAN_TARGET): $(TMP_DIR)/info/.$(SCAN_TARGET)-$(1)
> -  $(TMP_DIR)/info/.$(SCAN_TARGET)-$(1): $(SCAN_DIR)/$(2)/Makefile
> $(SCAN_STAMP) $(foreach DEP,$(DEPS_$(SCAN_DIR)/$(2)/Makefile)
> $(SCAN_DEPS),$(wildcard $(if $(filter
> /%,$(DEP)),$(DEP),$(SCAN_DIR)/$(2)/$(DEP))))
> +  $(TMP_DIR)/info/.$(SCAN_TARGET)-$(1): $(2)/Makefile $(SCAN_STAMP)
> $(foreach DEP,$(DEPS_$(2)/Makefile) $(SCAN_DEPS),$(wildcard $(if $(filter
> /%,$(DEP)),$(DEP),$(2)/$(DEP))))
>         { \
> -               $$(call progress,Collecting $(SCAN_NAME) info:
> $(SCAN_DIR)/$(2)) \
> -               echo Source-Makefile: $(SCAN_DIR)/$(2)/Makefile; \
> +               $$(call progress,Collecting $(SCAN_NAME) info: $(2)) \
> +               echo Source-Makefile: $(2)/Makefile; \
>                 $(if $(3),echo Override: $(3),true); \
> -               $(NO_TRACE_MAKE) --no-print-dir -r DUMP=1 FEED="$(call
> feedname,$(2))" -C $(SCAN_DIR)/$(2) $(SCAN_MAKEOPTS) 2>/dev/null || { \
> -                       mkdir -p "$(TOPDIR)/logs/$(SCAN_DIR)/$(2)"; \
> -                       $(NO_TRACE_MAKE) --no-print-dir -r DUMP=1
> FEED="$(call feedname,$(2))" -C $(SCAN_DIR)/$(2) $(SCAN_MAKEOPTS) >
> $(TOPDIR)/logs/$(SCAN_DIR)/$(2)/dump.txt 2>&1; \
> -                       $$(call progress,ERROR: please fix
> $(SCAN_DIR)/$(2)/Makefile - see logs/$(SCAN_DIR)/$(2)/dump.txt for
> details\n) \
> +               $(NO_TRACE_MAKE) --no-print-dir -r DUMP=1 FEED="$(call
> feedname,$(2))" -C $(2) $(SCAN_MAKEOPTS) 2>/dev/null || { \
> +                       mkdir -p "$(TOPDIR)/logs/$(2)"; \
> +                       $(NO_TRACE_MAKE) --no-print-dir -r DUMP=1
> FEED="$(call feedname,$(2))" -C $(2) $(SCAN_MAKEOPTS) >
> $(TOPDIR)/logs/$(2)/dump.txt 2>&1; \
> +                       $$(call progress,ERROR: please fix $(2)/Makefile -
> see logs/$(2)/dump.txt for details\n) \
>                         rm -f $$@; \
>                 }; \
>                 echo; \
> @@ -55,11 +56,11 @@ endif
>
>  $(FILELIST): $(OVERRIDELIST)
>         rm -f $(TMP_DIR)/info/.files-$(SCAN_TARGET)-*
> -       $(call FIND_L, $(SCAN_DIR)) $(SCAN_EXTRA) -mindepth 1 $(if
> $(SCAN_DEPTH),-maxdepth $(SCAN_DEPTH)) -name Makefile | xargs grep -aHE
> 'call $(GREP_STRING)' | sed -e 's#^$(SCAN_DIR)/##' -e 's#/Makefile:.*##' |
> uniq | awk -v of=$(OVERRIDELIST) -f include/scan.awk > $@
> +       $(call FIND_L, $(SCAN_DIR)) $(SCAN_EXTRA) -mindepth 1 $(if
> $(SCAN_DEPTH),-maxdepth $(SCAN_DEPTH)) -name Makefile | xargs grep -aHE
> 'call $(GREP_STRING)' | sed -e 's#^$(PREFIX_DIR)/##' -e 's#/Makefile:.*##'
> | uniq | awk -v of=$(OVERRIDELIST) -f include/scan.awk > $@
>
>  $(TMP_DIR)/info/.files-$(SCAN_TARGET).mk: $(FILELIST)
>         ( \
> -               cat $< | awk '{print "$(SCAN_DIR)/" $$0 "/Makefile" }' |
> xargs grep -HE '^ *SCAN_DEPS *= *' | awk -F: '{ gsub(/^.*DEPS *= */, "",
> $$2); print "DEPS_" $$1 "=" $$2 }'; \
> +               cat $< | awk '{print "$(if $(PREFIX_DIR),$(PREFIX_DIR)/)"
> $$0 "/Makefile" }' | xargs grep -HE '^ *SCAN_DEPS *= *' | awk -F: '{
> gsub(/^.*DEPS *= */, "", $$2); print "DEPS_" $$1 "=" $$2 }'; \
>                 awk -F/ -v deps="$$DEPS" -v of="$(OVERRIDELIST)" ' \
>                 BEGIN { \
>                         while (getline < (of)) \
> @@ -73,7 +74,7 @@ $(TMP_DIR)/info/.files-$(SCAN_TARGET).mk: $(FILELIST)
>                         pkg=""; \
>                         if($$NF in override) \
>                                 pkg=override[$$NF]; \
> -                       print "$$(eval $$(call PackageDir," info "," dir
> "," pkg "))"; \
> +                       print "$$(eval $$(call PackageDir," info ",$(if
> $(PREFIX_DIR),$(PREFIX_DIR)/)" dir "," pkg "))"; \
>                 } ' < $<; \
>                 true; \
>         ) > $@
> diff --git a/scripts/feeds b/scripts/feeds
> index 79b5284..ddaf9f5 100755
> --- a/scripts/feeds
> +++ b/scripts/feeds
> @@ -99,8 +99,8 @@ sub update_index($)
>         -d "./feeds/$name.tmp/info" or mkdir "./feeds/$name.tmp/info" or
> return 1;
>
>         system("$mk -s prepare-mk OPENWRT_BUILD=
> TMP_DIR=\"$ENV{TOPDIR}/feeds/$name.tmp\"");
> -       system("$mk -s -f include/scan.mk IS_TTY=1
> SCAN_TARGET=\"packageinfo\" SCAN_DIR=\"feeds/$name\" SCAN_NAME=\"package\"
> SCAN_DEPS=\"$ENV{TOPDIR}/include/package*.mk\" SCAN_DEPTH=5 SCAN_EXTRA=\"\"
> TMP_DIR=\"$ENV{TOPDIR}/feeds/$name.tmp\"");
> -       system("$mk -s -f include/scan.mk IS_TTY=1
> SCAN_TARGET=\"targetinfo\" SCAN_DIR=\"feeds/$name\" SCAN_NAME=\"target\"
> SCAN_DEPS=\"profiles/*.mk $ENV{TOPDIR}/include/target.mk\" SCAN_DEPTH=5
> SCAN_EXTRA=\"\" SCAN_MAKEOPTS=\"TARGET_BUILD=1\"
> TMP_DIR=\"$ENV{TOPDIR}/feeds/$name.tmp\"");
> +       system("$mk -s -f include/scan.mk IS_TTY=1 PREFIX_DIR=\"feeds\"
> SCAN_TARGET=\"packageinfo\" SCAN_DIR=\"feeds/$name\" SCAN_NAME=\"package\"
> SCAN_DEPS=\"$ENV{TOPDIR}/include/package*.mk\" SCAN_DEPTH=5 SCAN_EXTRA=\"\"
> TMP_DIR=\"$ENV{TOPDIR}/feeds/$name.tmp\"");
> +       system("$mk -s -f include/scan.mk IS_TTY=1 PREFIX_DIR=\"feeds\"
> SCAN_TARGET=\"targetinfo\" SCAN_DIR=\"feeds/$name\" SCAN_NAME=\"target\"
> SCAN_DEPS=\"profiles/*.mk $ENV{TOPDIR}/include/target.mk\" SCAN_DEPTH=5
> SCAN_EXTRA=\"\" SCAN_MAKEOPTS=\"TARGET_BUILD=1\"
> TMP_DIR=\"$ENV{TOPDIR}/feeds/$name.tmp\"");
>         system("ln -sf $name.tmp/.packageinfo ./feeds/$name.index");
>         system("ln -sf $name.tmp/.targetinfo ./feeds/$name.targetindex");
>
> --
> 1.7.9.5
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.infradead.org/pipermail/openwrt-devel/attachments/20150924/95055fca/attachment.htm>
-------------- next part --------------
_______________________________________________
openwrt-devel mailing list
openwrt-devel at lists.openwrt.org
https://lists.openwrt.org/cgi-bin/mailman/listinfo/openwrt-devel


More information about the openwrt-devel mailing list