From cdc494802f19d646988329c146ca82f541cbcf7c Mon Sep 17 00:00:00 2001 From: Yang Jeong Hun Date: Mon, 18 Nov 2024 14:15:58 +0900 Subject: [PATCH] gh-actions: Import Linux 6.12 CI builder Signed-off-by: Yang Jeong Hun --- .github/workflows/build.yml | 241 ++++++++++++++++++++++++++++++++++++ .gitignore | 1 + README.md | 64 ++++++++++ 3 files changed, 306 insertions(+) create mode 100644 .github/workflows/build.yml create mode 100644 README.md diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml new file mode 100644 index 000000000000..465f48700cdb --- /dev/null +++ b/.github/workflows/build.yml @@ -0,0 +1,241 @@ +name: Stable Kernel CI + +on: + push: + tags: + - 'linux-wsl-stable-6.12.[0-9]+' + +run-name: Stable Release Build ${{ github.ref_name }} + +jobs: + build: + runs-on: ubuntu-latest + container: nevuly/nevuly-dev-base:arch + outputs: + X86_IMAGE_SHA: ${{ steps.gen-sha-256.outputs.X86_IMAGE_SHA }} + X86_MODULE_SHA: ${{ steps.gen-sha-256.outputs.X86_MODULE_SHA }} + X86_OPTIONAL_SHA: ${{ steps.gen-sha-256.outputs.X86_OPTIONAL_SHA }} + ARM64_IMAGE_SHA: ${{ steps.gen-sha-256.outputs.ARM64_IMAGE_SHA }} + ARM64_MODULE_SHA: ${{ steps.gen-sha-256.outputs.ARM64_MODULE_SHA }} + ARM64_OPTIONAL_SHA: ${{ steps.gen-sha-256.outputs.ARM64_OPTIONAL_SHA }} + strategy: + matrix: + include: + - arch: x86 + image-name: bzImage-x86_64 + - arch: arm64 + image-name: Image-arm64 + + steps: + - name: Trust this directory + run: git config --global --add safe.directory /__w/WSL2-Linux-Kernel-Rolling/WSL2-Linux-Kernel-Rolling + + - uses: actions/checkout@main + + - name: Download WSL2 stable kernel + run: | + git clone https://github.com/Nevuly/WSL2-Linux-Kernel-Rolling.git --depth 1 -b ${{ github.ref_name }} linux + + - name: Build WSL2 stable kernel + run: | + cd linux + if [ ${{ matrix.arch }} == "x86" ] + then + make KCONFIG_CONFIG=arch/x86/configs/config-wsl-x86 -j$(echo `nproc` + 1 | bc) + cp arch/x86/boot/bzImage ../${{ matrix.image-name }} + else + export ARCH=arm64 && export CROSS_COMPILE=aarch64-linux-gnu- + make KCONFIG_CONFIG=arch/arm64/configs/config-wsl-arm64 -j$(echo `nproc` + 1 | bc) + cp arch/arm64/boot/Image ../${{ matrix.image-name }} + fi + echo "Done" + + - name: Generate kernel modules package + run: | + echo "Check kernel version" + IFS=- read -r var1 var2 var3 version <<< ${{ github.ref_name }} + echo "Kernel verison: $version" + cd linux + echo "Download kernel modules package installer script" + wget https://gist.githubusercontent.com/Nevuly/cf1d17db72cdfde6ed149461eef0215c/raw/a6144e829a9cb00066d0dabe4434397c6a4d5466/modules-install.sh + chmod 775 modules-install.sh + echo "Generate kernel modules tarball" + mkdir -p ${{ matrix.image-name }}-modules_install && make modules_install INSTALL_MOD_PATH=${{ matrix.image-name }}-modules_install + cp modules-install.sh ${{ matrix.image-name }}-modules_install/ + rm -rf ${{ matrix.image-name }}-modules_install/lib/modules/$version-WSL2-STABLE+/build + echo "$version" >> ${{ matrix.image-name }}-modules_install/kernel_version.txt + tar -czf ${{ matrix.image-name }}-modules_install.tar.gz ${{ matrix.image-name }}-modules_install && mv ${{ matrix.image-name }}-modules_install.tar.gz ../ + echo "Done" + + - name: Generate kernel optional package (headers, docs) + run: | + echo "Check kernel version" + IFS=- read -r var1 var2 var3 version <<< ${{ github.ref_name }} + echo "Kernel verison: $version" + cd linux + echo "Download kernel optionals package installer script" + wget https://gist.githubusercontent.com/Nevuly/b203682442ba2c6cf4cad3b35afb6f4b/raw/72cffc2e83a6c9298667a79c91cfe53bbcfcc6e1/optionals-install.sh + chmod 775 optionals-install.sh + echo "Generate kernel headers tarball" + mkdir -p ${{ matrix.image-name }}-optional_install/build + export optional_path=${{ matrix.image-name }}-optional_install/build + install -Dt "$optional_path" -m644 Makefile Module.symvers System.map vmlinux + install -Dt "$optional_path/kernel" -m644 kernel/Makefile + if [ ${{ matrix.arch }} == "x86" ] + then + install -Dt "$optional_path/arch/x86" -m644 arch/x86/Makefile + else + install -Dt "$optional_path/arch/arm64" -m644 arch/arm64/Makefile + fi + cp -t "$optional_path" -a scripts + if [ ${{ matrix.arch }} == "x86" ] + then + install -Dt "$optional_path/tools/objtool" tools/objtool/objtool + install -Dt "$optional_path/tools/bpf/resolve_btfids" tools/bpf/resolve_btfids/resolve_btfids + fi + cp -t "$optional_path" -a include + if [ ${{ matrix.arch }} == "x86" ] + then + cp -t "$optional_path/arch/x86" -a arch/x86/include + install -Dt "$optional_path/arch/x86/kernel" -m644 arch/x86/kernel/asm-offsets.s + else + cp -t "$optional_path/arch/arm64" -a arch/arm64/include + install -Dt "$optional_path/arch/arm64/kernel" -m644 arch/arm64/kernel/asm-offsets.s + mkdir -p "$optional_path/arch/arm" + cp -t "$optional_path/arch/arm" -a arch/arm/include + fi + install -Dt "$optional_path/drivers/md" -m644 drivers/md/*.h + install -Dt "$optional_path/net/mac80211" -m644 net/mac80211/*.h + install -Dt "$optional_path/drivers/media/i2c" -m644 drivers/media/i2c/msp3400-driver.h + install -Dt "$optional_path/drivers/media/usb/dvb-usb" -m644 drivers/media/usb/dvb-usb/*.h + install -Dt "$optional_path/drivers/media/dvb-frontends" -m644 drivers/media/dvb-frontends/*.h + install -Dt "$optional_path/drivers/media/tuners" -m644 drivers/media/tuners/*.h + install -Dt "$optional_path/drivers/iio/common/hid-sensors" -m644 drivers/iio/common/hid-sensors/*.h + find . -name 'Kconfig*' -exec install -Dm644 {} "$optional_path/{}" \; + export arch + if [ ${{ matrix.arch }} == "x86" ] + then + for arch in "$optional_path"/arch/*/; do + [[ $arch = */x86/ ]] && continue + echo "Removing $(basename "$arch")" + rm -r "$arch" + done + else + for arch in "$optional_path"/arch/*/; do + [[ $arch = */arm64/ ]] && continue + echo "Removing $(basename "$arch")" + rm -r "$arch" + done + fi + rm -r $optional_path/Documentation + find -L "$optional_path" -type l -printf 'Removing %P\n' -delete + find -L "$optional_path" -type f -name '*.o' -printf 'Removing %P\n' -delete + export file + export STRIP_SHARED + export STRIP_STATIC + export STRIP_BINARIES + while read -rd '' $file; do + case "$(file -Sib "$file")" in + application/x-sharedlib\;*) + strip -v $STRIP_SHARED $file ;; + application/x-archive\;*) + strip -v $STRIP_STATIC $file ;; + application/x-executable\;*) + strip -v $STRIP_BINARIES $file ;; + application/x-pie-executable\;*) + strip -v $STRIP_SHARED $file ;; + esac + done < <(find "$optional_path" -type f -perm -u+x ! -name vmlinux -print0) + if [ ${{ matrix.arch }} == "x86" ] + then + strip -v $STRIP_STATIC "$optional_path/vmlinux" + fi + echo "Generate kernel documentations tarball" + cp -r Documentation $optional_path/Documentation + cp optionals-install.sh ${{ matrix.image-name }}-optional_install/ + echo "$version" >> ${{ matrix.image-name }}-optional_install/kernel_version.txt + tar -czf ${{ matrix.image-name }}-optional_install.tar.gz ${{ matrix.image-name }}-optional_install && mv ${{ matrix.image-name }}-optional_install.tar.gz ../ + echo "Done" + + - name: Generate SHA-256 Checksum + id: gen-sha-256 + run: | + if [ ${{ matrix.arch }} == "x86" ] + then + read -r x86ImageSHA rest <<< "$(sha256sum ${{ matrix.image-name }})" + read -r x86ModuleSHA rest <<< "$(sha256sum ${{ matrix.image-name }}-modules_install.tar.gz)" + read -r x86OptionalSHA rest <<< "$(sha256sum ${{ matrix.image-name }}-optional_install.tar.gz)" + echo "X86_IMAGE_SHA=$x86ImageSHA" >> $GITHUB_OUTPUT + echo "X86_MODULE_SHA=$x86ModuleSHA" >> $GITHUB_OUTPUT + echo "X86_OPTIONAL_SHA=$x86OptionalSHA" >> $GITHUB_OUTPUT + else + read -r arm64ImageSHA rest <<< "$(sha256sum ${{ matrix.image-name }})" + read -r arm64ModuleSHA rest <<< "$(sha256sum ${{ matrix.image-name }}-modules_install.tar.gz)" + read -r arm64OptionalSHA rest <<< "$(sha256sum ${{ matrix.image-name }}-optional_install.tar.gz)" + echo "ARM64_IMAGE_SHA=$arm64ImageSHA" >> $GITHUB_OUTPUT + echo "ARM64_MODULE_SHA=$arm64ModuleSHA" >> $GITHUB_OUTPUT + echo "ARM64_OPTIONAL_SHA=$arm64OptionalSHA" >> $GITHUB_OUTPUT + fi + echo "Done" + + - name: Upload kernel Images + uses: actions/upload-artifact@main + with: + name: ${{ matrix.image-name }} + path: | + ${{ matrix.image-name }} + ${{ matrix.image-name }}-modules_install.tar.gz + ${{ matrix.image-name }}-optional_install.tar.gz + + release: + runs-on: ubuntu-latest + needs: build + env: + X86_IMAGE_SHA: ${{ needs.build.outputs.X86_IMAGE_SHA }} + X86_MODULE_SHA: ${{ needs.build.outputs.X86_MODULE_SHA }} + X86_OPTIONAL_SHA: ${{ needs.build.outputs.X86_OPTIONAL_SHA }} + ARM64_IMAGE_SHA: ${{ needs.build.outputs.ARM64_IMAGE_SHA }} + ARM64_MODULE_SHA: ${{ needs.build.outputs.ARM64_MODULE_SHA }} + ARM64_OPTIONAL_SHA: ${{ needs.build.outputs.ARM64_OPTIONAL_SHA }} + + steps: + - uses: actions/checkout@main + - uses: actions/download-artifact@main + with: + path: release_images/ + + - name: Release Kernel + uses: softprops/action-gh-release@master + with: + name: ${{ github.ref_name }} + tag_name: ${{ github.ref_name }} + body: | + **NOTICE For Docker Users** + If you use `Docker Desktop`, You must install kernel modules in `docker-desktop` WSL2 image. More information is [here](https://github.com/Nevuly/WSL2-Rolling-Kernel-Issue/issues/21#issuecomment-2293228925). + + **WARNING** + ARM64 kernel has not been tested. If you have any issues, please leave an issue on the [Issues tab](https://github.com/Nevuly/WSL2-Rolling-Kernel-Issue/issues)! + + **Hash Information** + | File Name | SHA-256 Checksum | + |:--------------:|:------:| + | bzImage-x86_64 | ${{ env.X86_IMAGE_SHA }} | + | bzImage-x86_64-modules_install.tar.gz | ${{ env.X86_MODULE_SHA }} | + | bzImage-x86_64-optional_install.tar.gz | ${{ env.X86_OPTIONAL_SHA }} | + | Image-arm64 | ${{ env.ARM64_IMAGE_SHA }} | + | Image-arm64-modules_install.tar.gz | ${{ env.ARM64_MODULE_SHA }} | + | Image-arm64-optional_install.tar.gz | ${{ env.ARM64_OPTIONAL_SHA }} | + + **How to apply this kernel?** + Before you try to apply this kernel, You **MUST** shutdown your WSL. (wsl --shutdown) + Check this [document](https://learn.microsoft.com/en-us/windows/wsl/wsl-config). + + **How to install kernel module and optional packages in WSL2?** + Please check this [guideline](https://github.com/Nevuly/WSL2-Linux-Kernel-Rolling/wiki#kernel-modules-and-kernel-headers-installation-guide). + + **This kernel built on ArchLinux.** + + files: | + release_images/*/* + token: ${{ secrets.CUSTOM_GITHUB_TOKEN }} + fail_on_unmatched_files: true diff --git a/.gitignore b/.gitignore index 56972adb5031..b1af8ea86904 100644 --- a/.gitignore +++ b/.gitignore @@ -11,6 +11,7 @@ # Normal rules (sorted alphabetically) # .* +!.github *.a *.asn1.[ch] *.bin diff --git a/README.md b/README.md new file mode 100644 index 000000000000..d343d04cc454 --- /dev/null +++ b/README.md @@ -0,0 +1,64 @@ +# Rolling Release Stable Kernel for WSL2 + +[![Stable Kernel CI](https://img.shields.io/github/actions/workflow/status/Nevuly/WSL2-Linux-Kernel-Rolling/build.yml?label=github%20actions%20build&logo=github-actions&logoColor=%23FFFFFF&style=for-the-badge&labelColor=%23000000)](https://github.com/Nevuly/WSL2-Linux-Kernel-Rolling/actions/workflows/build.yml) +[![Release](https://img.shields.io/github/v/release/Nevuly/WSL2-Linux-Kernel-Rolling?display_name=tag&label=LATEST&logo=Linux&logoColor=%23FFFFFF&style=for-the-badge&labelColor=%23000000)](https://github.com/Nevuly/WSL2-Linux-Kernel-Rolling/releases/latest) + +Maintainer: Yang Jeong Hun (Nevuly) + +## Current Kernel Status + +| Kernel Version | Status | +|:--------------:|:------:| +| [Linux 6.12.x][wsl2-kernel-6.12] | Stable Support | + +## Introduction + +The [WSL2-Linux-Kernel-Rolling][wsl2-kernel-rolling] repo contains the latest stable kernel source code and +configuration files for the [WSL2][about-wsl2]. + +This kernel is automatically built via [Github Actions][gh-actions] CI whenever a [newer stable kernel is released][kernel-stable]. + +## Reporting Bugs + +If you discover an issue relating to WSL or the WSL2 kernel, please report it on +the [Issues tab][issue]. + +## Feature Requests + +If you want to fix a bug or add new features, Please use the [Pull Request][pr]. + +## Build Instructions + +Instructions for building WSL2 kernel with an Arch Linux distribution are +as follows: + +1. Install the build dependencies (Arch Linux): + `$ sudo pacman -S aarch64-linux-gnu-gcc bc bison curl flex gcc git pahole python unzip wget zip` + +2. Build the kernel using the WSL2 kernel configuration (x86): + `$ make KCONFIG_CONFIG=arch/x86/configs/config-wsl-x86` + +3. Build the kernel using the WSL2 kernel configuration (arm64): + `$ export ARCH=arm64 && export CROSS_COMPILE=aarch64-linux-gnu-` + `$ make KCONFIG_CONFIG=arch/arm64/configs/config-wsl-arm64` + +4. Save the module to a separate folder (Optional. Only for local build): + `$ sudo make modules_install` + +## Install Instructions + +Please see the documentation on the [.wslconfig configuration +file][install-inst] for information on using a custom built kernel. + +## Credits + * The Linux community who created a awesome kernel. + * Microsoft which produced WSL2 and dxgkrnl patches. + +[wsl2-kernel-6.12]: https://github.com/Nevuly/WSL2-Linux-Kernel-Rolling/tree/wsl-6.12-rolling +[wsl2-kernel-rolling]: https://github.com/Nevuly/WSL2-Linux-Kernel-Rolling +[about-wsl2]: https://docs.microsoft.com/en-us/windows/wsl/about#what-is-wsl-2 +[gh-actions]: https://github.com/Nevuly/WSL2-Linux-Kernel-Rolling/actions +[kernel-stable]: https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git/log/?h=linux-6.12.y +[issue]: https://github.com/Nevuly/WSL2-Rolling-Kernel-Issue/issues +[pr]: https://github.com/Nevuly/WSL2-Linux-Kernel-Rolling/pulls +[install-inst]: https://docs.microsoft.com/en-us/windows/wsl/wsl-config#configure-global-options-with-wslconfig \ No newline at end of file