-
Notifications
You must be signed in to change notification settings - Fork 0
/
build.sh
executable file
·187 lines (154 loc) · 4 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
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
#!/bin/bash
# stop on errors:
set -e
set -xv
spec_name="SPECS/kernel.spec"
build_arch="aarch64"
build_opts=(--define "%_topdir $PWD")
${cross_compile:""}
if [ -n "${do_release:=}" ]; then
if ! (echo "$do_release" | sed -e '/^txos2[0-9][.][0-9][0-9]$/Q0;Q1'); then
echo "Release string '$do_release' does not fit the version format: txos2\\d.\\d\\d"
exit 1
fi
do_build=yes
txos_release=$do_release
fi
if [ x"$do_build" == x"clean" ]; then
pushd BUILD
rm -rf ./*
popd
pushd BUILDROOT
rm -rf ./*
popd
pushd RPMS
rm -rf ./*
popd
pushd SRPMS
rm -rf ./*
popd
exit 0;
fi
cross_compile=${build_arch}-linux
build_target=${build_arch}-linux
host_type=`uname -m`
if [ x"$host_type" != x"aarch64" -o x"$ilp32" == x"yes" ]; then
export CROSS_COMPILE=${cross_compile}-gnu-
export ARCH=arm64
build_opts+=(--define "__strip ${cross_compile}-gnu-strip")
fi
build_opts+=(--target "${build_target}")
build_opts+=(--define "_build_arch ${build_arch}")
if [ x"$no_deps" == x"yes" ]; then
build_opts+=(--nodeps)
fi
if [ x"$no_perf" == x"yes" ]; then
build_opts+=(--without=perf)
fi
if [ x"$no_debug" == x"yes" ]; then
build_opts+=(--without=debug --without=debuginfo)
fi
if ([ -e SOURCES/linux-txos.tar.xz ] \
&& ([ -n "$do_release" ] || [ -n "${cid:-}" ])); then
rm SOURCES/linux-txos.tar.xz
fi
if [ ! -e SOURCES/linux-txos.tar.xz ]; then
(
topdir=$(pwd)
mkdir -p SOURCES/linux-txos
cd SOURCES/linux-txos
if [ -d .git ]; then
git fetch origin
else
git clone --reference-if-able ${txosgit:-$(cd $topdir/../ThunderX-TXOS; pwd)} \
https://github.com/MarvellServer/ThunderX-TXOS.git -n .
fi
git checkout ${cid:-origin/next}
git config tar.tar.xz.command "xz -c"
git archive HEAD --prefix=linux-txos/ \
-o $topdir/SOURCES/linux-txos.tar.xz
)
fi
if [ -e SOURCES/linux-txos.tar.xz ]; then
txos_cid=$(xzcat SOURCES/linux-txos.tar.xz | git get-tar-commit-id)
fi
if [ -n "${txos_base:-}" ] && \
[ -n "${txos_patchlevel:-}" ] && \
[ -n "${txos_release:-}" ]; then
: # package information already defined
elif [ -n "$txos_cid:-" ];then
txos=$(
cd SOURCES/linux-txos
git describe --match txos-2\*.\* --abbrev=0 --always $txos_cid
)
txosfull=$(
cd SOURCES/linux-txos
git describe --match txos-2\*.\* --abbrev=12 --always $txos_cid
)
pkg=$(
cd SOURCES/linux-txos
git describe --match txos-\*-\* --abbrev=0 --always $txos_cid
)
pkgfull=$(
cd SOURCES/linux-txos
git describe --match txos-\*-\* --abbrev=12 --always $txos_cid
)
base=${pkg%-*}
base=${base#txos-}
txos_base="$base"
txos_patchlevel="${pkg##*-}"
if [ -n "${txos_release:-}" ]; then
txos_release="$txos_release"
elif [ "$txos" = "$txosfull" ]; then
txos_release="txos${txos#txos-}"
else
txos_release="txos${txos#txos-}+"
fi
if [ "$pkg" = "$pkgfull" ]; then
: # nop
elif [ -n "$do_release" ]; then
cat<<EOF
There is no annotated kernel version tag in the format:
txos-<base>-<patchlevel>
Use something like the following to create one:
$ git tag -a txos-5.4.42-3 -m 'TXOS 5.4.42-3' txos/next
EOF
exit 1
else
buildid=".g${pkgfull##*-g}"
fi
else
echo "No TXOS package information found"
exit 1
fi
cat<<EOF >SOURCES/txos.inc
%define txos_base ${txos_base:?}
%define txos_patchlevel ${txos_patchlevel:?}
%define txos_release ${txos_release:?}
EOF
if [ -n "${buildid:-}" ]; then
cat<<EOF >>SOURCES/txos.inc
%define buildid $buildid
EOF
fi
cat SOURCES/txos.inc
echo "PWD:${PWD}"
echo build_opts:${build_opts[@]}
if [ x"$do_build" == x"srpm" ]; then
rpmbuild "${build_opts[@]}" \
-bs ${spec_name} \
2>&1 | tee build-out.log
exit 0;
fi
if [ x"$do_build" == x"yes" ]; then
rpmbuild "${build_opts[@]}" \
-ba ${spec_name} \
--without kabichk \
--without kernel_abi_whitelists \
--without cross_headers \
2>&1 | tee build-out.log
else
echo build target: $build_target
echo build arch: $build_arch
echo build opts: $build_opts
fi