-
-
Notifications
You must be signed in to change notification settings - Fork 10
Expand file tree
/
Copy pathbuild.sh
More file actions
executable file
·66 lines (51 loc) · 2.12 KB
/
Copy pathbuild.sh
File metadata and controls
executable file
·66 lines (51 loc) · 2.12 KB
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
#!/bin/bash
set -eu -o pipefail
## Update fedora docker image tag, because kernel build is using `uname -r` when defining package version variable
RPMBUILD_PATH=/root/rpmbuild
MBP_VERSION=mbp16
FEDORA_KERNEL_VERSION=5.13.5-200.fc34 # https://bodhi.fedoraproject.org/updates/?search=&packages=kernel&releases=F34
REPO_PWD=$(pwd)
### Debug commands
echo "FEDORA_KERNEL_VERSION=$FEDORA_KERNEL_VERSION"
pwd
echo "CPU threads: $(nproc --all)"
grep 'model name' /proc/cpuinfo | uniq
### Dependencies
dnf install -y fedpkg fedora-packager rpmdevtools ncurses-devel pesign git libkcapi libkcapi-devel libkcapi-static libkcapi-tools zip curl dwarves libbpf
## Set home build directory
rpmdev-setuptree
## Install the kernel source and finish installing dependencies
cd ${RPMBUILD_PATH}/SOURCES
koji download-build --arch=src kernel-${FEDORA_KERNEL_VERSION}
rpm -Uvh kernel-${FEDORA_KERNEL_VERSION}.src.rpm
cd ${RPMBUILD_PATH}/SPECS
dnf -y builddep kernel.spec
### Create patch file with custom drivers
echo >&2 "===]> Info: Creating patch file... ";
FEDORA_KERNEL_VERSION=${FEDORA_KERNEL_VERSION} "${REPO_PWD}"/patch_driver.sh
### Apply patches
echo >&2 "===]> Info: Applying patches... ";
mkdir -p "${REPO_PWD}"/patches
while IFS= read -r file
do
echo "adding $file"
"${REPO_PWD}"/patch_kernel.sh "$file"
done < <(find "${REPO_PWD}"/patches -type f -name "*.patch" | sort)
### Change buildid to mbp
echo >&2 "===]> Info: Setting kernel name... ";
sed -i "s/# define buildid.*/%define buildid .${MBP_VERSION}/" "${RPMBUILD_PATH}"/SPECS/kernel.spec
### Build non-debug rpms
echo >&2 "===]> Info: Bulding kernel ... ";
cd "${RPMBUILD_PATH}"/SPECS
rpmbuild -bb --without debug --without debuginfo --without perf --without tools --target=x86_64 kernel.spec
rpmbuild_exitcode=$?
### Copy artifacts to shared volume
echo >&2 "===]> Info: Copying rpms and calculating SHA256 ... ";
cp -rfv ${RPMBUILD_PATH}/RPMS/x86_64/*.rpm /tmp/artifacts/
sha256sum ${RPMBUILD_PATH}/RPMS/x86_64/*.rpm > /tmp/artifacts/sha256
### Add patches to artifacts
cd "${REPO_PWD}"
zip -r patches.zip patches/
cp -rfv patches.zip /tmp/artifacts/
du -h /tmp/artifacts/
exit $rpmbuild_exitcode