@@ -19,70 +19,82 @@ fatal() {
1919 exit 1
2020}
2121
22- # needed to clone repository
23- packages=" git"
24- # will pull gcc-aarch64-linux-gnu; should pull a native compiler on arm64 and
25- # a cross-compiler on other architectures
26- packages=" ${packages} crossbuild-essential-arm64"
27- # linux build-dependencies; see linux/scripts/package/mkdebian
28- packages=" ${packages} make flex bison bc libdw-dev libelf-dev libssl-dev"
29- packages=" ${packages} libssl-dev:arm64"
30- # linux build-dependencies for debs
31- packages=" ${packages} dpkg-dev debhelper-compat kmod python3 rsync"
32- # for nproc
33- packages=" ${packages} coreutils"
22+ check_dependencies () {
23+ # needed to clone repository
24+ packages=" git"
25+ # will pull gcc-aarch64-linux-gnu; should pull a native compiler on arm64
26+ # and a cross-compiler on other architectures
27+ packages=" ${packages} crossbuild-essential-arm64"
28+ # linux build-dependencies; see linux/scripts/package/mkdebian
29+ packages=" ${packages} make flex bison bc libdw-dev libelf-dev libssl-dev"
30+ packages=" ${packages} libssl-dev:arm64"
31+ # linux build-dependencies for debs
32+ packages=" ${packages} dpkg-dev debhelper-compat kmod python3 rsync"
33+ # for nproc
34+ packages=" ${packages} coreutils"
3435
35- log_i " Checking build-dependencies ($packages )"
36- missing=" "
37- for pkg in ${packages} ; do
38- # check if package with this name is installed
39- if dpkg -l " ${pkg} " 2>&1 | grep -q " ^ii ${pkg} " ; then
40- continue
41- fi
42- # otherwise, check if it's a virtual package and if some package providing
43- # it is installed
44- providers=" $( apt-cache showpkg " ${pkg} " |
45- sed -e ' 1,/^Reverse Provides: *$/ d' -e ' s/ .*$//' |
46- sort -u) "
47- provider_found=" no"
48- for provider in ${providers} ; do
49- if dpkg -l " ${provider} " 2>&1 | grep -q " ^ii ${provider} " ; then
50- provider_found=" yes"
51- break
36+ missing=" "
37+ for pkg in ${packages} ; do
38+ # check if package with this name is installed
39+ if dpkg -l " ${pkg} " 2>&1 | grep -q " ^ii ${pkg} " ; then
40+ continue
41+ fi
42+ # otherwise, check if it's a virtual package and if some package
43+ # providing it is installed
44+ providers=" $( apt-cache showpkg " ${pkg} " |
45+ sed -e ' 1,/^Reverse Provides: *$/ d' -e ' s/ .*$//' |
46+ sort -u) "
47+ provider_found=" no"
48+ for provider in ${providers} ; do
49+ if dpkg -l " ${provider} " 2>&1 | grep -q " ^ii ${provider} " ; then
50+ provider_found=" yes"
51+ break
52+ fi
53+ done
54+ if [ " ${provider_found} " = yes ]; then
55+ continue
5256 fi
57+ missing=" ${missing} ${pkg} "
5358 done
54- if [ " ${provider_found} " = yes ]; then
55- continue
59+ if [ -n " ${missing} " ]; then
60+ fatal " Missing build-dependencies: ${missing} "
5661 fi
57- missing=" ${missing} ${pkg} "
58- done
59- if [ -n " ${missing} " ]; then
60- fatal " Missing build-dependencies: ${missing} "
61- fi
62+ }
6263
63- log_i " Cloning Linux (${GIT_REPO} :${GIT_BRANCH} )"
64- git clone --depth=1 --branch " ${GIT_BRANCH} " " ${GIT_REPO} " linux
64+ get_kernel () {
65+ git clone --depth=1 --branch " ${GIT_BRANCH} " " ${GIT_REPO} " linux
66+ }
67+
68+ configure_kernel () {
69+ rm -vf linux/kernel/configs/local.config
70+ for fragment in " $@ " ; do
71+ log_i " Adding config fragment to local.config: ${fragment} "
72+ touch linux/kernel/configs/local.config
73+ cat " $fragment " >> linux/kernel/configs/local.config
74+ done
75+
76+ if [ -r kernel/configs/local.config ]; then
77+ make -C linux ARCH=arm64 " ${CONFIG} " local.config
78+ else
79+ make -C linux ARCH=arm64 " ${CONFIG} "
80+ fi
81+ }
82+
83+ build_kernel () {
84+ make " -j$( nproc) " \
85+ ARCH=arm64 DEB_HOST_ARCH=arm64 CROSS_COMPILE=aarch64-linux-gnu- \
86+ deb-pkg
87+ }
6588
66- log_i " Configuring Linux (base config: ${CONFIG} )"
67- rm -vf linux/kernel/configs/local.config
68- for fragment in " $@ " ; do
69- log_i " Adding config fragment to local.config: ${fragment} "
70- touch linux/kernel/configs/local.config
71- cat " $fragment " >> linux/kernel/configs/local.config
72- done
89+ log_i " Checking build-dependencies"
90+ check_dependencies
7391
74- # only change working directory after having read config fragments passed on
75- # the command-line as these might be relative pathnames
76- cd linux
92+ log_i " Getting Linux from repo ${GIT_REPO} and branch ${GIT_BRANCH} "
93+ get_kernel
7794
78- if [ -r kernel/configs/local.config ]; then
79- make ARCH=arm64 " ${CONFIG} " local.config
80- else
81- make ARCH=arm64 " ${CONFIG} "
82- fi
95+ log_i " Configuring Linux with base config ${CONFIG} and config fragments $* "
96+ configure_kernel " $@ "
8397
8498log_i " Building Linux deb"
85- make " -j$( nproc) " \
86- ARCH=arm64 DEB_HOST_ARCH=arm64 CROSS_COMPILE=aarch64-linux-gnu- \
87- deb-pkg
99+ build_kernel
88100
0 commit comments