From 7104292ac13a5a8db8ad7db4c8dbe674a2230d5f Mon Sep 17 00:00:00 2001 From: Aditya Garg <85610623+AdityaGarg8@users.noreply.github.com> Date: Sat, 18 May 2024 17:00:21 +0530 Subject: [PATCH] Add support for Arch packages --- docs/tools/firmware.sh | 113 ++++++++++++++++++++++++++++++++++------- 1 file changed, 95 insertions(+), 18 deletions(-) diff --git a/docs/tools/firmware.sh b/docs/tools/firmware.sh index 3e45a014..5a428f5e 100644 --- a/docs/tools/firmware.sh +++ b/docs/tools/firmware.sh @@ -38,22 +38,20 @@ read -p "Press enter to install Homebrew." fi } -dpkg_check () { +create_deb () { if [ ! -f "/usr/local/bin/dpkg" ] then -echo -e "\ndpkg not found!" +echo -e "\ndpkg and/or its dependencies are missing!" echo -read -p "Press enter to install dpkg via Homebrew. This script can install Homebrew automatically if you haven't installed it. Alternatively you can terminate this script by pressing Control+C and install dpkg yourself, if you want to install it via some alternate method." +read -p "Press enter to install dpkg and its dependencies via Homebrew. This script can install Homebrew automatically if you haven't installed it. Alternatively you can terminate this script by pressing Control+C and install dpkg yourself, if you want to install it via some alternate method." homebrew_check -echo -e "\nInstalling dpkg" +echo -e "\nInstalling dpkg and its dependencies" brew install dpkg fi -} -create_deb () { echo -e "\nBuilding deb package" workarea=$(mktemp -d) -python3 $0 /usr/share/firmware ${workarea}/firmware.tar +python3 "$0" /usr/share/firmware ${workarea}/firmware.tar cd ${workarea} mkdir -p deb cd deb @@ -73,7 +71,7 @@ fi cat </dev/null Package: apple-firmware -Version: ${ver} +Version: ${ver}-1 Maintainer: Apple Architecture: amd64 Description: Wi-Fi and Bluetooth firmware for T2 Macs @@ -96,15 +94,16 @@ then dpkg-deb --build --root-owner-group -Zgzip deb dpkg-name deb.deb else -dpkg-deb --build --root-owner-group -Zgzip deb >/dev/null +dpkg-deb --build --root-owner-group -Zgzip deb >/dev/null || echo "Failed to make deb package. Run the script with -v to get logs." dpkg-name deb.deb >/dev/null fi -cp ${verbose} apple-firmware_${ver}_amd64.deb $HOME/Downloads + +cp ${verbose} apple-firmware_${ver}-1_amd64.deb $HOME/Downloads echo -e "\nCleaning up" sudo rm -r ${verbose} ${workarea} cat </dev/null +pkgname=apple-firmware +pkgver=${ver} +pkgrel=1 +pkgdesc="Wi-Fi and Bluetooth Firmware for T2 Macs" +arch=("x86_64") +url="" +license=('unknown') +replaces=('apple-bcm-wifi-firmware') +source=("firmware.tar") +noextract=("firmware.tar") +sha256sums=('SKIP') +package() { + mkdir -p \$pkgdir/usr/lib/firmware/brcm + cd \$pkgdir/usr/lib/firmware/brcm + tar xf \$srcdir/firmware.tar +} +EOF + +# Set path to use newer bsdtar and GNU touch +PATH_OLD=$PATH +PATH=/usr/local/Cellar/libarchive/$(ls /usr/local/Cellar/libarchive | head -n 1)/bin:/usr/local/opt/coreutils/libexec/gnubin:$PATH_OLD + +# Build +if [[ ${verbose} = -v ]] +then +makepkg +else +makepkg >/dev/null 2&>/dev/null || echo "Failed to make Arch package. Run the script with -v to get logs." +fi + +# Revert path to its original form +PATH=${PATH_OLD} + +# Copy to Downloads and cleanup +cp ${verbose} apple-firmware-${ver}-1-x86_64.pkg.tar.gz $HOME/Downloads +echo -e "\nCleaning up" +sudo rm -r ${verbose} ${workarea} +cat <