From edd9772fbb6814a9694d435187accdd4f80308fa Mon Sep 17 00:00:00 2001 From: Alexander Dahl Date: Fri, 31 Jul 2015 07:23:00 +0200 Subject: [PATCH 1/5] targets can change after checkout of another version --- build.sh | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/build.sh b/build.sh index 9647566..c5914d5 100755 --- a/build.sh +++ b/build.sh @@ -89,10 +89,10 @@ echo # build pushd .. -TARGETS=$(make 2>/dev/null | grep '^ [*] ' | cut -d' ' -f3) +OLD_TARGETS=$(make 2>/dev/null | grep '^ [*] ' | cut -d' ' -f3) echo -e "\033[32mpreparing gluon build ...\033[0m" -for target in ${TARGETS} +for target in ${OLD_TARGETS} do make clean GLUON_TARGET=${target} $VERBOSE done @@ -101,14 +101,15 @@ git checkout master git pull git checkout ${GLUON_CHECKOUT} -for target in ${TARGETS} +NEW_TARGETS=$(make 2>/dev/null | grep '^ [*] ' | cut -d' ' -f3) +for target in ${NEW_TARGETS} do make clean GLUON_TARGET=${target} $VERBOSE done make update $VERBOSE -for target in ${TARGETS} +for target in ${NEW_TARGETS} do echo -e "starting to build target \033[32m${target}\033[0m ..." make GLUON_TARGET=${target} -j4 $VERBOSE From d91be4e2822345e1b9bb406680a656808e346f44 Mon Sep 17 00:00:00 2001 From: Alexander Dahl Date: Fri, 31 Jul 2015 11:24:35 +0200 Subject: [PATCH 2/5] ask if old images should be removed --- build.sh | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/build.sh b/build.sh index c5914d5..1adef6e 100755 --- a/build.sh +++ b/build.sh @@ -78,7 +78,7 @@ echo -e "GLUON_BRANCH: \033[32m${GLUON_BRANCH}\033[0m" echo -e "GLUON_RELEASE: \033[32m${GLUON_RELEASE}\033[0m" # wait five seconds to give user time to read the things above -for i in $(seq 5) +for i in $(seq 3) do sleep 1 echo -n '.' @@ -89,6 +89,14 @@ echo # build pushd .. +# ask if old images should be removed +echo -n 'Cleanup old image directory? (y/N) ' +read ANSWER +if [ "${ANSWER}" = 'y' ] +then + rm -vrf images/factory images/sysupgrade +fi + OLD_TARGETS=$(make 2>/dev/null | grep '^ [*] ' | cut -d' ' -f3) echo -e "\033[32mpreparing gluon build ...\033[0m" From 9f2f615bb872a5a302fa11a93ed590daf6ca5c2c Mon Sep 17 00:00:00 2001 From: Alexander Dahl Date: Fri, 31 Jul 2015 11:47:27 +0200 Subject: [PATCH 3/5] check openwrt releases of old and new gluon checkout against each other experience shows builds will break on downgrade and maybe brake on upgrade, so we ask if a `make dirclean` should be invoked before build. --- build.sh | 24 +++++++++++++++++++++--- 1 file changed, 21 insertions(+), 3 deletions(-) diff --git a/build.sh b/build.sh index 1adef6e..62d443b 100755 --- a/build.sh +++ b/build.sh @@ -97,9 +97,10 @@ then rm -vrf images/factory images/sysupgrade fi +OLD_OPENWRT_RELEASE=$(grep 'RELEASE:=' include/toplevel.mk | sed -e 's/RELEASE:=//') OLD_TARGETS=$(make 2>/dev/null | grep '^ [*] ' | cut -d' ' -f3) -echo -e "\033[32mpreparing gluon build ...\033[0m" +echo -e "\033[32mPreparing gluon build ...\033[0m" for target in ${OLD_TARGETS} do make clean GLUON_TARGET=${target} $VERBOSE @@ -117,13 +118,30 @@ done make update $VERBOSE +# OpenWRT release branch check +NEW_OPENWRT_RELEASE=$(grep 'RELEASE:=' include/toplevel.mk | sed -e 's/RELEASE:=//') +if [ "${OLD_OPENWRT_RELEASE}" != "${NEW_OPENWRT_RELEASE}" ] +then + echo '----' + echo -e "Previous OpenWRT release checkout:\t${OLD_OPENWRT_RELEASE}" + echo -e "Current OpenWRT release checkout:\t${NEW_OPENWRT_RELEASE}" + echo -e "\033[40;93mOpenWRT releases differ. Recommended to rebuild toolchains!\033[0m" + echo -n 'Clean the entire tree? (y/N) ' + read ANSWER + if [ "${ANSWER}" = 'y' ] + then + make dirclean + fi +fi +echo -e "OpenWRT release branch: \033[32m${NEW_OPENWRT_RELEASE}\033[0m" + for target in ${NEW_TARGETS} do - echo -e "starting to build target \033[32m${target}\033[0m ..." + echo -e "Starting to build target \033[32m${target}\033[0m ..." make GLUON_TARGET=${target} -j4 $VERBOSE done -echo -e "\033[32mmaking manifest ...\033[0m" +echo -e "\033[32mMaking manifest ...\033[0m" make manifest $VERBOSE # .. From 34a80d344a2d13466e44951f79b8263923bd7800 Mon Sep 17 00:00:00 2001 From: Alexander Dahl Date: Fri, 31 Jul 2015 13:43:58 +0200 Subject: [PATCH 4/5] new option -y for "all yes" (maybe useful in automated builds) --- build.sh | 24 +++++++++++++++++++++--- 1 file changed, 21 insertions(+), 3 deletions(-) diff --git a/build.sh b/build.sh index 62d443b..247dd6a 100755 --- a/build.sh +++ b/build.sh @@ -13,10 +13,12 @@ print_usage() { echo 'Options:' echo ' -h show this help' echo ' -v verbose mode' + echo ' -y answer all questions with yes' } # command line options handling -ARGS=`getopt hv $*` +ALLYES='false' +ARGS=$(getopt hvy $*) if [ $? -ne 0 ] then print_usage @@ -35,6 +37,10 @@ do VERBOSE='V=s' shift ;; + -y) + ALLYES='true' + shift + ;; --) shift; break;; esac @@ -91,7 +97,13 @@ pushd .. # ask if old images should be removed echo -n 'Cleanup old image directory? (y/N) ' -read ANSWER +if [ "${ALLYES}" = 'true' ] +then + ANSWER='y' + echo ${ANSWER} +else + read ANSWER +fi if [ "${ANSWER}" = 'y' ] then rm -vrf images/factory images/sysupgrade @@ -127,7 +139,13 @@ then echo -e "Current OpenWRT release checkout:\t${NEW_OPENWRT_RELEASE}" echo -e "\033[40;93mOpenWRT releases differ. Recommended to rebuild toolchains!\033[0m" echo -n 'Clean the entire tree? (y/N) ' - read ANSWER + if [ "${ALLYES}" = 'true' ] + then + ANSWER='y' + echo ${ANSWER} + else + read ANSWER + fi if [ "${ANSWER}" = 'y' ] then make dirclean From 945ad6688f819a734fc74cbd8f6bbee2b11193ad Mon Sep 17 00:00:00 2001 From: Alexander Dahl Date: Fri, 31 Jul 2015 13:44:35 +0200 Subject: [PATCH 5/5] some more explaining comments --- build.sh | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/build.sh b/build.sh index 247dd6a..49883fb 100755 --- a/build.sh +++ b/build.sh @@ -78,7 +78,7 @@ export GLUON_BRANCH GLUON_PRIORITY # get GLUON_CHECKOUT from site dir pushd ${SCRIPTDIR} -eval `make -s -f helper.mk` +eval $(make -s -f helper.mk) echo -e "GLUON_CHECKOUT: \033[32m${GLUON_CHECKOUT}\033[0m" echo -e "GLUON_BRANCH: \033[32m${GLUON_BRANCH}\033[0m" echo -e "GLUON_RELEASE: \033[32m${GLUON_RELEASE}\033[0m" @@ -92,7 +92,7 @@ done sleep 1 echo -# build +# goto gluon dir pushd .. # ask if old images should be removed @@ -109,9 +109,11 @@ then rm -vrf images/factory images/sysupgrade fi +# gather some information about current build tree before clean OLD_OPENWRT_RELEASE=$(grep 'RELEASE:=' include/toplevel.mk | sed -e 's/RELEASE:=//') OLD_TARGETS=$(make 2>/dev/null | grep '^ [*] ' | cut -d' ' -f3) +# prepare gluon tree echo -e "\033[32mPreparing gluon build ...\033[0m" for target in ${OLD_TARGETS} do @@ -130,7 +132,7 @@ done make update $VERBOSE -# OpenWRT release branch check +# check OpenWRT release branch NEW_OPENWRT_RELEASE=$(grep 'RELEASE:=' include/toplevel.mk | sed -e 's/RELEASE:=//') if [ "${OLD_OPENWRT_RELEASE}" != "${NEW_OPENWRT_RELEASE}" ] then @@ -153,12 +155,14 @@ then fi echo -e "OpenWRT release branch: \033[32m${NEW_OPENWRT_RELEASE}\033[0m" +# loop through all targets and build them for target in ${NEW_TARGETS} do echo -e "Starting to build target \033[32m${target}\033[0m ..." make GLUON_TARGET=${target} -j4 $VERBOSE done +# finalize echo -e "\033[32mMaking manifest ...\033[0m" make manifest $VERBOSE