This repository has been archived by the owner on Nov 3, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 33
/
compile_fw
executable file
·189 lines (156 loc) · 5.52 KB
/
compile_fw
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
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
#!/bin/bash -xe
# Cleaning
[ -d ./tmp ] && rm -rf ./tmp
[ -d ./bin ] && rm -rf ./bin
[ -d ./bin-nor ] && rm -rf ./bin-nor
[ -d ./logs ] && rm -rf ./logs
[ -d ./logs-nand ] && rm -rf ./logs-nand
[ -d ./logs-nor ] && rm -rf ./logs-nor
[ -d ./logs-initram ] && rm -rf ./logs-initram
export TMPDIR="$PWD/tmp"
mkdir $TMPDIR
if [ "$1" = turris ] || [ "$1" = omnia ]; then
export TARGET_BOARD="$1"
shift
else
echo "The first argument is empty or unknown!"
echo "You have to specify target board - options are 'turris' or 'omnia'"
exit 1
fi
make_defconfig() {
make defconfig "$@"
egrep '^(#[[:space:]]+)?CONFIG_KERNEL' configs/common configs/$TARGET_BOARD | sed 's|.*:||' >> ./.config
if [ -n "${PKG_BRANCH}" ] && [ "${PKG_BRANCH}" \!= master ] && [ "${PKG_BRANCH}" \!= stable ] && [ "${PKG_BRANCH}" \!= stable-omnia ]; then
echo CONFIG_PACKAGE_cznic-repo-keys-test=y >> .config
echo CONFIG_PACKAGE_getbranch-test=y >> .config
else
echo CONFIG_PACKAGE_cznic-repo-keys-test=m >> .config
echo CONFIG_PACKAGE_getbranch-deploy=y >> .config
fi
}
# Clean feeds
./scripts/feeds clean
./scripts/feeds update -a
# Patch feeds
pushd patches
for feed in *; do
pushd $feed
for patch in *; do
pushd ../../feeds/$feed
patch -p1 < ../../patches/$feed/$patch
popd
done
popd
done
popd
./scripts/feeds update -i
./scripts/feeds install -a
# Uninstall broken pkgs
./scripts/feeds uninstall \
$([ \! -f ./disabled_packages.common ] || echo $(cut -d '#' -f1 ./disabled_packages.common)) \
$([ \! -f ./disabled_packages.$TARGET_BOARD ] || echo $(cut -d '#' -f1 ./disabled_packages.$TARGET_BOARD))
# Override packages release numbers
scripts/override_release_numbers.sh
# Build NAND FW
[ -z "$OPENWRT_BRANCH" ] || PKG_BRANCH="-$OPENWRT_BRANCH"
[ -n "$REAL_PKG_BRANCH" ] || REAL_PKG_BRANCH="$PKG_BRANCH"
cat configs/common configs/$TARGET_BOARD | sed -e "s|@BOARD@|$TARGET_BOARD|" -e "s|@BRANCH@|$PKG_BRANCH|" > .config
[ -n "$BUILD_ALL" ] && echo -e "CONFIG_ALL=y\nCONFIG_SDK=y\nCONFIG_IB=y\nCONFIG_IB_STANDALONE=n\nCONFIG_PACKAGE_ucollect-meta=m" >> .config
echo CONFIG_ALL_KMODS=y >> .config
[ -n "$USE_CCACHE" ] && echo "CONFIG_CCACHE=y" >> .config
if [ -f "$HOME"/mime.key ]; then
echo "CONFIG_SIGNED_PACKAGES=y" >> .config
rm -f key-build key-build.pub
cp "$HOME/mime.key" key-build
cp "$HOME/mime.pub" key-build.pub
fi
make_defconfig
if [ -d .git ] ; then
git log -n1 --format='%H' >files/etc/git-version
fi
make clean
[ -z "$BUILD_ALL" ] || make dirclean
set -- "$@" PKG_BRANCH=${PKG_BRANCH/-/}
[ -z "$PERSISTENT_CCACHE" ] || set -- "$@" CCACHE_DIR="`pwd`/ccache" CCACHE_HOST_DIR="`pwd`/ccache-host"
if [ -n "$FORCE" ]; then
make "$@" || make "$@" -j"`echo x"$@" | sed 's|.*-j\([0-9]\+\).*|\1 / 2 + 1|' | bc`" || make "$@" -j1 V=s
else
make "$@"
fi
# Get Turris OS and OpenWRT version
./scripts/unpack-version.sh bin/*/packages bin/*/
if [ -n "$PRIMARY_ONLY" ] ; then
# If we want only the primary system and want to use the build directory for more tests, exit now
exit
fi
# Nice junit export
./scripts/generate_junit.sh
[ \! -d ./logs ] || cp ./.config logs/config
[ \! -d ./logs ] || mv ./logs ./logs-nand
COMMIT_DATE="`git log --format=format:%cD -1`"
if [ "$TARGET_BOARD" = turris ]; then
# Preserve the uncompressed image too
mv build_dir/target-powerpc_*/root-mpc85xx bin/mpc85xx/root
cd bin/mpc85xx/root
rm var
find -type l ! -exec test -r {} \; -delete
cd ../../..
fi
# Clean
[ -d ./bin-nand ] && rm -rf ./bin-nand
mv ./bin ./bin-nand
[ -d ./tmp ] && rm -rf ./tmp
PUB_BIN_DIR="`ls -1d bin-nand/* | head -n1`"
# Generate lists
[ -n "$BUILD_ALL" ] || USRLISTS_ARGS="--minimal"
LIST_BRANCH="${PKG_BRANCH#-}"
[ -n "$LIST_BRANCH" ] || LIST_BRANCH="$(echo "$GIT_BRANCH" | sed 's|.*/||')"
scripts/gen-userlists.sh --model $TARGET_BOARD --branch "${LIST_BRANCH}" $USRLISTS_ARGS $PUB_BIN_DIR/lists
# Generate packages that block each other, based on their file collisions
# For some reason, mktemp -d doesn't work with TMPDIR set, so avoid that here.
# This is deactivated for now until updater #186 is resolved.
#TMPDIR= ./scripts/negative_deps.pl $PUB_BIN_DIR >>$PUB_BIN_DIR/lists/base.lua
# Sign all lists
make package/system/usign/host/install
if [ -f "$HOME"/mime.key ]; then
for i in $PUB_BIN_DIR/lists/*.lua; do
if [ -r "$i" ]; then
staging_dir/host/bin/usign -S -m $i -s "$HOME"/mime.key
fi
done
fi
if [ "$TARGET_BOARD" = "omnia" ]; then
rm -f $PUB_BIN_DIR/*.ext4 $PUB_BIN_DIR/*sums
fi
if [ -n "$BUILD_ALL" ]; then
# Compile host tools
make package/curl/host/install package/libevent2/host/install package/lua/host/install package/usign/host/install
make package/updater-ng/host/install
# Generate medkit
if [ "$TARGET_BOARD" = "turris" ]; then
MED_ARCH=mpc85xx
else
MED_ARCH=mvebu-musl
fi
BASE_PATH="$(pwd)"
MED_PATH="bin-nand/${MED_ARCH}/medkit"
MED_TAR="$TARGET_BOARD-medkit-$(date -d "$COMMIT_DATE" +%Y%m%d%H%M).tar.gz"
MED_TAR_LATEST="$TARGET_BOARD-medkit-latest.tar.gz"
mkdir -p "$MED_PATH"
MED_BIN_SOURCE="bin-nand/${MED_ARCH}"
ERR_CMD="false"
if fakeroot ./scripts/updater-medkit.sh --model "$TARGET_BOARD" $MED_ARGS $MED_BIN_SOURCE "$MED_PATH/$MED_TAR"; then
pushd "$MED_PATH"
ln -sf "$MED_TAR" "$MED_TAR_LATEST"
"$BASE_PATH"/staging_dir/host/bin/usign -S -m "$MED_TAR" -s "$HOME"/mime.key
ln -s "$MED_TAR".sig "$MED_TAR_LATEST".sig
md5sum "$MED_TAR" > "$MED_TAR".md5
md5sum "$MED_TAR_LATEST" > "$MED_TAR_LATEST".md5
sha256sum "$MED_TAR" > "$MED_TAR".sha256
sha256sum "$MED_TAR_LATEST" > "$MED_TAR_LATEST".sha256
popd
else
echo "$@" | grep -q 'IGNORE_ERRORS="m"' || exit 1
fi
fi
cp -r "$TARGET_BOARD-legacy"/* .