forked from chadmed/asahi-gentoosupport
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathinstall.sh
executable file
·168 lines (133 loc) · 5.13 KB
/
install.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
#!/bin/bash
# Copyright 2022 James Calligeros <[email protected]>
# SPDX-License-Identifier: MIT
set -e
install_overlay() {
echo "Installing the Asahi Overlay. For more information, visit"
echo "https://github.com/chadmed/asahi-overlay/"
echo
cp resources/repo.conf /etc/portage/repos.conf/asahi.conf
emaint sync -r asahi
echo "The Asahi overlay has been installed."
}
install_uboot() {
echo "Installing U-Boot."
emerge -q u-boot
echo "U-Boot has been installed."
}
install_grub() {
echo "Installing GRUB."
echo "GRUB_PLATFORMS=\"efi-64\"" >> /etc/portage/make.conf
emerge -q grub:2
echo "GRUB has been installed."
}
install_m1n1() {
echo "Installing m1n1."
emerge -qv m1n1
update-m1n1
echo "m1n1 has been installed."
}
merge_kernel_sources() {
# Install a package.use for the kernel
if [[ ! -d /etc/portage/package.use ]]; then
mkdir -p /etc/portage/package.use
fi
echo "sys-kernel/asahi-sources symlink" >> /etc/portage/package.use/kernel
emerge -qv asahi-sources
echo "The patched kernel sources are now available in"
echo "/usr/src/linux."
}
make_kernel() {
echo "We are going to install a known-good kernel for you now. You"
echo "can edit this at any time after the install procedure has finished."
echo "In fact, you should edit it once you've booted in to the filesystem."
echo
read -sp "Press Enter to continue..."
echo
# Check if genkernel is installed
if [[ ! -f /usr/bin/dracut ]]; then
emerge -qv dracut
fi
echo "sys-apps/kmod zstd" >> /etc/portage/package.use/kernel
emerge -qv kmod
zcat /proc/config.gz > /usr/src/linux/.config
make -C /usr/src/linux -j $(nproc)
KERNVER=$(make -C /usr/src/linux -s kernelrelease)
make -C /usr/src/linux modules_install
# Gentoo's GRUB expects Image and the initramfs to be
# in pairs with the same release tag, with the tag
# -linux taking precedence over all others. If
# a kernel already exists with that tag, we need to
# move it so that our kernel and initramfs become the
# default booted
if [[ -e /boot/vmlinu{x,z}-linux ]]; then
mv /boot/vmlinu{x,z}-linux /boot/vmlinu{x,z}-old
fi
if [[ -e /boot/initramfs-linux.img ]]; then
mv /boot/initramfs-linux.img /boot/initramfs-old.img
fi
make -C /usr/src/linux install
if [[ ! -d /etc/dracut.conf.d/ ]]; then
mkdir -p /etc/dracut.conf.d/
fi
cp resources/dracut.conf /etc/dracut.conf.d/10-apple.conf
dracut \
--force \
--quiet \
--kver ${KERNVER} \
--compress gzip \
/boot/initramfs-${KERNVER}.img
# We need to rebuild GRUB
grub-install --removable --efi-directory=/boot/efi --boot-directory=/boot
grub-mkconfig -o /boot/grub/grub.cfg
}
install_fw() {
echo "We will now install the Apple Silicon firmware to /lib/firmware."
echo
echo "Be sure to install whatever userspace network/WiFi management"
echo "software you want before you reboot."
read -sp "Press Enter to continue..."
echo
echo "Installing firmware management scripts"
emerge -q asahi-firmware
echo
echo "Extracting firmware..."
if [[ ! -d /lib/firmware ]]; then
echo "sys-kernel/linux-firmware linux-fw-redistributable no-source-code" >> /etc/portage/package.license
emerge -qv linux-firmware
fi
/usr/sbin/asahi-fwextract
echo "Firmware installed."
read -sp "Press Enter to continue..."
}
if [[ $(whoami) != "root" ]]; then
echo "You must run this script as root."
exit 1
fi
if [[ ! -d /boot/efi/vendorfw ]]; then
echo "You must mount the Asahi EFI System Partition to /boot/efi."
echo "This is absolutely necessary for the proper functioning of the"
echo "system. Please mount the ESP at /boot/efi and add it to your"
echo "fstab before continuing."
exit 1
fi
echo "This script automates the setup and configuration of Apple Silicon"
echo "specific tooling. Please ensure that /boot is mounted where you want, and"
echo "the Asahi EFI System Partition is mounted to /boot/efi."
echo
echo "NOTE: This script will install linux-firmware automatically. It is not"
echo "possible to run these machines properly without binary blobs. Please make"
echo "sure you understand this, and agree to the linux-fw-redistributable and"
echo "no-source-code licenses before continuing."
echo
read -sp "Press Enter to continue..."
install_overlay
install_uboot
install_grub
merge_kernel_sources
make_kernel
install_m1n1
install_fw
echo "This script will now exit. Continue setting up your machine as per the"
echo "Gentoo Handbook, skipping the steps related to setting up the kernel or"
echo "GRUB as these have been done for you."