diff --git a/.gitignore b/.gitignore index 1e4b237..53752db 100644 --- a/.gitignore +++ b/.gitignore @@ -1 +1 @@ -build_files +output diff --git a/.travis.yml b/.travis.yml index 570cc46..19dd455 100644 --- a/.travis.yml +++ b/.travis.yml @@ -7,9 +7,9 @@ os: services: - docker -branches: - only: - - master +#branches: +# only: +# - master stages: - test @@ -33,6 +33,7 @@ jobs: cd /repo apk add --no-cache shellcheck bash shellcheck ./*.sh + shellcheck ./files/*.sh ' - stage: build_deploy name: "Build Ubuntu and Deploy to GitHub Releases" @@ -41,7 +42,7 @@ jobs: provider: releases api_key: "$GITHUB_TOKEN" file_glob: true - file: "/build_files/output_zip/*" + file: "output/*" skip_cleanup: true on: tags: true diff --git a/README.md b/README.md index fb8dbfb..73e8669 100644 --- a/README.md +++ b/README.md @@ -1,59 +1,35 @@ # mbp-ubuntu +This Repo is still Work in progress. The haven't installed yet. The ISO in from this repo should allow you to install ubuntu without using an external keyboard or mouse. Make sure that the required modules are enabled in initramfs and modules.d after installing. + +``` +printf '\n# apple-bce\nhid-apple\nbcm5974\nsnd-seq\napple-bce' >>/etc/modules-load.d/apple-bce.conf +printf '\n# apple-bce\nhid-apple\nsnd-seq\napple-bce' >>/etc/initramfs-tools/modules + +printf '\n# applespi\napple_ibridge\napple_ib_tb\napple_ib_als' >>/etc/modules-load.d/applespi.conf +``` + + +The easiest way to get Ubuntu in your MBP is following this Post: https://gist.github.com/gbrow004/096f845c8fe8d03ef9009fbb87b781a4 + [![Build Status](https://travis-ci.com/marcosfad/mbp-ubuntu.svg?branch=master)](https://travis-ci.com/marcosfad/mbp-ubuntu) UBUNTU 20.04 ISO with Apple T2 patches built-in (Macbooks produced >= 2018). -All available Apple T2 drivers are integrated with this iso. Most things work, besides those mentioned in [not working section](#not-working). +All available Apple T2 drivers are integrated with this iso. + +This repo is a rework of https://github.com/mikeeq/mbp-fedora + +Most things should be work, besides those mentioned in [not working section](#not-working). Kernel - -Drivers: +Drivers you should use: +- Apple T2 (apple-bce) (audio, keyboard, touchpad) - +- Touchbar (apple-ibridge, apple-ib-tb, apple-ib-als) - -- Apple T2 (audio, keyboard, touchpad) - -- Apple SMC - -- Touchbar - -> Tested on: Macbook Pro 16,1 16" 2019 i9 TouchBar - -``` -Boot ROM Version: 220.270.99.0.0 (iBridge: 16.16.6571.0.0,0) -macOS Mojave: 10.14.6 (18G103) -``` - -## How to install - -- Turn off secure boot - -- Download .iso from releases section - - - If it's splitted into multiple zip parts, you need to join splitted files into one and then extract it via `unzip` or extract them directly via `7z x` or `7za x` - - -- Burn the image on USB stick >=8GB via: - - dd - `dd bs=4M if=/home/user/Downloads/ubuntu-20.04-beta-minimal-mbp.iso of=/dev/sdc conv=fdatasync status=progress` - - rufus (GPT)- - - balenaEtcher- - - don't use `livecd-iso-to-disk`, because it's overwriting grub settings -- Install Ubuntu - - Boot directly from macOS boot manager. (You can boot into it by pressing and holding option key after clicking the power-on button). - - There will be three boot options available, usually the third one works for me. (There are three of them, because there are three partitions in ISO: 1) ISO9660: with installer data, 2) fat32, 3) hfs+) - - I recommend to shrink (resize) macOS APFS partition and not removing macOS installation entirely from your MacBook, because it's the only way to keep your device up-to-date. macOS OS updates also contains security patches to EFI/Apple T2 - - HowTo: # Steps to Resize Mac Partition - - You should use standard partition layout during partitioning your Disk in anaconda, because i haven't tested LVM scenario yet. - - /boot/efi - 1024MB fat32 - - /boot - 1024MB EXT4 - - / - xxxGB EXT4 - -- Put wifi firmware files to `/lib/firmware/brcm/` - - tutorial - -- 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: -``` -# /etc/modprobe.d/hid_apple.conf -options hid_apple swap_fn_leftctrl=1 -options hid_apple swap_opt_cmd=1 - -grub2-mkconfig -o /boot/efi/EFI/ubuntu/grub.cfg -``` - -## Not working +## Not working (Following the mikeeq/mbp-fedora) - Dynamic audio input/output change (on connecting/disconnecting headphones jack) - TouchID - (@MCMrARM is working on it - https://github.com/Dunedan/mbp-2016-linux/issues/71#issuecomment-528545490) @@ -62,8 +38,10 @@ grub2-mkconfig -o /boot/efi/EFI/ubuntu/grub.cfg ## TODO +- Tests +- Check installer. -## Known issues +## Known issues (Following the mikeeq/mbp-fedora) - Kernel/Mac related issues are mentioned in kernel repo @@ -76,11 +54,16 @@ grub2-mkconfig -o /boot/efi/EFI/ubuntu/grub.cfg - Discord: - WiFi firmware: - Linux on a MBP Late 2016: +- Repack Bootable ISO: +- ### Ubuntu - - +- +- +- ### Github @@ -94,6 +77,7 @@ grub2-mkconfig -o /boot/efi/EFI/ubuntu/grub.cfg - ArchLinux installation guide: - hid-apple-patched module for changing mappings of ctrl, fn, option keys: - Audio configuration: +- Ubuntu in MBP16: ## Credits @@ -104,4 +88,3 @@ grub2-mkconfig -o /boot/efi/EFI/ubuntu/grub.cfg - @aunali1 - thanks for ArchLinux Kernel CI - @ppaulweber - thanks for keyboard and Macbook Air patches - @kevineinarsson - thanks for the audio settings -- @roadrunner2 - thanks for the overview diff --git a/build.sh b/build.sh index e86b7bc..9aa94d6 100755 --- a/build.sh +++ b/build.sh @@ -2,175 +2,83 @@ set -eu -o pipefail ROOT_PATH=$(pwd) -WORKING_PATH=$(pwd)/build_files +WORKING_PATH=/root/work +CHROOT_PATH="${WORKING_PATH}/chroot" +IMAGE_PATH="${WORKING_PATH}/image" +#KERNEL_VERSION=5.4.0-26-generic +KERNEL_VERSION=5.6.7-mbp if [ -d "$WORKING_PATH" ]; then - rm -rf "$WORKING_PATH" + rm -rf "$WORKING_PATH" fi mkdir -p "$WORKING_PATH" -echo >&2 "===]> Info: Build dependencies... "; +echo >&2 "===]> Info: Build dependencies... " export DEBIAN_FRONTEND=noninteractive apt-get update apt-get install -y -qq -o Dpkg::Options::="--force-confdef" -o Dpkg::Options::="--force-confold" \ - binutils \ - debootstrap \ - squashfs-tools \ - xorriso \ - grub-pc-bin \ - grub-efi-amd64-bin \ - mtools \ - dosfstools \ - zip + binutils \ + debootstrap \ + squashfs-tools \ + xorriso \ + grub-pc-bin \ + grub-efi-amd64-bin \ + mtools \ + dosfstools \ + zip \ + isolinux \ + syslinux \ + lz4 -command -v wget >/dev/null 2>&1 || { echo >&2 "I require wget but it's not installed. Aborting."; exit 1; } +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} \\ + KERNEL_VERSION=${KERNEL_VERSION} \\ + ${ROOT_PATH}/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} \\ + IMAGE_PATH=${IMAGE_PATH} \\ + KERNEL_VERSION=${KERNEL_VERSION} \\ + ${ROOT_PATH}/build_image.sh +" -echo >&2 "===]> Info: Checkout bootstrap... "; -debootstrap \ - --arch=amd64 \ - --variant=minbase \ - focal \ - "$WORKING_PATH/chroot" \ - http://de.archive.ubuntu.com/ubuntu/ +echo >&2 "===]> Info: Prepare Boot for ISO... " +/bin/bash -c " + IMAGE_PATH=${IMAGE_PATH} \\ + CHROOT_PATH=${CHROOT_PATH} \\ + ${ROOT_PATH}/prepare_iso.sh +" - -echo >&2 "===]> Info: Creating chroot environment... "; -mount --bind /dev "$WORKING_PATH/chroot/dev" -# mount --bind /run "$WORKING_PATH/chroot/run" - -cp -r "$ROOT_PATH/files" "$WORKING_PATH/chroot/tmp/setup_files" -chroot "$WORKING_PATH/chroot" /tmp/setup_files/chroot_build.sh - - -echo >&2 "===]> Info: Cleanup the chroot environment... "; -# umount -lf "$WORKING_PATH/chroot/run" -umount "$WORKING_PATH/chroot/dev" - - -echo >&2 "===]> Info: Create image directory and populate it... "; -cd "$WORKING_PATH" -if [ -d "$WORKING_PATH/image" ]; then - rm -rf "$WORKING_PATH/image" -fi -if [ -e "$WORKING_PATH/ubuntu-for-mbp.iso" ]; then - rm -f "$WORKING_PATH/ubuntu-for-mbp.iso" -fi -mkdir -p image/{casper,isolinux,install} -cp chroot/boot/vmlinuz-*-mbp image/casper/vmlinuz -cp chroot/boot/initrd.img-*-mbp image/casper/initrd - - -echo >&2 "===]> Info: Create manifest... "; -cd "$WORKING_PATH" -# shellcheck disable=SC2016 -chroot chroot dpkg-query -W --showformat='${Package} ${Version}\n' | tee image/casper/filesystem.manifest - -cp -v image/casper/filesystem.manifest image/casper/filesystem.manifest-desktop -sed -i '/ubiquity/d' image/casper/filesystem.manifest-desktop -sed -i '/casper/d' image/casper/filesystem.manifest-desktop -sed -i '/discover/d' image/casper/filesystem.manifest-desktop -sed -i '/laptop-detect/d' image/casper/filesystem.manifest-desktop -sed -i '/os-prober/d' image/casper/filesystem.manifest-desktop - - -### Workaround - travis_wait -while true -do - date - sleep 30 -done & -bgPID=$! - -echo >&2 "===]> Info: Compress the chroot... "; -cd "$WORKING_PATH" -mksquashfs chroot image/casper/filesystem.squashfs -printf "%s" "$(du -sx --block-size=1 chroot | cut -f1)" > image/casper/filesystem.size - - -echo >&2 "===]> Info: Create diskdefines... "; -cat < image/README.diskdefines -#define DISKNAME Ubuntu 20.04 LTS "Focal Fossa" - MacBook Pro Beta amd64 -#define TYPE binary -#define TYPEbinary 1 -#define ARCH amd64 -#define ARCHamd64 1 -#define DISKNUM 1 -#define DISKNUM1 1 -#define TOTALNUM 0 -#define TOTALNUM0 1 -EOF - - -echo >&2 "===]> Info: Grub configuration... "; -touch image/ubuntu -cp "$ROOT_PATH/files/grub/grub.cfg" image/isolinux/grub.cfg -cp -r "$ROOT_PATH/files/preseed" image/pressed - -echo >&2 "===]> Info: Create ISO Image for a LiveCD... "; -cd "$WORKING_PATH/image" - -grub-mkstandalone \ - --format=x86_64-efi \ - --output=isolinux/bootx64.efi \ - --locales="" \ - --fonts="" \ - "boot/grub/grub.cfg=isolinux/grub.cfg" - -( - cd isolinux && \ - dd if=/dev/zero of=efiboot.img bs=1M count=10 && \ - mkfs.vfat efiboot.img && \ - LC_CTYPE=C mmd -i efiboot.img efi efi/boot && \ - LC_CTYPE=C mcopy -i efiboot.img ./bootx64.efi ::efi/boot/ -) - -grub-mkstandalone \ - --format=i386-pc \ - --output=isolinux/core.img \ - --install-modules="linux16 linux normal iso9660 biosdisk memdisk search tar ls" \ - --modules="linux16 linux normal iso9660 biosdisk search" \ - --locales="" \ - --fonts="" \ - "boot/grub/grub.cfg=isolinux/grub.cfg" - -cat /usr/lib/grub/i386-pc/cdboot.img isolinux/core.img > isolinux/bios.img - -(find . -type f -print0 | xargs -0 md5sum | grep -v "\./md5sum.txt" > md5sum.txt) - -xorriso \ - -as mkisofs \ - -iso-level 3 \ - -full-iso9660-filenames \ - -volid "Ubuntu MBP 20.04 beta minimal" \ - -eltorito-boot boot/grub/bios.img \ - -no-emul-boot \ - -boot-load-size 4 \ - -boot-info-table \ - --eltorito-catalog boot/grub/boot.cat \ - --grub2-boot-info \ - --grub2-mbr /usr/lib/grub/i386-pc/boot_hybrid.img \ - -eltorito-alt-boot \ - -e EFI/efiboot.img \ - -no-emul-boot \ - -append_partition 2 0xef isolinux/efiboot.img \ - -output "../ubuntu-mbp-20.04-beta-minimal.iso" \ - -graft-points \ - "." \ - /boot/grub/bios.img=isolinux/bios.img \ - /EFI/efiboot.img=isolinux/efiboot.img +echo >&2 "===]> Info: Create ISO... " +/bin/bash -c " + ROOT_PATH=${ROOT_PATH} \\ + IMAGE_PATH=${IMAGE_PATH} \\ + CHROOT_PATH=${CHROOT_PATH} \\ + KERNEL_VERSION=${KERNEL_VERSION} \\ + ${ROOT_PATH}/create_iso.sh +" livecd_exitcode=$? ### Zip iso and split it into multiple parts - github max size of release attachment is 2GB, where ISO is sometimes bigger than that -cd "$WORKING_PATH" -mkdir -p ./output_zip -zip -s 1500m ./output_zip/livecd.zip ./*.iso +cd "${ROOT_PATH}" +if [ -d "${ROOT_PATH}/output" ]; then + rm -rf "${ROOT_PATH}/output" +fi +mkdir -p "${ROOT_PATH}/output" +zip -s 1500m "${ROOT_PATH}/output/livecd.zip" ./*.iso ### Calculate sha256 sums of built ISO -sha256sum ./*.iso > ./output_zip/sha256 +sha256sum "${ROOT_PATH}"/*.iso >"${ROOT_PATH}/output/sha256" find ./ | grep ".iso" find ./ | grep ".zip" -kill "$bgPID" exit "$livecd_exitcode" diff --git a/build_file_system.sh b/build_file_system.sh new file mode 100755 index 0000000..5ae8f00 --- /dev/null +++ b/build_file_system.sh @@ -0,0 +1,23 @@ +#!/bin/bash +set -eu -o pipefail + +echo >&2 "===]> Info: Checkout bootstrap... " +debootstrap \ + --arch=amd64 \ + --variant=minbase \ + focal \ + "${CHROOT_PATH}" \ + http://archive.ubuntu.com/ubuntu/ + +echo >&2 "===]> Info: Creating chroot environment... " +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" + +echo >&2 "===]> Info: Cleanup the chroot environment... " +# In docker there is no run? +#umount "${CHROOT_PATH}/run" +umount "${CHROOT_PATH}/dev" + diff --git a/build_image.sh b/build_image.sh new file mode 100755 index 0000000..1e123d1 --- /dev/null +++ b/build_image.sh @@ -0,0 +1,52 @@ +#!/bin/bash +set -eu -o pipefail + +echo >&2 "===]> Info: Create image directory and populate it... " +cd "${WORKING_PATH}" + +if [ -d "${IMAGE_PATH}" ]; then + rm -rf "${IMAGE_PATH}" +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 +#cd "${IMAGE_PATH}/casper" && lz4 initrd.lz4 # TODO: Workarround for lz4 format not recongnised + +touch "${IMAGE_PATH}"/ubuntu + +echo >&2 "===]> Info: Grub configuration... " +cp -r "${ROOT_PATH}"/files/preseed "${IMAGE_PATH}"/pressed +#cp -r "${ROOT_PATH}"/files/boot/* "${IMAGE_PATH}/" +cp "${ROOT_PATH}/files/grub/grub.cfg" "${IMAGE_PATH}"/isolinux/grub.cfg +#cp "${ROOT_PATH}/files/isolinux/txt.cfg" "${IMAGE_PATH}"/isolinux/txt.cfg + + +echo >&2 "===]> Info: Compress the chroot... " +cd "${WORKING_PATH}" +mksquashfs chroot "${IMAGE_PATH}"/casper/filesystem.squashfs +printf "%s" "$(du -sx --block-size=1 "${CHROOT_PATH}" | cut -f1)" >"${IMAGE_PATH}"/casper/filesystem.size + +echo >&2 "===]> Info: Create manifest... " +# shellcheck disable=SC2016 +chroot "${CHROOT_PATH}" dpkg-query -W --showformat='${Package} ${Version}\n' | + tee "${IMAGE_PATH}"/casper/filesystem.manifest +cp -v "${IMAGE_PATH}"/casper/filesystem.manifest "${IMAGE_PATH}"/casper/filesystem.manifest-desktop + +REMOVE='ubiquity ubiquity-frontend-gtk ubiquity-frontend-kde casper lupin-casper live-initramfs user-setup discover1 xresprobe os-prober libdebian-installer4' +for i in $REMOVE; do + sed -i "/${i}/d" "${IMAGE_PATH}"/casper/filesystem.manifest-desktop +done + +echo >&2 "===]> Info: Create diskdefines... " +cat <"${IMAGE_PATH}"/README.diskdefines +#define DISKNAME Ubuntu MBP 20.04 LTS "Focal Fossa" - Beta amd64 +#define TYPE binary +#define TYPEbinary 1 +#define ARCH amd64 +#define ARCHamd64 1 +#define DISKNUM 1 +#define DISKNUM1 1 +#define TOTALNUM 0 +#define TOTALNUM0 1 +EOF diff --git a/create_iso.sh b/create_iso.sh new file mode 100755 index 0000000..fa92aac --- /dev/null +++ b/create_iso.sh @@ -0,0 +1,30 @@ +#!/bin/bash +set -eu -o pipefail + +cd "${IMAGE_PATH}" +### Generate md5sum.txt. Generate it two times, to get the own checksum right. +(find . -type f -print0 | xargs -0 md5sum >"${IMAGE_PATH}/md5sum.txt") + + +echo >&2 "===]> Info: Create Isolinux... " +xorriso -as mkisofs \ + -iso-level 3 \ + -full-iso9660-filenames \ + -volid "Ubuntu 20.04 LTS MBP" \ + -b boot/grub/bios.img \ + -no-emul-boot \ + -boot-load-size 4 \ + -boot-info-table \ + -c boot/grub/boot.cat \ + --grub2-boot-info \ + --grub2-mbr "${CHROOT_PATH}/usr/lib/grub/i386-pc/boot_hybrid.img" \ + -eltorito-alt-boot \ + -e "EFI/efiboot.img" \ + -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" \ + -graft-points \ + "." \ + /boot/grub/bios.img=isolinux/bios.img \ + /EFI/efiboot.img=isolinux/efiboot.img diff --git a/files/chroot_build.sh b/files/chroot_build.sh index 11d9879..eae02d3 100755 --- a/files/chroot_build.sh +++ b/files/chroot_build.sh @@ -2,8 +2,7 @@ set -eu -o pipefail - -echo >&2 "===]> Info: Configure environment... "; +echo >&2 "===]> Info: Configure environment... " mount none -t proc /proc mount none -t sysfs /sys @@ -12,147 +11,166 @@ mount none -t devpts /dev/pts export HOME=/root export LC_ALL=C -echo "ubuntu-fs-live" > /etc/hostname +echo "ubuntu-fs-live" >/etc/hostname +echo >&2 "===]> Info: Configure and update apt... " -echo >&2 "===]> Info: Configure and update apt... "; - -cat < /etc/apt/sources.list -deb http://de.archive.ubuntu.com/ubuntu/ focal main restricted universe multiverse -deb-src http://de.archive.ubuntu.com/ubuntu/ focal main restricted universe multiverse -deb http://de.archive.ubuntu.com/ubuntu/ focal-security main restricted universe multiverse -deb-src http://de.archive.ubuntu.com/ubuntu/ focal-security main restricted universe multiverse -deb http://de.archive.ubuntu.com/ubuntu/ focal-updates main restricted universe multiverse -deb-src http://de.archive.ubuntu.com/ubuntu/ focal-updates main restricted universe multiverse +cat </etc/apt/sources.list +deb http://archive.ubuntu.com/ubuntu/ focal main restricted universe multiverse +deb-src http://archive.ubuntu.com/ubuntu/ focal main restricted universe multiverse +deb http://archive.ubuntu.com/ubuntu/ focal-security main restricted universe multiverse +deb-src http://archive.ubuntu.com/ubuntu/ focal-security main restricted universe multiverse +deb http://archive.ubuntu.com/ubuntu/ focal-updates main restricted universe multiverse +deb-src http://archive.ubuntu.com/ubuntu/ focal-updates main restricted universe multiverse EOF apt-get update - -echo >&2 "===]> Info: Install systemd and Ubuntu MBP Repo... "; +echo >&2 "===]> Info: Install systemd and Ubuntu MBP Repo... " apt-get install -y systemd-sysv gnupg curl wget mkdir -p /etc/apt/sources.list.d -echo "deb https://mbp-ubuntu-kernel.herokuapp.com/ /" > /etc/apt/sources.list.d/mbp-ubuntu-kernel.list +echo "deb https://mbp-ubuntu-kernel.herokuapp.com/ /" >/etc/apt/sources.list.d/mbp-ubuntu-kernel.list curl -L https://mbp-ubuntu-kernel.herokuapp.com/KEY.gpg | apt-key add - apt-get update -echo >&2 "===]> Info: Configure machine-id and divert... "; +echo >&2 "===]> Info: Configure machine-id and divert... " -dbus-uuidgen > /etc/machine-id +dbus-uuidgen >/etc/machine-id ln -fs /etc/machine-id /var/lib/dbus/machine-id dpkg-divert --local --rename --add /sbin/initctl ln -s /bin/true /sbin/initctl - -echo >&2 "===]> Info: Install packages needed for Live System... "; +echo >&2 "===]> Info: Install packages needed for Live System... " export DEBIAN_FRONTEND=noninteractive +#dpkg -i "/tmp/setup_files/kernel/linux-image-${KERNEL_VERSION}_${KERNEL_VERSION}-1_amd64.deb" +#dpkg -i "/tmp/setup_files/kernel/linux-headers-${KERNEL_VERSION}_${KERNEL_VERSION}-1_amd64.deb" +#apt-get install -f apt-get install -y -qq -o Dpkg::Options::="--force-confdef" -o Dpkg::Options::="--force-confold" \ - ubuntu-standard \ - casper \ - lupin-casper \ - discover \ - laptop-detect \ - os-prober \ - network-manager \ - resolvconf \ - net-tools \ - wireless-tools \ - wpagui \ - locales \ - linux-image-5.6.4-mbp \ - linux-headers-5.6.4-mbp + ubuntu-standard \ + casper \ + lupin-casper \ + discover \ + laptop-detect \ + os-prober \ + network-manager \ + resolvconf \ + net-tools \ + wireless-tools \ + wpagui \ + locales \ + initramfs-tools \ + binutils \ + linux-generic \ + "linux-image-${KERNEL_VERSION}" \ + "linux-headers-${KERNEL_VERSION}" +# linux-headers-generic - -echo >&2 "===]> Info: Install Graphical installer... "; +echo >&2 "===]> Info: Install window manager... " apt-get install -y -qq -o Dpkg::Options::="--force-confdef" -o Dpkg::Options::="--force-confold" \ - ubiquity \ - ubiquity-casper \ - ubiquity-frontend-gtk \ - ubiquity-slideshow-ubuntu \ - ubiquity-ubuntu-artwork + plymouth-theme-ubuntu-logo \ + ubuntu-desktop-minimal \ + ubuntu-gnome-wallpapers - -echo >&2 "===]> Info: Install window manager... "; +echo >&2 "===]> Info: Install Graphical installer... " 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 + ubiquity \ + ubiquity-casper \ + ubiquity-frontend-gtk \ + ubiquity-slideshow-ubuntu \ + ubiquity-ubuntu-artwork - -echo >&2 "===]> Info: Install useful applications... "; +echo >&2 "===]> Info: Install useful applications... " apt-get install -y -qq -o Dpkg::Options::="--force-confdef" -o Dpkg::Options::="--force-confold" \ - git \ - curl \ - nano \ - gcc \ - make \ - dracut + git \ + curl \ + nano \ + make \ + gcc -echo >&2 "===]> Info: Add custom drivers... "; +echo >&2 "===]> Info: Change initramfs format (for grub)... " +sed -i "s/COMPRESS=lz4/COMPRESS=gzip/g" "/etc/initramfs-tools/initramfs.conf" -KERNEL_VERSION=5.6.4-mbp -BCE_DRIVER_GIT_URL=https://github.com/MCMrARM/mbp2018-bridge-drv.git -BCE_DRIVER_BRANCH_NAME=master -BCE_DRIVER_COMMIT_HASH=b43fcc069da73e051072fde24af4014c9c487286 +echo >&2 "===]> Info: Add drivers... " + +APPLE_BCE_DRIVER_GIT_URL=https://github.com/aunali1/mbp2018-bridge-drv.git +APPLE_BCE_DRIVER_BRANCH_NAME=aur +APPLE_BCE_DRIVER_COMMIT_HASH=c884d9ca731f2118a58c28bb78202a0007935998 APPLE_IB_DRIVER_GIT_URL=https://github.com/roadrunner2/macbook12-spi-driver.git APPLE_IB_DRIVER_BRANCH_NAME=mbp15 APPLE_IB_DRIVER_COMMIT_HASH=90cea3e8e32db60147df8d39836bd1d2a5161871 mkdir -p /opt/drivers -mkdir -p "/lib/modules/${KERNEL_VERSION}/extra" +mkdir -p "/lib/modules/${KERNEL_VERSION}/kernel/drivers" -git clone --single-branch --branch ${BCE_DRIVER_BRANCH_NAME} ${BCE_DRIVER_GIT_URL} /opt/drivers/bce -git -C /opt/drivers/bce/ checkout ${BCE_DRIVER_COMMIT_HASH} -PATH=/usr/share/Modules/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/root/bin make -C /lib/modules/${KERNEL_VERSION}/build/ M=/opt/drivers/bce modules +printf '\nblacklist thunderbolt' >>/etc/modprobe.d/blacklist.conf -git clone --single-branch --branch ${APPLE_IB_DRIVER_BRANCH_NAME} ${APPLE_IB_DRIVER_GIT_URL} /opt/drivers/touchbar -git -C /opt/drivers/touchbar/ checkout ${APPLE_IB_DRIVER_COMMIT_HASH} -PATH=/usr/share/Modules/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/root/bin make -C /lib/modules/${KERNEL_VERSION}/build/ M=/opt/drivers/touchbar modules +git clone --single-branch --branch ${APPLE_BCE_DRIVER_BRANCH_NAME} ${APPLE_BCE_DRIVER_GIT_URL} \ + /opt/drivers/apple-bce +git -C /opt/drivers/apple-bce/ checkout "${APPLE_BCE_DRIVER_COMMIT_HASH}" +PATH=/usr/share/Modules/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/root/bin \ + make -C /lib/modules/"${KERNEL_VERSION}"/build/ M=/opt/drivers/apple-bce modules +cp -rf /opt/drivers/apple-bce/*.ko /lib/modules/"${KERNEL_VERSION}"/kernel/drivers/ +printf '\n# apple-bce\nhid-apple\nbcm5974\nsnd-seq\napple-bce' >>/etc/modules-load.d/apple-bce.conf +printf '\n# apple-bce\nhid-apple\nsnd-seq\napple-bce' >>/etc/initramfs-tools/modules -cp -rf /opt/drivers/bce/*.ko /lib/modules/${KERNEL_VERSION}/extra/ -cp -rf /opt/drivers/touchbar/*.ko /lib/modules/${KERNEL_VERSION}/extra/ +git clone --single-branch --branch ${APPLE_IB_DRIVER_BRANCH_NAME} ${APPLE_IB_DRIVER_GIT_URL} \ + /opt/drivers/applespi +git -C /opt/drivers/applespi/ checkout "${APPLE_IB_DRIVER_COMMIT_HASH}" +PATH=/usr/share/Modules/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/root/bin \ + make -C /lib/modules/"${KERNEL_VERSION}"/build/ M=/opt/drivers/applespi modules +printf '\n# applespi\napple_ibridge\napple_ib_tb\napple_ib_als' >>/etc/modules-load.d/applespi.conf +#printf "\n# applespi\napplespi\nspi_pxa2xx_platform\nintel_lpss_pci" >> /etc/initramfs-tools/modules +cp -rf /opt/drivers/applespi/*.ko /lib/modules/"${KERNEL_VERSION}"/kernel/drivers/ -### Add custom drivers to be loaded at boot -echo -e 'hid-apple\nbcm5974\nsnd-seq\nbce\napple_ibridge\napple_ib_tb' > /etc/modules-load.d/bce.conf -echo -e 'blacklist thunderbolt' > /etc/modprobe.d/blacklist.conf -echo -e 'add_drivers+="hid_apple snd-seq bce"\nforce_drivers+="hid_apple snd-seq bce"' > /etc/dracut.conf -/usr/sbin/depmod -a ${KERNEL_VERSION} -dracut -f /boot/initramfs-$KERNEL_VERSION.img $KERNEL_VERSION +rm -rf /opt/drivers -### Copy audio config files +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}" + +## Copy audio config files mkdir -p /usr/share/alsa/cards/ mv -fv /tmp/setup_files/audio/AppleT2.conf /usr/share/alsa/cards/AppleT2.conf mv -fv /tmp/setup_files/audio/apple-t2.conf /usr/share/pulseaudio/alsa-mixer/profile-sets/apple-t2.conf mv -fv /tmp/setup_files/audio/91-pulseaudio-custom.rules /usr/lib/udev/rules.d/91-pulseaudio-custom.rules -echo >&2 "===]> Info: Remove unused applications ... "; +echo >&2 "===]> Info: Remove unused applications ... " apt-get purge -y -qq \ - transmission-gtk \ - transmission-common \ - gnome-mahjongg \ - gnome-mines \ - gnome-sudoku \ - aisleriot \ - hitori\ - linux-headers-5.6.4-mbp \ - dracut + transmission-gtk \ + transmission-common \ + gnome-mahjongg \ + gnome-mines \ + gnome-sudoku \ + aisleriot \ + hitori \ + xiterm+thai \ + firefox \ + make \ + gcc \ + vim \ + binutils +# \ +# initramfs-tools +# "linux-headers-${KERNEL_VERSION}" apt-get autoremove -y -echo >&2 "===]> Info: Reconfigure environment ... "; +echo >&2 "===]> Info: Reconfigure environment ... " locale-gen --purge en_US.UTF-8 en_US -echo -e 'LANG="C.UTF-8"\nLANGUAGE="C.UTF-8"\n' > /etc/default/locale +printf 'LANG="C.UTF-8"\nLANGUAGE="C.UTF-8"\n' >/etc/default/locale dpkg-reconfigure -f readline resolvconf -cat < /etc/NetworkManager/NetworkManager.conf +cat </etc/NetworkManager/NetworkManager.conf [main] rc-manager=resolvconf plugins=ifupdown,keyfile @@ -162,8 +180,7 @@ managed=false EOF dpkg-reconfigure network-manager - -echo >&2 "===]> Info: Cleanup the chroot environment... "; +echo >&2 "===]> Info: Cleanup the chroot environment... " truncate -s 0 /etc/machine-id rm /sbin/initctl @@ -171,7 +188,6 @@ dpkg-divert --rename --remove /sbin/initctl apt-get clean rm -rf /tmp/* ~/.bash_history rm -rf /tmp/setup_files -rm -rf /opt/drivers umount -lf /dev/pts umount -lf /sys diff --git a/files/grub/grub.cfg b/files/grub/grub.cfg index b2df726..58596ec 100644 --- a/files/grub/grub.cfg +++ b/files/grub/grub.cfg @@ -6,50 +6,16 @@ insmod all_video set default="0" set timeout=30 -menuentry "Try Ubuntu FS without installing" { - linux /casper/vmlinuz boot=casper file=/cdrom/preseed/ubuntu.seed quiet splash --- - initrd /casper/initrd +menuentry "Try Ubuntu 1 FS without installing" { + linux /casper/vmlinuz boot=casper ro enforcing=0 efi=noruntime pcie_ports=compat + initrd /casper/initrd } -menuentry "Try Ubuntu without installing (safe graphics)" { - set gfxpayload=keep - linux /casper/vmlinuz boot=casper file=/cdrom/preseed/ubuntu.seed quiet splash nomodeset --- - initrd /casper/initrd -} - menuentry "Install Ubuntu FS" { - linux /casper/vmlinuz boot=casper file=/cdrom/preseed/ubuntu.seed only-ubiquity quiet splash --- - initrd /casper/initrd -} - -menuentry "Install Ubuntu FS (safe graphics)" { - set gfxpayload=keep - linux /casper/vmlinuz boot=casper file=/cdrom/preseed/ubuntu.seed only-ubiquity quiet splash --- - initrd /casper/initrd + linux /casper/vmlinuz boot=casper only-ubiquity quiet splash + initrd /casper/initrd } menuentry "Check disc for defects" { - linux /casper/vmlinuz boot=casper integrity-check quiet splash --- - initrd /casper/initrd + linux /casper/vmlinuz boot=casper integrity-check quiet splash --- + initrd /casper/initrd } - -menuentry "Test memory Memtest86+ (BIOS)" { - linux16 /install/memtest86+ -} - -menuentry "Test memory Memtest86 (UEFI, long load time)" { - insmod part_gpt - insmod search_fs_uuid - insmod chain - loopback loop /install/memtest86 - chainloader (loop,gpt1)/efi/boot/BOOTX64.efi -} - -grub_platform -if [ "$grub_platform" = "efi" ]; then -menuentry 'Boot from next volume' { - exit -} -menuentry 'UEFI Firmware Settings' { - fwsetup -} -fi \ No newline at end of file diff --git a/files/isohdpfx.bin b/files/isohdpfx.bin new file mode 100644 index 0000000..a87faf5 Binary files /dev/null and b/files/isohdpfx.bin differ diff --git a/files/preseed/cli.seed b/files/preseed/cli.seed deleted file mode 100644 index f8a57e2..0000000 --- a/files/preseed/cli.seed +++ /dev/null @@ -1,5 +0,0 @@ -# Only install the standard system and language packs. -tasksel tasksel/first multiselect -d-i pkgsel/language-pack-patterns string -# No language support packages. -d-i pkgsel/install-language-support boolean false diff --git a/files/preseed/finisher.sh b/files/preseed/finisher.sh new file mode 100644 index 0000000..d93a486 --- /dev/null +++ b/files/preseed/finisher.sh @@ -0,0 +1,35 @@ +#KERNEL_VERSION=5.4.0-25-generic +#APPLE_BCE_DRIVER_GIT_URL=https://github.com/aunali1/mbp2018-bridge-drv.git +#APPLE_BCE_DRIVER_BRANCH_NAME=aur +#APPLE_BCE_DRIVER_COMMIT_HASH=c884d9ca731f2118a58c28bb78202a0007935998 +#APPLE_IB_DRIVER_GIT_URL=https://github.com/roadrunner2/macbook12-spi-driver.git +#APPLE_IB_DRIVER_BRANCH_NAME=mbp15 +#APPLE_IB_DRIVER_COMMIT_HASH=90cea3e8e32db60147df8d39836bd1d2a5161871 +# +#mkdir -p /opt/drivers +#mkdir -p "/lib/modules/${KERNEL_VERSION}/extra" +# +#git clone --single-branch --branch ${APPLE_BCE_DRIVER_BRANCH_NAME} ${APPLE_BCE_DRIVER_GIT_URL} /opt/drivers/apple-bce +#git -C /opt/drivers/apple-bce/ checkout ${APPLE_BCE_DRIVER_COMMIT_HASH} +#PATH=/usr/share/Modules/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/root/bin make -C /lib/modules/${KERNEL_VERSION}/build/ M=/opt/drivers/apple-bce modules +# +#git clone --single-branch --branch ${APPLE_IB_DRIVER_BRANCH_NAME} ${APPLE_IB_DRIVER_GIT_URL} /opt/drivers/touchbar +#git -C /opt/drivers/touchbar/ checkout ${APPLE_IB_DRIVER_COMMIT_HASH} +#PATH=/usr/share/Modules/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/root/bin make -C /lib/modules/${KERNEL_VERSION}/build/ M=/opt/drivers/touchbar modules +# +#cp -rf /opt/drivers/apple-bce/*.ko /lib/modules/${KERNEL_VERSION}/extra/ +#cp -rf /opt/drivers/touchbar/*.ko /lib/modules/${KERNEL_VERSION}/extra/ +# +#### Add custom drivers to be loaded at boot +#echo -e 'hid-apple\nbcm5974\nsnd-seq\nbce\napple_ibridge\napple_ib_tb' > /etc/modules-load.d/apple-bce.conf +#echo -e 'blacklist thunderbolt' > /etc/modprobe.d/blacklist.conf +#echo -e 'add_drivers+="hid_apple snd-seq apple-bce"\nforce_drivers+="hid_apple snd-seq apple-bce"' > /etc/dracut.conf +#/usr/sbin/depmod -a ${KERNEL_VERSION} +#ls -la /boot/ +#dracut -f /boot/initramfs-$KERNEL_VERSION.img $KERNEL_VERSION +# +### Copy audio config files +#mkdir -p /usr/share/alsa/cards/ +#mv -fv /tmp/setup_files/audio/AppleT2.conf /usr/share/alsa/cards/AppleT2.conf +#mv -fv /tmp/setup_files/audio/apple-t2.conf /usr/share/pulseaudio/alsa-mixer/profile-sets/apple-t2.conf +#mv -fv /tmp/setup_files/audio/91-pulseaudio-custom.rules /usr/lib/udev/rules.d/91-pulseaudio-custom.rules diff --git a/files/preseed/ltsp.seed b/files/preseed/ltsp.seed deleted file mode 100644 index bc26a91..0000000 --- a/files/preseed/ltsp.seed +++ /dev/null @@ -1,11 +0,0 @@ -# Build an LTSP client chroot. -d-i anna/choose_modules string ltsp-client-builder -d-i ltsp-client-builder/run boolean true -# Enable extras.ubuntu.com. -d-i apt-setup/extras boolean true -# Install the Ubuntu desktop and LTSP server. -tasksel tasksel/first multiselect ubuntu-desktop -d-i pkgsel/include/install-recommends boolean true -d-i pkgsel/include string ltsp-server-standalone openssh-server -# Build a client chroot. -d-i preseed/late_command string chroot /target /usr/sbin/ltsp-update-sshkeys diff --git a/files/preseed/ubuntu.seed b/files/preseed/ubuntu.seed index 8ee3dc1..c216e19 100644 --- a/files/preseed/ubuntu.seed +++ b/files/preseed/ubuntu.seed @@ -1,9 +1,12 @@ # Enable extras.ubuntu.com. d-i apt-setup/extras boolean true # Install the Ubuntu desktop. -tasksel tasksel/first multiselect ubuntu-desktop +tasksel tasksel/first multiselect ubuntu-desktop-minimal # On live DVDs, don't spend huge amounts of time removing substantial # application packages pulled in by language packs. Given that we clearly # have the space to include them on the DVD, they're useful and we might as # well keep them installed. ubiquity ubiquity/keep-installed string icedtea6-plugin openoffice.org + + +#d-i preseed/late_command string cp /cdrom/pressed/finisher.sh /target/root/; chroot /target chmod +x /root/finisher.sh; chroot /target bash /root/finisher.sh diff --git a/prepare_iso.sh b/prepare_iso.sh new file mode 100755 index 0000000..b5da0ea --- /dev/null +++ b/prepare_iso.sh @@ -0,0 +1,36 @@ +#!/bin/bash +set -eu -o pipefail + +echo >&2 "===]> Info: Create ISO Image for a LiveCD... " +cd "${IMAGE_PATH}" + +### Create a grub UEFI image +grub-mkstandalone \ + --format=x86_64-efi \ + --output=isolinux/BOOTx64.EFI \ + --locales="" \ + --fonts="" \ + "boot/grub/grub.cfg=isolinux/grub.cfg" + +### Create a FAT16 UEFI boot disk image containing the EFI bootloader +( + cd isolinux && + dd if=/dev/zero of=efiboot.img bs=1M count=10 && + mkfs.vfat efiboot.img && + LC_CTYPE=C mmd -i efiboot.img EFI EFI/BOOT && + LC_CTYPE=C mcopy -i efiboot.img ./BOOTx64.EFI ::EFI/BOOT/ +) + +### Create a grub BIOS image +grub-mkstandalone \ + --format=i386-pc \ + --output=isolinux/core.img \ + --install-modules="linux16 linux normal iso9660 biosdisk memdisk search tar ls" \ + --modules="linux16 linux normal iso9660 biosdisk search" \ + --locales="" \ + --fonts="" \ + "boot/grub/grub.cfg=isolinux/grub.cfg" + +### Combine a bootable grub cdboot.img +cat "${CHROOT_PATH}/usr/lib/grub/i386-pc/cdboot.img" "${IMAGE_PATH}/isolinux/core.img" \ + >"${IMAGE_PATH}/isolinux/bios.img"