-
-
Notifications
You must be signed in to change notification settings - Fork 59
/
runbuild
executable file
·58 lines (48 loc) · 1.56 KB
/
runbuild
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
58
#!/bin/bash
# ci build script
# runs tests and then builds the OpenWrt package
# requires the following env vars:
# - $BUILD_DIR
# - $DOWNLOADS_DIR
# - $CORES (defaults to 1)
# - $COMPILE_TARGET (defaults to mips_24kc)
set -e
CI=${CI:-0}
[ "$CI" -eq "1" ] || ./runtests
BUILD_DIR=${BUILD_DIR-./build}
DOWNLOADS_DIR=${DOWNLOADS_DIR-./downloads}
START_TIME=${START_TIME-$(date +"%Y-%m-%d-%H%M%S")}
VERSIONED_DIR="$DOWNLOADS_DIR/$START_TIME"
COMPILE_TARGET=${COMPILE_TARGET-mips_24kc}
LATEST_LINK="$DOWNLOADS_DIR/latest"
CORES=${CORES:-1}
CURRENT_DIR=$(pwd)
OPENWRT_BRANCH="openwrt-23.05"
mkdir -p "$BUILD_DIR"
mkdir -p "$VERSIONED_DIR"
cd "$BUILD_DIR"
if ! [ -d "openwrt" ]; then
git clone https://git.openwrt.org/openwrt/openwrt.git --depth 1 --branch $OPENWRT_BRANCH
fi
cd openwrt
git reset --hard HEAD
git checkout $OPENWRT_BRANCH
git pull origin $OPENWRT_BRANCH
# configure feeds
echo "src-link openwisp $CURRENT_DIR" >feeds.conf
cat feeds.conf.default >>feeds.conf
# remove unneeded feeds
sed -i '/telephony/d' feeds.conf
sed -i '/routing/d' feeds.conf
./scripts/feeds update -a
./scripts/feeds install -a
echo "CONFIG_PACKAGE_openwisp-config=y" >>.config
make defconfig
if [ ! "$CI_CACHE" ]; then
make -j"$CORES" tools/install || make -j1 V=s tools/install
make -j"$CORES" toolchain/install || make -j1 V=s toolchain/install
fi
make -j"$CORES" package/openwisp-config/compile || make -j1 V=s package/openwisp-config/compile || exit 1
mv "$BUILD_DIR"/openwrt/bin/packages/"$COMPILE_TARGET"/openwisp "$VERSIONED_DIR"
rm "$LATEST_LINK" || true
ln -s "$VERSIONED_DIR" "$LATEST_LINK"