-
Notifications
You must be signed in to change notification settings - Fork 3
/
build.sh
executable file
·68 lines (55 loc) · 1.6 KB
/
build.sh
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
#!/bin/sh
# shellcheck disable=SC2086,SC3043,SC2164,SC2103,SC2046,SC2155
get_sources() {
# the checkout actions will set $HOME to other directory,
# we need to reset some necessary git configs again.
git config --global user.name "OpenWrt Builder"
git config --global user.email "buster-openwrt@ovvo.uk"
git clone $BUILD_REPO --single-branch -b $GITHUB_REF_NAME openwrt
cd openwrt
./scripts/feeds update -a
./scripts/feeds install -a
cd -
}
echo_version() {
echo "[=============== openwrt version ===============]"
cd openwrt && git log -1 && cd -
echo
echo "[=============== configs version ===============]"
cd configs && git log -1 && cd -
}
apply_patches() {
[ -d patches ] || return 0
dirname $(find patches -type f -name "*.patch") | sort -u | while read -r dir; do
local patch_dir="$(realpath $dir)"
cd "$(echo $dir | sed 's|^patches/|openwrt/|')"
find $patch_dir -type f -name "*.patch" | while read -r patch; do
git am $patch
done
cd -
done
}
build_firmware() {
cd openwrt
cp ${GITHUB_WORKSPACE}/configs/${BUILD_PROFILE} .config
make -j$(($(nproc) + 1)) V=e || make -j1 V=sc || exit 1
cd -
}
package_binaries() {
local bin_dir="openwrt/bin"
local tarball="${BUILD_PROFILE}.tar.gz"
tar -zcvf $tarball -C $bin_dir $(ls $bin_dir -1)
}
package_dl_src() {
[ -n "$BACKUP_DL_SRC" ] || return 0
[ $BACKUP_DL_SRC = 1 ] || return 0
local dl_dir="openwrt/dl"
local tarball="${BUILD_PROFILE}_dl-src.tar.gz"
tar -zcvf $tarball -C $dl_dir $(ls $dl_dir -1)
}
get_sources
echo_version
apply_patches
build_firmware
package_binaries
package_dl_src