Add fallback boot directory detection and cross-compile kernel with D… #47
This file contains hidden or 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
| name: Build WLAN Pi Kernel for Debian Bookworm | |
| on: | |
| push: | |
| branches: | |
| - 6.12-bookworm | |
| workflow_dispatch: | |
| jobs: | |
| build: | |
| runs-on: ubuntu-24.04-arm | |
| env: | |
| DISTRO: bookworm | |
| VERSION_CODENAME: bookworm | |
| KERNEL_TARGET_DISTRO: Debian | |
| KERNEL_TARGET_VERSION: bookworm | |
| steps: | |
| # Step 1: Checkout the repository | |
| - name: Checkout Repository | |
| uses: actions/checkout@v4 | |
| with: | |
| fetch-depth: 0 | |
| # Step 2: Restore APT Cache | |
| - name: Restore APT Cache | |
| uses: actions/cache@v3 | |
| with: | |
| path: cache-apt | |
| key: ${{ runner.os }}-apt-${{ hashFiles('build-kernel.sh') }} | |
| restore-keys: | | |
| ${{ runner.os }}-apt- | |
| # Step 3: Prepare APT Cache for Caching | |
| - name: Prepare APT Cache for Caching | |
| run: | | |
| mkdir -p cache-apt | |
| find /var/cache/apt/archives -path /var/cache/apt/archives/partial -prune -o -type f -name '*.deb' -exec cp {} cache-apt/ \; | |
| # Step 4: Install Dependencies | |
| - name: Install Dependencies | |
| run: | | |
| sudo apt-get update | |
| sudo apt-get install -y build-essential git libncurses-dev flex bison libssl-dev \ | |
| bc libelf-dev libudev-dev libpci-dev libiberty-dev autoconf automake libtool \ | |
| libpython3-dev crossbuild-essential-arm64 dpkg-dev gcc-aarch64-linux-gnu | |
| # Step 5: Cache Kernel Build Directory | |
| - name: Cache Kernel Build Directory | |
| uses: actions/cache@v3 | |
| with: | |
| path: linux | |
| key: ${{ runner.os }}-kernel-${{ hashFiles('build-kernel.sh') }} | |
| restore-keys: | | |
| ${{ runner.os }}-kernel- | |
| # Step 6: Verify Custom Config File Presence | |
| - name: Verify Custom Config File Presence | |
| run: | | |
| echo "Verifying presence of wlanpi_v8_defconfig in root directory..." | |
| if [ -f wlanpi_v8_defconfig ]; then | |
| echo "wlanpi_v8_defconfig found." | |
| else | |
| echo "ERROR: wlanpi_v8_defconfig not found in root directory." | |
| exit 1 | |
| fi | |
| # Step 7: Make the build script executable | |
| - name: Make Build Script Executable | |
| run: chmod +x build-kernel.sh | |
| # Step 8: Execute the build script | |
| - name: Execute Build Script | |
| id: build-kernel | |
| run: ./build-kernel.sh | |
| # Step 9: Extract Kernel Version and Date | |
| - name: Extract Kernel Version and Date | |
| id: version-info | |
| run: | | |
| echo "KERNEL_VERSION=unknown" >> $GITHUB_ENV | |
| echo "BUILD_DATE=unknown" >> $GITHUB_ENV | |
| echo "PACKAGE_NAME=wlanpi-kernel-bookworm" >> $GITHUB_ENV | |
| echo "PACKAGE_VERSION=unknown" >> $GITHUB_ENV | |
| echo "Files in output directory:" | |
| ls -la output/ | |
| DEB_FILES=$(find output -name '*.deb' -type f) | |
| if [ -z "$DEB_FILES" ]; then | |
| echo "ERROR: No .deb files found in output directory." | |
| fi | |
| KERNEL_DEB=$(ls output/wlanpi-kernel-bookworm_*.deb 2>/dev/null | head -n 1) | |
| if [ -z "$KERNEL_DEB" ]; then | |
| echo "ERROR: Kernel .deb file not found" | |
| fi | |
| echo Processing kernel deb: $KERNEL_DEB | |
| FILENAME=$(basename "$KERNEL_DEB") | |
| echo "Processing filename: $FILENAME" | |
| VERSION=$(echo "$FILENAME" | sed -nE 's/^[^_]+_([^_]+)_.+$/\1/p') | |
| if [ -z "$VERSION" ]; then | |
| echo "ERROR: Could not extract version from filename" | |
| exit 0 | |
| fi | |
| echo "Extracted version: $VERSION" | |
| BUILD_DATE=$(echo "$VERSION" | grep -o '[0-9]\{8\}$' || echo "") | |
| if [ -z "$BUILD_DATE" ]; then | |
| echo "ERROR: Could not extract build date from version" | |
| echo "KERNEL_VERSION=$VERSION" >> $GITHUB_ENV | |
| echo "PACKAGE_VERSION=$VERSION" >> $GITHUB_ENV | |
| exit 0 | |
| fi | |
| KERNEL_VERSION=${VERSION%-$BUILD_DATE} | |
| if [ -z "$KERNEL_VERSION" ]; then | |
| echo "ERROR: Could not extract kernel version" | |
| echo "KERNEL_VERSION=$VERSION" >> $GITHUB_ENV | |
| echo "BUILD_DATE=$BUILD_DATE" >> $GITHUB_ENV | |
| echo "PACKAGE_VERSION=$VERSION" >> $GITHUB_ENV | |
| exit 0 | |
| fi | |
| echo "KERNEL_VERSION=$KERNEL_VERSION" >> $GITHUB_ENV | |
| echo "BUILD_DATE=$BUILD_DATE" >> $GITHUB_ENV | |
| echo "PACKAGE_NAME=wlanpi-kernel-bookworm" >> $GITHUB_ENV | |
| echo "PACKAGE_VERSION=$VERSION" >> $GITHUB_ENV | |
| echo "Extracted values:" | |
| echo "KERNEL_VERSION=$KERNEL_VERSION" | |
| echo "BUILD_DATE=$BUILD_DATE" | |
| echo "PACKAGE_VERSION=$VERSION" | |
| # Step 10: Debug Kernel and Package Versions | |
| - name: Debug Kernel and Package Versions | |
| run: | | |
| echo "Kernel Version: ${{ env.KERNEL_VERSION }}" | |
| echo "Build Date: ${{ env.BUILD_DATE }}" | |
| echo "Package Name: ${{ env.PACKAGE_NAME }}" | |
| echo "Package Version: ${{ env.PACKAGE_VERSION }}" | |
| # Step 11: Upload Debian Package as Artifact | |
| - name: Upload Debian Package | |
| uses: actions/upload-artifact@v4 | |
| with: | |
| name: ${{ env.PACKAGE_NAME }}-${{ env.KERNEL_VERSION }}-${{ env.BUILD_DATE }} | |
| path: output/*.deb | |