[source] sdk: fix Git URL detection

LEDE Commits lede-commits at lists.infradead.org
Fri Jan 20 01:11:23 PST 2017

jow pushed a commit to source.git, branch lede-17.01:

commit 2c4d158d8089c3cf79f7a8279f641d7272a4250a
Author: Jo-Philipp Wich <jo at mein.io>
AuthorDate: Fri Jan 20 09:51:38 2017 +0100

    sdk: fix Git URL detection
    Instead of relying on complex sed patterns that trip up make syntax rules, use
    GNU Makes builtin filter function to match desired URLs.
    Signed-off-by: Jo-Philipp Wich <jo at mein.io>
 target/sdk/Makefile | 7 +++++--
 1 file changed, 5 insertions(+), 2 deletions(-)

diff --git a/target/sdk/Makefile b/target/sdk/Makefile
index c93e317..47a7382 100644
--- a/target/sdk/Makefile
+++ b/target/sdk/Makefile
@@ -36,10 +36,13 @@ SDK_DIRS = \
-BASE_FEED:=$(shell git config --get remote.origin.url 2>/dev/null | sed -ne '\#\(git\|http\|https\)://#s/^/src-git base /p')
+GIT_URL:=$(filter git://% http://% https://%,$(shell git config --get remote.origin.url 2>/dev/null))
+GIT_BRANCH:=$(filter-out master,$(shell git rev-parse --abbrev-ref HEAD 2>/dev/null))
+BASE_FEED:=$(if $(GIT_URL),src-git base $(GIT_URL)$(if $(GIT_BRANCH),;$(GIT_BRANCH)))
 BASE_FEED:=$(if $(BASE_FEED),$(BASE_FEED),$(shell cd $(TOPDIR); LC_ALL=C git svn info 2>/dev/null | sed -ne 's/^URL: /src-gitsvn base /p'))
 BASE_FEED:=$(if $(BASE_FEED),$(BASE_FEED),$(shell cd $(TOPDIR); LC_ALL=C svn info 2>/dev/null | sed -ne 's/^URL: /src-svn base /p'))
-BASE_FEED:=$(if $(BASE_FEED),$(BASE_FEED),src-git base https://git.lede-project.org/source.git$(filter-out ;master,;$(shell git rev-parse --abbrev-ref HEAD)))
+BASE_FEED:=$(if $(BASE_FEED),$(BASE_FEED),src-git base https://git.lede-project.org/source.git$(if $(GIT_BRANCH),;$(GIT_BRANCH)))
 KDIR_BASE = $(patsubst $(TOPDIR)/%,%,$(LINUX_DIR))

More information about the lede-commits mailing list