diff --git a/.github/workflows/CI.yml b/.github/workflows/CI.yml index 203a5b8..19198ac 100644 --- a/.github/workflows/CI.yml +++ b/.github/workflows/CI.yml @@ -5,8 +5,14 @@ on: [push, workflow_dispatch] jobs: + ISO: + strategy: + matrix: + target: + - image: ubuntu + - image: kubuntu + #- image: ubuntu-unity - ISO-Kubuntu: runs-on: ubuntu-latest steps: - uses: actions/checkout@v6 @@ -26,11 +32,13 @@ jobs: echo Version is ${VER}-${REL} echo "kver=${VER}" >> $GITHUB_ENV echo "isotag=${VER}-${REL}" >> $GITHUB_ENV + CAPS=$(echo "${{ matrix.target.image }}" | tr '_-' ' ' | awk '{for(i=1;i<=NF;i++) $i=toupper(substr($i,1,1)) substr($i,2); print}') + echo "caps=${CAPS}" >> $GITHUB_ENV - name: Run build script run: | chmod +x ${{ github.workspace }}/build_in_docker.sh - ${{ github.workspace }}/build_in_docker.sh kubuntu + ${{ github.workspace }}/build_in_docker.sh ${{ matrix.target.image }} - name: print sha256sum run: | @@ -41,15 +49,15 @@ jobs: - name: Upload package artifact uses: actions/upload-artifact@v7 with: - name: ISO-Kubuntu - path: ${{ github.workspace }}/output/kubuntu-25.10-${{ env.kver }}-t2-questing.iso + name: ISO-${{ matrix.target.image }} + path: ${{ github.workspace }}/output/${{ matrix.target.image }}-25.10-${{ env.kver }}-t2-questing.iso archive: false - name: Remove unsplit ISO run: | sudo rm ${{ github.workspace }}/output/*.iso - name: Release - if: github.ref == 'refs/heads/flavourMainline' + if: github.ref == 'refs/heads/mainline' uses: softprops/action-gh-release@v2 with: files: ${{ github.workspace }}/output/* @@ -61,7 +69,7 @@ jobs: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} - name: Update the json - if: github.ref == 'refs/heads/flavourMainline' + if: github.ref == 'refs/heads/mainline' run: | git clone https://github.com/t2linux/wiki.git cd wiki/docs/tools @@ -69,9 +77,9 @@ jobs: cat << EOF > update.py import json # Define the new links - new_link1 = "https://github.com/t2linux/T2-Ubuntu/releases/download/v${{ env.isotag }}/kubuntu-25.10-${{ env.kver }}-t2-questing.iso.00" - new_link2 = "https://github.com/t2linux/T2-Ubuntu/releases/download/v${{ env.isotag }}/kubuntu-25.10-${{ env.kver }}-t2-questing.iso.01" - new_link3 = "https://github.com/t2linux/T2-Ubuntu/releases/download/v${{ env.isotag }}/kubuntu-25.10-${{ env.kver }}-t2-questing.iso.02" + new_link1 = "https://github.com/t2linux/T2-Ubuntu/releases/download/v${{ env.isotag }}/${{ matrix.target.image }}-25.10-${{ env.kver }}-t2-questing.iso.00" + new_link2 = "https://github.com/t2linux/T2-Ubuntu/releases/download/v${{ env.isotag }}/${{ matrix.target.image }}-25.10-${{ env.kver }}-t2-questing.iso.01" + new_link3 = "https://github.com/t2linux/T2-Ubuntu/releases/download/v${{ env.isotag }}/${{ matrix.target.image }}-25.10-${{ env.kver }}-t2-questing.iso.02" # Load the JSON file with open('distro-metadata.json', 'r') as file: data = json.load(file) @@ -82,7 +90,7 @@ jobs: distro['iso'] = new_links distro['sha256'] = sha256 # Update the links - update_links(data['all'], "Kubuntu 25.10 - Questing Quokka", [new_link1, new_link2, new_link3], "${{ env.sha256 }}") + update_links(data['all'], "${{ env.caps }} 25.10 - Questing Quokka", [new_link1, new_link2, new_link3], "${{ env.sha256 }}") # Save the updated JSON back to the file with open('distro-metadata.json', 'w') as file: json.dump(data, file, indent=2) @@ -94,7 +102,7 @@ jobs: cd - - name: Push updated links to t2linux.org - if: github.ref == 'refs/heads/flavourMainline' + if: github.ref == 'refs/heads/mainline' uses: cpina/github-action-push-to-another-repository@main env: API_TOKEN_GITHUB: ${{ secrets.PAT }} @@ -105,105 +113,4 @@ jobs: user-email: github-actions[bot]@users.noreply.github.com user-name: github-actions[bot] target-branch: master - commit-message: Distro metadata - Update Kubuntu 25.10 to v${{ env.isotag }} - - ISO-Ubuntu-Unity: - runs-on: ubuntu-latest - steps: - - uses: actions/checkout@v6 - - - name: Free up disk space for the CI - uses: AdityaGarg8/remove-unwanted-software@v5 - with: - remove-android: 'true' - remove-dotnet: 'true' - remove-haskell: 'true' - - - name: Generate Tag - id: tag - run: | - VER=$(egrep ^KERNEL_VERSION build.sh|cut -d= -f2) - REL=$(egrep ^PKGREL build.sh|cut -d= -f2) - echo Version is ${VER}-${REL} - echo "kver=${VER}" >> $GITHUB_ENV - echo "isotag=${VER}-${REL}" >> $GITHUB_ENV - - - name: Run build script - run: | - chmod +x ${{ github.workspace }}/build_in_docker.sh - ${{ github.workspace }}/build_in_docker.sh ubuntu-unity - - - name: print sha256sum - run: | - cat ${{ github.workspace }}/output/sha256* - SHA256=$(cat ${{ github.workspace }}/output/sha256* | cut -d " " -f 1) - echo "sha256=${SHA256}" >> $GITHUB_ENV - - - name: Upload package artifact - uses: actions/upload-artifact@v7 - with: - name: ISO-Ubuntu-Unity - path: ${{ github.workspace }}/output/ubuntu-unity-25.10-${{ env.kver }}-t2-questing.iso - archive: false - - - name: Remove unsplit ISO - run: | - sudo rm ${{ github.workspace }}/output/*.iso - - name: Release - if: github.ref == 'refs/heads/flavourMainline' - uses: softprops/action-gh-release@v2 - with: - files: ${{ github.workspace }}/output/* - tag_name: v${{ env.isotag }} - #body_path: ${{ github.workspace }}/.github/workflows/instructions.txt - draft: false - prerelease: false - env: - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} - - - name: Update the json - if: github.ref == 'refs/heads/flavourMainline' - run: | - git clone https://github.com/t2linux/wiki.git - cd wiki/docs/tools - - cat << EOF > update.py - import json - # Define the new links - new_link1 = "https://github.com/t2linux/T2-Ubuntu/releases/download/v${{ env.isotag }}/ubuntu-unity-25.10-${{ env.kver }}-t2-questing.iso.00" - new_link2 = "https://github.com/t2linux/T2-Ubuntu/releases/download/v${{ env.isotag }}/ubuntu-unity-25.10-${{ env.kver }}-t2-questing.iso.01" - new_link3 = "https://github.com/t2linux/T2-Ubuntu/releases/download/v${{ env.isotag }}/ubuntu-unity-25.10-${{ env.kver }}-t2-questing.iso.02" - # Load the JSON file - with open('distro-metadata.json', 'r') as file: - data = json.load(file) - # Function to update the links - def update_links(distros, name, new_links, sha256): - for distro in distros: - if distro['name'] == name: - distro['iso'] = new_links - distro['sha256'] = sha256 - # Update the links - update_links(data['all'], "Ubuntu Unity 25.10 - Questing Quokka", [new_link1, new_link2, new_link3], "${{ env.sha256 }}") - # Save the updated JSON back to the file - with open('distro-metadata.json', 'w') as file: - json.dump(data, file, indent=2) - print("Links updated successfully.") - EOF - - python3 update.py - rm update.py - cd - - - - name: Push updated links to t2linux.org - if: github.ref == 'refs/heads/flavourMainline' - uses: cpina/github-action-push-to-another-repository@main - env: - API_TOKEN_GITHUB: ${{ secrets.PAT }} - with: - source-directory: 'wiki' - destination-github-username: 't2linux' - destination-repository-name: 'wiki' - user-email: github-actions[bot]@users.noreply.github.com - user-name: github-actions[bot] - target-branch: master - commit-message: Distro metadata - Update Ubuntu Unity 25.10 to v${{ env.isotag }} + commit-message: Distro metadata - Update ${{ env.caps }} 25.10 to v${{ env.isotag }} diff --git a/01_edit_iso.sh b/01_edit_iso.sh index e5d7ceb..4ca8138 100755 --- a/01_edit_iso.sh +++ b/01_edit_iso.sh @@ -3,15 +3,30 @@ set -eu -o pipefail # Prepare the ISO Directories mkdir -p "$ISO_MOUNT_DIR" "$ISO_WORK_DIR" "$CHROOT_DIR" +if [ "$SUBIQUITY" = "yes" ]; then + mkdir -p "$CHROOT_DIR_EXTRA" +fi + # Mount the Original ISO and Copy Files echo "mounting $ISO_IMAGE" if [ ! -f "$ISO_IMAGE" ]; then echo "Error: ISO file $ISO_IMAGE not found." exit 1 fi + mount -o loop "$(pwd)/$ISO_IMAGE" "$ISO_MOUNT_DIR" -rsync -a "$ISO_MOUNT_DIR/" "$ISO_WORK_DIR" -umount "$ISO_MOUNT_DIR" -unsquashfs -d "$CHROOT_DIR" "$ISO_WORK_DIR/casper/filesystem.squashfs" + +if [ "$SUBIQUITY" = "yes" ]; then + rsync -a "$ISO_MOUNT_DIR/" "$ISO_WORK_DIR" --include="casper/initrd" --include="casper/vmlinuz" --include="casper/minimal.standard.live.squashfs" --include="casper/minimal.standard.live.manifest" --include="casper/minimal.standard.live.size" --exclude="casper/*" --exclude="md5sum.txt" --exclude="MD5SUMS" --exclude=".disk/release_notes_url" --exclude="casper/*.gpg" + unsquashfs -d "$CHROOT_DIR" "$ISO_MOUNT_DIR/casper/minimal.squashfs" + unsquashfs -d "$CHROOT_DIR_EXTRA" "$ISO_MOUNT_DIR/casper/minimal.standard.squashfs" + rsync -a "$CHROOT_DIR_EXTRA/" "$CHROOT_DIR/" + rm -rf "$CHROOT_DIR_EXTRA" + umount "$ISO_MOUNT_DIR" +else + rsync -a "$ISO_MOUNT_DIR/" "$ISO_WORK_DIR" + umount "$ISO_MOUNT_DIR" + unsquashfs -d "$CHROOT_DIR" "$ISO_WORK_DIR/casper/filesystem.squashfs" +fi rm "$(pwd)/$ISO_IMAGE" diff --git a/02_create_iso.sh b/02_create_iso.sh index 331a7dd..5c3291e 100755 --- a/02_create_iso.sh +++ b/02_create_iso.sh @@ -4,13 +4,19 @@ set -eu -o pipefail echo >&2 "===]> Info: Getting Kernel version ... " echo $T2_KERNEL -# Update GRUB Configuration in ISO -echo >&2 "===]> Info: Copying Linux vmlinuz and initrd ... " -cp "$CHROOT_DIR/boot/vmlinuz-$T2_KERNEL" "$ISO_WORK_DIR/casper/vmlinuz" -cp "$CHROOT_DIR/boot/initrd.img-$T2_KERNEL" "$ISO_WORK_DIR/casper/initrd" +if [ "$SUBIQUITY" = "no" ]; then + echo >&2 "===]> Info: Copying Linux vmlinuz and initrd ... " + cp "$CHROOT_DIR/boot/vmlinuz-$T2_KERNEL" "$ISO_WORK_DIR/casper/vmlinuz" + cp "$CHROOT_DIR/boot/initrd.img-$T2_KERNEL" "$ISO_WORK_DIR/casper/initrd" +fi +# Update GRUB Configuration in ISO echo >&2 "===]> Info: Modify existing grub.cfg ..." -sed -i 's/--- quiet splash/--- quiet splash intel_iommu=on iommu=pt pcie_ports=native/g' "$ISO_WORK_DIR/boot/grub/grub.cfg" +if [ "$SUBIQUITY" = "yes" ]; then + sed -i 's/--- quiet splash/--- quiet splash intel_iommu=on iommu=pt pcie_ports=native/g' "$ISO_WORK_DIR/boot/grub/grub.cfg" +else + sed -i 's/--- quiet splash/boot=casper quiet splash intel_iommu=on iommu=pt pcie_ports=native ---/g' "$ISO_WORK_DIR/boot/grub/grub.cfg" +fi echo >&2 "===]> Info: Creating EFI image ... " dd if=/dev/zero of="$ISO_WORK_DIR/EFI/efiboot.img" bs=1M count=10 diff --git a/build.sh b/build.sh index 035fc04..ceae316 100755 --- a/build.sh +++ b/build.sh @@ -6,6 +6,7 @@ ROOT_PATH=$(pwd)/work OUTPUT_PATH=$(pwd)/output FLAVOUR=$1 +FLAVOUR_CAP=$(echo "${FLAVOUR}" | tr '_-' ' ' | awk '{for(i=1;i<=NF;i++) $i=toupper(substr($i,1,1)) substr($i,2); print}') ISO_MOUNT_DIR="$ROOT_PATH/${FLAVOUR}-original" # Temporary mount point for the original ISO VER=25.10 CODENAME=questing @@ -15,6 +16,13 @@ ISO_IMAGE=${FLAVOUR}-25.10-desktop-amd64.iso ISO_IMAGE_OUTPUT="${OUTPUT_PATH}/${FLAVOUR}-${VER}-${KERNEL_VERSION}-t2-${CODENAME}.iso" ISO_WORK_DIR="$ROOT_PATH/${FLAVOUR}-iso" CHROOT_DIR="$ROOT_PATH/${FLAVOUR}-edit" +CHROOT_DIR_EXTRA="$ROOT_PATH/${FLAVOUR}-edit-extra" + +if [ "$FLAVOUR" = "ubuntu" ]; then + SUBIQUITY=yes +else + SUBIQUITY=no +fi echo "ROOT_PATH=$ROOT_PATH" echo "ISO_MOUNT_DIR=$ISO_MOUNT_DIR" @@ -34,7 +42,11 @@ apt update && apt update && \ xorriso isolinux grub-efi-amd64-bin mtools dosfstools curl echo >&2 "===]> Info: Download ISO..." -curl -L -o "$(pwd)/${ISO_IMAGE}" "https://cdimage.ubuntu.com/${FLAVOUR}/releases/${VER}/release/${ISO_IMAGE}" +if [ "$FLAVOUR" = "ubuntu" ]; then + curl -L -o "$(pwd)/${ISO_IMAGE}" "https://releases.ubuntu.com/${VER}/ubuntu-${VER}-desktop-amd64.iso" +else + curl -L -o "$(pwd)/${ISO_IMAGE}" "https://cdimage.ubuntu.com/${FLAVOUR}/releases/${VER}/release/${ISO_IMAGE}" +fi # Run entrypoint.sh to extract and customize the ISO echo >&2 "===]> Info: Starting extraction and customization..." @@ -43,9 +55,11 @@ echo >&2 "===]> Info: Starting extraction and customization..." ISO_MOUNT_DIR=${ISO_MOUNT_DIR} \\ ISO_WORK_DIR=${ISO_WORK_DIR} \\ CHROOT_DIR=${CHROOT_DIR} \\ + CHROOT_DIR_EXTRA=${CHROOT_DIR_EXTRA} \\ ROOT_PATH=${ROOT_PATH} \\ KERNEL_VERSION=${KERNEL_VERSION} \\ FLAVOUR=${FLAVOUR} \\ + SUBIQUITY=${SUBIQUITY} \\ $(pwd)/01_edit_iso.sh" # Enter the Chroot Environment and Apply Customizations @@ -64,13 +78,14 @@ cp -p /etc/resolv.conf "${CHROOT_DIR}/etc/resolv.conf" cp "$(pwd)/chroot_iso.sh" "${CHROOT_DIR}/tmp/setup_files" ls "${CHROOT_DIR}/tmp/setup_files" echo >&2 "===]> Info: Running chroot environment... " -chroot "${CHROOT_DIR}" /bin/bash -c "KERNEL_VERSION=${KERNEL_VERSION} PKGREL=${PKGREL} /tmp/setup_files/chroot_iso.sh" +chroot "${CHROOT_DIR}" /bin/bash -c "KERNEL_VERSION=${KERNEL_VERSION} PKGREL=${PKGREL} SUBIQUITY=${SUBIQUITY} /tmp/setup_files/chroot_iso.sh" echo >&2 "===]> Info: Getting Kernel environment... " T2_KERNEL=${KERNEL_VERSION}-${PKGREL}-t2-${CODENAME} echo >&2 "===]> Info: Cleanup the chroot environment... " # restore backup cp -p "${CHROOT_DIR}/etc/resolv.conf.backup" "${CHROOT_DIR}/etc/resolv.conf" +sleep 10 #Sometimes umount fails as mounts are busy. umount "${CHROOT_DIR}/dev/pts" umount "${CHROOT_DIR}/dev" umount "${CHROOT_DIR}/proc" @@ -79,8 +94,38 @@ umount "${CHROOT_DIR}/sys" echo >&2 "===]> Info: Reset firmware flag for fresh boot... " rm -f "${CHROOT_DIR}/etc/get_apple_firmware_attempted" || true -echo >&2 "===]> Info: Squashing $(echo ${FLAVOUR} | cut -c1 | tr '[a-z]' '[A-Z]')$(echo ${FLAVOUR} | cut -c2-) file system ... " -mksquashfs "$CHROOT_DIR" "$ISO_WORK_DIR/casper/filesystem.squashfs" -comp xz -noappend +echo >&2 "===]> Info: Squashing ${FLAVOUR_CAP} file system ... " +if [ "$SUBIQUITY" = "yes" ]; then + mksquashfs "$CHROOT_DIR" "$ISO_WORK_DIR/casper/minimal.squashfs" -comp xz -noappend + printf "%s" "$(du -sx --block-size=1 "${CHROOT_DIR}" | cut -f1)" >"${ISO_WORK_DIR}"/casper/minimal.size + chroot "${CHROOT_DIR}" dpkg-query -W --showformat='${Package} ${Version}\n' | tee "${ISO_WORK_DIR}"/casper/minimal.manifest + cd ${ISO_WORK_DIR}/casper + ln -s minimal.size minimal.standard.size + ln -s minimal.squashfs minimal.standard.squashfs + ln -s minimal.manifest filesystem.manifest + FILESYSTEM_SIZE=$(($(cat minimal.size)+$(cat minimal.standard.live.size))) + echo ${FILESYSTEM_SIZE} > filesystem.size +cat <&2 "===]> Info: Creating iso ... " ROOT_PATH=${ROOT_PATH} \\ T2_KERNEL=${T2_KERNEL} \\ FLAVOUR=${FLAVOUR} \\ + SUBIQUITY=${SUBIQUITY} \\ $(pwd)/02_create_iso.sh" # split iso diff --git a/chroot_iso.sh b/chroot_iso.sh index 6b65afa..6358ddc 100755 --- a/chroot_iso.sh +++ b/chroot_iso.sh @@ -14,11 +14,96 @@ echo "deb [signed-by=/etc/apt/trusted.gpg.d/t2-ubuntu-repo.gpg] https://github.c apt update +echo >&2 "===]> Info: Update grub... " # Add Kernel Parameters to GRUB for Installed System sed -i 's/GRUB_CMDLINE_LINUX_DEFAULT="quiet splash"/GRUB_CMDLINE_LINUX_DEFAULT="quiet splash intel_iommu=on iommu=pt pcie_ports=native"/' /etc/default/grub update-grub + +echo >&2 "===]> Info: Install audio and wifi firmware script... " apt install -y apple-t2-audio-config apple-firmware-script + +echo >&2 "===]> Info: Install the T2 kernel... " +if [ "$SUBIQUITY" = "yes" ]; then +# Create a fake linux-t2 package with version 0.1 that ships dkms modules instead of the kernel +apt install -y git + +conf=$RANDOM +mkdir t2 +cd t2 +mkdir ./DEBIAN +mkdir -p ./etc/modprobe.d/ +mkdir -p ./usr/src + +cat < ./etc/modprobe.d/${conf}.conf +install usbhid /sbin/modprobe bcm5974; /sbin/modprobe --ignore-install usbhid +EOF + +cat < ./DEBIAN/control +Package: linux-t2 +Version: 0.1 +Maintainer: Aditya Garg +Architecture: amd64 +Description: Kernel to support T2 Macs +Depends: dkms +EOF + +cat < ./DEBIAN/postinst +dkms add -m apple-bce -v 0.2 +dkms build -m apple-bce -v 0.2 && dkms install -m apple-bce -v 0.2 --force || true +dkms add -m bcm5974-t2 -v 0.1 +dkms build -m bcm5974-t2 -v 0.1 && dkms install -m bcm5974-t2 -v 0.1 --force || true +dkms add -m applesmc-t2 -v 0.1 +dkms build -m applesmc-t2 -v 0.1 && dkms install -m applesmc-t2 -v 0.1 --force || true +dkms add -m linux-apfs-rw -v 0.1 +dkms build -m linux-apfs-rw -v 0.1 && dkms install -m linux-apfs-rw -v 0.1 --force || true +EOF +chmod a+x ./DEBIAN/postinst + +cat < ./DEBIAN/prerm +dkms remove -m apple-bce -v 0.2 --all || true +dkms remove -m bcm5974-t2 -v 0.1 --all || true +dkms remove -m applesmc-t2 -v 0.1 --all || true +dkms remove -m linux-apfs-rw -v 0.1 --all || true +EOF +chmod a+x ./DEBIAN/prerm + +cd ./usr/src + +git clone --depth 1 https://github.com/t2linux/apple-bce-drv.git ./apple-bce-0.2 +cat << 'EOF' > ./apple-bce-0.2/dkms.conf +PACKAGE_NAME="apple-bce" +PACKAGE_VERSION="0.2" +MAKE[0]="make KVERSION=$kernelver" +CLEAN="make clean" +BUILT_MODULE_NAME[0]="apple-bce" +DEST_MODULE_LOCATION[0]="/kernel/drivers/misc" +AUTOINSTALL="yes" +EOF + +git clone --depth 1 https://github.com/AdityaGarg8/bcm5974-t2.git ./bcm5974-t2-0.1 + +git clone --depth 1 https://github.com/AdityaGarg8/applesmc-t2 ./applesmc-t2-0.1 + +git clone --depth 1 https://github.com/linux-apfs/linux-apfs-rw.git ./linux-apfs-rw-0.1 +sed -i 's/PACKAGE_VERSION=.*/PACKAGE_VERSION="0.1"/g' ./linux-apfs-rw-0.1/dkms.conf + +cd .. +cd .. +cd .. +dpkg-deb --build --root-owner-group t2 + +rm -rf t2 +apt install -y ./t2.deb +rm ./t2.deb + +KVER=$(ls /boot | grep generic | grep vmlinuz | cut -d '-' -f 2-) +dkms install -m apple-bce -v 0.2 -k ${KVER} --force || true +dkms install -m bcm5974-t2 -v 0.1 -k ${KVER} --force || true +dkms install -m applesmc-t2 -v 0.1 -k ${KVER} --force || true +dkms install -m linux-apfs-rw -v 0.1 -k ${KVER} --force || true +else apt install -y linux-t2=${KERNEL_VERSION}-${PKGREL}-${CODENAME} +fi echo >&2 "===]> Info: Add udev Rule to stop annoying WiFi popup... " mkdir -p /etc/NetworkManager/conf.d