forked from ovh/overthebox
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbuild.sh
executable file
·95 lines (75 loc) · 2.43 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
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
#!/bin/sh
set -e
umask 0022
unset GREP_OPTIONS SED
_get_repo() (
mkdir -p "$1"
cd "$1"
[ -d .git ] || git init
if git remote get-url origin >/dev/null 2>/dev/null; then
git remote set-url origin "$2"
else
git remote add origin "$2"
fi
git fetch origin
git fetch origin --tags
git checkout "origin/$3" -B "build" 2>/dev/null || git checkout "$3" -B "build"
)
OTB_DIST=${OTB_DIST:-otb}
OTB_HOST=${OTB_HOST:-$(curl -sS ipaddr.ovh)}
OTB_PORT=${OTB_PORT:-8000}
OTB_REPO=${OTB_REPO:-http://$OTB_HOST:$OTB_PORT/$OTB_PATH}
OTB_TARGET=${OTB_TARGET:-x86_64}
OTB_TARGET_CONFIG="config-$OTB_TARGET"
OTB_FEED_URL="${OTB_FEED_URL:-https://github.com/ovh/overthebox-feeds}"
OTB_FEED_SRC="${OTB_FEED_SRC:-master}"
if [ ! -f "$OTB_TARGET_CONFIG" ]; then
echo "Target $OTB_TARGET not found !"
exit 1
fi
OTB_FEED_BRANCH="openwrt-18.06@{2018-09-04 00:00:00}"
_get_repo source https://github.com/ovh/overthebox-lede "otb-18.09.04"
_get_repo feeds/packages https://github.com/openwrt/packages "$OTB_FEED_BRANCH"
_get_repo feeds/luci https://github.com/openwrt/luci "$OTB_FEED_BRANCH"
_get_repo feeds/routing https://github.com/openwrt-routing/packages "$OTB_FEED_BRANCH"
if [ -z "$OTB_FEED" ]; then
OTB_FEED=feeds/overthebox
_get_repo "$OTB_FEED" "$OTB_FEED_URL" "$OTB_FEED_SRC"
fi
rm -rf source/bin source/files source/tmp
cp -rf root source/files
cat >> source/files/etc/banner <<EOF
-----------------------------------------------------
PACKAGE: $OTB_DIST
VERSION: $(git describe --tag --always)
BUILD REPO: $(git config --get remote.origin.url)
BUILD DATE: $(date -u)
-----------------------------------------------------
EOF
cat > source/feeds.conf <<EOF
src-link packages $(readlink -f feeds/packages)
src-link luci $(readlink -f feeds/luci)
src-link routing $(readlink -f feeds/routing)
src-link overthebox $(readlink -f "$OTB_FEED")
EOF
cat "$OTB_TARGET_CONFIG" config -> source/.config <<EOF
CONFIG_IMAGEOPT=y
CONFIG_IB=y
CONFIG_IB_STANDALONE=y
CONFIG_VERSIONOPT=y
CONFIG_VERSION_DIST="$OTB_DIST"
CONFIG_VERSION_REPO="$OTB_REPO"
CONFIG_VERSION_NUMBER="$(git describe --tag --always)"
CONFIG_VERSION_CODE="$(git -C "$OTB_FEED" describe --tag --always)"
CONFIG_PACKAGE_$OTB_DIST=y
EOF
echo "Building $OTB_DIST for the target $OTB_TARGET"
cd source
cp .config .config.keep
scripts/feeds clean
scripts/feeds update -a
scripts/feeds install -a -d y -f -p overthebox
cp .config.keep .config
make defconfig
make "$@"
tar zcf bin/imagebuilder-files.tgz files