summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorKarel Kočí <karel.koci@nic.cz>2018-08-28 10:24:39 +0200
committerKarel Kočí <karel.koci@nic.cz>2018-08-28 10:24:39 +0200
commit12ae05f4610735d7867712f347a5371844f525c8 (patch)
tree36361ec8760968fa244d9ff44f4599575867f7ec
parent81157ba2ddbdab2f20ca069f96d020bb40894ae1 (diff)
downloadlaminar-cnf-12ae05f4610735d7867712f347a5371844f525c8.tar.gz
laminar-cnf-12ae05f4610735d7867712f347a5371844f525c8.tar.bz2
laminar-cnf-12ae05f4610735d7867712f347a5371844f525c8.zip
turris4x: preserve precompiled sdk
-rw-r--r--scripts/utils19
-rwxr-xr-xtemplates/turris4x.run51
2 files changed, 54 insertions, 16 deletions
diff --git a/scripts/utils b/scripts/utils
index fd50dd8..c096f29 100644
--- a/scripts/utils
+++ b/scripts/utils
@@ -5,6 +5,11 @@ echo_stage() {
echo -e "\033[1;34m========== $@ ==========\033[0m"
}
+# Simple echo wrapper for stage marking
+echo_info() {
+ echo -e "\033[1;32m---------- $@ ----------\033[0m"
+}
+
# Fetch bare git repository to WORKSPACE
# First argument has to be a source URL
# Second argument is name of directory to which will be repository cloned to.
@@ -27,3 +32,17 @@ git_fetch() {
[ -n "$BRANCH" ] || BRANCH=master
git --git-dir="$WORKSPACE/$2" --bare worktree add --detach $2 $BRANCH
}
+
+# Lock special lock for this job
+# Extension appended to lock name has to be provided as first argument
+laminar_self_lock() {
+ # TODO trap release
+ laminarc lock "$(basename "$0")-$1"
+}
+
+# Unlock special lock for this job
+# Extension appended to lock name has to be provided as first argument
+laminar_self_unlock() {
+ # TODO remove trap release
+ laminarc unlock "$(basename "$0")-$1"
+}
diff --git a/templates/turris4x.run b/templates/turris4x.run
index 699b148..67844cf 100755
--- a/templates/turris4x.run
+++ b/templates/turris4x.run
@@ -8,28 +8,47 @@ MAKE="make -j4 IS_TTY=1 BUILD_LOG=1"
echo_stage "Get packages"
git_fetch "https://git.cynerd.cz/openwrt-personal-pkgs" pkgs
-echo_stage "Get turris-build"
-HASH="$(curl "https://repo.turris.cz/$BOARD-$BRANCH/git-hash" | awk '/ \* turris-build\: /{print $3}')"
-HASH="9544f32cf06c29aedf8c3d88b9ff8745179dfa69" # TODO remove this when repo_checkout is integrated
-git_fetch "https://gitlab.labs.nic.cz/turris/turris-build.git" turris-build "$HASH"
-
-echo_stage "Prepare SDK"
-mkdir openwrt
-cd openwrt
-echo ../turris-build/compile_fw -t $BOARD -p $BRANCH repo_prepare
-GIT_MIRROR="$WORKSPACE/mirror" \
- CCACHE_HOST_DIR="$WORKSPACE/ccache-host" \
- CCACHE_TARGET_DIR="$WORKSPACE/ccache-target" \
- ../turris-build/compile_fw -t $BOARD -p $BRANCH repo_prepare
+curl "https://repo.turris.cz/$BOARD-$BRANCH/git-hash" > git-hash
+if [ -f "$WORKSPACE/openwrt-git-hash" ] && cmp -s git-hash "$WORKSPACE/openwrt-git-hash"; then
+ echo_info "Using previous version of SDK"
+ cp -a "$WORKSPACE/sdk" openwrt
+ cd openwrt
+
+else
+ echo_info "Building new version of SDK"
+
+ echo_stage "Get turris-build"
+ HASH="$( | awk '/ \* turris-build\: /{print $3}')"
+ HASH="9544f32cf06c29aedf8c3d88b9ff8745179dfa69" # TODO remove this when repo_checkout is integrated
+ git_fetch "https://gitlab.labs.nic.cz/turris/turris-build.git" turris-build "$HASH"
+
+ echo_stage "Prepare SDK"
+ mkdir openwrt
+ cd openwrt
+ echo ../turris-build/compile_fw -t $BOARD -p $BRANCH repo_prepare
+ GIT_MIRROR="$WORKSPACE/mirror" \
+ CCACHE_HOST_DIR="$WORKSPACE/ccache-host" \
+ CCACHE_TARGET_DIR="$WORKSPACE/ccache-target" \
+ ../turris-build/compile_fw -t $BOARD -p $BRANCH repo_prepare
+
+ echo_stage "Compile tools"
+ $MAKE tools/compile toolchain/compile package/usign/host/compile
+
+ echo_stage "Store SDK in workspace"
+ cd ..
+ laminar_self_lock sdk
+ rm -rf "$WORKSPACE/sdk"
+ cp -a openwrt "$WORKSPACE/sdk"
+ laminar_self_unlock sdk
+ cd openwrt
+
+fi
echo_stage "Add our repository as feed"
echo "src-git personal file://$WORKSPACE/pkgs" >> feeds.conf
./scripts/feeds update personal
./scripts/feeds install -p personal -d y -f -a
-echo_stage "Compile tools"
-$MAKE tools/compile toolchain/compile package/usign/host/compile
-
echo_stage "Compile packages from our feed"
$MAKE $(./scripts/feeds list -r personal | sed -n 's/^\([^ ]*\).*$/package\/\1\/compile/p' | tr '\n' ' ')