From 37f1248d3d44766a931111cf393ba678193aadf9 Mon Sep 17 00:00:00 2001
From: Matthias Schiffer <mschiffer@universe-factory.net>
Date: Sat, 28 Dec 2013 22:13:18 +0100
Subject: [PATCH] Add some more fixes and some checks for the new module system

---
 Makefile               | 11 +++++++++--
 include/toplevel.mk    |  2 +-
 scripts/openwrt_rev.sh |  3 ---
 3 files changed, 10 insertions(+), 6 deletions(-)
 delete mode 100755 scripts/openwrt_rev.sh

diff --git a/Makefile b/Makefile
index 9925550b6..54f90a4a8 100644
--- a/Makefile
+++ b/Makefile
@@ -30,6 +30,7 @@ unpatch: FORCE
 	$(GLUONDIR)/scripts/unpatch.sh $(GLUONDIR)
 
 update-patches: FORCE
+	$(GLUONDIR)/scripts/update.sh $(GLUONDIR)
 	$(GLUONDIR)/scripts/update-patches.sh $(GLUONDIR)
 	$(GLUONDIR)/scripts/patch.sh $(GLUONDIR)
 
@@ -38,9 +39,8 @@ update-patches: FORCE
 _SINGLE=export MAKEFLAGS=$(space);
 
 override OPENWRT_BUILD=1
-override REVISION:=$(shell $(GLUONDIR)/scripts/openwrt_rev.sh $(GLUONDIR))
 GREP_OPTIONS=
-export OPENWRT_BUILD GREP_OPTIONS REVISION
+export OPENWRT_BUILD GREP_OPTIONS
 
 -include $(TOPDIR)/include/debug.mk
 -include $(TOPDIR)/include/depends.mk
@@ -53,20 +53,27 @@ endef
 
 include $(GLUONDIR)/include/profiles.mk
 
+CheckExternal := test -d $(GLUON_OPENWRTDIR) || (echo 'You don'"'"'t seem to have optained the external repositories needed by Gluon; please call `make update` first!'; false)
+
 all: FORCE
+	+@$(CheckExternal)
 	+@$(GLUONMAKE) prepare
 	+@$(GLUONMAKE) images
 
 download prepare images: FORCE
+	+@$(CheckExternal)
 	+@$(GLUONMAKE) $@
 
 dirclean: clean
+	+@$(CheckExternal)
 	+@$(SUBMAKE) -C $(TOPDIR) -r dirclean
 
 cleanall: clean
+	+@$(CheckExternal)
 	+@$(SUBMAKE) -C $(TOPDIR) -r clean
 
 clean:
+	+@$(CheckExternal)
 	+@$(GLUONMAKE) clean
 
 else
diff --git a/include/toplevel.mk b/include/toplevel.mk
index be3f7445b..c20d9ab6d 100644
--- a/include/toplevel.mk
+++ b/include/toplevel.mk
@@ -12,7 +12,7 @@ PREP_MK= OPENWRT_BUILD= QUIET=0
 
 -include $(TOPDIR)/include/verbose.mk
 
-REVISION:=$(shell $(TOPDIR)/scripts/getver.sh)
+REVISION:=$(shell $(TOPDIR)/scripts/getver.sh 2>/dev/null)
 
 HOSTCC ?= gcc
 OPENWRTVERSION:=$(RELEASE)$(if $(REVISION), ($(REVISION)))
diff --git a/scripts/openwrt_rev.sh b/scripts/openwrt_rev.sh
deleted file mode 100755
index 1cb94913d..000000000
--- a/scripts/openwrt_rev.sh
+++ /dev/null
@@ -1,3 +0,0 @@
-#!/bin/sh
-
-echo "r$(git --git-dir="$1"/.git/modules/openwrt log | grep -m 1 git-svn-id | awk '{ gsub(/.*@/, "", $0); print $1 }')"
-- 
GitLab