Skip to content

Commit

Permalink
Fedora 37 release, add sha256 artifact fix, add support for mbp-fedor…
Browse files Browse the repository at this point in the history
…a-t2-config rpm (#64)
  • Loading branch information
mikeeq authored Nov 4, 2022
1 parent 8ef667c commit 4adee28
Show file tree
Hide file tree
Showing 14 changed files with 63 additions and 251 deletions.
1 change: 1 addition & 0 deletions .dockerignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
.git
4 changes: 4 additions & 0 deletions .github/agent-info.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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'
Expand Down
2 changes: 1 addition & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
FROM fedora:34
FROM fedora:37

RUN dnf upgrade -y \
&& dnf install -y \
Expand Down
63 changes: 7 additions & 56 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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: <https://github.com/mikeeq/mbp-fedora-kernel>

Kernel patches: <https://github.com/AdityaGarg8/linux-t2-patches>

> Tested on: Macbook Pro 15,2 13" 2019 i5 TouchBar Z0WQ000AR MV972ZE/A/R1 && Macbook Pro 16,2 13" 2020 i5
Expand Down Expand Up @@ -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: <https://github.com/mikeeq/mbp-fedora-kernel#how-to-update-kernel-mbp>
- 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: <https://github.com/free5lot/hid-apple-patched>

```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
Expand All @@ -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
Expand All @@ -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
Expand All @@ -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: <https://github.com/mikeeq/mbp-fedora#todo>
- 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
Expand All @@ -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
Expand Down
27 changes: 16 additions & 11 deletions build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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:-}"
Expand All @@ -23,23 +24,24 @@ 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 \
zip \
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/

Expand Down Expand Up @@ -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"
Expand Down
5 changes: 3 additions & 2 deletions build_in_docker.sh
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

set -eu -o pipefail

DOCKER_IMAGE=fedora:34
DOCKER_IMAGE=fedora:37

docker pull ${DOCKER_IMAGE}
docker run \
Expand All @@ -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'
10 changes: 5 additions & 5 deletions build_local.sh
Original file line number Diff line number Diff line change
Expand Up @@ -2,19 +2,19 @@

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 \
-e FEDORA_DESKTOP_ENV="${FEDORA_DESKTOP_ENV:-gnome}" \
-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'
55 changes: 21 additions & 34 deletions fedora-mbp.ks
Original file line number Diff line number Diff line change
@@ -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
Expand All @@ -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"
Expand All @@ -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
7 changes: 0 additions & 7 deletions files/audio/91-pulseaudio-custom.rules

This file was deleted.

Loading

0 comments on commit 4adee28

Please sign in to comment.