Skip to content

Commit 4946302

Browse files
committed
Add create_uninstaller.sh
1 parent ed42780 commit 4946302

File tree

2 files changed

+76
-0
lines changed

2 files changed

+76
-0
lines changed

Uninstaller/Scripts/postinstall

+8
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
#!/bin/bash
2+
3+
file="/Library/Audio/Plug-Ins/HAL/BlackHole256ch.driver"
4+
5+
if [ -d "$file" ] ; then
6+
sudo rm -R "$file"
7+
sudo killall coreaudiod
8+
fi

Uninstaller/create_uninstaller.sh

+68
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,68 @@
1+
#!/bin/bash
2+
set -euo pipefail
3+
4+
devTeamID="Q5C99V536K" # ⚠️ Replace this with your own developer team ID
5+
notarize=true # To skip notarization, set this to false
6+
notarizeProfile="notarize" # ⚠️ Replace this with your own notarytool keychain profile name
7+
8+
# Basic Validation
9+
if [ ! -d BlackHole.xcodeproj ]; then
10+
echo "This script must be run from the BlackHole repo root folder."
11+
echo "For example:"
12+
echo " cd /path/to/BlackHole"
13+
echo " ./Uninstaller/create_uninstaller.sh"
14+
exit 1
15+
fi
16+
17+
for channels in 2 16 64 128 256; do
18+
19+
# create script
20+
echo \
21+
'#!/bin/bash
22+
23+
file="/Library/Audio/Plug-Ins/HAL/BlackHole'$channels'ch.driver"
24+
25+
if [ -d "$file" ] ; then
26+
sudo rm -R "$file"
27+
sudo killall coreaudiod
28+
fi' > Uninstaller/Scripts/postinstall
29+
30+
chmod 755 Uninstaller/Scripts/postinstall
31+
32+
# Build .pkg
33+
packageName='Uninstaller/BlackHole'$channels'ch-Uninstaller.pkg'
34+
35+
pkgbuild --nopayload --scripts Uninstaller/Scripts --sign $devTeamID --identifier 'audio.existential.BlackHole'$channels'ch.Uninstaller' $packageName
36+
37+
# Notarize and Staple
38+
if [ "$notarize" = true ]; then
39+
40+
# Submit the package for notarization and capture output, also displaying it simultaneously
41+
output=$(xcrun notarytool submit "$packageName" --progress --wait --keychain-profile "notarize" 2>&1 | tee /dev/tty)
42+
43+
# Extract the submission ID
44+
submission_id=$(echo "$output" | grep -o -E 'id: [a-f0-9-]+' | awk '{print $2}' | head -n1)
45+
46+
if [ -z "$submission_id" ]; then
47+
echo "Failed to extract submission ID. ❌"
48+
exit 1
49+
fi
50+
51+
# Check the captured output for the "status: Invalid" indicator
52+
if echo "$output" | grep -q "status: Invalid"; then
53+
echo "Error detected during notarization: Submission Invalid ❌"
54+
55+
# Fetch and display notarization logs
56+
echo -e "\nFetching logs for submission ID: $submission_id"
57+
xcrun notarytool log --keychain-profile "notarize" "$submission_id"
58+
exit 1
59+
else
60+
echo "Notarization submitted successfully ✅"
61+
fi
62+
63+
xcrun stapler staple $packageName
64+
fi
65+
66+
done
67+
68+
rm Uninstaller/Scripts/postinstall

0 commit comments

Comments
 (0)