summaryrefslogtreecommitdiff
path: root/templates/turris4x.run
blob: 4d18de822bf038f64fbf543ec02b4c9e103d0e5d (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
#!/bin/sh
# vim: ft=sh
. "$(dirname "$(readlink -f "$0")")/../job.common"

if [ "$V" -ge 1 ]; then
	make="make -j1 IS_TTY=1 BUILD_LOG=1 V=99"
else
	make="make -j4 IS_TTY=1 BUILD_LOG=1"
fi

curl "https://repo.turris.cz/$BOARD-$BRANCH/git-hash" > git-hash
cat git-hash
# TODO take lock so we won't run multiple instances of new builds
if [ -z "$CLEAN" ] && [ -f "$WORKSPACE/openwrt-git-hash" ] && cmp -s git-hash "$WORKSPACE/openwrt-git-hash"; then
	echo_info "Using previous version of SDK"
	tar -xzf "$WORKSPACE/openwrt.tar.gz"
else
	echo_info "Building new version of SDK"
	echo_stage "Get turris-build"
	TB_HASH="$(awk '/ \* turris-build\: /{print $3}' git-hash)"
	git_fetch_t "https://gitlab.labs.nic.cz/turris/turris-build.git" turris-build "$TB_HASH"

	echo_stage "Prepare SDK"
	mkdir openwrt
	cd openwrt
	GIT_MIRROR="$TWORKSPACE/openwrt-git-mirror" \
		CCACHE_HOST_DIR="$TWORKSPACE/ccache-host" \
		CCACHE_TARGET_DIR="$WORKSPACE/ccache-target" \
		../turris-build/compile_fw -a "$njobs" -t $BOARD -p $BRANCH repo_prepare
	$make toolchain/compile target/compile
	cd ..
	tar -czf openwrt.tar.gz openwrt
	mv openwrt.tar.gz "$WORKSPACE/openwrt.tar.gz"
	mv git-hash "$WORKSPACE/openwrt-git-hash"
fi
cd openwrt

echo_stage "Add our repository as feed"
echo "src-git personal git@cynerd.cz:openwrt-personal-pkgs" >> feeds.conf
./scripts/feeds update personal
./scripts/feeds uninstall $(./scripts/feeds list -r personal | awk '{print $1}')
./scripts/feeds install -p personal -d y -f -a

echo_stage "Compile packages from personal feed"
$make $(ls package/feeds/personal | sed -n 's/^\([^ ]*\).*$/package\/\1\/compile/p' | tr '\n' ' ')

echo_stage "Generate index and sign"
$make package/index BUILD_KEY=~/openwrt-repo.key

echo_stage "Deploy"
ssh upload rm -rf "deploy-turris4x-$BOARD"
scp -r "bin/packages/$ARCH/personal" upload:deploy-turris4x-$BOARD
ssh upload /bin/sh -e <<EOF
	mkdir -p /var/www/repo/openwrt
	rm -rf /var/www/repo/openwrt/$BOARD
	mv deploy-turris4x-$BOARD /var/www/repo/openwrt/$BOARD
EOF