Skip to content

Commit

Permalink
Address feedback
Browse files Browse the repository at this point in the history
  • Loading branch information
sharpenedblade committed Jun 14, 2024
1 parent ce61da3 commit 23c7db4
Showing 1 changed file with 13 additions and 16 deletions.
29 changes: 13 additions & 16 deletions docs/tools/firmware.sh
Original file line number Diff line number Diff line change
Expand Up @@ -367,7 +367,7 @@ homebrew_check () {
}

detect_package_manager () {
if [[ $(uname) == "Darwin" ]]
if [[ $(uname -s) == "Darwin" ]]
then
echo brew
elif apt --help >/dev/null 2>&1
Expand All @@ -388,7 +388,7 @@ install_package() {
local package=$1
local package_manager
package_manager=$(detect_package_manager)
read -rp "Press enter to install $package and its dependencies. Alternatively you can terminate this script by pressing Control+C and install $package yourself, if you want to install it via some alternate method."
read -rp "$package is missing. Press enter to install $package and its dependencies. Alternatively you can terminate this script by pressing Control+C and install $package yourself, if you want to install it via some alternate method."

case $package_manager in
"apt")
Expand Down Expand Up @@ -440,7 +440,7 @@ create_firmware_archive() {
firmware_tree=$1
archive=$2
rename_firmware "$firmware_tree" "$archive" ${verbose}
if [[ $(uname) == "Darwin" ]]; then
if [[ $(uname -s) == "Darwin" ]]; then
identifier=$(system_profiler SPHardwareDataType | grep "Model Identifier" | cut -d ":" -f 2 | xargs)
if [[ (${identifier} = iMac19,1) || (${identifier} = iMac19,2) || (${identifier} = iMacPro1,1) ]]; then
nvramfile=$(ioreg -l | grep RequestedFiles | cut -d "/" -f 5 | rev | cut -c 4- | rev)
Expand Down Expand Up @@ -677,9 +677,7 @@ create_arch_pkg () {
os=$(uname -s)
case "$os" in
(Darwin)
if [[ $verbose = "-v" ]]; then
echo "Detected macOS"
fi
echo "Detected macOS"
ver=$(sw_vers -productVersion)
ver_check=$(sw_vers -productVersion | cut -d "." -f 1)
identifier=$(system_profiler SPHardwareDataType | grep "Model Identifier" | cut -d ":" -f 2 | xargs)
Expand Down Expand Up @@ -786,9 +784,7 @@ case "$os" in
;;

(Linux)
if [[ $verbose = "-v" ]]; then
echo "Detected Linux"
fi
echo "Detected Linux"
if [[ ! -e /lib/firmware/brcm ]]; then
cat <<- EOF
/lib/firmware/brcm does not seem to exist. This script requires that directory to function.
Expand All @@ -798,6 +794,7 @@ case "$os" in
EOF
exit 1
fi
echo
cat <<- EOF
How do you want to copy the firmware to Linux?
Expand All @@ -810,7 +807,7 @@ case "$os" in
read -r choice
case ${choice} in
(1)
echo -e "Re-mounting the EFI partition"
echo -e "\nRe-mounting the EFI partition"
mountpoint=$(mktemp -d)
workdir=$(mktemp -d)
echo "Installing Wi-Fi and Bluetooth firmware"
Expand All @@ -821,11 +818,11 @@ case "$os" in
sudo tar ${verbose} -xC /lib/firmware/brcm -f "${workdir}/firmware-renamed.tar"

reload_kernel_modules
echo "Keeping a copy of the firmware and the script in the EFI partition shall allow you to set up Wi-Fi again in the future by running this script or the commands told in the macOS step in Linux only, without the macOS step."
echo -e "\nKeeping a copy of the firmware and the script in the EFI partition shall allow you to set up Wi-Fi again in the future by running this script or the commands told in the macOS step in Linux only, without the macOS step."
read -rp "Do you want to keep a copy? (y/N)" input
if [[ ($input != y) && ($input != Y) ]]
then
echo -e "Removing the copy from the EFI partition"
echo -e "\nRemoving the copy from the EFI partition"
for file in "$mountpoint/brcmfmac4364b2-pcie.txt" \
"$mountpoint/brcmfmac4364b2-pcie.txcap_blob" \
"$mountpoint/firmware.tar.gz" \
Expand All @@ -840,7 +837,7 @@ case "$os" in
sudo rm -r ${verbose} "${workdir}"
sudo umount "$mountpoint"
sudo rmdir "$mountpoint"
echo -e "Done!"
echo -e "\nDone!"
;;
(2)
# Load the apfs driver, and install if missing
Expand All @@ -859,7 +856,7 @@ case "$os" in
sudo rm -r ${verbose} "${macosdir}" || true
}

echo -e "Mounting the macOS volume"
echo -e "\nMounting the macOS volume"
workdir=$(mktemp -d)
macosdir=$(mktemp -d)
macosvol=/dev/$(lsblk -o NAME,FSTYPE | grep nvme0n1 | grep apfs | head -1 | awk '{print $1}' | rev | cut -c -9 | rev)
Expand Down Expand Up @@ -904,7 +901,7 @@ case "$os" in
sudo losetup -d /dev/"${loopdev}"
}

echo -e "Downloading macOS Recovery Image"
echo -e "\nDownloading macOS Recovery Image"
workdir=$(mktemp -d)
imgdir=$(mktemp -d)
cd "${workdir}"
Expand All @@ -916,7 +913,7 @@ case "$os" in
fi
echo -e "\nNote: In order to get complete firmware files, download macOS Monterey or later.\n"
python3 fetch-macOS-v2.py
echo -e "Converting image from .dmg to .img"
echo -e "\nConverting image from .dmg to .img"
if [[ ${verbose} = "-v" ]]
then
dmg2img -v BaseSystem.dmg fw.img
Expand Down

0 comments on commit 23c7db4

Please sign in to comment.