diff --git a/.dockerignore b/.dockerignore new file mode 100644 index 0000000..6b8710a --- /dev/null +++ b/.dockerignore @@ -0,0 +1 @@ +.git diff --git a/.github/agent-info.sh b/.github/agent-info.sh index de23ad1..db429b2 100755 --- a/.github/agent-info.sh +++ b/.github/agent-info.sh @@ -20,6 +20,10 @@ echo -e '\n' info "Egress Public IP: $(curl -4 -s ifconfig.co)" echo -e '\n' +info "pwd" +pwd +echo -e '\n' + info "df -h" df -h echo -e '\n' diff --git a/Dockerfile b/Dockerfile index 86108bf..86d8c0f 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,4 +1,4 @@ -FROM fedora:34 +FROM fedora:37 RUN dnf upgrade -y \ && dnf install -y \ diff --git a/README.md b/README.md index 613df77..b51bc48 100644 --- a/README.md +++ b/README.md @@ -7,6 +7,7 @@ Fedora ISO with Apple T2 patches built-in (Macbooks produced >= 2018). All available Apple T2 drivers and patches are integrated into this ISO. Kernel: + Kernel patches: > Tested on: Macbook Pro 15,2 13" 2019 i5 TouchBar Z0WQ000AR MV972ZE/A/R1 && Macbook Pro 16,2 13" 2020 i5 @@ -74,28 +75,18 @@ macOS Mojave: 10.14.6 (18G103) ![anaconda partitioning](screenshots/anaconda-3.png) - - There will be an error on `Installing bootloader...` step, click Yes - It's related to `efi=noruntime` kernel arg - - ![bootloader issue](screenshots/bootloader.png) - - ```bash - # /tmp/anaconda.log - 13:39:49,173 INF bootloader.grub2: bootloader.py: used boot args: resume=UUID=8a64abbd-b1a3-4d4a-85c3-b73800e46a1e rd.lvm.lv=fedora_localhost-live/root rd.lvm.lv=fedora_localhost-live/swap rhgb quiet - 13:39:54,649 ERR bootloader.installation: bootloader.write failed: Failed to set new efi boot target. This is most likely a kernel or firmware bug. - ``` - - To install additional languages (only English is available out of the box), install appropriate langpack via dnf `dnf search langpacks`, i.e.: to install Polish language pack execute: `dnf install langpacks-pl` -- After login you can update kernel by running `sudo update_kernel_mbp`, more info here: - You can change mappings of ctrl, 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: ```bash + sudo -i + # /etc/modprobe.d/hid_apple.conf options hid_apple swap_fn_leftctrl=1 options hid_apple swap_opt_cmd=1 - sudo -i - # Refresh grub and dracut config by executing update_kernel_mbp script - update_kernel_mbp + # Refresh dracut (initramfs) + dracut -f ``` - To change function key mappings for models with touchbar see `modinfo apple_ib_tb` and use `echo 2 > /sys/class/input/*/device/fnmode` instead of the `hid_apple` options. See @@ -110,7 +101,7 @@ sudo -i # Upgrade kernel beforehand ## update_kernel_mbp has built-in selfupgrade function, so when it fails it's just due to script update - please rerun everything should be good on second run -KERNEL_VERSION="5.18.6-f36" UPDATE_SCRIPT_BRANCH="v5.18-f36" update_kernel_mbp +KERNEL_VERSION="6.0.5-f37" UPDATE_SCRIPT_BRANCH="v6.0-f37" update_kernel_mbp # Upgrade your OS dnf upgrade -y --refresh @@ -119,7 +110,7 @@ dnf install -y dnf-plugin-system-upgrade # Exclude official kernel from upgrade to not override mbp-fedora-kernel ## If you're trying to upgrade older version of mbp-fedora to latest version, please repeat a process by upgrading only to one major release of Fedora, i.e.: Fedora 33 -> 34, 34 -> 35, 35 -> 36 -FEDORA_VERSION=36 dnf system-upgrade download -y --releasever=${FEDORA_VERSION} --exclude='kernel*' +FEDORA_VERSION=37 dnf system-upgrade download -y --releasever=${FEDORA_VERSION} --exclude='kernel*' # Reboot your Mac dnf system-upgrade reboot @@ -135,42 +126,10 @@ dnf clean all - TouchID - (@MCMrARM is working on it - https://github.com/Dunedan/mbp-2016-linux/issues/71#issuecomment-528545490) - Audio - - Dynamic audio input/output change (on connecting/disconnecting headphones jack) - - manual switch works, see here: - Microphone (it's recognized with new apple t2 sound driver, but there is a low mic volume amp) ## TODO -- add Fedora icon to usb installer -- alsa/pulseaudio config - - Dynamic audio input/output change (on connecting/disconnecting headphones jack) - - ```bash - ## to fix pipewire configs on current mbp-fedora installations - sudo -i - curl -Ls https://raw.githubusercontent.com/mikeeq/mbp-fedora/cdc2fa6e7ef53f995041f1b86d50f34587d7b738/files/audio/apple-t2.conf -o /usr/share/alsa-card-profile/mixer/profile-sets/apple-t2.conf - curl -Ls https://raw.githubusercontent.com/mikeeq/mbp-fedora/cdc2fa6e7ef53f995041f1b86d50f34587d7b738/files/audio/91-pulseaudio-custom.rules -o /usr/lib/udev/rules.d/91-pulseaudio-custom.rules - reboot - - ## if you're using MBP16,1 please apply those commands - # https://gist.github.com/kevineinarsson/8e5e92664f97508277fefef1b8015fba - sudo -i - curl -Ls https://gist.github.com/kevineinarsson/8e5e92664f97508277fefef1b8015fba/raw/bb8319991923e1ad10f68f5c345706f2796ede21/AppleT2.conf -o /usr/share/alsa/cards/AppleT2.conf - curl -Ls https://gist.github.com/kevineinarsson/8e5e92664f97508277fefef1b8015fba/raw/bb8319991923e1ad10f68f5c345706f2796ede21/apple-t2.conf -o /usr/share/alsa-card-profile/mixer/profile-sets/apple-t2.conf - curl -Ls https://raw.githubusercontent.com/mikeeq/mbp-fedora/cdc2fa6e7ef53f995041f1b86d50f34587d7b738/files/audio/91-pulseaudio-custom.rules -o /usr/lib/udev/rules.d/91-pulseaudio-custom.rules - reboot - - ## to manually change audio profile via PulseAudio cli execute - # to headphones output - pactl set-card-profile $(pactl list cards | grep -B10 "Apple T2 Audio" | head -n1 | cut -d "#" -f2) output:codec-output+input:codec-input - - # to speakers output - pactl set-card-profile $(pactl list cards | grep -B10 "Apple T2 Audio" | head -n1 | cut -d "#" -f2) output:builtin-speaker+input:builtin-mic - - ## to manually adjust built-in mic volume - pactl set-source-volume $(pactl list sources | grep -B3 "Built-in Mic" | head -n1 | cut -d"#" -f2) 300000 - ``` - - disable iBridge network interface (awkward internal Ethernet device?) - disable not working camera device - there are two video devices (web cameras) initialized/discovered, don't know why yet @@ -196,14 +155,6 @@ dnf clean all > workaround applied - HFS+ ESP is reformatted to FAT32 in post-scripts step and labelled as `msftdata` -- efibootmgr write command freezes Mac (it's executed in Anaconda during `Install bootloader...` step) - nvram is blocked from writing - - - since macOS Catalina EFI is blocked even from reading, so access to EFI is blocked via adding `efi=noruntime` to kernel args - - ```bash - efibootmgr --c -w -L Fedora /d /dev/nvme0n1 -p 3 -l \EFI\fedora\shimx64.efi - ``` - - `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 7ccc584..a72ff7d 100755 --- a/build.sh +++ b/build.sh @@ -3,12 +3,13 @@ set -eu -o pipefail CURRENT_PWD=$(pwd) -FEDORA_VERSION=36 +FEDORA_VERSION=37 FEDORA_KICKSTARTS_GIT_URL=https://pagure.io/fedora-kickstarts.git -FEDORA_KICKSTARTS_BRANCH_NAME=f36 -FEDORA_KICKSTARTS_COMMIT_HASH=dfbad4bdf5f5b9c6a93b3b192bfe91580ac08915 # https://pagure.io/fedora-kickstarts/commits/f36 -LIVECD_TOOLS_GIT_URL=https://github.com/mikeeq/livecd-tools -LIVECD_TOOLS_GIT_BRANCH_NAME=feature/fix-f35-build +FEDORA_KICKSTARTS_BRANCH_NAME=f37 +FEDORA_KICKSTARTS_COMMIT_HASH=10450ca67bdf48e9d6180ff9337d2e5ce4b1ea63 # https://pagure.io/fedora-kickstarts/commits/f37 +LIVECD_TOOLS_GIT_URL=https://github.com/livecd-tools/livecd-tools +LIVECD_TOOLS_GIT_BRANCH_NAME=main +LIVECD_TOOLS_GIT_COMMIT_HASH=51bd0fefdfd6c06c03990d46b4e7d838cefc9da4 LIVECD_CACHE_PATH=/var/cache/live FEDORA_DESKTOP_ENV="${FEDORA_DESKTOP_ENV:-}" @@ -23,7 +24,6 @@ echo "CPU threads: $(nproc --all)" grep 'model name' /proc/cpuinfo | uniq echo >&2 "===]> Info: Installing dependencies..." -# dnf install -y git zip livecd-tools-27.1-9.fc34.x86_64 dnf install -y \ git \ curl \ @@ -31,15 +31,17 @@ dnf install -y \ make \ livecd-tools -echo >&2 "===]> Info: Install livecd-tools fix" + [ -x "$(command -v python)" ] || ln -s /usr/bin/python3 /usr/bin/python +echo >&2 "===]> Info: Install livecd-tools from git" git clone --single-branch --branch ${LIVECD_TOOLS_GIT_BRANCH_NAME} ${LIVECD_TOOLS_GIT_URL} /tmp/livecd-tools cd /tmp/livecd-tools +git checkout $LIVECD_TOOLS_GIT_COMMIT_HASH make install cd "${CURRENT_PWD}" -echo >&2 "===]> Info: Copy efibootmgr fix for anaconda" +echo >&2 "===]> Info: Copy files to /tmp/kickstart_files/ path" mkdir -p /tmp/kickstart_files/ cp -rfv files/* /tmp/kickstart_files/ @@ -71,11 +73,14 @@ cd "${CURRENT_PWD}" echo >&2 "===]> Info: Zip iso and split it into multiple parts" # Github max size of release attachment is 2GB, where ISO is sometimes bigger than that mkdir -p ./output_zip -zip -s 1000m ./output_zip/"${ARTIFACT_NAME}" ./*.iso +du -sh ./*.iso +zip -s 800m ./output_zip/"${ARTIFACT_NAME}" ./*.iso echo >&2 "===]> Info: Calculate sha256 sums of built ISO" -sha256sum ./output_zip/* > ./output_zip/sha256 -sha256sum ./*.iso >> ./output_zip/sha256 +sha256sum ./output_zip/* > "./output_zip/sha256_${FEDORA_DESKTOP_ENV}" +sha256sum ./*.iso >> "./output_zip/sha256_${FEDORA_DESKTOP_ENV}" + +cat "./output_zip/sha256_${FEDORA_DESKTOP_ENV}" find ./ | grep ".iso" find ./ | grep ".zip" diff --git a/build_in_docker.sh b/build_in_docker.sh index e2c1631..f6b37d7 100755 --- a/build_in_docker.sh +++ b/build_in_docker.sh @@ -2,7 +2,7 @@ set -eu -o pipefail -DOCKER_IMAGE=fedora:34 +DOCKER_IMAGE=fedora:37 docker pull ${DOCKER_IMAGE} docker run \ @@ -11,5 +11,6 @@ docker run \ -e FEDORA_DESKTOP_ENV="${FEDORA_DESKTOP_ENV:-gnome}" \ -t \ -v "$(pwd)":/repo \ + -w /repo \ ${DOCKER_IMAGE} \ - /bin/bash -c 'cd /repo && ./build.sh' + /bin/bash -c './build.sh' diff --git a/build_local.sh b/build_local.sh index d74409d..47a0377 100755 --- a/build_local.sh +++ b/build_local.sh @@ -2,12 +2,11 @@ set -eu -o pipefail -# docker build -t fedora_iso:34 . -# DOCKER_IMAGE=fedora:34 -DOCKER_IMAGE=fedora_iso:34 +docker build -t fedora_iso:37 . + +DOCKER_IMAGE=fedora_iso:37 LIVECD_CACHE_PATH=/var/cache/live -# docker pull ${DOCKER_IMAGE} docker run \ --privileged \ --rm \ @@ -15,6 +14,7 @@ docker run \ -t \ -v "$(pwd)":/repo \ -v /dev:/dev \ + -w /repo \ -v ${LIVECD_CACHE_PATH}:${LIVECD_CACHE_PATH} \ ${DOCKER_IMAGE} \ - /bin/bash -c 'cd /repo && ./build.sh' + /bin/bash -c './build.sh' diff --git a/fedora-mbp.ks b/fedora-mbp.ks index 02cdeaa..7969e67 100644 --- a/fedora-mbp.ks +++ b/fedora-mbp.ks @@ -1,8 +1,8 @@ ### Add rpm repo hosted on heroku https://github.com/mikeeq/mbp-fedora-kernel/releases -repo --name=fedora-mbp --baseurl=http://fedora-mbp-repo.herokuapp.com/ +repo --name=fedora-mbp --baseurl=https://fedora-mbp-repo.herokuapp.com/ ### Selinux in permissive mode -bootloader --append="enforcing=0 efi=noruntime pcie_ports=compat" +bootloader --append="enforcing=0 intel_iommu=on iommu=pt pcie_ports=compat" ### Accepting EULA eula --agreed @@ -11,19 +11,16 @@ eula --agreed # https://pykickstart.readthedocs.io/en/latest/kickstart-docs.html#chapter-9-package-selection %packages +## Install mbp-fedora-kernel, mbp-fedora-t2-config, mbp-fedora-t2-repo curl -iwd wpa_supplicant --shim-ia32-15.[0-9]*-[0-9].x86_64 --shim-x64-15.[0-9]*-[0-9].x86_64 --kernel-5.*.fc36.x86_64 -kernel-*.*[0-9].mbp.fc34.x86_64 - -## Install mbp-fedora-kernel and remove newer shim than 15-8 +-kernel-5.*.fc37.x86_64 +kernel-*.*[0-9].mbp.fc36.x86_64 +mbp-fedora-t2-config +mbp-fedora-t2-repo %end - %post ### Add dns server configuration echo "===]> Info: Printing PWD" @@ -39,48 +36,38 @@ echo 'nameserver 8.8.8.8' > /etc/resolv.conf echo "===]> Info: Print /etc/resolv.conf" cat /etc/resolv.conf -KERNEL_VERSION=5.18.6-200.mbp.fc34.x86_64 -UPDATE_SCRIPT_BRANCH=v5.18-f36 - -### Remove not compatible kernels -rpm -e $(rpm -qa | grep kernel | grep -v headers | grep -v oops | grep -v wifi | grep -v mbp) +KERNEL_VERSION=6.0.5-200.mbp.fc36.x86_64 +UPDATE_SCRIPT_BRANCH=v6.0-f37 -### Add custom drivers to be loaded at boot -echo -e 'hid-apple\nbcm5974\nsnd-seq\napple_bce' > /etc/modules-load.d/apple_bce.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} dracut -f /boot/initramfs-$KERNEL_VERSION.img $KERNEL_VERSION +### Adding fedora-mbp yum repo gpg key +curl -sSL "https://raw.githubusercontent.com/mikeeq/mbp-fedora-kernel/${UPDATE_SCRIPT_BRANCH}/yum-repo/fedora-mbp.gpg" > ./fedora-mbp.gpg +rpm --import ./fedora-mbp.gpg +rm -rf ./fedora-mbp.gpg + ### Add update_kernel_mbp script curl -L https://raw.githubusercontent.com/mikeeq/mbp-fedora-kernel/${UPDATE_SCRIPT_BRANCH}/update_kernel_mbp.sh -o /usr/bin/update_kernel_mbp chmod +x /usr/bin/update_kernel_mbp -### Remove temporary -dnf remove -y kernel-headers -rm -rf /opt/drivers +### Remove temporary files mv /etc/resolv.conf_backup /etc/resolv.conf +### Remove not compatible kernels +rpm -e $(rpm -qa | grep kernel | grep -v headers | grep -v oops | grep -v wifi | grep -v mbp) + ### Add kernel RPM packages to YUM/DNF exclusions -sed -i '/^type=rpm.*/a exclude=kernel,kernel-core,kernel-devel,kernel-devel-matched,kernel-modules,kernel-modules-extra,kernel-modules-internal,shim-*' /etc/yum.repos.d/fedora*.repo +sed -i '/^type=rpm.*/a exclude=kernel,kernel-core,kernel-devel,kernel-devel-matched,kernel-modules,kernel-modules-extra,kernel-modules-internal' /etc/yum.repos.d/fedora*.repo %end %post --nochroot -### Copy grub config without finding macos partition +### Copy grub config without finding macos partition to fix failure reading sector error cp -rfv /tmp/kickstart_files/grub/30_os-prober ${INSTALL_ROOT}/etc/grub.d/30_os-prober chmod 755 ${INSTALL_ROOT}/etc/grub.d/30_os-prober -### Post install anaconda scripts - Reformatting HFS+ EFI partition to FAT32 +### Post install anaconda scripts - Reformatting HFS+ EFI partition to FAT32 and rebuilding grub config cp -rfv /tmp/kickstart_files/post-install-kickstart/*.ks ${INSTALL_ROOT}/usr/share/anaconda/post-scripts/ -### Copy audio config files -mkdir -p ${INSTALL_ROOT}/usr/share/alsa/cards/ -cp -rfv /tmp/kickstart_files/audio/AppleT2.conf ${INSTALL_ROOT}/usr/share/alsa/cards/AppleT2.conf -cp -rfv /tmp/kickstart_files/audio/apple-t2.conf ${INSTALL_ROOT}/usr/share/alsa-card-profile/mixer/profile-sets/apple-t2.conf -cp -rfv /tmp/kickstart_files/audio/91-pulseaudio-custom.rules ${INSTALL_ROOT}/usr/lib/udev/rules.d/91-pulseaudio-custom.rules - -### Copy suspend fix -cp -rfv /tmp/kickstart_files/suspend/rmmod_tb.sh ${INSTALL_ROOT}/lib/systemd/system-sleep/rmmod_tb.sh -chmod +x ${INSTALL_ROOT}/lib/systemd/system-sleep/rmmod_tb.sh - %end diff --git a/files/audio/91-pulseaudio-custom.rules b/files/audio/91-pulseaudio-custom.rules deleted file mode 100644 index 4688cde..0000000 --- a/files/audio/91-pulseaudio-custom.rules +++ /dev/null @@ -1,7 +0,0 @@ -SUBSYSTEM!="sound", GOTO="pulseaudio_end" -ACTION!="change", GOTO="pulseaudio_end" -KERNEL!="card*", GOTO="pulseaudio_end" - -SUBSYSTEMS=="pci", ATTRS{vendor}=="0x106b", ATTRS{device}=="0x1803", ENV{PULSE_PROFILE_SET}="apple-t2.conf", ENV{ACP_PROFILE_SET}="apple-t2.conf" - -LABEL="pulseaudio_end" diff --git a/files/audio/AppleT2.conf b/files/audio/AppleT2.conf deleted file mode 100644 index 9d12163..0000000 --- a/files/audio/AppleT2.conf +++ /dev/null @@ -1,77 +0,0 @@ - - - -AppleT2.pcm.default { - @args [ CARD ] - @args.CARD { - type string - } - - type asym - playback.pcm { - type plug - slave.pcm { - type hw - card $CARD - device 0 - } - } - capture.pcm { - type plug - slave.pcm { - type hw - card $CARD - device 1 - } - } - hint.device_output 0 - hint.device_input 1 -} - -AppleT2.pcm.front.0 { - @args [ CARD ] - @args.CARD { - type string - } - type asym - playback.pcm { - type hw - card $CARD - device 0 - } - capture.pcm { - type hw - card $CARD - device 1 - } - hint.device_output 0 - hint.device_input 1 -} -AppleT2.pcm.front.1 { - @args [ CARD ] - @args.CARD { - type string - } - type asym - playback.pcm { - type hw - card $CARD - device 2 - } - capture.pcm { - type hw - card $CARD - device 3 - } - hint.device_output 2 - hint.device_input 3 -} -AppleT2.pcm.front.2 { - @args [ CARD ] - @args.CARD { - type string - } - type hw - card $CARD - device 4 -} diff --git a/files/audio/apple-t2.conf b/files/audio/apple-t2.conf deleted file mode 100644 index c227ed9..0000000 --- a/files/audio/apple-t2.conf +++ /dev/null @@ -1,34 +0,0 @@ -[General] -auto-profiles = yes - -[Mapping builtin-speaker] -description = Built-in Speaker -device-strings = front:%f -paths-output = builtin-speaker-output -channel-map = front-left,front-right,rear-left,rear-right -priority = 100 -direction = output - -[Mapping builtin-mic] -description = Built-in Mic -device-strings = front:%f -paths-input = builtin-mic-input -channel-map = left,center,right -priority = 100 -direction = input - -[Mapping codec-output] -description = Headphone -device-strings = front:%f,1 -paths-output = codec-output -channel-map = left,right -priority = 100 -direction = output - -[Mapping codec-input] -description = Headphone Mic -device-strings = front:%f,1 -paths-input = codec-input -channel-map = mono -priority = 100 -direction = input diff --git a/files/post-install-kickstart/98-mbp-regenerate-grub-cfg.ks b/files/post-install-kickstart/98-mbp-regenerate-grub-cfg.ks deleted file mode 100644 index a9f7eea..0000000 --- a/files/post-install-kickstart/98-mbp-regenerate-grub-cfg.ks +++ /dev/null @@ -1,16 +0,0 @@ -%post - -GRUB_CMDLINE_VALUE=$(grep -v '#' /etc/default/grub | grep -w GRUB_CMDLINE_LINUX | cut -d'"' -f2) - -for i in efi=noruntime pcie_ports=compat; do - if ! echo "$GRUB_CMDLINE_VALUE" | grep -w $i; then - GRUB_CMDLINE_VALUE="$GRUB_CMDLINE_VALUE $i" - fi -done - -sed -i "s:^GRUB_CMDLINE_LINUX=.*:GRUB_CMDLINE_LINUX=\"${GRUB_CMDLINE_VALUE}\":g" /etc/default/grub -sed -i '/^GRUB_ENABLE_BLSCFG=true/c\GRUB_ENABLE_BLSCFG=false' /etc/default/grub - -grub2-mkconfig -o /boot/grub2/grub.cfg - -%end diff --git a/files/post-install-kickstart/99-rebuild-grub.ks b/files/post-install-kickstart/99-rebuild-grub.ks new file mode 100644 index 0000000..86464e4 --- /dev/null +++ b/files/post-install-kickstart/99-rebuild-grub.ks @@ -0,0 +1,5 @@ +%post + +grub2-mkconfig -o /boot/grub2/grub.cfg + +%end diff --git a/files/suspend/rmmod_tb.sh b/files/suspend/rmmod_tb.sh deleted file mode 100755 index 0e4acc7..0000000 --- a/files/suspend/rmmod_tb.sh +++ /dev/null @@ -1,8 +0,0 @@ -#!/bin/sh -if [ "${1}" = "pre" ]; then - modprobe -r apple_ib_tb - modprobe -r hid_apple -elif [ "${1}" = "post" ]; then - modprobe hid_apple - modprobe apple_ib_tb -fi