This repository has been archived by the owner on Apr 24, 2021. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 2
/
build_release.sh
executable file
·255 lines (224 loc) · 6.16 KB
/
build_release.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
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
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
#!/bin/sh
# todo:
# - stick to specific git-revision
# - autodownload .definitions
# arguments e.g.:
# "HARDWARE.Linksys WRT54G:GS:GL" standard kernel.addzram kcmdlinetweak patch:901-minstrel-try-all-rates.patch dataretention nopppoe b43minimal olsrsimple nohttps nonetperf
# "HARDWARE.TP-LINK TL-WR1043ND" standard kernel.addzram kcmdlinetweak patch:901-minstrel-try-all-rates.patch dataretention
log()
{
logger -s "$( date +"%F %R" ): [$( basename "$(pwd)" )]: $0: $1"
}
[ -z "$1" ] && {
log "Usage: $0 <buildstring>"
exit 1
}
[ "$( id -u )" = "0" ] && {
log "please run as normal user"
exit 1
}
[ -x "./openwrt-build/mybuild.sh" ] || {
log "please run the script in the current directory!"
exit 1
}
resolve_meta() {
while [ $# -gt 0 ]
do
case "$1" in
*meta.* )
read NEW_ARGS < "./openwrt-config/config_${1}.txt"
ARGS=$(echo "$ARGS" "$NEW_ARGS" | sed "s/$1//g")
resolve_meta $ARGS
;;
* )
;;
esac
shift
done
}
ARGS="$@"
resolve_meta $ARGS
log "[INFO] used options: $ARGS"
TRUNK=trunk
case "$ARGS" in
*use_lede*)
log "[INFO] we use lede-project.org"
TRUNK=lede
;;
*use_trunk*)
log "[INFO] we will be on top of openwrt development"
TRUNK=trunk
;;
*use_bb1407*)
log "[INFO] we will use the 14.07 barrier breaker stable version"
TRUNK=bb1407
;;
*use_cc1505*)
log "[INFO] we will use the 15.05 chaos calmer stable version"
TRUNK=cc1505
;;
esac
changedir()
{
[ -d "$1" ] || {
log "creating dir $1"
mkdir -p "$1"
}
log "going into $1"
cd "$1"
}
clone()
{
local repo="$1"
local dir="$( basename "$repo" | cut -d'.' -f1 )"
if [ -d "$dir" ]; then
read OPENWRT_RELEASE < "$dir/.openwrt_version"
[ "$OPENWRT_RELEASE" = "$TRUNK" ] || {
log "Error: OpenWRT version mismatch: $OPENWRT_RELEASE already cloned but $TRUNK requested"
log "Delete folder '$dir' and try again!"
exit 1
}
log "git-cloning of '$repo' already done, just pulling"
changedir "$dir"
git stash
git pull || {
log "error pulling repo"
exit 1
}
changedir ..
else
log "git-cloning from '$repo'"
git clone --depth=1 "$repo" openwrt || {
log "error cloning repo"
exit 1
}
echo "$TRUNK" > "$dir/.openwrt_version"
fi
if [ -e "../openwrt-config/git_revs" ] && [ $TRUNK = 0 ]; then
. "../openwrt-config/git_revs"
case "$repo" in
*"openwrt"*)
[ -n "$MY_OPENWRT" ] && {
changedir "$dir"
git branch -D "r$MY_OPENWRT"
git checkout "$( git log -z | tr '\n\0' ' \n' | grep "@$MY_OPENWRT " | cut -d' ' -f2 )" -b r"$MY_OPENWRT" || {
log "error during git checkout"
exit 1
}
changedir ..
}
;;
# *"packages"*)
# [ -n "$MY_PACKAGES" ] && {
# changedir "$dir"
# git branch -D "r$MY_PACKAGES"
# git checkout "$( git log -z | tr '\n\0' ' \n' | grep "@$MY_PACKAGES" | cut -d' ' -f2 )" -b r$MY_PACKAGES || {
# log "error during git checkout"
# exit 1
# }
# changedir ..
# }
# ;;
esac
fi
}
# print a json file with openwrt and weimarnetz revision, we assume to be in the openwrt directory
print_revisions()
{
OPENWRT_REV="$( ./scripts/getver.sh )"
KALUA_REV="$( grep FFF_PLUS package/base-files/files/etc/variables_fff+ | tr -d '[:space:]'|cut -d '=' -f 2|cut -d '#' -f 1)"
echo "{\"OPENWRT_REV\":\"$OPENWRT_REV\",\"KALUA_REV\":\"$KALUA_REV\"}" > "bin/revisions.json"
}
mymake() # fixme! how to ahve a quiet 'make defconfig'?
{
log "[START] executing 'make $1 $2 $3'"
make $1 $2 $3
log "[READY] executing 'make $1 $2 $3'"
}
prepare_build() # check possible values via:
{ # ./openwrt-build/mybuild.sh set_build list
local action
log "$@"
for action in "$@"; do {
log "[START] '$action' from '$*'"
case "$action" in
r[0-9]|r[0-9][0-9]|r[0-9][0-9][0-9]|r[0-9][0-9][0-9][0-9]|r[0-9][0-9][0-9][0-9][0-9])
REV="$( echo "$action" | cut -d'r' -f2 )"
log "switching to revision r$REV"
git stash
git checkout "$( git log -z | tr '\n\0' ' \n' | grep "@$REV " | cut -d' ' -f2 )" -b r"$REV" || {
log "error while git checkout"
exit 1
}
continue
;;
*use_*)
continue
;;
reset_config)
./scripts/feeds clean
git checkout master
git branch -D patched
git checkout -b patched master
esac
"../openwrt-build/mybuild.sh" set_build "$action" || {
log "[ERROR] $action failed. aborting"
exit 1
}
log "[READY] '$action' from '$*'"
} done
}
show_args()
{
local word
for word in "$@"; do {
case "$word" in
*" "*)
echo -n " '$word'"
;;
*)
echo -n " $word"
;;
esac
} done
}
#[ -e "/tmp/apply_profile.code.definitions" ] || {
# log "please make sure, that you have placed you settings in '/tmp/apply_profile.code.definitions'"
# log "otherwise i'll take the community-settings"
# sleep 5
#}
# changedir release
if [ "$TRUNK" = "bb1407" ]; then
clone "git://git.openwrt.org/14.07/openwrt.git" "$TRUNK"
elif [ "$TRUNK" = "cc1505" ]; then
clone "git://git.openwrt.org/15.05/openwrt.git" "$TRUNK"
elif [ "$TRUNK" = "lede" ]; then
clone "https://github.com/lede-project/source.git" "$TRUNK"
else
clone "git://git.openwrt.org/openwrt.git" "$TRUNK"
fi
changedir openwrt
# clone "$REPOURL"
#copy feeds.conf to openwrt directory
if [ "$TRUNK" = "bb1407" ]; then
cp "../openwrt-build/feeds.conf.1407" ./feeds.conf
elif [ "$TRUNK" = "cc1505" ]; then
cp "../openwrt-build/feeds.conf.1505" ./feeds.conf
else
cp "../openwrt-build/feeds.conf" ./
fi
prepare_build "reset_config" || exit 1
mymake package/symlinks || exit 1
prepare_build $ARGS || exit 1
mymake defconfig || exit 1
for SPECIAL in unoptimized kcmdlinetweak; do {
case "$ARGS" in
*"$SPECIAL"*)
prepare_build $SPECIAL
;;
esac
} done
"../openwrt-build/mybuild.sh" make || exit 1
print_revisions
log "please removing everything via 'rm -fR release' if you are ready"
log "# buildstring: $( show_args "$ARGS" )"