Skip to content

Commit

Permalink
Merge pull request #50 from marcosfad/feature/multipleKernels
Browse files Browse the repository at this point in the history
Multiple Kernel LiveCD
  • Loading branch information
marcosfad authored Dec 15, 2021
2 parents 296bfd7 + 9a0609f commit e249af2
Show file tree
Hide file tree
Showing 13 changed files with 231 additions and 183 deletions.
11 changes: 11 additions & 0 deletions .github/FUNDING.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
---
github: ['marcosfad']
patreon:
open_collective:
ko_fi:
tidelift:
community_bridge:
liberapay:
issuehunt:
otechie:
custom: ['https://www.paypal.com/paypalme/marcosfad']
22 changes: 11 additions & 11 deletions .github/workflows/CI.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,23 +10,22 @@ jobs:
steps:
- uses: actions/checkout@v2

- name: Configure variables
id: variables
run: |
BUILD=$(date '+%Y%m%d%H%M%S')
echo "::set-output name=build::${BUILD}"
- name: Build
run: sudo ./build.sh

- name: print sha256sum
run: cat output/sha256

- name: Generate Tag
id: tag
run: |
VER=$(egrep ^KERNEL_VERSION build.sh|cut -d= -f2)
echo Version is $VER
echo "::set-output name=tag::${VER}"
- name: Upload iso artifact
uses: actions/upload-artifact@v2
with:
name: mbp-ubuntu-${{ steps.tag.outputs.tag }}.z01
name: mbp-ubuntu-${{ steps.variables.outputs.build }}
path: ${{ github.workspace }}/output/*

- name: Instructions for putting it back together
Expand All @@ -35,15 +34,16 @@ jobs:
Download all the artifacts, and put them in a folder
without other files. Then run:"
unzip "*.z??.zip"
cat livecd-${{ steps.tag.outputs.tag }}-mbp.z?? > cd.zip
cat livecd-${{ steps.variables.outputs.build }}-mbp.z?? > cd.zip
echo unzip cd.zip
EOF
- name: Release
if: github.ref == 'refs/heads/master'
uses: softprops/action-gh-release@v1
with:
data: ${{ github.workspace }}/output/*
tag_name: v20.04-${{ steps.tag.outputs.tag }}
files: ${{ github.workspace }}/output/*
tag_name: v20.04-${{ steps.variables.outputs.build }}
draft: true
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
output
/.idea
/files/kernels
49 changes: 0 additions & 49 deletions .travis.yml

This file was deleted.

2 changes: 1 addition & 1 deletion 01_build_file_system.sh
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ mount --bind /dev "${CHROOT_PATH}/dev"
mount --bind /run "${CHROOT_PATH}/run"

cp -r "${ROOT_PATH}/files" "${CHROOT_PATH}/tmp/setup_files"
chroot "${CHROOT_PATH}" /bin/bash -c "KERNEL_VERSION=${KERNEL_VERSION} /tmp/setup_files/chroot_build.sh"
chroot "${CHROOT_PATH}" /bin/bash -c "/tmp/setup_files/chroot_build.sh"

echo >&2 "===]> Info: Cleanup the chroot environment... "
# In docker there is no run?
Expand Down
45 changes: 42 additions & 3 deletions 02_build_image.sh
Original file line number Diff line number Diff line change
Expand Up @@ -9,15 +9,54 @@ if [ -d "${IMAGE_PATH}" ]; then
fi

mkdir -p "${IMAGE_PATH}"/{casper,install,isolinux}
cp "${CHROOT_PATH}"/boot/vmlinuz-"${KERNEL_VERSION}" "${IMAGE_PATH}"/casper/vmlinuz
cp "${CHROOT_PATH}"/boot/initrd.img-"${KERNEL_VERSION}" "${IMAGE_PATH}"/casper/initrd

echo >&2 "===]> Info: Grub configuration... "
# we add an empty file to use it with the search command in grub later on.
touch "${IMAGE_PATH}"/ubuntu
cp -r "${ROOT_PATH}"/files/preseed "${IMAGE_PATH}"/preseed
cp "${ROOT_PATH}/files/grub/grub.cfg" "${IMAGE_PATH}"/isolinux/grub.cfg

cat <<EOF > "${IMAGE_PATH}"/isolinux/grub.cfg
search --set=root --file /ubuntu
insmod all_video
EOF

find "${CHROOT_PATH}"/boot -maxdepth 1 -type f -name 'vmlinuz-*'
find "${CHROOT_PATH}"/boot -maxdepth 1 -type f -name 'initrd*'

for file in $(find "${CHROOT_PATH}"/boot -maxdepth 1 -type f -name 'vmlinuz-*' | grep t2 | cut -d'/' -f 6 | cut -d'-' -f2-10 | sort); do
echo "==> Adding $file"
cp "${CHROOT_PATH}/boot/vmlinuz-${file}" "${IMAGE_PATH}/casper/vmlinuz-${file}"
cp "${CHROOT_PATH}/boot/initrd.img-${file}" "${IMAGE_PATH}/casper/initrd-${file}"
cat <<EOF >> "${IMAGE_PATH}"/isolinux/grub.cfg
submenu "Ubuntu, with Linux $file" {
menuentry "Try Ubuntu FS without installing" {
linux /casper/vmlinuz-$file file=/cdrom/preseed/mbp.seed boot=casper ro efi=noruntime pcie_ports=compat ---
initrd /casper/initrd-$file
}
menuentry "Try Ubuntu FS without installing (blacklist=thunderbolt)" {
linux /casper/vmlinuz-$file file=/cdrom/preseed/mbp.seed boot=casper ro efi=noruntime pcie_ports=compat --- modprobe.blacklist=thunderbolt
initrd /casper/initrd-$file
}
menuentry "Install Ubuntu FS" {
linux /casper/vmlinuz-$file preseed/file=/cdrom/preseed/mbp.seed boot=casper only-ubiquity efi=noruntime pcie_ports=compat ---
initrd /casper/initrd-$file
}
menuentry "Install Ubuntu FS (blacklist=thunderbolt)" {
linux /casper/vmlinuz-$file preseed/file=/cdrom/preseed/mbp.seed boot=casper only-ubiquity efi=noruntime pcie_ports=compat --- modprobe.blacklist=thunderbolt
initrd /casper/initrd-$file
}
menuentry "Check disc for defects" {
linux /casper/vmlinuz-$file boot=casper integrity-check efi=noruntime enforcing=0 efi=noruntime pcie_ports=compat ---
initrd /casper/initrd-$file
}
menuentry "Check disc for defects (blacklist=thunderbolt)" {
linux /casper/vmlinuz-$file boot=casper integrity-check efi=noruntime enforcing=0 efi=noruntime pcie_ports=compat --- modprobe.blacklist=thunderbolt
initrd /casper/initrd-$file
}
}
EOF
done

echo >&2 "===]> Info: Compress the chroot... "
cd "${WORKING_PATH}"
Expand Down
2 changes: 1 addition & 1 deletion 04_create_iso.sh
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ xorriso -as mkisofs \
-no-emul-boot \
-isohybrid-mbr "${ROOT_PATH}/files/isohdpfx.bin" \
-isohybrid-gpt-basdat -isohybrid-apm-hfsplus \
-output "${ROOT_PATH}/ubuntu-20.04-${KERNEL_VERSION}.iso" \
-output "${ROOT_PATH}/ubuntu-20.04.iso" \
-graft-points \
"." \
/boot/grub/bios.img=isolinux/bios.img \
Expand Down
15 changes: 12 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,14 +17,21 @@ I'm using the Kernel from - <https://github.com/marcosfad/mbp-ubuntu-kernel>
Using additional drivers:
- [Apple T2 (apple-bce) (audio, keyboard, touchpad)](https://github.com/t2linux/apple-bce-drv)
- [Touchbar (apple-ibridge, apple-ib-tb, apple-ib-als)](https://github.com/t2linux/apple-ib-drv)
- [mbpfan](https://github.com/networkException/mbpfan)

Bootloader is configure correctly out of the box. No workaround needed.

## Before I begin, what version should I use? "mbp" or "mbp-16x-wifi"?
## Which kernel to choose

The difference between the two is that the mbp-16x-wifi version includes a different version of the brcmfmac wifi driver, made by corellium for M1 macs. This version of the wifi driver works on some models that the brcmfmac driver included with the mbp version doesn't support. Refer to the table on [this page](https://wiki.t2linux.org/guides/wifi/) to figure out which versions will work (Look at the "Firmware Options" column, Mojave means you can use the "mbp" version, and Big Sur means you can use the "mbp-16x-wifi" version).
I've pre installed several different kernel, to allow better support to different hardware.

**!! Please note that as of the v20.04-5.10.52 release, the mbp-16x-wifi iso does not support wifi on models with the BCM4377 chipset. For now, you can install a kernel from [here](https://github.com/AdityaGarg8/mbp-16.x-ubuntu-kernel/releases/tag/v5.13.12-1) after installing ubuntu if you have the BCM4377 chipset.**
If your macbook came with Big Sur preinstalled, you should use a bigsur version of kernel.

If your macbook came with mojave, you should use a mojave version of the kernel.

This will allow you to activate wifi in your macbook. See [this page for more information about wifi drivers](https://wiki.t2linux.org/guides/wifi/)

I've recommend starting with the HWE Kernel. That one comes from Ubuntu own repository and I have had great performance with it.

## Installation

Expand All @@ -51,6 +58,8 @@ sudo dd bs=4096 if=ubuntu-20.04-5.6.10-mbp.iso of=/dev/diskX
12. Start again using the option key. Select the new efi boot.
13. Enjoy.

See <https://wiki.t2linux.org/distributions/ubuntu/installation/> for more details.

## Configuration

- See <https://wiki.t2linux.org/guides/wifi/>
Expand Down
85 changes: 39 additions & 46 deletions build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ ROOT_PATH=$(pwd)
WORKING_PATH=/root/work
CHROOT_PATH="${WORKING_PATH}/chroot"
IMAGE_PATH="${WORKING_PATH}/image"
KERNEL_VERSION=5.10.52

if [ -d "$WORKING_PATH" ]; then
rm -rf "$WORKING_PATH"
Expand All @@ -32,55 +31,49 @@ apt-get install -y -qq -o Dpkg::Options::="--force-confdef" -o Dpkg::Options::="
isolinux \
syslinux

echo >&2 "===]> Info: Start loop... "
for ALTERNATIVE in mbp mbp-16x-wifi
do
echo >&2 "===]> Info: Start building ${ALTERNATIVE}... "
echo >&2 "===]> Info: Start building... "

echo >&2 "===]> Info: Build Ubuntu FS... "
/bin/bash -c "
ROOT_PATH=${ROOT_PATH} \\
WORKING_PATH=${WORKING_PATH} \\
CHROOT_PATH=${CHROOT_PATH}_${ALTERNATIVE} \\
IMAGE_PATH=${IMAGE_PATH} \\
KERNEL_VERSION=${KERNEL_VERSION}-${ALTERNATIVE} \\
${ROOT_PATH}/01_build_file_system.sh
"
echo >&2 "===]> Info: Build Ubuntu FS... "
/bin/bash -c "
ROOT_PATH=${ROOT_PATH} \\
WORKING_PATH=${WORKING_PATH} \\
CHROOT_PATH=${CHROOT_PATH} \\
IMAGE_PATH=${IMAGE_PATH} \\
${ROOT_PATH}/01_build_file_system.sh
"

echo >&2 "===]> Info: Build Image FS... "
/bin/bash -c "
ROOT_PATH=${ROOT_PATH} \\
WORKING_PATH=${WORKING_PATH} \\
CHROOT_PATH=${CHROOT_PATH}_${ALTERNATIVE} \\
IMAGE_PATH=${IMAGE_PATH} \\
KERNEL_VERSION=${KERNEL_VERSION}-${ALTERNATIVE} \\
${ROOT_PATH}/02_build_image.sh
"
echo >&2 "===]> Info: Build Image FS... "
/bin/bash -c "
ROOT_PATH=${ROOT_PATH} \\
WORKING_PATH=${WORKING_PATH} \\
CHROOT_PATH=${CHROOT_PATH} \\
IMAGE_PATH=${IMAGE_PATH} \\
${ROOT_PATH}/02_build_image.sh
"

echo >&2 "===]> Info: Prepare Boot for ISO... "
/bin/bash -c "
IMAGE_PATH=${IMAGE_PATH} \\
CHROOT_PATH=${CHROOT_PATH}_${ALTERNATIVE} \\
${ROOT_PATH}/03_prepare_iso.sh
"
echo >&2 "===]> Info: Prepare Boot for ISO... "
/bin/bash -c "
IMAGE_PATH=${IMAGE_PATH} \\
CHROOT_PATH=${CHROOT_PATH} \\
${ROOT_PATH}/03_prepare_iso.sh
"

echo >&2 "===]> Info: Create ISO... "
/bin/bash -c "
ROOT_PATH=${ROOT_PATH} \\
IMAGE_PATH=${IMAGE_PATH} \\
CHROOT_PATH=${CHROOT_PATH} \\
${ROOT_PATH}/04_create_iso.sh
"
livecd_exitcode=$?
if [ "${livecd_exitcode}" -ne 0 ]; then
echo "Error building"
exit "${livecd_exitcode}"
fi
### Zip iso and split it into multiple parts - github max size of release attachment is 2GB, where ISO is sometimes bigger than that
cd "${ROOT_PATH}"
zip -s 1500m "${ROOT_PATH}/output/livecd.zip" "${ROOT_PATH}/ubuntu-20.04.iso"

echo >&2 "===]> Info: Create ISO... "
/bin/bash -c "
ROOT_PATH=${ROOT_PATH} \\
IMAGE_PATH=${IMAGE_PATH} \\
CHROOT_PATH=${CHROOT_PATH}_${ALTERNATIVE} \\
KERNEL_VERSION=${KERNEL_VERSION}-${ALTERNATIVE} \\
${ROOT_PATH}/04_create_iso.sh
"
livecd_exitcode=$?
if [ "${livecd_exitcode}" -ne 0 ]; then
echo "Error building ${KERNEL_VERSION}-${ALTERNATIVE}"
exit "${livecd_exitcode}"
fi
### Zip iso and split it into multiple parts - github max size of release attachment is 2GB, where ISO is sometimes bigger than that
cd "${ROOT_PATH}"
zip -s 1500m "${ROOT_PATH}/output/livecd-${KERNEL_VERSION}-${ALTERNATIVE}.zip" "${ROOT_PATH}/ubuntu-20.04-${KERNEL_VERSION}-${ALTERNATIVE}.iso"
done
### Calculate sha256 sums of built ISO
sha256sum "${ROOT_PATH}"/*.iso >"${ROOT_PATH}/output/sha256"

Expand Down
3 changes: 2 additions & 1 deletion build_in_docker.sh
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,11 @@ set -eu -o pipefail
DOCKER_IMAGE=ubuntu:20.04

docker pull ${DOCKER_IMAGE}

docker run \
--privileged \
--rm \
-t \
-v "$(pwd)":/repo \
${DOCKER_IMAGE} \
/bin/bash -c 'cd /repo && ./build.sh'
/bin/bash -c "cd /repo && ./build.sh"
Loading

0 comments on commit e249af2

Please sign in to comment.