diff --git a/README.md b/README.md index 73e8669..da5ea1c 100644 --- a/README.md +++ b/README.md @@ -1,33 +1,72 @@ # 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 +The ISO in from this repo should allow you to install ubuntu without using an external keyboard or mouse on a MacBook Pro 16,1. It work in my MacBook Pro 16,1. [![Build Status](https://travis-ci.com/marcosfad/mbp-ubuntu.svg?branch=master)](https://travis-ci.com/marcosfad/mbp-ubuntu) +**If this repo helped you in any way, consider inviting a coffee to the people in the [credits](https://github.com/marcosfad/mbp-ubuntu#credits) or [me](https://paypal.me/marcosfad)** + UBUNTU 20.04 ISO with Apple T2 patches built-in (Macbooks produced >= 2018). -All available Apple T2 drivers are integrated with this iso. +Apple T2 drivers are integrated with this iso. -This repo is a rework of https://github.com/mikeeq/mbp-fedora +This repo is a rework of the great work done by [@mikeeq](https://github.com/mikeeq/mbp-fedora) -Most things should be work, besides those mentioned in [not working section](#not-working). +I'm using the Kernel from - -Kernel - +Using additional drivers: +- [Apple T2 (apple-bce) (audio, keyboard, touchpad)](https://github.com/MCMrARM/mbp2018-bridge-drv) +- [Touchbar (apple-ibridge, apple-ib-tb, apple-ib-als)](https://github.com/roadrunner2/macbook12-spi-driver/tree/mbp15) -Drivers you should use: -- Apple T2 (apple-bce) (audio, keyboard, touchpad) - -- Touchbar (apple-ibridge, apple-ib-tb, apple-ib-als) - +Bootloader is configure correctly out of the box. No workaround needed. +**IF YOU UPDATE THE KERNEL, REMEMBER TO ADD THE REQUIRED DRIVERS AGAIN.** +Check to see how it is done. + +## Installation + +1. Reduce the size of the mac partition in MacOS +2. Download ISO file from releases. +3. Copy it to a USB using dd (or gdd if installed over brew): +```bash +diskutil list # found which number has the USB +diskutil umountDisk /dev/diskX +sudo gdd bs=4M if=ubuntu-20.04-5.6.10-mbp.iso of=/dev/diskX conv=fdatasync status=progress +``` +4. Boot in Recovery mode and allow booting unknown OS +5. Restart and immediately press the option key until the Logo come up +6. Select "EFI Boot" (the third option was the one that worked for me) +7. Launch Ubuntu Live +8. Use Ubiquity to install (just click on it) +9. Select the options that work for you and use for the partition the following setup: + * Leave the efi boot as preselected by the installer. Your Mac will keep on working with out problems. + * Add a ext4 partition and mounted as /boot (1024MB) + * Add a ext4 partition and monted as / (rest) +10. Run the installer (In my case it had some problem removing some packages at the end, but this is no real problem) +11. Shutdown and remove the USB Drive +12. Start again using the option key. Select the new efi boot. +13. Enjoy. + +## Configuration + +- Put wifi firmware files to `/lib/firmware/brcm/` + - tutorial - + - this is not working with MBP 16,1 +- 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 ` + - see https://askubuntu.com/questions/149876/how-can-i-install-one-language-by-command-line +- 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 +``` +- I switch the touchbar to show f* by default. If you like another configuration, change /etc/modprobe.d/apple-tb.conf or remove it. +- To update grub, run: `grub-mkconfig -o /boot/grub/grub.cfg` + +## Know issues + +- Sound is not working after the install. Follow the instructions detailed by @kevineinarsson: +- Checksum is failing for 2 files: md5sum.txt and /boot/grub/bios.img ## Not working (Following the mikeeq/mbp-fedora) @@ -38,15 +77,12 @@ Drivers you should use: ## TODO -- Tests -- Check installer. +- ISO is using gzip initramfs. It would be great to change it lz4 +- Optimize the software installed. ## Known issues (Following the mikeeq/mbp-fedora) - Kernel/Mac related issues are mentioned in kernel repo - -- Macbooks with Apple T2 can't boot EFI binaries from HFS+ formatted ESP - only FAT32 (FAT32 have to be labelled as msftdata). - - `ctrl+x` is not working in GRUB, so if you are trying to change kernel parameters - start your OS by clicking `ctrl+shift+f10` on external keyboard ## Docs diff --git a/build.sh b/build.sh index 9aa94d6..7131760 100755 --- a/build.sh +++ b/build.sh @@ -1,12 +1,12 @@ #!/bin/bash set -eu -o pipefail -ROOT_PATH=$(pwd) -WORKING_PATH=/root/work -CHROOT_PATH="${WORKING_PATH}/chroot" -IMAGE_PATH="${WORKING_PATH}/image" +export ROOT_PATH=$(pwd) +export WORKING_PATH=/root/work +export CHROOT_PATH="${WORKING_PATH}/chroot" +export IMAGE_PATH="${WORKING_PATH}/image" #KERNEL_VERSION=5.4.0-26-generic -KERNEL_VERSION=5.6.7-mbp +export KERNEL_VERSION=5.6.10-mbp if [ -d "$WORKING_PATH" ]; then rm -rf "$WORKING_PATH" @@ -27,8 +27,7 @@ apt-get install -y -qq -o Dpkg::Options::="--force-confdef" -o Dpkg::Options::=" dosfstools \ zip \ isolinux \ - syslinux \ - lz4 + syslinux echo >&2 "===]> Info: Build Ubuntu FS... " /bin/bash -c " diff --git a/build_file_system.sh b/build_file_system.sh index 5ae8f00..d1dc8fe 100755 --- a/build_file_system.sh +++ b/build_file_system.sh @@ -13,7 +13,7 @@ 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" +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... " @@ -21,3 +21,21 @@ echo >&2 "===]> Info: Cleanup the chroot environment... " #umount "${CHROOT_PATH}/run" umount "${CHROOT_PATH}/dev" + +## Copy audio config files +echo >&2 "===]> Info: Copy audio config files... " +mkdir -p "${CHROOT_PATH}"/usr/share/alsa/cards/ +cp -fv "${ROOT_PATH}"/files/audio/AppleT2.conf "${CHROOT_PATH}"/usr/share/alsa/cards/AppleT2.conf +cp -fv "${ROOT_PATH}"/files/audio/apple-t2.conf "${CHROOT_PATH}"/usr/share/pulseaudio/alsa-mixer/profile-sets/apple-t2.conf +cp -fv "${ROOT_PATH}"/files/audio/91-pulseaudio-custom.rules "${CHROOT_PATH}"/usr/lib/udev/rules.d/91-pulseaudio-custom.rules + + +### Copy grub config without finding macos partition +echo >&2 "===]> Info: Patch Grub... " +cp -rfv "${ROOT_PATH}"/files/grub/30_os-prober "${CHROOT_PATH}"/etc/grub.d/30_os-prober +chmod 755 "${CHROOT_PATH}"/etc/grub.d/30_os-prober + +### Copy suspend fix +echo >&2 "===]> Info: Fix suspend... " +cp -rfv "${ROOT_PATH}"/files/suspend/rmmod_tb.sh ${CHROOT_PATH}/lib/systemd/system-sleep/rmmod_tb.sh +chmod +x ${CHROOT_PATH}/lib/systemd/system-sleep/rmmod_tb.sh diff --git a/build_image.sh b/build_image.sh index 1e123d1..5a8f388 100755 --- a/build_image.sh +++ b/build_image.sh @@ -11,15 +11,12 @@ 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 -r "${ROOT_PATH}"/files/preseed "${IMAGE_PATH}"/preseed 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... " @@ -33,7 +30,7 @@ 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' +REMOVE='ubiquity casper lupin-casper user-setup discover discover-data os-prober laptop-detect' for i in $REMOVE; do sed -i "/${i}/d" "${IMAGE_PATH}"/casper/filesystem.manifest-desktop done diff --git a/create_iso.sh b/create_iso.sh index fa92aac..e039b74 100755 --- a/create_iso.sh +++ b/create_iso.sh @@ -10,14 +10,14 @@ echo >&2 "===]> Info: Create Isolinux... " xorriso -as mkisofs \ -iso-level 3 \ -full-iso9660-filenames \ - -volid "Ubuntu 20.04 LTS MBP" \ + -volid "UBUNTU_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" \ + --grub2-mbr "/usr/lib/grub/i386-pc/boot_hybrid.img" \ -eltorito-alt-boot \ -e "EFI/efiboot.img" \ -no-emul-boot \ diff --git a/files/chroot_build.sh b/files/chroot_build.sh index eae02d3..e725502 100755 --- a/files/chroot_build.sh +++ b/files/chroot_build.sh @@ -44,11 +44,9 @@ ln -s /bin/true /sbin/initctl 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 \ + sudo \ casper \ lupin-casper \ discover \ @@ -63,16 +61,19 @@ apt-get install -y -qq -o Dpkg::Options::="--force-confdef" -o Dpkg::Options::=" initramfs-tools \ binutils \ linux-generic \ + grub-efi-amd64-signed \ "linux-image-${KERNEL_VERSION}" \ - "linux-headers-${KERNEL_VERSION}" -# linux-headers-generic + "linux-headers-${KERNEL_VERSION}" \ + intel-microcode \ + thermald 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 + ubuntu-gnome-wallpapers \ + snapd echo >&2 "===]> Info: Install Graphical installer... " @@ -124,7 +125,7 @@ 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 +printf '\n# display f* key in touchbar\noptions apple-ib-tb fnmode=2\n' >> /etc/modprobe.d/apple-tb.conf cp -rf /opt/drivers/applespi/*.ko /lib/modules/"${KERNEL_VERSION}"/kernel/drivers/ rm -rf /opt/drivers @@ -135,12 +136,6 @@ echo >&2 "===]> Info: Update initramfs... " /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 ... " apt-get purge -y -qq \ @@ -156,10 +151,15 @@ apt-get purge -y -qq \ make \ gcc \ vim \ - binutils -# \ -# initramfs-tools -# "linux-headers-${KERNEL_VERSION}" + binutils \ + linux-generic \ + linux-headers-5.4.0-28 \ + linux-headers-5.4.0-28-generic \ + linux-headers-generic \ + linux-image-5.4.0-28-generic \ + linux-image-generic \ + linux-modules-5.4.0-28-generic \ + linux-modules-extra-5.4.0-28-generic apt-get autoremove -y diff --git a/files/grub/30_os-prober b/files/grub/30_os-prober new file mode 100644 index 0000000..1ec418d --- /dev/null +++ b/files/grub/30_os-prober @@ -0,0 +1,326 @@ +#!/usr/bin/sh +set -e + +# grub-mkconfig helper script. +# Copyright (C) 2006,2007,2008,2009 Free Software Foundation, Inc. +# +# GRUB is free software: you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. +# +# GRUB is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with GRUB. If not, see . + +prefix="/usr" +exec_prefix="/usr" +datarootdir="/usr/share" + +export TEXTDOMAIN=grub +export TEXTDOMAINDIR="${datarootdir}/locale" + +. "$pkgdatadir/grub-mkconfig_lib" + +if [ "x${GRUB_DISABLE_OS_PROBER}" = "xtrue" ]; then + exit 0 +fi + +if [ -z "`which os-prober 2> /dev/null`" ] || [ -z "`which linux-boot-prober 2> /dev/null`" ] ; then + # missing os-prober and/or linux-boot-prober + exit 0 +fi + +OSPROBED="`os-prober | tr ' ' '^' | paste -s -d ' '`" +if [ -z "${OSPROBED}" ] ; then + # empty os-prober output, nothing doing + exit 0 +fi + +osx_entry() { + found_other_os=1 + # TRANSLATORS: it refers on the OS residing on device %s + onstr="$(gettext_printf "(on %s)" "${DEVICE}")" + hints="" + for hint in `"${grub_probe}" --device ${device} --target=efi_hints 2> /dev/null` ; do + hints="${hints} --hint=${hint}" + done + cat << EOF +menuentry '$(echo "${LONGNAME} $onstr" | grub_quote)' --class osx --class darwin --class os \$menuentry_id_option 'osprober-xnu-$2-$(grub_get_device_id "${DEVICE}")' { +EOF + save_default_entry | grub_add_tab + prepare_grub_to_access_device ${DEVICE} | grub_add_tab + cat << EOF + set gfxpayload=keep + load_video + insmod part_gpt + insmod hfsplus + search --no-floppy --fs-uuid --set=root ${hints} $(grub_get_device_id "${DEVICE}") + chainloader (\$root)/System/Library/CoreServices/boot.efi + boot +} +EOF +} + +used_osprober_linux_ids= + +for OS in ${OSPROBED} ; do + DEVICE="`echo ${OS} | cut -d ':' -f 1`" + LONGNAME="`echo ${OS} | cut -d ':' -f 2 | tr '^' ' '`" + LABEL="`echo ${OS} | cut -d ':' -f 3 | tr '^' ' '`" + BOOT="`echo ${OS} | cut -d ':' -f 4`" + if UUID="`${grub_probe} --target=fs_uuid --device ${DEVICE%@*}`"; then + EXPUUID="$UUID" + + if [ x"${DEVICE#*@}" != x ] ; then + EXPUUID="${EXPUUID}@${DEVICE#*@}" + fi + + if [ "x${GRUB_OS_PROBER_SKIP_LIST}" != "x" ] && [ "x`echo ${GRUB_OS_PROBER_SKIP_LIST} | grep -i -e '\b'${EXPUUID}'\b'`" != "x" ] ; then + echo "Skipped ${LONGNAME} on ${DEVICE} by user request." >&2 + continue + fi + fi + + BTRFS="`echo ${OS} | cut -d ':' -f 5`" + if [ "x$BTRFS" = "xbtrfs" ]; then + BTRFSuuid="`echo ${OS} | cut -d ':' -f 6`" + BTRFSsubvol="`echo ${OS} | cut -d ':' -f 7`" + fi + + if [ -z "${LONGNAME}" ] ; then + LONGNAME="${LABEL}" + fi + + # os-prober returns text string followed by optional counter + 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')" + + gettext_printf "Found %s on %s\n" "${LONGNAME}" "${DEVICE}" >&2 + + case ${BOOT} in + chain) + found_other_os=1 + + onstr="$(gettext_printf "(on %s)" "${DEVICE}")" + cat << EOF +menuentry '$(echo "${LONGNAME} $onstr" | grub_quote)' $CLASS --class os \$menuentry_id_option 'osprober-chain-$(grub_get_device_id "${DEVICE}")' { +EOF + save_default_entry | grub_add_tab + prepare_grub_to_access_device ${DEVICE} | grub_add_tab + + if [ x"`${grub_probe} --device ${DEVICE} --target=partmap`" = xmsdos ]; then + cat << EOF + parttool \${root} hidden- +EOF + fi + + case ${LONGNAME} in + Windows\ Vista*|Windows\ 7*|Windows\ Server\ 2008*) + ;; + *) + cat << EOF + drivemap -s (hd0) \${root} +EOF + ;; + esac + + cat < /dev/null; do + counter=$((counter+1)); + done + if [ -z "$boot_device_id" ]; then + boot_device_id="$(grub_get_device_id "${DEVICE}")" + fi + used_osprober_linux_ids="$used_osprober_linux_ids 'osprober-gnulinux-$LKERNEL-${recovery_params}-$counter-$boot_device_id'" + + if [ -z "${prepare_boot_cache}" ]; then + prepare_boot_cache="$(prepare_grub_to_access_device ${LBOOT} | grub_add_tab)" + fi + + if [ "x$is_top_level" = xtrue ] && [ "x${GRUB_DISABLE_SUBMENU}" != xy ]; then + cat << EOF +menuentry '$(echo "$OS $onstr" | grub_quote)' $CLASS --class gnu-linux --class gnu --class os \$menuentry_id_option 'osprober-gnulinux-simple-$boot_device_id' { +EOF + save_default_entry | grub_add_tab + printf '%s\n' "${prepare_boot_cache}" + cat << EOF + linux ${LKERNEL} ${LPARAMS} +EOF + if [ -n "${LINITRD}" ] ; then + cat << EOF + initrd ${LINITRD} +EOF + fi + cat << EOF +} +EOF + echo "submenu '$(gettext_printf "Advanced options for %s" "${OS} $onstr" | grub_quote)' \$menuentry_id_option 'osprober-gnulinux-advanced-$boot_device_id' {" + is_top_level=false + fi + title="${LLABEL} $onstr" + cat << EOF + menuentry '$(echo "$title" | grub_quote)' --class gnu-linux --class gnu --class os \$menuentry_id_option 'osprober-gnulinux-$LKERNEL-${recovery_params}-$boot_device_id' { +EOF + save_default_entry | sed -e "s/^/$grub_tab$grub_tab/" + printf '%s\n' "${prepare_boot_cache}" | grub_add_tab + cat << EOF + linux ${LKERNEL} ${LPARAMS} +EOF + if [ -n "${LINITRD}" ] ; then + cat << EOF + initrd ${LINITRD} +EOF + fi + cat << EOF + } +EOF + if [ x"$title" = x"$GRUB_ACTUAL_DEFAULT" ] || [ x"Previous Linux versions>$title" = x"$GRUB_ACTUAL_DEFAULT" ]; then + replacement_title="$(echo "Advanced options for ${OS} $onstr" | sed 's,>,>>,g')>$(echo "$title" | sed 's,>,>>,g')" + quoted="$(echo "$GRUB_ACTUAL_DEFAULT" | grub_quote)" + title_correction_code="${title_correction_code}if [ \"x\$default\" = '$quoted' ]; then default='$(echo "$replacement_title" | grub_quote)'; fi;" + 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")" + fi + done + if [ x"$is_top_level" != xtrue ]; then + echo '}' + fi + echo "$title_correction_code" + ;; + macosx) + # for subdevice in ${DEVICE%[[:digit:]]*}* ; do + # parttype="`"${grub_probe}" --device ${device} --target=gpt_parttype "${subdevice}" 2> /dev/null`" + # if [[ "$parttype" = "426f6f74-0000-11aa-aa11-00306543ecac" ]]; then + # DEVICE="${subdevice}" osx_entry + # fi + # done + ;; + hurd) + found_other_os=1 + onstr="$(gettext_printf "(on %s)" "${DEVICE}")" + cat << EOF +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}")' { +EOF + save_default_entry | grub_add_tab + prepare_grub_to_access_device ${DEVICE} | grub_add_tab + grub_device="`${grub_probe} --device ${DEVICE} --target=drive`" + mach_device="`echo "${grub_device}" | sed -e 's/(\(hd.*\),msdos\(.*\))/\1s\2/'`" + grub_fs="`${grub_probe} --device ${DEVICE} --target=fs`" + case "${grub_fs}" in + *fs) hurd_fs="${grub_fs}" ;; + *) hurd_fs="${grub_fs}fs" ;; + esac + cat << EOF + multiboot /boot/gnumach.gz root=device:${mach_device} + module /hurd/${hurd_fs}.static ${hurd_fs} --readonly \\ + --multiboot-command-line='\${kernel-command-line}' \\ + --host-priv-port='\${host-port}' \\ + --device-master-port='\${device-port}' \\ + --exec-server-task='\${exec-task}' -T typed '\${root}' \\ + '\$(task-create)' '\$(task-resume)' + module /lib/ld.so.1 exec /hurd/exec '\$(exec-task=task-create)' +} +EOF + ;; + minix) + found_other_os=1 + cat << EOF +menuentry "${LONGNAME} (on ${DEVICE}, Multiboot)" { +EOF + save_default_entry | sed -e "s/^/\t/" + prepare_grub_to_access_device ${DEVICE} | sed -e "s/^/\t/" + cat << EOF + multiboot /boot/image_latest +} +EOF + ;; + *) + case ${DEVICE} in + *.efi) + cat << EOF +menuentry '$(echo "${LONGNAME}" | grub_quote)' { +EOF + save_default_entry | grub_add_tab + cat << EOF + chainloader /EFI/${DEVICE} + boot +} +EOF + ;; + *) + echo -n " " + # TRANSLATORS: %s is replaced by OS name. + gettext_printf "%s is not yet supported by grub-mkconfig.\n" "${LONGNAME}" >&2 + ;; + esac + esac +done + +# We override the results of the menu_auto_hide code here, this is a bit ugly, +# but grub-mkconfig writes out the file linearly, so this is the only way +if [ "${found_other_os}" = "1" ]; then + cat << EOF +# Other OS found, undo autohiding of menu unless menu_auto_hide=2 +if [ "\${orig_timeout_style}" -a "\${menu_auto_hide}" != "2" ]; then + set timeout_style=\${orig_timeout_style} + set timeout=\${orig_timeout} +fi +EOF +fi diff --git a/files/grub/grub.cfg b/files/grub/grub.cfg index 58596ec..b474993 100644 --- a/files/grub/grub.cfg +++ b/files/grub/grub.cfg @@ -6,16 +6,15 @@ insmod all_video set default="0" set timeout=30 -menuentry "Try Ubuntu 1 FS without installing" { - linux /casper/vmlinuz boot=casper ro enforcing=0 efi=noruntime pcie_ports=compat +menuentry "Try Ubuntu FS without installing" { + linux /casper/vmlinuz file=/cdrom/preseed/mbp.seed boot=casper ro quiet splash pcie_ports=compat --- initrd /casper/initrd } menuentry "Install Ubuntu FS" { - linux /casper/vmlinuz boot=casper only-ubiquity quiet splash + linux /casper/vmlinuz preseed/file=/cdrom/preseed/mbp.seed boot=casper only-ubiquity quiet splash pcie_ports=compat --- initrd /casper/initrd } - menuentry "Check disc for defects" { - linux /casper/vmlinuz boot=casper integrity-check quiet splash --- + linux /casper/vmlinuz boot=casper integrity-check quiet splash pcie_ports=compat --- initrd /casper/initrd } diff --git a/files/preseed/finisher.sh b/files/preseed/finisher.sh deleted file mode 100644 index d93a486..0000000 --- a/files/preseed/finisher.sh +++ /dev/null @@ -1,35 +0,0 @@ -#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/mbp.seed b/files/preseed/mbp.seed new file mode 100644 index 0000000..ad96b89 --- /dev/null +++ b/files/preseed/mbp.seed @@ -0,0 +1,11 @@ +# Enable extras.ubuntu.com. +# d-i apt-setup/extra boolean true +# Install the Ubuntu desktop. +# tasksel tasksel/first multiselect ubuntu-desktop +# 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 debian-installer/add-kernel-opts string efi=noruntime pcie_ports=compat loglevel=3 diff --git a/files/preseed/ubuntu.seed b/files/preseed/ubuntu.seed deleted file mode 100644 index c216e19..0000000 --- a/files/preseed/ubuntu.seed +++ /dev/null @@ -1,12 +0,0 @@ -# Enable extras.ubuntu.com. -d-i apt-setup/extras boolean true -# Install the 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/files/suspend/rmmod_tb.sh b/files/suspend/rmmod_tb.sh new file mode 100755 index 0000000..21c3234 --- /dev/null +++ b/files/suspend/rmmod_tb.sh @@ -0,0 +1,6 @@ +#!/bin/sh +if [ "${1}" == "pre" ]; then + modprobe -r apple_ib_tb +elif [ "${1}" == "post" ]; then + modprobe apple_ib_tb +fi diff --git a/prepare_iso.sh b/prepare_iso.sh index b5da0ea..5644107 100755 --- a/prepare_iso.sh +++ b/prepare_iso.sh @@ -32,5 +32,5 @@ grub-mkstandalone \ "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" \ +cat "/usr/lib/grub/i386-pc/cdboot.img" "${IMAGE_PATH}/isolinux/core.img" \ >"${IMAGE_PATH}/isolinux/bios.img"