aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJo-Philipp Wich <jow@openwrt.org>2015-01-10 11:17:02 +0000
committerJo-Philipp Wich <jow@openwrt.org>2015-01-10 11:17:02 +0000
commitf1dfc77d7b7bfa2883e5542953cf97babc9de684 (patch)
tree410f6b2e0f69f909b2fa99e2446ae70c2a956411
parent515dd33cf9a41b4b73a3f01a40ac357bf5fc2711 (diff)
downloadmaster-187ad058-f1dfc77d7b7bfa2883e5542953cf97babc9de684.tar.gz
master-187ad058-f1dfc77d7b7bfa2883e5542953cf97babc9de684.tar.bz2
master-187ad058-f1dfc77d7b7bfa2883e5542953cf97babc9de684.zip
sdk: track files with git and use it to implement proper clean targets
Initialize a Git repository in the SDK and use git reset / git clean to rollback any SDK changes with "make clean" or "make dirclean". This approach is more robust than nuking entire directory trees because some parts of them might have been shipped with the original archive. Signed-off-by: Jo-Philipp Wich <jow@openwrt.org> git-svn-id: svn://svn.openwrt.org/openwrt/trunk@43904 3c298f89-4303-0410-b956-a3cf2f4a3e73
-rw-r--r--include/toplevel.mk2
-rw-r--r--target/sdk/files/Makefile19
2 files changed, 17 insertions, 4 deletions
diff --git a/include/toplevel.mk b/include/toplevel.mk
index 8a21f7eef4..f623e03118 100644
--- a/include/toplevel.mk
+++ b/include/toplevel.mk
@@ -135,7 +135,7 @@ kernel_menuconfig: prepare_kernel_conf
kernel_nconfig: prepare_kernel_conf
$(_SINGLE)$(NO_TRACE_MAKE) -C target/linux nconfig
-tmp/.prereq-build: include/prereq-build.mk
+tmp/.prereq-build: $(if $(SDK),.git/config) include/prereq-build.mk
mkdir -p tmp
rm -f tmp/.host.mk
@$(_SINGLE)$(NO_TRACE_MAKE) -j1 -r -s -f $(TOPDIR)/include/prereq-build.mk prereq 2>/dev/null || { \
diff --git a/target/sdk/files/Makefile b/target/sdk/files/Makefile
index 0c27f1a473..01c1e1c788 100644
--- a/target/sdk/files/Makefile
+++ b/target/sdk/files/Makefile
@@ -14,6 +14,16 @@ export TOPDIR LC_ALL LANG SDK
world:
+# Initialize SDK snapshot
+.git/config:
+ @( \
+ echo -n "Initializing SDK ... "; \
+ git init -q .; \
+ find . -mindepth 1 -maxdepth 1 -not -name feeds | xargs git add; \
+ git commit -q -m "Initial state"; \
+ echo "ok."; \
+ )
+
include $(TOPDIR)/include/host.mk
ifneq ($(OPENWRT_BUILD),1)
@@ -36,14 +46,17 @@ else
$(package/stamp-compile): $(BUILD_DIR)/.prepared
$(BUILD_DIR)/.prepared: Makefile
@mkdir -p $$(dirname $@)
- @mkdir -p bin/packages
@touch $@
clean: FORCE
- rm -rf $(BUILD_DIR) $(BIN_DIR)
+ git clean -f -d $(STAGING_DIR); true
+ git clean -f -d $(BUILD_DIR); true
+ git clean -f -d $(BIN_DIR); true
dirclean: clean
- rm -rf $(TMP_DIR)
+ git reset --hard HEAD
+ git clean -f -d
+ rm -rf feeds/
# check prerequisites before starting to build
prereq: $(package/stamp-prereq) ;