Build image with multiple kernels

This commit is contained in:
marcosfad 2021-09-12 00:15:37 +02:00
parent 1ea892eed3
commit 0ab1f3c5d5
11 changed files with 124 additions and 141 deletions

View File

@ -13,18 +13,11 @@ jobs:
- name: Configure variables
id: variables
run: |
sudo apt install curl
VERSION=5.10
ALTERNATIVE=mbp
LATEST_BUILD=$(curl -s https://mbp-ubuntu-kernel.herokuapp.com/ -L |
grep "linux-image-5.10" | grep ${ALTERNATIVE} |
grep a | cut -d'>' -f2 | cut -d'<' -f1 |sort -r | head -n 1 | cut -d'_' -f1 |
cut -d'-' -f 3-20)
echo "Using kernel ${LATEST_BUILD}"
echo "::set-output name=version::${LATEST_BUILD}"
BUILD=$(date '+%Y%m%d%H%M%S')
echo "::set-output name=build::${BUILD}"
- name: Build
run: KERNEL_VERSION=${{ steps.variables.outputs.version }} sudo ./build.sh
run: sudo ./build.sh
- name: print sha256sum
run: cat output/sha256
@ -32,7 +25,7 @@ jobs:
- name: Upload iso artifact
uses: actions/upload-artifact@v2
with:
name: mbp-ubuntu-${{ steps.variables.outputs.version }}
name: mbp-ubuntu-${{ steps.variables.outputs.build }}
path: ${{ github.workspace }}/output/*
- name: Instructions for putting it back together
@ -41,7 +34,7 @@ jobs:
Download all the artifacts, and put them in a folder
without other files. Then run:"
unzip "*.z??.zip"
cat livecd-${{ steps.variables.outputs.version }}-mbp.z?? > cd.zip
cat livecd-${{ steps.variables.outputs.build }}-mbp.z?? > cd.zip
echo unzip cd.zip
EOF
@ -50,7 +43,7 @@ jobs:
uses: softprops/action-gh-release@v1
with:
files: ${{ github.workspace }}/output/*
tag_name: v20.04-${{ steps.variables.outputs.version }}
tag_name: v20.04-${{ steps.variables.outputs.build }}
draft: true
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

1
.gitignore vendored
View File

@ -1,2 +1,3 @@
output
/.idea
/files/kernels

View File

@ -1,49 +0,0 @@
---
language: bash
os:
- linux
services:
- docker
# branches:
# only:
# - master
stages:
- test
- build_deploy
jobs:
include:
- stage: test
name: "YamlLint"
script: |
docker run --rm -v $(pwd):/repo -it alpine:latest /bin/sh -c '
cd /repo
apk add --no-cache python3 py-pip
pip install yamllint
yamllint .
'
- stage: test
name: "ShellCheck"
script: |
docker run --rm -v $(pwd):/repo -it alpine:latest /bin/sh -c '
cd /repo
apk add --no-cache shellcheck bash
shellcheck ./*.sh
shellcheck ./files/*.sh
'
- stage: build_deploy
name: "Build Ubuntu and Deploy to GitHub Releases"
script: ./build_in_docker.sh
deploy:
provider: releases
api_key: "$GITHUB_TOKEN"
file_glob: true
file: "output/*"
skip_cleanup: true
# yamllint disable-line rule:truthy
on:
tags: true

View File

@ -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?

View File

@ -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}"

View File

@ -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 \

View File

@ -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
@ -50,6 +57,8 @@ sudo gdd bs=4M if=ubuntu-20.04-5.6.10-mbp.iso of=/dev/diskX conv=fdatasync statu
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/>

View File

@ -5,10 +5,6 @@ ROOT_PATH=$(pwd)
WORKING_PATH=/root/work
CHROOT_PATH="${WORKING_PATH}/chroot"
IMAGE_PATH="${WORKING_PATH}/image"
if [ -z "${KERNEL_VERSION}" ]; then
echo "Kernel version is undefined, fallback set."
KERNEL_VERSION=5.10.52-mbp
fi
if [ -d "$WORKING_PATH" ]; then
rm -rf "$WORKING_PATH"
@ -35,7 +31,7 @@ apt-get install -y -qq -o Dpkg::Options::="--force-confdef" -o Dpkg::Options::="
isolinux \
syslinux
echo >&2 "===]> Info: Start building ${KERNEL_VERSION}... "
echo >&2 "===]> Info: Start building... "
echo >&2 "===]> Info: Build Ubuntu FS... "
/bin/bash -c "
@ -43,7 +39,6 @@ echo >&2 "===]> Info: Build Ubuntu FS... "
WORKING_PATH=${WORKING_PATH} \\
CHROOT_PATH=${CHROOT_PATH} \\
IMAGE_PATH=${IMAGE_PATH} \\
KERNEL_VERSION=${KERNEL_VERSION}\\
${ROOT_PATH}/01_build_file_system.sh
"
@ -53,7 +48,6 @@ echo >&2 "===]> Info: Build Image FS... "
WORKING_PATH=${WORKING_PATH} \\
CHROOT_PATH=${CHROOT_PATH} \\
IMAGE_PATH=${IMAGE_PATH} \\
KERNEL_VERSION=${KERNEL_VERSION} \\
${ROOT_PATH}/02_build_image.sh
"
@ -69,17 +63,16 @@ echo >&2 "===]> Info: Create ISO... "
ROOT_PATH=${ROOT_PATH} \\
IMAGE_PATH=${IMAGE_PATH} \\
CHROOT_PATH=${CHROOT_PATH} \\
KERNEL_VERSION=${KERNEL_VERSION} \\
${ROOT_PATH}/04_create_iso.sh
"
livecd_exitcode=$?
if [ "${livecd_exitcode}" -ne 0 ]; then
echo "Error building ${KERNEL_VERSION}"
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-${KERNEL_VERSION}.zip" "${ROOT_PATH}/ubuntu-20.04-${KERNEL_VERSION}.iso"
zip -s 1500m "${ROOT_PATH}/output/livecd.zip" "${ROOT_PATH}/ubuntu-20.04.iso"
### Calculate sha256 sums of built ISO
sha256sum "${ROOT_PATH}"/*.iso >"${ROOT_PATH}/output/sha256"

View File

@ -6,18 +6,10 @@ DOCKER_IMAGE=ubuntu:20.04
docker pull ${DOCKER_IMAGE}
VERSION=5
ALTERNATIVE=mbp
LATEST_BUILD=$(curl -s https://mbp-ubuntu-kernel.herokuapp.com/ -L |
grep "linux-image-${VERSION}" | grep ${ALTERNATIVE} |
grep a | cut -d'>' -f2 | cut -d'<' -f1 |sort -r | head -n 1 | cut -d'_' -f1 |
cut -d'-' -f 3-20)
echo "Using kernel ${LATEST_BUILD}"
docker run \
--privileged \
--rm \
-t \
-v "$(pwd)":/repo \
${DOCKER_IMAGE} \
/bin/bash -c "cd /repo && KERNEL_VERSION=${LATEST_BUILD} ./build.sh"
/bin/bash -c "cd /repo && ./build.sh"

View File

@ -43,6 +43,7 @@ ln -s /bin/true /sbin/initctl
echo >&2 "===]> Info: Install packages needed for Live System... "
# todo: Install the latest kernel automatically
export DEBIAN_FRONTEND=noninteractive
apt-get install -y -qq -o Dpkg::Options::="--force-confdef" -o Dpkg::Options::="--force-confold" \
ubuntu-standard \
@ -60,20 +61,42 @@ apt-get install -y -qq -o Dpkg::Options::="--force-confdef" -o Dpkg::Options::="
locales \
initramfs-tools \
binutils \
linux-generic-hwe-20.04 \
linux-headers-generic-hwe-20.04 \
linux-firmware \
grub-efi-amd64-signed \
"linux-image-${KERNEL_VERSION}" \
"linux-headers-${KERNEL_VERSION}" \
intel-microcode \
linux-headers-5.11.22-t2-hwe-bigsur \
linux-headers-5.11.22-t2-hwe-mojave \
linux-headers-5.12.19-t2-a-bigsur \
linux-headers-5.12.19-t2-a-mojave \
linux-headers-5.13.15-t2-j-bigsur \
linux-headers-5.13.15-t2-j-mojave \
linux-image-5.11.22-t2-hwe-bigsur \
linux-image-5.11.22-t2-hwe-mojave \
linux-image-5.12.19-t2-a-bigsur \
linux-image-5.12.19-t2-a-mojave \
linux-image-5.13.15-t2-j-bigsur \
linux-image-5.13.15-t2-j-mojave \
thermald
echo >&2 "===]> Info: Add firmwares"
for file in skl_guc_49.0.1.bin bxt_guc_49.0.1.bin kbl_guc_49.0.1.bin glk_guc_49.0.1.bin kbl_guc_49.0.1.bin kbl_guc_49.0.1.bin cml_guc_49.0.1.bin icl_guc_49.0.1.bin ehl_guc_49.0.1.bin ehl_guc_49.0.1.bin tgl_huc_7.5.0.bin tgl_guc_49.0.1.bin tgl_huc_7.5.0.bin tgl_guc_49.0.1.bin tgl_huc_7.5.0.bin tgl_guc_49.0.1.bin dg1_dmc_ver2_02.bin
do
curl -L https://git.kernel.org/pub/scm/linux/kernel/git/firmware/linux-firmware.git/plain/i915/$file \
--output /lib/firmware/i915/$file
done
if [ -d /tmp/setup_files/kernels ]; then
echo >&2 "===]> Info: Install patched kernels... "
dpkg -i /tmp/setup_files/kernels/*.deb
fi
echo >&2 "===]> Info: Install window manager... "
apt-get install -y -qq -o Dpkg::Options::="--force-confdef" -o Dpkg::Options::="--force-confold" \
plymouth-theme-ubuntu-logo \
ubuntu-desktop-minimal \
ubuntu-gnome-wallpapers \
netplan.io \
snapd
echo >&2 "===]> Info: Install Graphical installer... "
@ -87,7 +110,7 @@ apt-get install -y -qq -o Dpkg::Options::="--force-confdef" -o Dpkg::Options::="
echo >&2 "===]> Info: Install useful applications... "
apt-get install -y -qq -o Dpkg::Options::="--force-confdef" -o Dpkg::Options::="--force-confold" \
apt-get install -y --no-install-recommends -qq -o Dpkg::Options::="--force-confdef" -o Dpkg::Options::="--force-confold" \
git \
curl \
nano \
@ -112,17 +135,17 @@ git clone --single-branch --branch ${APPLE_BCE_DRIVER_BRANCH_NAME} ${APPLE_BCE_D
git -C /usr/src/"${APPLE_BCE_DRIVER_MODULE_NAME}-${APPLE_BCE_DRIVER_MODULE_VERSION}" checkout "${APPLE_BCE_DRIVER_COMMIT_HASH}"
cat << EOF > /usr/src/${APPLE_BCE_DRIVER_MODULE_NAME}-${APPLE_BCE_DRIVER_MODULE_VERSION}/dkms.conf
PACKAGE_NAME=apple-bce
PACKAGE_VERSION=0.2
PACKAGE_NAME="apple-bce"
PACKAGE_VERSION="${APPLE_BCE_DRIVER_MODULE_VERSION}"
MAKE[0]="make KVERSION=\$kernelver"
CLEAN="make clean"
MAKE="make"
BUILT_MODULE_NAME[0]="apple-bce"
DEST_MODULE_LOCATION[0]="/updates"
DEST_MODULE_LOCATION[0]="/kernel/drivers/misc"
AUTOINSTALL="yes"
REMAKE_INITRD="yes"
EOF
dkms install -m "${APPLE_BCE_DRIVER_MODULE_NAME}" -v "${APPLE_BCE_DRIVER_MODULE_VERSION}" -k "${KERNEL_VERSION}"
dkms install -m "${APPLE_BCE_DRIVER_MODULE_NAME}" -v "${APPLE_BCE_DRIVER_MODULE_VERSION}" --all
printf '\n### apple-bce start ###\napple-bce\n### apple-bce end ###' >>/etc/modules-load.d/apple-bce.conf
printf '\n### apple-bce start ###\nhapple-bce\n### apple-bce end ###' >>/etc/initramfs-tools/modules
@ -135,8 +158,10 @@ APPLE_IB_DRIVER_MODULE_VERSION=0.1
git clone --single-branch --branch ${APPLE_IB_DRIVER_BRANCH_NAME} ${APPLE_IB_DRIVER_GIT_URL} \
/usr/src/"${APPLE_IB_DRIVER_MODULE_NAME}-${APPLE_IB_DRIVER_MODULE_VERSION}"
git -C /usr/src/"${APPLE_IB_DRIVER_MODULE_NAME}-${APPLE_IB_DRIVER_MODULE_VERSION}" checkout "${APPLE_IB_DRIVER_COMMIT_HASH}"
dkms install -m "${APPLE_IB_DRIVER_MODULE_NAME}" -v "${APPLE_IB_DRIVER_MODULE_VERSION}" -k "${KERNEL_VERSION}"
printf '\n### applespi start ###\napple_ib_tb\napple_ib_als\n### applespi end ###' >>/etc/modules-load.d/applespi.conf
dkms install -m "${APPLE_IB_DRIVER_MODULE_NAME}" -v "${APPLE_IB_DRIVER_MODULE_VERSION}" --all
printf '\n### applespi start ###\napple_ib_tb\napple_ib_als\n### applespi end ###' >> /etc/modules-load.d/applespi.conf
printf '\n# display f* key in touchbar\noptions apple-ib-tb fnmode=2\n' >> /etc/modprobe.d/apple-touchbar.conf
## Add optional dkms for brcm80211-mbp16x
@ -158,6 +183,9 @@ printf '\n# display f* key in touchbar\noptions apple-ib-tb fnmode=2\n' >> /etc
#cd /tmp
#rm -rf *55.zip 22*
echo >&2 "===]> Debug dkms status"
dkms status
echo >&2 "===]> Configure amdgpu"
cat << EOF > /etc/udev/rules.d/30-amdgpu-pm.rules
KERNEL=="card0", SUBSYSTEM=="drm", DRIVERS=="amdgpu", ATTR{device/power_dpm_force_performance_level}="high"
@ -166,8 +194,18 @@ EOF
echo >&2 "===]> Info: Update initramfs... "
## Add custom drivers to be loaded at boot
/usr/sbin/depmod -a "${KERNEL_VERSION}"
update-initramfs -u -v -k "${KERNEL_VERSION}"
for kernel in $(dpkg -l | grep linux-image | grep ii | grep t2 | cut -d' ' -f3|cut -d'-' -f3-10); do
echo "==> Adding $kernel"
/usr/sbin/depmod -a "$kernel"
update-initramfs -u -v -k "$kernel"
done
#echo >&2 "===]> Info: install mpbfan ... "
#git clone https://github.com/networkException/mbpfan /tmp/mbpfan
#cd /tmp/mbpfan
#make install
#cp mbpfan.service /etc/systemd/system/
#systemctl enable mbpfan.service
echo >&2 "===]> Info: Remove unused applications ... "
@ -185,13 +223,12 @@ apt-get purge -y -qq \
vim \
binutils \
linux-generic \
linux-headers-5.4.0-28 \
linux-headers-5.4.0-28-generic \
'^linux-headers-5\.4\..*' \
linux-headers-generic \
linux-image-5.4.0-28-generic \
'^linux-image-5\.4\..*' \
linux-image-generic \
linux-modules-5.4.0-28-generic \
linux-modules-extra-5.4.0-28-generic
'^linux-modules-5\.4\..*' \
'^linux-modules-extra-5\.4\..*'
apt-get autoremove -y

View File

@ -1,32 +0,0 @@
search --set=root --file /ubuntu
insmod all_video
set default="0"
set timeout=30
menuentry "Try Ubuntu FS without installing" {
linux /casper/vmlinuz file=/cdrom/preseed/mbp.seed boot=casper ro efi=noruntime pcie_ports=compat acpi=force ---
initrd /casper/initrd
}
menuentry "Try Ubuntu FS without installing (blacklist=thunderbolt)" {
linux /casper/vmlinuz file=/cdrom/preseed/mbp.seed boot=casper ro efi=noruntime pcie_ports=compat acpi=force --- modprobe.blacklist=thunderbolt
initrd /casper/initrd
}
menuentry "Install Ubuntu FS" {
linux /casper/vmlinuz preseed/file=/cdrom/preseed/mbp.seed boot=casper only-ubiquity efi=noruntime pcie_ports=compat acpi=force ---
initrd /casper/initrd
}
menuentry "Install Ubuntu FS (blacklist=thunderbolt)" {
linux /casper/vmlinuz preseed/file=/cdrom/preseed/mbp.seed boot=casper only-ubiquity efi=noruntime pcie_ports=compat acpi=force --- modprobe.blacklist=thunderbolt
initrd /casper/initrd
}
menuentry "Check disc for defects" {
linux /casper/vmlinuz boot=casper integrity-check efi=noruntime enforcing=0 efi=noruntime pcie_ports=compat acpi=force ---
initrd /casper/initrd
}
menuentry "Check disc for defects (blacklist=thunderbolt)" {
linux /casper/vmlinuz boot=casper integrity-check efi=noruntime enforcing=0 efi=noruntime pcie_ports=compat --- modprobe.blacklist=thunderbolt
initrd /casper/initrd
}