├── .github
├── FUNDING.yml
├── dependabot.yml
└── workflows
│ ├── .ymllint
│ ├── CI.yml
│ ├── instructions.txt
│ └── iso.sh
├── .gitignore
├── .travis.yml
├── 01_build_file_system.sh
├── 02_build_image.sh
├── 03_prepare_iso.sh
├── 04_create_iso.sh
├── README.md
├── build.sh
├── build_in_docker.sh
└── files
├── audio
├── 91-pulseaudio-custom.rules
├── AppleT2.conf
└── apple-t2.conf
├── chroot_build.sh
├── grub
├── 30_os-prober
└── grub.cfg
├── isohdpfx.bin
└── preseed
├── mbp.seed
└── mbp164.seed
/.github/FUNDING.yml:
--------------------------------------------------------------------------------
1 | # These are supported funding model platforms
2 |
3 | github: [AdityaGarg8]
4 | custom: ['https://www.buymeacoffee.com/gargadityav']
5 |
--------------------------------------------------------------------------------
/.github/dependabot.yml:
--------------------------------------------------------------------------------
1 | version: 2
2 | updates:
3 |
4 | - package-ecosystem: "github-actions"
5 | directory: "/"
6 | schedule:
7 | interval: "daily"
8 | - package-ecosystem: "github-actions"
9 | directory: "/"
10 | schedule:
11 | interval: "daily"
12 | target-branch: "mainline"
13 | - package-ecosystem: "github-actions"
14 | directory: "/"
15 | schedule:
16 | interval: "daily"
17 | target-branch: "kubuntuMainline"
18 | - package-ecosystem: "github-actions"
19 | directory: "/"
20 | schedule:
21 | interval: "daily"
22 | target-branch: "kubuntuLTS"
23 |
--------------------------------------------------------------------------------
/.github/workflows/.ymllint:
--------------------------------------------------------------------------------
1 | rules:
2 |
3 | line-length: disable
4 |
--------------------------------------------------------------------------------
/.github/workflows/CI.yml:
--------------------------------------------------------------------------------
1 | ---
2 | name: CI
3 | # yamllint disable-line rule:truthy
4 | on:
5 | [push, workflow_dispatch]
6 |
7 | jobs:
8 | Mainline:
9 | runs-on: ubuntu-latest
10 | steps:
11 | - name: 'Checkout LTS Repo'
12 | uses: actions/checkout@v4
13 |
14 | - name: Get version
15 | run: |
16 | VERSION=$(grep ^KERNEL_VERSION build.sh | head -n1| cut -d = -f2)
17 | REL=$(grep "PKGREL=\d*" build.sh | cut -d = -f2)
18 | echo "ver=${VERSION}" >> $GITHUB_ENV
19 | echo "release=${REL}" >> $GITHUB_ENV
20 |
21 | - name: 'Checkout mainline Repo'
22 | uses: actions/checkout@v4
23 | with:
24 | ref: mainline
25 | persist-credentials: false
26 |
27 | - name: 'Push new version to mainline'
28 | id: publish
29 | run: |
30 | sed -i "s/KERNEL_VERSION=6.*/KERNEL_VERSION=${{ env.ver }}/g" build.sh
31 | sed -i "s/PKGREL=.*/PKGREL=${{ env.release }}/g" build.sh
32 | git config --local user.email "41898282+github-actions[bot]@users.noreply.github.com"
33 | git config --local user.name "github-actions[bot]"
34 | git commit -m "${{ env.ver }}-${{ env.release }}" -a
35 | - name: Push changes to the repo
36 | uses: ad-m/github-push-action@master
37 | with:
38 | github_token: ${{ secrets.PAT }}
39 | branch: mainline
40 |
41 | Flavour:
42 | runs-on: ubuntu-latest
43 | steps:
44 | - name: 'Checkout LTS Repo'
45 | uses: actions/checkout@v4
46 |
47 | - name: Get version
48 | run: |
49 | VERSION=$(grep ^KERNEL_VERSION build.sh | head -n1| cut -d = -f2)
50 | REL=$(grep "PKGREL=\d*" build.sh | cut -d = -f2)
51 | echo "ver=${VERSION}" >> $GITHUB_ENV
52 | echo "release=${REL}" >> $GITHUB_ENV
53 |
54 | - name: 'Checkout flavourLTS Repo'
55 | uses: actions/checkout@v4
56 | with:
57 | ref: flavourLTS
58 | persist-credentials: false
59 |
60 | - name: 'Push new version to flavourLTS'
61 | id: publish
62 | run: |
63 | sed -i "s/KERNEL_VERSION=6.*/KERNEL_VERSION=${{ env.ver }}/g" build.sh
64 | sed -i '/^PKGREL=/ s/PKGREL=[0-9]*/PKGREL=${{ env.release }}/' build.sh
65 | git config --local user.email "41898282+github-actions[bot]@users.noreply.github.com"
66 | git config --local user.name "github-actions[bot]"
67 | git commit -m "${{ env.ver }}-${{ env.release }}" -a
68 | - name: Push changes to the repo
69 | uses: ad-m/github-push-action@master
70 | with:
71 | github_token: ${{ secrets.PAT }}
72 | branch: flavourLTS
73 |
74 | ISO:
75 | runs-on: ubuntu-latest
76 | steps:
77 | - uses: actions/checkout@v4
78 |
79 | - name: Build
80 | run: sudo ./build_in_docker.sh
81 |
82 | - name: print sha256sum
83 | run: cat output/sha256*
84 |
85 | - name: Generate Tag
86 | id: tag
87 | run: |
88 | VER=$(egrep ^KERNEL_VERSION build.sh|cut -d= -f2)
89 | REL=$(grep "PKGREL=\d*" build.sh | cut -d = -f2)
90 | echo Version is $VER
91 | echo "kver=${VER}" >> $GITHUB_ENV
92 | echo "isotag=${VER}-${REL}" >> $GITHUB_ENV
93 |
94 | - name: Upload iso artifact
95 | uses: actions/upload-artifact@v4
96 | with:
97 | name: mbp-ubuntu-${{ steps.tag.outputs.tag }}.z01
98 | path: ${{ github.workspace }}/output/*
99 |
100 | - name: Instructions for putting it back together
101 | run: |
102 | cat << EOF
103 | Download all the artifacts, and put them in a folder
104 | without other files. Then run:"
105 | unzip "*.z??.zip"
106 | cat livecd-${{ env.isotag }}-t2.z?? > cd.zip
107 | echo unzip cd.zip
108 | EOF
109 |
110 | - name: Get the ISO script
111 | run: |
112 | sudo sed -i 's/GITHUBRELEASE/v${{ env.isotag }}/g' ${{ github.workspace }}/.github/workflows/iso.sh
113 | sudo cp ${{ github.workspace }}/.github/workflows/iso.sh ${{ github.workspace }}/output/iso.sh
114 |
115 | - name: Release
116 | if: github.ref == 'refs/heads/LTS'
117 | uses: softprops/action-gh-release@v2
118 | with:
119 | #files: ${{ github.workspace }}/ISO/*.tar.gz
120 | #files: ${{ github.workspace }}/ISO/*.iso
121 | files: ${{ github.workspace }}/output/*
122 | tag_name: v${{ env.isotag }}
123 | body_path: ${{ github.workspace }}/.github/workflows/instructions.txt
124 | draft: false
125 | prerelease: false
126 | env:
127 | GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
128 |
129 | - name: Update the json
130 | if: github.ref == 'refs/heads/LTS'
131 | run: |
132 | git clone https://github.com/t2linux/wiki.git
133 | cd wiki/docs/tools
134 |
135 | cat << EOF > update.py
136 | import json
137 |
138 | # Define the new links
139 | new_link1 = "https://github.com/t2linux/T2-Ubuntu/releases/download/v${{ env.isotag }}/ubuntu-24.04-${{ env.kver }}-t2-noble.iso.00"
140 | new_link2 = "https://github.com/t2linux/T2-Ubuntu/releases/download/v${{ env.isotag }}/ubuntu-24.04-${{ env.kver }}-t2-noble.iso.01"
141 | new_link3 = "https://github.com/t2linux/T2-Ubuntu/releases/download/v${{ env.isotag }}/ubuntu-24.04-${{ env.kver }}-t2-noble.iso.02"
142 |
143 | # Load the JSON file
144 | with open('distro-metadata.json', 'r') as file:
145 | data = json.load(file)
146 |
147 | # Function to update the links
148 | def update_links(distros, name, new_links):
149 | for distro in distros:
150 | if distro['name'] == name:
151 | distro['iso'] = new_links
152 |
153 | # Update the links
154 | update_links(data['all'], "Ubuntu 24.04 - Noble Numbat", [new_link1, new_link2, new_link3])
155 |
156 | # Save the updated JSON back to the file
157 | with open('distro-metadata.json', 'w') as file:
158 | json.dump(data, file, indent=2)
159 |
160 | print("Links updated successfully.")
161 | EOF
162 |
163 | python3 update.py
164 | rm update.py
165 | cd -
166 |
167 | - name: Push updated links to t2linux.org
168 | if: github.ref == 'refs/heads/LTS'
169 | uses: cpina/github-action-push-to-another-repository@main
170 | env:
171 | API_TOKEN_GITHUB: ${{ secrets.PAT }}
172 | with:
173 | source-directory: 'wiki'
174 | destination-github-username: 't2linux'
175 | destination-repository-name: 'wiki'
176 | user-email: github-actions[bot]@users.noreply.github.com
177 | user-name: github-actions[bot]
178 | target-branch: master
179 | commit-message: Distro metadata - Update Ubuntu 24.04 to v${{ env.isotag }}
180 |
--------------------------------------------------------------------------------
/.github/workflows/instructions.txt:
--------------------------------------------------------------------------------
1 | ## How to download the ISO?
2 |
3 | Download the "iso.sh" script in the **assets** below, run it on the terminal and follow the on screen instructions.
4 |
5 | ## Adding Wi-Fi and Bluetooth support:
6 |
7 | Once you're booted and in your desktop, run `get-apple-firmware` and choose the option **"Retrieve the firmware directly from macOS"**.
8 |
9 | If this method doesn't work, follow [this guide](https://wiki.t2linux.org/guides/wifi-bluetooth/) to get firmware for Wi-Fi and Bluetooth.
10 |
11 | ## Adding support for customisable Touch Bar:
12 |
13 | If your Mac has a Touch Bar, and you want to customise it, install `tiny-dfr` by running `sudo apt update && sudo apt install tiny-dfr`. After installing restart your Mac and run `sudo touchbar` to customise.
14 |
--------------------------------------------------------------------------------
/.github/workflows/iso.sh:
--------------------------------------------------------------------------------
1 | #!/bin/bash
2 |
3 | os=$(uname -s)
4 | case "$os" in
5 | (Darwin)
6 | true
7 | ;;
8 | (Linux)
9 | true
10 | ;;
11 | (*)
12 | echo "This script is meant to be run only on Linux or macOS"
13 | exit 1
14 | ;;
15 | esac
16 |
17 | echo -e "GET http://github.com HTTP/1.0\n\n" | nc github.com 80 > /dev/null 2>&1
18 |
19 | if [ $? -eq 0 ]; then
20 | true
21 | else
22 | echo "Please connect to the internet"
23 | exit 1
24 | fi
25 |
26 | set -e
27 |
28 | cd $HOME/Downloads
29 |
30 | #latest=$(curl -sL https://github.com/t2linux/T2-Ubuntu/releases/latest/ | grep "
Release" | awk -F " " '{print $2}' )
31 | latest=GITHUBRELEASE
32 | latestkver=$(echo $latest | cut -d "v" -f 2 | cut -d "-" -f 1)
33 |
34 | cat < ${iso}.iso
101 |
102 | echo -e "\nDownloading Part 2 for ${flavourcap} ${ver}\n"
103 | curl -#L https://github.com/t2linux/T2-Ubuntu/releases/download/${latest}/${iso}.iso.01 >> ${iso}.iso
104 |
105 | echo -e "\nDownloading Part 3 for ${flavourcap} ${ver}\n"
106 | curl -#L https://github.com/t2linux/T2-Ubuntu/releases/download/${latest}/${iso}.iso.02 >> ${iso}.iso
107 |
108 | echo -e "\nVerifying sha256 checksums"
109 |
110 | actual_iso_chksum=$(curl -sL https://github.com/t2linux/T2-Ubuntu/releases/download/${latest}/sha256-${flavour}-$(echo ${ver} | cut -d " " -f 1) | cut -d " " -f 1)
111 |
112 | case "$os" in
113 | (Darwin)
114 | downloaded_iso_chksum=$(shasum -a 256 $HOME/Downloads/${iso}.iso | cut -d " " -f 1)
115 | ;;
116 | (Linux)
117 | downloaded_iso_chksum=$(sha256sum $HOME/Downloads/${iso}.iso | cut -d " " -f 1)
118 | ;;
119 | (*)
120 | echo "This script is meant to be run only on Linux or macOS"
121 | exit 1
122 | ;;
123 | esac
124 |
125 | if [[ ${actual_iso_chksum} != ${downloaded_iso_chksum} ]]
126 | then
127 | echo -e "\nError: Failed to verify sha256 checksums of the ISO"
128 | rm $HOME/Downloads/${iso}.iso
129 | exit 1
130 | fi
131 |
132 | echo -e "\nISO saved to Downloads"
133 |
--------------------------------------------------------------------------------
/.gitignore:
--------------------------------------------------------------------------------
1 | output
2 | /.idea
3 | .DS_Store
4 |
--------------------------------------------------------------------------------
/.travis.yml:
--------------------------------------------------------------------------------
1 | ---
2 | language: bash
3 |
4 | os:
5 | - linux
6 |
7 | services:
8 | - docker
9 |
10 | # branches:
11 | # only:
12 | # - master
13 |
14 | stages:
15 | - test
16 | - build_deploy
17 |
18 | jobs:
19 | include:
20 | - stage: test
21 | name: "YamlLint"
22 | script: |
23 | docker run --rm -v $(pwd):/repo -it alpine:latest /bin/sh -c '
24 | cd /repo
25 | apk add --no-cache python3 py-pip
26 | pip install yamllint
27 | yamllint .
28 | '
29 | - stage: test
30 | name: "ShellCheck"
31 | script: |
32 | docker run --rm -v $(pwd):/repo -it alpine:latest /bin/sh -c '
33 | cd /repo
34 | apk add --no-cache shellcheck bash
35 | shellcheck ./*.sh
36 | shellcheck ./files/*.sh
37 | '
38 | - stage: build_deploy
39 | name: "Build Ubuntu and Deploy to GitHub Releases"
40 | script: ./build_in_docker.sh
41 | deploy:
42 | provider: releases
43 | api_key: "$GITHUB_TOKEN"
44 | file_glob: true
45 | file: "output/*"
46 | skip_cleanup: true
47 | # yamllint disable-line rule:truthy
48 | on:
49 | tags: true
50 |
--------------------------------------------------------------------------------
/01_build_file_system.sh:
--------------------------------------------------------------------------------
1 | #!/bin/bash
2 | set -eu -o pipefail
3 |
4 | echo >&2 "===]> Info: Checkout bootstrap... "
5 | debootstrap \
6 | --arch=amd64 \
7 | --variant=minbase \
8 | noble \
9 | "${CHROOT_PATH}" \
10 | http://archive.ubuntu.com/ubuntu/
11 |
12 | echo >&2 "===]> Info: Creating chroot environment... "
13 | mount --bind /dev "${CHROOT_PATH}/dev"
14 | mount --bind /run "${CHROOT_PATH}/run"
15 |
16 | cp -r "${ROOT_PATH}/files" "${CHROOT_PATH}/tmp/setup_files"
17 | chroot "${CHROOT_PATH}" /bin/bash -c "KERNEL_VERSION=${KERNEL_VERSION} /tmp/setup_files/chroot_build.sh"
18 |
19 | echo >&2 "===]> Info: Cleanup the chroot environment... "
20 | # In docker there is no run?
21 | #umount "${CHROOT_PATH}/run"
22 | umount "${CHROOT_PATH}/dev"
23 |
24 |
25 | ## Copy audio config files
26 | #echo >&2 "===]> Info: Copy audio config files... "
27 | #mkdir -p "${CHROOT_PATH}"/usr/share/alsa/cards/
28 | #cp -fv "${ROOT_PATH}"/files/audio/AppleT2.conf "${CHROOT_PATH}"/usr/share/alsa/cards/AppleT2.conf
29 | #cp -fv "${ROOT_PATH}"/files/audio/apple-t2.conf "${CHROOT_PATH}"/usr/share/pulseaudio/alsa-mixer/profile-sets/apple-t2.conf
30 | #cp -fv "${ROOT_PATH}"/files/audio/91-pulseaudio-custom.rules "${CHROOT_PATH}"/usr/lib/udev/rules.d/91-pulseaudio-custom.rules
31 | #printf "\n load-module module-combine-sink channels=6 channel_map=front-left,front-right,rear-left,rear-right,front-center,lfe" >> /etc/pulse/default.pa
32 | #printf "\ndefault-sample-channels = 6\nremixing-produce-lfe = yes\nremixing-consume-lfe = yes" >> /etc/pulse/daemon.conf
33 |
34 | ### Copy grub config without finding macos partition
35 | echo >&2 "===]> Info: Patch Grub... "
36 | cp -rfv "${ROOT_PATH}"/files/grub/30_os-prober "${CHROOT_PATH}"/etc/grub.d/30_os-prober
37 | chmod 755 "${CHROOT_PATH}"/etc/grub.d/30_os-prober
38 |
--------------------------------------------------------------------------------
/02_build_image.sh:
--------------------------------------------------------------------------------
1 | #!/bin/bash
2 | set -eu -o pipefail
3 |
4 | echo >&2 "===]> Info: Create image directory and populate it... "
5 | cd "${WORKING_PATH}"
6 |
7 | if [ -d "${IMAGE_PATH}" ]; then
8 | rm -rf "${IMAGE_PATH}"
9 | fi
10 |
11 | mkdir -p "${IMAGE_PATH}"/{casper,install,isolinux}
12 | cp "${CHROOT_PATH}"/boot/vmlinuz-"${KERNEL_VERSION}" "${IMAGE_PATH}"/casper/vmlinuz
13 | cp "${CHROOT_PATH}"/boot/initrd.img-"${KERNEL_VERSION}" "${IMAGE_PATH}"/casper/initrd
14 |
15 | echo >&2 "===]> Info: Grub configuration... "
16 | # we add an empty file to use it with the search command in grub later on.
17 | touch "${IMAGE_PATH}"/ubuntu
18 | cp -r "${ROOT_PATH}"/files/preseed "${IMAGE_PATH}"/preseed
19 | cp "${ROOT_PATH}/files/grub/grub.cfg" "${IMAGE_PATH}"/isolinux/grub.cfg
20 |
21 |
22 | echo >&2 "===]> Info: Compress the chroot... "
23 | cd "${WORKING_PATH}"
24 | mksquashfs "${CHROOT_PATH}" "${IMAGE_PATH}"/casper/filesystem.squashfs
25 | printf "%s" "$(du -sx --block-size=1 "${CHROOT_PATH}" | cut -f1)" >"${IMAGE_PATH}"/casper/filesystem.size
26 |
27 | echo >&2 "===]> Info: Create manifest... "
28 | # shellcheck disable=SC2016
29 | chroot "${CHROOT_PATH}" dpkg-query -W --showformat='${Package} ${Version}\n' |
30 | tee "${IMAGE_PATH}"/casper/filesystem.manifest
31 | cp -v "${IMAGE_PATH}"/casper/filesystem.manifest "${IMAGE_PATH}"/casper/filesystem.manifest-desktop
32 |
33 | REMOVE='ubiquity casper lupin-casper user-setup discover discover-data os-prober laptop-detect'
34 | for i in $REMOVE; do
35 | sed -i "/${i}/d" "${IMAGE_PATH}"/casper/filesystem.manifest-desktop
36 | done
37 |
38 | echo >&2 "===]> Info: Create diskdefines... "
39 | cat <"${IMAGE_PATH}"/README.diskdefines
40 | #define DISKNAME Ubuntu MBP 24.04 LTS "Noble Numbat" - amd64
41 | #define TYPE binary
42 | #define TYPEbinary 1
43 | #define ARCH amd64
44 | #define ARCHamd64 1
45 | #define DISKNUM 1
46 | #define DISKNUM1 1
47 | #define TOTALNUM 0
48 | #define TOTALNUM0 1
49 | EOF
50 |
--------------------------------------------------------------------------------
/03_prepare_iso.sh:
--------------------------------------------------------------------------------
1 | #!/bin/bash
2 | set -eu -o pipefail
3 |
4 | echo >&2 "===]> Info: Create ISO Image for a LiveCD... "
5 | cd "${IMAGE_PATH}"
6 |
7 | ### Create a grub UEFI image
8 | grub-mkstandalone \
9 | --format=x86_64-efi \
10 | --output=isolinux/BOOTx64.EFI \
11 | --locales="" \
12 | --fonts="" \
13 | "boot/grub/grub.cfg=isolinux/grub.cfg"
14 |
15 | ### Create a FAT16 UEFI boot disk image containing the EFI bootloader
16 | (
17 | cd isolinux &&
18 | dd if=/dev/zero of=efiboot.img bs=1M count=10 &&
19 | mkfs.vfat efiboot.img &&
20 | LC_CTYPE=C mmd -i efiboot.img EFI EFI/BOOT &&
21 | LC_CTYPE=C mcopy -i efiboot.img ./BOOTx64.EFI ::EFI/BOOT/
22 | )
23 |
24 | ### Create a grub BIOS image
25 | grub-mkstandalone \
26 | --format=i386-pc \
27 | --output=isolinux/core.img \
28 | --install-modules="linux16 linux normal iso9660 biosdisk memdisk search tar ls" \
29 | --modules="linux16 linux normal iso9660 biosdisk search" \
30 | --locales="" \
31 | --fonts="" \
32 | "boot/grub/grub.cfg=isolinux/grub.cfg"
33 |
34 | ### Combine a bootable grub cdboot.img
35 | cat "/usr/lib/grub/i386-pc/cdboot.img" "${IMAGE_PATH}/isolinux/core.img" \
36 | >"${IMAGE_PATH}/isolinux/bios.img"
37 |
--------------------------------------------------------------------------------
/04_create_iso.sh:
--------------------------------------------------------------------------------
1 | #!/bin/bash
2 | set -eu -o pipefail
3 |
4 | cd "${IMAGE_PATH}"
5 | ### Generate md5sum.txt. Generate it two times, to get the own checksum right.
6 | (find . -type f -print0 | xargs -0 md5sum >"${IMAGE_PATH}/md5sum.txt")
7 |
8 |
9 | echo >&2 "===]> Info: Create Isolinux... "
10 | xorriso -as mkisofs \
11 | -iso-level 3 \
12 | -full-iso9660-filenames \
13 | -volid "UBUNTU_MBP" \
14 | -b boot/grub/bios.img \
15 | -no-emul-boot \
16 | -boot-load-size 4 \
17 | -boot-info-table \
18 | -c boot/grub/boot.cat \
19 | --grub2-boot-info \
20 | --grub2-mbr "/usr/lib/grub/i386-pc/boot_hybrid.img" \
21 | -eltorito-alt-boot \
22 | -e "EFI/efiboot.img" \
23 | -no-emul-boot \
24 | -isohybrid-mbr "${ROOT_PATH}/files/isohdpfx.bin" \
25 | -isohybrid-gpt-basdat -isohybrid-apm-hfsplus \
26 | -output "${ROOT_PATH}/ubuntu-24.04-${KERNEL_VERSION}.iso" \
27 | -graft-points \
28 | "." \
29 | /boot/grub/bios.img=isolinux/bios.img \
30 | /EFI/efiboot.img=isolinux/efiboot.img
31 |
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 | # T2-Ubuntu
2 |
3 | The ISOs from this repo should allow you to install Ubuntu and its flavours without using an external keyboard or mouse on a T2 Mac.
4 |
5 | 
6 |
7 | **If this repo helped you in any way, consider inviting a coffee to the people in the [credits](https://github.com/AdityaGarg8/T2-Ubuntu#credits), [link](https://wiki.t2linux.org/contribute/).**
8 |
9 | Supported flavours:
10 |
11 | - Ubuntu
12 | - Kubuntu
13 | - Ubuntu Unity
14 |
15 | We support Kubuntu thanks to [@lemmyg](https://github.com/lemmyg)!
16 |
17 | Apple T2 drivers are integrated with the ISOs.
18 |
19 | This repo is a rework of the great work done by [@mikeeq](https://github.com/mikeeq/mbp-fedora). It originally was [@marcosfad's mbp-ubuntu repo](https://github.com/marcosfad/mbp-ubuntu) and has been transferred to [t2linux](https://github.com/t2linux).
20 |
21 | Kernel is being used from -
22 |
23 | Using additional patches to support T2 Macs -
24 |
25 | Bootloader is configure correctly out of the box. No workaround needed.
26 |
27 | ## Installation
28 |
29 | 1. Reduce the size of the mac partition in MacOS
30 | 2. Download ISO file from releases.
31 | 3. Copy it to a USB using dd (or gdd if installed over brew):
32 | ```bash
33 | diskutil list # found which number has the USB
34 | diskutil umountDisk /dev/diskX
35 | sudo gdd bs=4M if=ubuntu-20.04-5.6.10-mbp.iso of=/dev/diskX conv=fdatasync status=progress
36 | ```
37 | 4. Boot in Recovery mode and allow booting unknown OS
38 | 5. Restart and immediately press the option key until the Logo come up
39 | 6. Select "EFI Boot" (the third option was the one that worked for me)
40 | 7. Launch Ubuntu Live
41 | 8. Use Ubiquity to install (just click on it)
42 | 9. Select the options that work for you and use for the partition the following setup:
43 | * Leave the efi boot as preselected by the installer, unless you require a [separate efi partition](https://wiki.t2linux.org/guides/windows/#using-seperate-efi-partitions).
44 | * Add a ext4 partition and monted as `/`.
45 | * Swap and other partitions are optional.
46 | 10. Run the installer.
47 | 11. Shutdown and remove the USB Drive.
48 | 12. Start again using the option key. Select the new efi boot.
49 | 13. Enjoy.
50 |
51 | ## Configuration
52 |
53 | - See
54 | - To install additional languages, install appropriate langpack via apt `sudo apt-get install language-pack-[cod] language-pack-gnome-[cod] language-pack-[cod]-base language-pack-gnome-[cod]-base `
55 | - see https://askubuntu.com/questions/149876/how-can-i-install-one-language-by-command-line
56 | - You can change mappings of ctrl, fn, option keys (PC keyboard mappings) by creating `/etc/modprobe.d/hid_apple.conf` file and recreating grub config. All available modifications could be found here:
57 | ```
58 | # /etc/modprobe.d/hid_apple.conf
59 | options hid_apple swap_fn_leftctrl=1
60 | options hid_apple swap_opt_cmd=1
61 | ```
62 |
63 | ## MISC
64 |
65 | ### Activate Grub Menu
66 |
67 | For the people who want to have a menu, they can modify `/etc/default/grub` with the following changes:
68 | ```
69 | GRUB_TIMEOUT_STYLE=menu
70 | GRUB_TIMEOUT=10
71 | ```
72 | and then:
73 | `sudo update-grub`
74 |
75 | ## Update to newer kernels
76 |
77 | Follow [this guide](https://github.com/t2linux/T2-Debian-and-Ubuntu-Kernel?tab=readme-ov-file#installation).
78 |
79 | ## Know issues
80 |
81 | - Checksum is failing for 2 files: md5sum.txt and /boot/grub/bios.img
82 |
83 | ## Not working (Following the mikeeq/mbp-fedora)
84 |
85 | - Dynamic audio input/output change (on connecting/disconnecting headphones jack)
86 | - TouchID
87 | - Thunderbolt (is disabled, because driver was causing kernel panics (not tested with 5.5 kernel))
88 | - Microphone (it's recognised with new apple t2 sound driver, but there is a low mic volume amp)
89 |
90 | ## Known issues
91 |
92 | - `ctrl+x` is not working in GRUB, so if you are trying to change kernel parameters - start your OS by pressing `F10` on external keyboard
93 |
94 | ## Docs
95 |
96 | - Discord: Shout out to the great community support. If you are not there yet, you must definitely join us.
97 | - Linux on a MBP Late 2016:
98 | - Repack Bootable ISO:
99 | -
100 |
101 | ### Ubuntu
102 |
103 | -
104 | -
105 | -
106 | -
107 | -
108 |
109 | ### Github
110 |
111 | - GitHub issue (RE history):
112 | - VHCI+Sound driver (Apple T2):
113 | - hid-apple keyboard backlight patch:
114 | - alsa/pulseaudio config files:
115 | - TouchBar driver:
116 | - Kernel patches (all are mentioned in github issue above):
117 | - ArchLinux kernel patches:
118 | - ArchLinux installation guide:
119 | - hid-apple-patched module for changing mappings of ctrl, fn, option keys:
120 | - Audio configuration:
121 | - Ubuntu in MBP16:
122 |
123 | ## Credits
124 |
125 | - @mikeeq - thanks for the amazing work in mbp-fedora
126 | - @marcosfad - thanks for the original work in mbp-ubuntu
127 | - @MCMrARM - thanks for all RE work
128 | - @ozbenh - thanks for submitting NVME patch
129 | - @roadrunner2 - thanks for SPI (touchbar) driver
130 | - @aunali1 - thanks for ArchLinux Kernel CI, the continuous support on discord and your continuous efforts.
131 | - @ppaulweber - thanks for keyboard and Macbook Air patches
132 | - @kevineinarsson - thanks for the audio settings
133 |
--------------------------------------------------------------------------------
/build.sh:
--------------------------------------------------------------------------------
1 | #!/bin/bash
2 | set -eu -o pipefail
3 |
4 | ROOT_PATH=$(pwd)
5 | WORKING_PATH=/root/work
6 | CHROOT_PATH="${WORKING_PATH}/chroot"
7 | IMAGE_PATH="${WORKING_PATH}/image"
8 | KERNEL_VERSION=6.14.8
9 | PKGREL=1
10 | sed -i "s/KVER/${KERNEL_VERSION}/g" $(pwd)/files/chroot_build.sh
11 | sed -i "s/PREL/${PKGREL}/g" $(pwd)/files/chroot_build.sh
12 |
13 | if [ -d "$WORKING_PATH" ]; then
14 | rm -rf "$WORKING_PATH"
15 | fi
16 | mkdir -p "$WORKING_PATH"
17 | if [ -d "${ROOT_PATH}/output" ]; then
18 | rm -rf "${ROOT_PATH}/output"
19 | fi
20 | mkdir -p "${ROOT_PATH}/output"
21 |
22 | echo >&2 "===]> Info: Build dependencies... "
23 | export DEBIAN_FRONTEND=noninteractive
24 | apt-get update
25 | apt-get install -y -qq -o Dpkg::Options::="--force-confdef" -o Dpkg::Options::="--force-confold" \
26 | binutils \
27 | debootstrap \
28 | squashfs-tools \
29 | xorriso \
30 | grub-pc-bin \
31 | grub-efi-amd64-bin \
32 | mtools \
33 | dosfstools \
34 | zip \
35 | isolinux \
36 | syslinux
37 |
38 | echo >&2 "===]> Info: Start loop... "
39 | for ALTERNATIVE in t2-noble
40 | do
41 | echo >&2 "===]> Info: Start building ${ALTERNATIVE}... "
42 |
43 | echo >&2 "===]> Info: Build Ubuntu Noble... "
44 | /bin/bash -c "
45 | ROOT_PATH=${ROOT_PATH} \\
46 | WORKING_PATH=${WORKING_PATH} \\
47 | CHROOT_PATH=${CHROOT_PATH}_${ALTERNATIVE} \\
48 | IMAGE_PATH=${IMAGE_PATH} \\
49 | KERNEL_VERSION=${KERNEL_VERSION}-${PKGREL}-${ALTERNATIVE} \\
50 | ALTERNATIVE=${ALTERNATIVE} \\
51 | ${ROOT_PATH}/01_build_file_system.sh
52 | "
53 |
54 | echo >&2 "===]> Info: Build Image Noble... "
55 | /bin/bash -c "
56 | ROOT_PATH=${ROOT_PATH} \\
57 | WORKING_PATH=${WORKING_PATH} \\
58 | CHROOT_PATH=${CHROOT_PATH}_${ALTERNATIVE} \\
59 | IMAGE_PATH=${IMAGE_PATH} \\
60 | KERNEL_VERSION=${KERNEL_VERSION}-${PKGREL}-${ALTERNATIVE} \\
61 | ALTERNATIVE=${ALTERNATIVE} \\
62 | ${ROOT_PATH}/02_build_image.sh
63 | "
64 |
65 | echo >&2 "===]> Info: Prepare Boot for ISO... "
66 | /bin/bash -c "
67 | IMAGE_PATH=${IMAGE_PATH} \\
68 | CHROOT_PATH=${CHROOT_PATH}_${ALTERNATIVE} \\
69 | ${ROOT_PATH}/03_prepare_iso.sh
70 | "
71 |
72 | echo >&2 "===]> Info: Create ISO... "
73 | /bin/bash -c "
74 | ROOT_PATH=${ROOT_PATH} \\
75 | IMAGE_PATH=${IMAGE_PATH} \\
76 | CHROOT_PATH=${CHROOT_PATH}_${ALTERNATIVE} \\
77 | KERNEL_VERSION=${KERNEL_VERSION}-${ALTERNATIVE} \\
78 | ALTERNATIVE=${ALTERNATIVE} \\
79 | ${ROOT_PATH}/04_create_iso.sh
80 | "
81 | livecd_exitcode=$?
82 | if [ "${livecd_exitcode}" -ne 0 ]; then
83 | echo "Error building ${KERNEL_VERSION}-${ALTERNATIVE}"
84 | exit "${livecd_exitcode}"
85 | fi
86 | ## Split iso into multiple parts - github max size of release attachment is 2GB, where ISO is sometimes bigger than that
87 | cd "${ROOT_PATH}"
88 | split -b 900M -x "${ROOT_PATH}/ubuntu-24.04-${KERNEL_VERSION}-${ALTERNATIVE}.iso" "${ROOT_PATH}/output/ubuntu-24.04-${KERNEL_VERSION}-${ALTERNATIVE}.iso."
89 | done
90 | ## Calculate sha256 sums of built ISO
91 | sha256sum "${ROOT_PATH}"/*.iso >"${ROOT_PATH}/output/sha256-ubuntu-24.04"
92 |
93 | find ./ | grep ".iso"
94 | #find ./ | grep ".zip"
95 |
96 | exit "${livecd_exitcode}"
97 |
--------------------------------------------------------------------------------
/build_in_docker.sh:
--------------------------------------------------------------------------------
1 | #!/bin/bash
2 |
3 | set -eu -o pipefail
4 |
5 | DOCKER_IMAGE=ubuntu:24.04
6 |
7 | docker pull ${DOCKER_IMAGE}
8 | docker run \
9 | --privileged \
10 | --rm \
11 | -t \
12 | -v "$(pwd)":/repo \
13 | ${DOCKER_IMAGE} \
14 | /bin/bash -c 'cd /repo && ./build.sh'
15 |
--------------------------------------------------------------------------------
/files/audio/91-pulseaudio-custom.rules:
--------------------------------------------------------------------------------
1 | SUBSYSTEM!="sound", GOTO="pulseaudio_end"
2 | ACTION!="change", GOTO="pulseaudio_end"
3 | KERNEL!="card*", GOTO="pulseaudio_end"
4 |
5 | SUBSYSTEMS=="pci", ATTRS{vendor}=="0x106b", ATTRS{device}=="0x1803", ENV{PULSE_PROFILE_SET}="apple-t2.conf"
6 |
7 | LABEL="pulseaudio_end"
8 |
--------------------------------------------------------------------------------
/files/audio/AppleT2.conf:
--------------------------------------------------------------------------------
1 |
2 |
3 | AppleT2.pcm.default {
4 | @args [ CARD ]
5 | @args.CARD {
6 | type string
7 | }
8 | type asym
9 | playback.pcm {
10 | type plug
11 | ttable {
12 | 0.0= 1
13 | 1.3= 1
14 | 2.1= 1
15 | 3.4= 1
16 | 4.0= 1
17 | 5.5= 1
18 | }
19 | slave {
20 | pcm {
21 | type hw
22 | card $CARD
23 | device 0
24 | }
25 | channels 6
26 | }
27 | }
28 | capture.pcm {
29 | type plug
30 | slave.pcm {
31 | type hw
32 | card $CARD
33 | device 1
34 | }
35 | }
36 | hint.device_output 0
37 | hint.device_input 1
38 | }
39 |
40 | AppleT2.pcm.front.0 {
41 | @args [ CARD ]
42 | @args.CARD {
43 | type string
44 | }
45 | type asym
46 | playback.pcm {
47 | type plug
48 | ttable {
49 | 0.0= 1
50 | 1.3= 1
51 | 2.1= 1
52 | 3.4= 1
53 | 4.0= 1
54 | 5.5= 1
55 | }
56 | slave {
57 | pcm {
58 | type hw
59 | card $CARD
60 | device 0
61 | }
62 | channels 6
63 | }
64 | }
65 | capture.pcm {
66 | type plug
67 | slave.pcm {
68 | type hw
69 | card $CARD
70 | device 1
71 | }
72 | }
73 | hint.device_output 0
74 | hint.device_input 1
75 | }
76 | AppleT2.pcm.front.1 {
77 | @args [ CARD ]
78 | @args.CARD {
79 | type string
80 | }
81 | type asym
82 | playback.pcm {
83 | type hw
84 | card $CARD
85 | device 2
86 | }
87 | capture.pcm {
88 | type hw
89 | card $CARD
90 | device 3
91 | }
92 | hint.device_output 2
93 | hint.device_input 3
94 | }
95 | AppleT2.pcm.front.2 {
96 | @args [ CARD ]
97 | @args.CARD {
98 | type string
99 | }
100 | type hw
101 | card $CARD
102 | device 4
103 | }
104 |
--------------------------------------------------------------------------------
/files/audio/apple-t2.conf:
--------------------------------------------------------------------------------
1 | [General]
2 | auto-profiles = no
3 |
4 | [Mapping builtin-speaker]
5 | description = Built-in Speaker
6 | device-strings = front:%f
7 | paths-output = builtin-speaker-output
8 | channel-map = front-left,front-right,rear-left,rear-right,front-center,lfe
9 | priority = 100
10 | direction = output
11 |
12 | [Mapping builtin-mic]
13 | description = Built-in Mic
14 | device-strings = front:%f
15 | paths-output = builtin-mic-input
16 | channel-map = left,center,right
17 | priority = 100
18 | direction = input
19 |
20 | [Mapping codec-output]
21 | description = Headphone
22 | device-strings = front:%f,1
23 | paths-output = codec-output
24 | channel-map = left,right
25 | priority = 100
26 | direction = output
27 |
28 | [Mapping codec-input]
29 | description = Headphone Mic
30 | device-strings = front:%f,1
31 | paths-output = codec-input
32 | channel-map = mono
33 | priority = 100
34 | direction = input
35 |
36 | [Profile output:builtin-speaker+input:builtin-mic]
37 | description = Built-in Speaker + Built-in Mic
38 | output-mappings = builtin-speaker
39 | input-mappings = builtin-mic
40 | skip-probe = yes
41 |
42 | [Profile output:codec-output+input:builtin-mic]
43 | description = Headphones + Built-in Mic
44 | output-mappings = codec-output
45 | input-mappings = builtin-mic
46 |
47 | [Profile output:codec-output+input:codec-input]
48 | description = Headphones + External Mic
49 | output-mappings = codec-output
50 | input-mappings = codec-input
51 |
52 | [Profile output:builtin-speaker+input:codec-input]
53 | description = Built-in Speaker + External Mic
54 | output-mappings = builtin-speaker
55 | input-mappings = codec-input
56 |
--------------------------------------------------------------------------------
/files/chroot_build.sh:
--------------------------------------------------------------------------------
1 | #!/bin/bash
2 |
3 | set -eu -o pipefail
4 |
5 | CODENAME=noble
6 |
7 | echo >&2 "===]> Info: Configure environment... "
8 |
9 | mount none -t proc /proc
10 | mount none -t sysfs /sys
11 | mount none -t devpts /dev/pts
12 |
13 | export HOME=/root
14 | export LC_ALL=C
15 |
16 | echo "ubuntu-${CODENAME}-live" >/etc/hostname
17 |
18 | echo >&2 "===]> Info: Configure and update apt... "
19 |
20 | cat </etc/apt/sources.list
21 | deb http://archive.ubuntu.com/ubuntu/ ${CODENAME} main restricted universe multiverse
22 | deb-src http://archive.ubuntu.com/ubuntu/ ${CODENAME} main restricted universe multiverse
23 | deb http://archive.ubuntu.com/ubuntu/ ${CODENAME}-security main restricted universe multiverse
24 | deb-src http://archive.ubuntu.com/ubuntu/ ${CODENAME}-security main restricted universe multiverse
25 | deb http://archive.ubuntu.com/ubuntu/ ${CODENAME}-updates main restricted universe multiverse
26 | deb-src http://archive.ubuntu.com/ubuntu/ ${CODENAME}-updates main restricted universe multiverse
27 | EOF
28 | apt-get update
29 |
30 | echo >&2 "===]> Info: Install systemd and Ubuntu MBP Repo... "
31 |
32 | apt-get install -y systemd-sysv gnupg curl wget
33 |
34 | mkdir -p /etc/apt/sources.list.d
35 | curl -s --compressed "https://adityagarg8.github.io/t2-ubuntu-repo/KEY.gpg" | gpg --dearmor | tee /etc/apt/trusted.gpg.d/t2-ubuntu-repo.gpg >/dev/null
36 | curl -s --compressed -o /etc/apt/sources.list.d/t2.list "https://adityagarg8.github.io/t2-ubuntu-repo/t2.list"
37 | echo "deb [signed-by=/etc/apt/trusted.gpg.d/t2-ubuntu-repo.gpg] https://github.com/AdityaGarg8/t2-ubuntu-repo/releases/download/${CODENAME} ./" | tee -a /etc/apt/sources.list.d/t2.list
38 | apt-get update
39 |
40 | echo >&2 "===]> Info: Configure machine-id and divert... "
41 |
42 | dbus-uuidgen >/etc/machine-id
43 | ln -fs /etc/machine-id /var/lib/dbus/machine-id
44 | dpkg-divert --local --rename --add /sbin/initctl
45 | ln -s /bin/true /sbin/initctl
46 |
47 | echo >&2 "===]> Info: Install packages needed for Live System... "
48 |
49 | export DEBIAN_FRONTEND=noninteractive
50 | apt-get install -y -qq -o Dpkg::Options::="--force-confdef" -o Dpkg::Options::="--force-confold" \
51 | ubuntu-standard \
52 | sudo \
53 | casper \
54 | discover \
55 | laptop-detect \
56 | os-prober \
57 | network-manager \
58 | resolvconf \
59 | net-tools \
60 | wireless-tools \
61 | locales \
62 | initramfs-tools \
63 | binutils \
64 | linux-generic \
65 | linux-headers-generic \
66 | grub-efi-amd64-signed \
67 | intel-microcode \
68 | thermald \
69 | grub2 \
70 | nautilus-admin
71 |
72 | #curl -L https://github.com/t2linux/T2-Ubuntu-Kernel/releases/download/vKVER-PREL/linux-headers-KVER-${ALTERNATIVE}_KVER-PREL_amd64.deb > /tmp/headers.deb
73 | #curl -L https://github.com/t2linux/T2-Ubuntu-Kernel/releases/download/vKVER-PREL/linux-image-KVER-${ALTERNATIVE}_KVER-PREL_amd64.deb > /tmp/image.deb
74 | #file /tmp/*
75 | #apt install /tmp/headers.deb /tmp/image.deb
76 |
77 | echo >&2 "===]> Info: Install the T2 kernel... "
78 |
79 | apt-get install -y -qq -o Dpkg::Options::="--force-confdef" -o Dpkg::Options::="--force-confold" \
80 | linux-t2=KVER-PREL-${CODENAME}
81 |
82 | echo >&2 "===]> Info: Install window manager... "
83 |
84 | apt-get install -y -qq -o Dpkg::Options::="--force-confdef" -o Dpkg::Options::="--force-confold" \
85 | plymouth-theme-spinner \
86 | plymouth-theme-ubuntu-text \
87 | ubuntu-desktop-minimal \
88 | ubuntu-gnome-wallpapers \
89 | snapd
90 |
91 | echo >&2 "===]> Info: Install Graphical installer... "
92 |
93 | apt-get install -y -qq -o Dpkg::Options::="--force-confdef" -o Dpkg::Options::="--force-confold" \
94 | ubiquity \
95 | ubiquity-casper \
96 | ubiquity-frontend-gtk \
97 | ubiquity-slideshow-ubuntu \
98 | ubiquity-ubuntu-artwork
99 |
100 | echo >&2 "===]> Info: Install useful applications and sound configuration... "
101 |
102 | apt-get install -y -qq -o Dpkg::Options::="--force-confdef" -o Dpkg::Options::="--force-confold" \
103 | git \
104 | curl \
105 | nano \
106 | make \
107 | gcc \
108 | dkms \
109 | gdisk \
110 | apple-t2-audio-config \
111 | apple-firmware-script
112 |
113 | echo >&2 "===]> Info: Change initramfs format (for grub)... "
114 | sed -i "s/COMPRESS=lz4/COMPRESS=gzip/g" "/etc/initramfs-tools/initramfs.conf"
115 |
116 | echo >&2 "===]> Info: Configure drivers... "
117 |
118 | # thunderbolt is working for me.
119 | #printf '\nblacklist thunderbolt' >>/etc/modprobe.d/blacklist.conf
120 |
121 | printf 'apple-bce' >>/etc/modules-load.d/t2.conf
122 | #printf '\n### apple-bce start ###\nsnd\nsnd_pcm\napple-bce\n### apple-bce end ###' >>/etc/initramfs-tools/modules
123 | #printf '\n# display f* key in touchbar\noptions apple-ib-tb fnmode=1\n' >> /etc/modprobe.d/apple-tb.conf
124 | #printf '\n# delay loading of the touchbar driver\ninstall apple-ib-tb /bin/sleep 7; /sbin/modprobe --ignore-install apple-ib-tb' >> /etc/modprobe.d/delay-tb.conf
125 |
126 | echo >&2 "===]> Info: Update initramfs... "
127 |
128 | ## Add custom drivers to be loaded at boot
129 | /usr/sbin/depmod -a "${KERNEL_VERSION}"
130 | update-initramfs -u -v -k "${KERNEL_VERSION}"
131 |
132 | echo >&2 "===]> Info: Remove unused applications ... "
133 |
134 | apt-get purge -y -qq \
135 | transmission-gtk \
136 | transmission-common \
137 | gnome-mahjongg \
138 | gnome-mines \
139 | gnome-sudoku \
140 | aisleriot \
141 | hitori \
142 | xiterm+thai \
143 | vim \
144 | linux-generic \
145 | linux-headers-6.8.0-31 \
146 | linux-headers-6.8.0-31-generic \
147 | linux-headers-generic \
148 | linux-image-6.8.0-31-generic \
149 | linux-image-generic \
150 | linux-modules-6.8.0-31-generic \
151 | linux-modules-extra-6.8.0-31-generic \
152 |
153 | apt-get autoremove -y
154 |
155 | echo >&2 "===]> Info: Reconfigure environment ... "
156 |
157 | locale-gen --purge en_US.UTF-8 en_US
158 | printf 'LANG="C.UTF-8"\nLANGUAGE="C.UTF-8"\n' >/etc/default/locale
159 |
160 | cat </etc/NetworkManager/NetworkManager.conf
161 | [main]
162 | plugins=ifupdown,keyfile
163 |
164 | [ifupdown]
165 | managed=false
166 |
167 | [device]
168 | wifi.scan-rand-mac-address=no
169 | EOF
170 | dpkg-reconfigure network-manager
171 |
172 | echo >&2 "===]> Info: Add udev Rule to stop annoying WiFi popup... "
173 | mkdir -p /etc/NetworkManager/conf.d
174 | cat <&2 "===]> Info: Add udev Rule for AMD GPU Power Management... "
184 | cat < /etc/udev/rules.d/30-amdgpu-pm.rules
185 | KERNEL=="card[012]", SUBSYSTEM=="drm", DRIVERS=="amdgpu", ATTR{device/power_dpm_force_performance_level}="low"
186 | EOF
187 |
188 | echo >&2 "===]> Info: Cleanup the chroot environment... "
189 |
190 | truncate -s 0 /etc/machine-id
191 | rm /sbin/initctl
192 | dpkg-divert --rename --remove /sbin/initctl
193 | apt-get clean
194 | rm -rf /tmp/* ~/.bash_history
195 | rm -rf /tmp/setup_files
196 |
197 | umount -lf /dev/pts
198 | umount -lf /sys
199 | umount -lf /proc
200 |
201 | export HISTSIZE=0
202 |
--------------------------------------------------------------------------------
/files/grub/30_os-prober:
--------------------------------------------------------------------------------
1 | #!/usr/bin/sh
2 | set -e
3 |
4 | # grub-mkconfig helper script.
5 | # Copyright (C) 2006,2007,2008,2009 Free Software Foundation, Inc.
6 | #
7 | # GRUB is free software: you can redistribute it and/or modify
8 | # it under the terms of the GNU General Public License as published by
9 | # the Free Software Foundation, either version 3 of the License, or
10 | # (at your option) any later version.
11 | #
12 | # GRUB is distributed in the hope that it will be useful,
13 | # but WITHOUT ANY WARRANTY; without even the implied warranty of
14 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 | # GNU General Public License for more details.
16 | #
17 | # You should have received a copy of the GNU General Public License
18 | # along with GRUB. If not, see .
19 |
20 | prefix="/usr"
21 | exec_prefix="/usr"
22 | datarootdir="/usr/share"
23 |
24 | export TEXTDOMAIN=grub
25 | export TEXTDOMAINDIR="${datarootdir}/locale"
26 |
27 | . "$pkgdatadir/grub-mkconfig_lib"
28 |
29 | if [ "x${GRUB_DISABLE_OS_PROBER}" = "xtrue" ]; then
30 | exit 0
31 | fi
32 |
33 | if [ -z "`which os-prober 2> /dev/null`" ] || [ -z "`which linux-boot-prober 2> /dev/null`" ] ; then
34 | # missing os-prober and/or linux-boot-prober
35 | exit 0
36 | fi
37 |
38 | OSPROBED="`os-prober | tr ' ' '^' | paste -s -d ' '`"
39 | if [ -z "${OSPROBED}" ] ; then
40 | # empty os-prober output, nothing doing
41 | exit 0
42 | fi
43 |
44 | osx_entry() {
45 | found_other_os=1
46 | # TRANSLATORS: it refers on the OS residing on device %s
47 | onstr="$(gettext_printf "(on %s)" "${DEVICE}")"
48 | hints=""
49 | for hint in `"${grub_probe}" --device ${device} --target=efi_hints 2> /dev/null` ; do
50 | hints="${hints} --hint=${hint}"
51 | done
52 | cat << EOF
53 | menuentry '$(echo "${LONGNAME} $onstr" | grub_quote)' --class osx --class darwin --class os \$menuentry_id_option 'osprober-xnu-$2-$(grub_get_device_id "${DEVICE}")' {
54 | EOF
55 | save_default_entry | grub_add_tab
56 | prepare_grub_to_access_device ${DEVICE} | grub_add_tab
57 | cat << EOF
58 | set gfxpayload=keep
59 | load_video
60 | insmod part_gpt
61 | insmod hfsplus
62 | search --no-floppy --fs-uuid --set=root ${hints} $(grub_get_device_id "${DEVICE}")
63 | chainloader (\$root)/System/Library/CoreServices/boot.efi
64 | boot
65 | }
66 | EOF
67 | }
68 |
69 | used_osprober_linux_ids=
70 |
71 | for OS in ${OSPROBED} ; do
72 | DEVICE="`echo ${OS} | cut -d ':' -f 1`"
73 | LONGNAME="`echo ${OS} | cut -d ':' -f 2 | tr '^' ' '`"
74 | LABEL="`echo ${OS} | cut -d ':' -f 3 | tr '^' ' '`"
75 | BOOT="`echo ${OS} | cut -d ':' -f 4`"
76 | if UUID="`${grub_probe} --target=fs_uuid --device ${DEVICE%@*}`"; then
77 | EXPUUID="$UUID"
78 |
79 | if [ x"${DEVICE#*@}" != x ] ; then
80 | EXPUUID="${EXPUUID}@${DEVICE#*@}"
81 | fi
82 |
83 | if [ "x${GRUB_OS_PROBER_SKIP_LIST}" != "x" ] && [ "x`echo ${GRUB_OS_PROBER_SKIP_LIST} | grep -i -e '\b'${EXPUUID}'\b'`" != "x" ] ; then
84 | echo "Skipped ${LONGNAME} on ${DEVICE} by user request." >&2
85 | continue
86 | fi
87 | fi
88 |
89 | BTRFS="`echo ${OS} | cut -d ':' -f 5`"
90 | if [ "x$BTRFS" = "xbtrfs" ]; then
91 | BTRFSuuid="`echo ${OS} | cut -d ':' -f 6`"
92 | BTRFSsubvol="`echo ${OS} | cut -d ':' -f 7`"
93 | fi
94 |
95 | if [ -z "${LONGNAME}" ] ; then
96 | LONGNAME="${LABEL}"
97 | fi
98 |
99 | # os-prober returns text string followed by optional counter
100 | CLASS="--class $(echo "${LABEL}" | LC_ALL=C sed 's,[[:digit:]]*$,,' | cut -d' ' -f1 | tr 'A-Z' 'a-z' | LC_ALL=C sed 's,[^[:alnum:]_],_,g')"
101 |
102 | gettext_printf "Found %s on %s\n" "${LONGNAME}" "${DEVICE}" >&2
103 |
104 | case ${BOOT} in
105 | chain)
106 | found_other_os=1
107 |
108 | onstr="$(gettext_printf "(on %s)" "${DEVICE}")"
109 | cat << EOF
110 | menuentry '$(echo "${LONGNAME} $onstr" | grub_quote)' $CLASS --class os \$menuentry_id_option 'osprober-chain-$(grub_get_device_id "${DEVICE}")' {
111 | EOF
112 | save_default_entry | grub_add_tab
113 | prepare_grub_to_access_device ${DEVICE} | grub_add_tab
114 |
115 | if [ x"`${grub_probe} --device ${DEVICE} --target=partmap`" = xmsdos ]; then
116 | cat << EOF
117 | parttool \${root} hidden-
118 | EOF
119 | fi
120 |
121 | case ${LONGNAME} in
122 | Windows\ Vista*|Windows\ 7*|Windows\ Server\ 2008*)
123 | ;;
124 | *)
125 | cat << EOF
126 | drivemap -s (hd0) \${root}
127 | EOF
128 | ;;
129 | esac
130 |
131 | cat < /dev/null; do
187 | counter=$((counter+1));
188 | done
189 | if [ -z "$boot_device_id" ]; then
190 | boot_device_id="$(grub_get_device_id "${DEVICE}")"
191 | fi
192 | used_osprober_linux_ids="$used_osprober_linux_ids 'osprober-gnulinux-$LKERNEL-${recovery_params}-$counter-$boot_device_id'"
193 |
194 | if [ -z "${prepare_boot_cache}" ]; then
195 | prepare_boot_cache="$(prepare_grub_to_access_device ${LBOOT} | grub_add_tab)"
196 | fi
197 |
198 | if [ "x$is_top_level" = xtrue ] && [ "x${GRUB_DISABLE_SUBMENU}" != xy ]; then
199 | cat << EOF
200 | menuentry '$(echo "$OS $onstr" | grub_quote)' $CLASS --class gnu-linux --class gnu --class os \$menuentry_id_option 'osprober-gnulinux-simple-$boot_device_id' {
201 | EOF
202 | save_default_entry | grub_add_tab
203 | printf '%s\n' "${prepare_boot_cache}"
204 | cat << EOF
205 | linux ${LKERNEL} ${LPARAMS}
206 | EOF
207 | if [ -n "${LINITRD}" ] ; then
208 | cat << EOF
209 | initrd ${LINITRD}
210 | EOF
211 | fi
212 | cat << EOF
213 | }
214 | EOF
215 | echo "submenu '$(gettext_printf "Advanced options for %s" "${OS} $onstr" | grub_quote)' \$menuentry_id_option 'osprober-gnulinux-advanced-$boot_device_id' {"
216 | is_top_level=false
217 | fi
218 | title="${LLABEL} $onstr"
219 | cat << EOF
220 | menuentry '$(echo "$title" | grub_quote)' --class gnu-linux --class gnu --class os \$menuentry_id_option 'osprober-gnulinux-$LKERNEL-${recovery_params}-$boot_device_id' {
221 | EOF
222 | save_default_entry | sed -e "s/^/$grub_tab$grub_tab/"
223 | printf '%s\n' "${prepare_boot_cache}" | grub_add_tab
224 | cat << EOF
225 | linux ${LKERNEL} ${LPARAMS}
226 | EOF
227 | if [ -n "${LINITRD}" ] ; then
228 | cat << EOF
229 | initrd ${LINITRD}
230 | EOF
231 | fi
232 | cat << EOF
233 | }
234 | EOF
235 | if [ x"$title" = x"$GRUB_ACTUAL_DEFAULT" ] || [ x"Previous Linux versions>$title" = x"$GRUB_ACTUAL_DEFAULT" ]; then
236 | replacement_title="$(echo "Advanced options for ${OS} $onstr" | sed 's,>,>>,g')>$(echo "$title" | sed 's,>,>>,g')"
237 | quoted="$(echo "$GRUB_ACTUAL_DEFAULT" | grub_quote)"
238 | title_correction_code="${title_correction_code}if [ \"x\$default\" = '$quoted' ]; then default='$(echo "$replacement_title" | grub_quote)'; fi;"
239 | grub_warn "$(gettext_printf "Please don't use old title \`%s' for GRUB_DEFAULT, use \`%s' (for versions before 2.00) or \`%s' (for 2.00 or later)" "$GRUB_ACTUAL_DEFAULT" "$replacement_title" "gnulinux-advanced-$boot_device_id>gnulinux-$version-$type-$boot_device_id")"
240 | fi
241 | done
242 | if [ x"$is_top_level" != xtrue ]; then
243 | echo '}'
244 | fi
245 | echo "$title_correction_code"
246 | ;;
247 | macosx)
248 | # for subdevice in ${DEVICE%[[:digit:]]*}* ; do
249 | # parttype="`"${grub_probe}" --device ${device} --target=gpt_parttype "${subdevice}" 2> /dev/null`"
250 | # if [[ "$parttype" = "426f6f74-0000-11aa-aa11-00306543ecac" ]]; then
251 | # DEVICE="${subdevice}" osx_entry
252 | # fi
253 | # done
254 | ;;
255 | hurd)
256 | found_other_os=1
257 | onstr="$(gettext_printf "(on %s)" "${DEVICE}")"
258 | cat << EOF
259 | menuentry '$(echo "${LONGNAME} $onstr" | grub_quote)' --class hurd --class gnu --class os \$menuentry_id_option 'osprober-gnuhurd-/boot/gnumach.gz-false-$(grub_get_device_id "${DEVICE}")' {
260 | EOF
261 | save_default_entry | grub_add_tab
262 | prepare_grub_to_access_device ${DEVICE} | grub_add_tab
263 | grub_device="`${grub_probe} --device ${DEVICE} --target=drive`"
264 | mach_device="`echo "${grub_device}" | sed -e 's/(\(hd.*\),msdos\(.*\))/\1s\2/'`"
265 | grub_fs="`${grub_probe} --device ${DEVICE} --target=fs`"
266 | case "${grub_fs}" in
267 | *fs) hurd_fs="${grub_fs}" ;;
268 | *) hurd_fs="${grub_fs}fs" ;;
269 | esac
270 | cat << EOF
271 | multiboot /boot/gnumach.gz root=device:${mach_device}
272 | module /hurd/${hurd_fs}.static ${hurd_fs} --readonly \\
273 | --multiboot-command-line='\${kernel-command-line}' \\
274 | --host-priv-port='\${host-port}' \\
275 | --device-master-port='\${device-port}' \\
276 | --exec-server-task='\${exec-task}' -T typed '\${root}' \\
277 | '\$(task-create)' '\$(task-resume)'
278 | module /lib/ld.so.1 exec /hurd/exec '\$(exec-task=task-create)'
279 | }
280 | EOF
281 | ;;
282 | minix)
283 | found_other_os=1
284 | cat << EOF
285 | menuentry "${LONGNAME} (on ${DEVICE}, Multiboot)" {
286 | EOF
287 | save_default_entry | sed -e "s/^/\t/"
288 | prepare_grub_to_access_device ${DEVICE} | sed -e "s/^/\t/"
289 | cat << EOF
290 | multiboot /boot/image_latest
291 | }
292 | EOF
293 | ;;
294 | *)
295 | case ${DEVICE} in
296 | *.efi)
297 | cat << EOF
298 | menuentry '$(echo "${LONGNAME}" | grub_quote)' {
299 | EOF
300 | save_default_entry | grub_add_tab
301 | cat << EOF
302 | chainloader /EFI/${DEVICE}
303 | boot
304 | }
305 | EOF
306 | ;;
307 | *)
308 | echo -n " "
309 | # TRANSLATORS: %s is replaced by OS name.
310 | gettext_printf "%s is not yet supported by grub-mkconfig.\n" "${LONGNAME}" >&2
311 | ;;
312 | esac
313 | esac
314 | done
315 |
316 | # We override the results of the menu_auto_hide code here, this is a bit ugly,
317 | # but grub-mkconfig writes out the file linearly, so this is the only way
318 | if [ "${found_other_os}" = "1" ]; then
319 | cat << EOF
320 | # Other OS found, undo autohiding of menu unless menu_auto_hide=2
321 | if [ "\${orig_timeout_style}" -a "\${menu_auto_hide}" != "2" ]; then
322 | set timeout_style=\${orig_timeout_style}
323 | set timeout=\${orig_timeout}
324 | fi
325 | EOF
326 | fi
327 |
--------------------------------------------------------------------------------
/files/grub/grub.cfg:
--------------------------------------------------------------------------------
1 |
2 | search --set=root --file /ubuntu
3 |
4 | insmod all_video
5 |
6 | set default="0"
7 | set timeout=30
8 |
9 | menuentry "Try or Install Ubuntu" {
10 | linux /casper/vmlinuz file=/cdrom/preseed/mbp.seed boot=casper ro quiet splash pcie_ports=native intel_iommu=on iommu=pt ---
11 | initrd /casper/initrd
12 | }
13 | menuentry "Ubuntu (Safe Graphics)" {
14 | linux /casper/vmlinuz file=/cdrom/preseed/mbp164.seed boot=casper ro quiet splash nomodeset pcie_ports=native intel_iommu=on iommu=pt ---
15 | initrd /casper/initrd
16 | }
17 | menuentry "Ubuntu (NVMe blacklisted)" {
18 | linux /casper/vmlinuz file=/cdrom/preseed/mbp.seed boot=casper ro quiet splash pcie_ports=native intel_iommu=on iommu=pt modprobe.blacklist=nvme ---
19 | initrd /casper/initrd
20 | }
21 | menuentry "Check disc for defects" {
22 | linux /casper/vmlinuz boot=casper integrity-check enforcing=0 efi=noruntime pcie_ports=native ---
23 | initrd /casper/initrd
24 | }
25 |
--------------------------------------------------------------------------------
/files/isohdpfx.bin:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/t2linux/T2-Ubuntu/684ab0da963acbf58b3bd1af07eebf6a70d2eb7f/files/isohdpfx.bin
--------------------------------------------------------------------------------
/files/preseed/mbp.seed:
--------------------------------------------------------------------------------
1 | # Enable extras.ubuntu.com.
2 | # d-i apt-setup/extra boolean true
3 | # Install the Ubuntu desktop.
4 | # tasksel tasksel/first multiselect ubuntu-desktop
5 | # On live DVDs, don't spend huge amounts of time removing substantial
6 | # application packages pulled in by language packs. Given that we clearly
7 | # have the space to include them on the DVD, they're useful and we might as
8 | # well keep them installed.
9 | #ubiquity ubiquity/keep-installed string icedtea6-plugin openoffice.org
10 |
11 | d-i debian-installer/add-kernel-opts string pcie_ports=native intel_iommu=on iommu=pt
12 |
--------------------------------------------------------------------------------
/files/preseed/mbp164.seed:
--------------------------------------------------------------------------------
1 | # Enable extras.ubuntu.com.
2 | # d-i apt-setup/extra boolean true
3 | # Install the Ubuntu desktop.
4 | # tasksel tasksel/first multiselect ubuntu-desktop
5 | # On live DVDs, don't spend huge amounts of time removing substantial
6 | # application packages pulled in by language packs. Given that we clearly
7 | # have the space to include them on the DVD, they're useful and we might as
8 | # well keep them installed.
9 | #ubiquity ubiquity/keep-installed string icedtea6-plugin openoffice.org
10 |
11 | d-i debian-installer/add-kernel-opts string pcie_ports=native intel_iommu=on iommu=pt nomodeset
12 |
--------------------------------------------------------------------------------