-
Notifications
You must be signed in to change notification settings - Fork 120
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: provide an easy way to manage kernel configuration
This automates the kernel configuration generation process described in `kernel/README.md` and wraps it as easy to use `make` targets, e.g.: * `make kernel-olddefconfig` updates kernel config for the new kernel version * `make kernel-menuconfig` launches interactive kernel configuration List of architectures can be updated via `PLATFORM=` variable override. Signed-off-by: Andrey Smirnov <[email protected]>
- Loading branch information
Showing
7 changed files
with
128 additions
and
113 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,32 +1,28 @@ | ||
# Kernel | ||
|
||
## Customizing the kernel | ||
## Updating kernel config | ||
|
||
When updating kernel to the new version, import proper defaults with: | ||
|
||
High-level notes: | ||
```sh | ||
make kernel-olddefconfig | ||
``` | ||
|
||
- In pkg.yaml, comment out the `build` and `install` steps | ||
- At the bottom of pkg.yaml, change the finalize step from | ||
If you want to update for a specific architecture only, use: | ||
|
||
```yaml | ||
finalize: | ||
- from: /rootfs | ||
to: / | ||
```sh | ||
make kernel-olddefconfig PLATFORM=linux/arm64 | ||
``` | ||
|
||
to | ||
## Customizing the kernel | ||
|
||
Run another target to get into `menuconfig`: | ||
|
||
```yaml | ||
finalize: | ||
- from: / | ||
to: / | ||
```sh | ||
make kernel-menuconfig | ||
``` | ||
|
||
- Create a local image with `docker buildx build -t kernel --target kernel -f Pkgfile --load .` | ||
- Run the kernel image we created: `docker run --rm -it --entrypoint=/toolchain/bin/bash kernel` | ||
- Set path: `export PATH=/toolchain/bin:/bin` | ||
- Change to build dir: `cd /tmp/build/0` | ||
- Make changes to kernel settings with `make menuconfig` and save upon exiting | ||
- With the container still running, copy the config out to local disk: `docker cp $CONTAINER_ID:/tmp/build/0/.config config-amd64` | ||
- Revert your changes to pkg.yaml | ||
## Testing | ||
|
||
- Build and push a test image with `make USERNAME=rsmitty PUSH=true kernel` | ||
- PR upstream (when ready) and profit |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,57 @@ | ||
name: kernel-prepare | ||
variant: scratch | ||
shell: /toolchain/bin/bash | ||
dependencies: | ||
- image: '{{ .TOOLS_IMAGE }}' | ||
steps: | ||
- sources: | ||
- url: https://cdn.kernel.org/pub/linux/kernel/v5.x/linux-5.7.7.tar.xz | ||
destination: linux.tar.xz | ||
sha256: f840b9679283343c165516585c3070ebb277528721c890e9410a58e9d071ee7f | ||
sha512: 49db85a1ce14e00411215d5d5bfda6db3d24ed2e0f2bd8e6603c18b3226614f45040856b21b4d6b525c44bb4463ab08fb594a06de6deca109d512588389cc3fd | ||
env: | ||
ARCH: {{ if eq .ARCH "aarch64"}}arm64{{ else if eq .ARCH "x86_64" }}x86_64{{ else }}unsupported{{ end }} | ||
prepare: | ||
- | | ||
tar -xJf linux.tar.xz --strip-components=1 | ||
rm linux.tar.xz | ||
mkdir /bin | ||
ln -sv /toolchain/bin/bash /bin/bash | ||
ln -sv /toolchain/bin/bash /bin/sh | ||
ln -sv /toolchain/lib /lib | ||
mkdir -p /usr/bin \ | ||
&& ln -sf /toolchain/bin/env /usr/bin/env \ | ||
&& ln -sf /toolchain/bin/true /bin/true \ | ||
&& ln -sf /toolchain/bin/false /bin/false \ | ||
&& ln -sf /toolchain/bin/pwd /bin/pwd | ||
# Ensure that `make menuconfig` works. | ||
ln -s /toolchain/bin/awk /usr/bin/awk | ||
mkdir -p /usr/lib/pkgconfig | ||
ln -s /toolchain/include /usr/include | ||
for lib in ncurses form panel menu ; do | ||
rm -vf /lib/lib${lib}.so | ||
echo "INPUT(-l${lib}w)" > /lib/lib${lib}.so | ||
ln -sfv ${lib}w.pc /lib/pkgconfig/${lib}.pc | ||
done | ||
make mrproper | ||
install: | ||
- | | ||
mkdir -p /src | ||
cp -a . /src/ | ||
finalize: | ||
- from: /src | ||
to: /src | ||
- from: /toolchain | ||
to: /toolchain | ||
- from: /usr | ||
to: /usr | ||
- from: /bin | ||
to: /bin | ||
- from: /lib | ||
to: /lib |
File renamed without changes.
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
name: kernel | ||
variant: scratch | ||
shell: /toolchain/bin/bash | ||
dependencies: | ||
- stage: kernel-prepare | ||
steps: | ||
- env: | ||
ARCH: {{ if eq .ARCH "aarch64"}}arm64{{ else if eq .ARCH "x86_64" }}x86_64{{ else }}unsupported{{ end }} | ||
CARCH: {{ if eq .ARCH "aarch64"}}arm64{{ else if eq .ARCH "x86_64" }}amd64{{ else }}unsupported{{ end }} | ||
prepare: | ||
- | | ||
cp -a /src/. . | ||
cp -v /pkg/config-${CARCH} .config | ||
build: | ||
- | | ||
make -j $(nproc) | ||
make -j $(nproc) modules | ||
install: | ||
- | | ||
mkdir -p /rootfs/boot | ||
case $ARCH in | ||
x86_64) | ||
mv arch/x86/boot/bzImage /rootfs/boot/vmlinuz | ||
mv vmlinux /rootfs/boot/vmlinux | ||
;; | ||
arm64) | ||
mv arch/arm64/boot/Image.gz /rootfs/boot/vmlinuz | ||
mv vmlinux /rootfs/boot/vmlinux | ||
;; | ||
*) | ||
echo "unsupported arch ${ARCH}" | ||
exit 1 | ||
;; | ||
esac | ||
export KERNELRELEASE=$(cat include/config/kernel.release) | ||
make -j $(nproc) modules_install DEPMOD=/toolchain/bin/depmod INSTALL_MOD_PATH=/rootfs | ||
depmod -b /rootfs $KERNELRELEASE | ||
unlink /rootfs/lib/modules/$KERNELRELEASE/build | ||
unlink /rootfs/lib/modules/$KERNELRELEASE/source | ||
finalize: | ||
- from: /rootfs | ||
to: / |
This file was deleted.
Oops, something went wrong.