Makefile: Add `make upgrade` target 65/49765/4
authorAlexandru Avadanii <Alexandru.Avadanii@enea.com>
Fri, 29 Dec 2017 17:17:05 +0000 (18:17 +0100)
committerAlexandru Avadanii <Alexandru.Avadanii@enea.com>
Fri, 29 Dec 2017 19:26:34 +0000 (19:26 +0000)
1. Fix missing default `make` target for `all`

2. `make submodules-clean` should checkout git submodule commit

   On patch apply, we tag the starting commit, so we can later export
   as patches all commits between that reference and another tag,
   applied simmetrically at the  end of the patch apply process.
   Previously, `submodules-clean` checked out that starting tag.
   Change that behavior to use the commit ID referenced by parent
   git repo (armband) submodule, so when armband git submodules are
   updated (e.g. sometimes `make upgrade` might include such changes),
   the new reference will be picked up automatically.

3. Add `make upgrade` for fetching latest changes on current branch

Change-Id: I03dc3953e91acfbe6ccb5e3bb2ccee7d28a0f7d5
Signed-off-by: Alexandru Avadanii <Alexandru.Avadanii@enea.com>
Makefile
armband-fuel-config.mk

index 68a85bb..bd1ef6d 100644 (file)
--- a/Makefile
+++ b/Makefile
@@ -30,7 +30,14 @@ export REVSTATE
 
 include armband-fuel-config.mk
 
-all: release
+all: upgrade
+
+# Ignore release tag and upgrade Armband to latest change on <branch>/HEAD
+.PHONY: upgrade
+upgrade:
+       @git fetch origin ${A_BRANCH}:${A_BRANCH}
+       @git checkout ${A_BRANCH}
+       @$(MAKE) -e submodules-clean patches-import
 
 # Fetch & update git submodules, checkout remote HEAD
 .PHONY: submodules-init
@@ -46,7 +53,7 @@ submodules-init: .submodules-init
 
 # Clean any changes made to submodules, checkout Armband root commit
 .PHONY: submodules-clean
-submodules-clean: .submodules-init
+submodules-clean:
        @git submodule -q foreach ' \
                git am -q --abort 2>/dev/null; \
                git checkout -q -f ${A_OPNFV_TAG}-root 2>/dev/null; \
@@ -54,7 +61,8 @@ submodules-clean: .submodules-init
                git tag | grep ${A_OPNFV_TAG} | xargs git tag -d > /dev/null 2>&1; \
                git reset -q --hard HEAD; \
                git clean -xdff'
-       @rm -f .submodules-patched
+       @rm -f .submodules-*
+       @$(MAKE) -e submodules-init
 
 # Generate patches from submodules
 .PHONY: patches-export
index 3b2bd7b..a4a0ad5 100644 (file)
@@ -12,6 +12,7 @@ A_FUEL_BASE := ${ARMBAND_BASE}/upstream/fuel
 A_PATCH_DIR := ${ARMBAND_BASE}/patches
 A_OPNFV_TAG  = armband-opnfv
 A_PATCHES    = $(shell find ${A_PATCH_DIR} -name '*.patch')
+A_BRANCH     = $(shell sed -ne 's/defaultbranch=//p' ${ARMBAND_BASE}/.gitreview)
 F_PATCH_DIR := ${A_FUEL_BASE}/mcp/patches
 
 # To enable remote tracking, set the following var to any non-empty string.