-
-
Notifications
You must be signed in to change notification settings - Fork 72
Expand file tree
/
Copy pathrunbuild
More file actions
executable file
·101 lines (89 loc) · 3.01 KB
/
Copy pathrunbuild
File metadata and controls
executable file
·101 lines (89 loc) · 3.01 KB
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
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
#!/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 number of CPU cores on system)
set -e
CI=${CI:-0}
[ "$CI" -eq "1" ] || ./runtests
BUILD_DIR=${BUILD_DIR-$(pwd)/build}
DOWNLOADS_DIR=${DOWNLOADS_DIR-$(pwd)/downloads}
START_TIME=${START_TIME-$(date +"%Y-%m-%d-%H%M%S")}
VERSIONED_DIR="$DOWNLOADS_DIR/$START_TIME"
LATEST_LINK="$DOWNLOADS_DIR/latest"
CORES=${CORES:-$(nproc)}
CURRENT_DIR=$(pwd)
OPENWRT_BRANCH="openwrt-25.12"
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 fetch --depth 1 origin $OPENWRT_BRANCH
git checkout -B $OPENWRT_BRANCH FETCH_HEAD
# OpenWrt generates a local key when CI does not provide the release key.
trap 'rm -f private-key.pem' EXIT
if [ -n "${OPENWRT_APK_PRIVATE_KEY:-}" ]; then
printf '%s\n' "$OPENWRT_APK_PRIVATE_KEY" >private-key.pem
chmod 600 private-key.pem
fi
# 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_USE_APK=y"
echo "CONFIG_SIGNED_PACKAGES=y"
echo "CONFIG_PACKAGE_openwisp-config=y"
} >>.config
make defconfig
COMPILE_TARGET=$(grep -E '^CONFIG_TARGET_ARCH_PACKAGES="[^"]+"$' .config | cut -d '"' -f 2)
if [ -z "$COMPILE_TARGET" ] || [ "$(printf '%s\n' "$COMPILE_TARGET" | wc -l)" -ne 1 ]; then
echo "ERROR: OpenWrt package architecture not found in .config"
exit 1
fi
PACKAGES_DIR="$BUILD_DIR/openwrt/bin/packages/$COMPILE_TARGET/openwisp"
rm -f "$PACKAGES_DIR"/*.apk "$PACKAGES_DIR"/packages.adb \
"$PACKAGES_DIR"/index.json "$PACKAGES_DIR"/public-key.pem \
"$PACKAGES_DIR"/sha256.manifest
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
# package/index creates packages.adb, the APK repository index used by apk,
# and index.json, a JSON representation of the package metadata.
make package/index V=s
PUBLIC_KEY="$BUILD_DIR/openwrt/public-key.pem"
if ! compgen -G "$PACKAGES_DIR/*.apk" >/dev/null; then
echo "ERROR: APK package files not found at $PACKAGES_DIR"
exit 1
fi
(
cd "$PACKAGES_DIR"
sha256sum ./*.apk >sha256.manifest
)
if [ ! -f "$PUBLIC_KEY" ]; then
echo "ERROR: APK repository public key not found at $PUBLIC_KEY"
exit 1
fi
cp "$PUBLIC_KEY" "$PACKAGES_DIR"
for index_file in packages.adb index.json public-key.pem sha256.manifest; do
if [ ! -f "$PACKAGES_DIR/$index_file" ]; then
echo "ERROR: APK repository metadata not found at $PACKAGES_DIR/$index_file"
exit 1
fi
done
# Move artifacts
mv "$PACKAGES_DIR" "$VERSIONED_DIR"
rm -f "$LATEST_LINK"
ln -s "$VERSIONED_DIR" "$LATEST_LINK"