This repository has been archived by the owner on Sep 22, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
/
xm-build
executable file
·98 lines (87 loc) · 3.16 KB
/
xm-build
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
#!/bin/bash
# -----------------------------------------------------------------------
# Build kernel.
# Author: Mario Roy - http://github.com/marioroy
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, version 2 or later of the License.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
# -----------------------------------------------------------------------
osver=$(source "/etc/os-release"; echo "$VERSION_ID")
if [[ ${osver} -le 41840 ]]; then
echo "The Clear kernel config enables ZSTD module compression."
echo "https://github.com/clearlinux-pkgs/linux/commit/2918f672"
echo ""
echo "This requires OS update CL 41850 (or later) to continue"
echo "i.e. kmod, toolchain, and zstd updates."
echo ""
exit 1
fi
function xm_build {
local variant="$1"
echo "Building linux-${variant}"
if [[ ! -d "SOURCES" ]]; then
echo "Please run fetch-src first and try again."
exit 2
fi
if [[ -n "$HZ" ]]; then
case "$HZ" in
100|250|300|500|625|800|1000) # pass
;;
*) echo "HZ=$HZ is invalid; try again."
exit 1
esac
fi
if [[ -n "$LOCALMODCONFIG" ]]; then
case "$LOCALMODCONFIG" in
0|1) # pass
;;
*) echo "LOCALMODCONFIG=$LOCALMODCONFIG is invalid; try again."
exit 1
esac
fi
# Sync patch files to SOURCES folder.
for p in ../patches/*; do
if [[ "$p" != *".diff"* ]]; then
diff "$p" SOURCES/. &>/dev/null || cp "$p" SOURCES/.
fi
done
# Build kernel.
local topdir="/tmp/${variant}.$$"
mkdir -p "$topdir"
( rpmbuild -bb --clean "SPECS/linux-${variant}.spec" \
--define "abi_package %{nil}" \
--define "debug_package %{nil}" \
--define "_buildhost $(hostname)" \
--define "_hzval ${HZ:-800}" \
--define "_localmodconfig ${LOCALMODCONFIG:-0}" \
--define "_topdir ${topdir}" \
--define "_unpackaged_files_terminate_build 0" \
--define "_sourcedir ${PWD}/SOURCES" \
--define "_source_payload w6T0.zstdio" \
--define "_binary_payload w6T0.zstdio" \
--undefine "_disable_source_fetch" \
|| { echo "Build failed"; kill $$; }
) 2>&1 | grep -Ev '^((chmod|find):.* No such file or directory|warning: Empty %files)'
mkdir -p "RPMS/x86_64"
mv "${topdir}/RPMS/x86_64"/*.rpm "RPMS/x86_64"/.
rm -fr "$topdir"
echo "done."
}
case "$1" in
clear | clear-rt | bore | bore-rt )
./fetch-src || exit 1
cd "rpmbuild" || exit 1
xm_build "xm${1}"
;;
* ) echo "synopsis"
echo " $0 clear | clear-rt | bore | bore-rt"
esac