hydra

Terminal replacement for Loopback — virtual audio devices and routing on macOS, from a ratatui TUI.
Log | Files | Refs | README | LICENSE

create_installer.sh (4281B)


      1 #!/usr/bin/env sh
      2 set -euo pipefail
      3 
      4 # Creates installer for different channel versions.
      5 # Run this script from the local BlackHole repo's root directory.
      6 # If this script is not executable from the Terminal, 
      7 # it may need execute permissions first by running this command:
      8 #   chmod +x create_installer.sh
      9 
     10 driverName="BlackHole"
     11 devTeamID="Q5C99V536K" # ⚠️ Replace this with your own developer team ID
     12 notarize=true # To skip notarization, set this to false
     13 notarizeProfile="notarize" # ⚠️ Replace this with your own notarytool keychain profile name
     14 
     15 ############################################################################
     16 
     17 # Basic Validation
     18 if [ ! -d BlackHole.xcodeproj ]; then
     19     echo "This script must be run from the BlackHole repo root folder."
     20     echo "For example:"
     21     echo "  cd /path/to/BlackHole"
     22     echo "  ./Installer/create_installer.sh"
     23     exit 1
     24 fi
     25 
     26 version=`cat VERSION`
     27 
     28 #Version Validation6
     29 if [ -z "$version" ]; then
     30     echo "Could not find version number. VERSION file is missing from repo root or is empty."
     31     exit 1
     32 fi
     33 
     34 for channels in 2 16 64 128 256; do
     35     # Env
     36     ch=$channels"ch"
     37     driverVartiantName=$driverName$ch
     38     bundleID="audio.existential.$driverVartiantName"
     39     
     40     # Build
     41     xcodebuild \
     42       -project BlackHole.xcodeproj \
     43       -configuration Release \
     44       -target BlackHole CONFIGURATION_BUILD_DIR=build \
     45       PRODUCT_BUNDLE_IDENTIFIER=$bundleID \
     46       GCC_PREPROCESSOR_DEFINITIONS='$GCC_PREPROCESSOR_DEFINITIONS 
     47       kNumber_Of_Channels='$channels' 
     48       kPlugIn_BundleID=\"'$bundleID'\" 
     49       kDriver_Name=\"'$driverName'\"'
     50     
     51     # Generate a new UUID
     52     uuid=$(uuidgen)
     53     awk '{sub(/e395c745-4eea-4d94-bb92-46224221047c/,"'$uuid'")}1' build/BlackHole.driver/Contents/Info.plist > Temp.plist
     54     mv Temp.plist build/BlackHole.driver/Contents/Info.plist
     55     
     56     mkdir Installer/root
     57     driverBundleName=$driverVartiantName.driver
     58     mv build/BlackHole.driver Installer/root/$driverBundleName
     59     rm -r build
     60     
     61     # Sign
     62     codesign \
     63       --force \
     64       --deep \
     65       --options runtime \
     66       --sign $devTeamID \
     67       Installer/root/$driverBundleName
     68     
     69     # Create package with pkgbuild
     70     chmod 755 Installer/Scripts/preinstall
     71     chmod 755 Installer/Scripts/postinstall
     72     
     73     pkgbuild \
     74       --sign $devTeamID \
     75       --root Installer/root \
     76       --scripts Installer/Scripts \
     77       --install-location /Library/Audio/Plug-Ins/HAL \
     78       "Installer/$driverName.pkg"
     79     rm -r Installer/root
     80     
     81     # Create installer with productbuild
     82     cd Installer
     83     
     84     echo "<?xml version=\"1.0\" encoding='utf-8'?>
     85     <installer-gui-script minSpecVersion='2'>
     86         <title>$driverName: Audio Loopback Driver ($ch) $version</title>
     87         <welcome file='welcome.html'/>
     88         <license file='../LICENSE'/>
     89         <conclusion file='conclusion.html'/>
     90         <domains enable_anywhere='false' enable_currentUserHome='false' enable_localSystem='true'/>
     91         <pkg-ref id=\"$bundleID\"/>
     92         <options customize='never' require-scripts='false' hostArchitectures='x86_64,arm64'/>
     93         <volume-check>
     94             <allowed-os-versions>
     95                 <os-version min='10.10'/>
     96             </allowed-os-versions>
     97         </volume-check>
     98         <choices-outline>
     99             <line choice=\"$bundleID\"/>
    100         </choices-outline>
    101         <choice id=\"$bundleID\" visible='true' title=\"$driverName $ch\" start_selected='true'>
    102             <pkg-ref id=\"$bundleID\"/>
    103         </choice>
    104         <pkg-ref id=\"$bundleID\" version=\"$version\" onConclusion='RequireRestart'>$driverName.pkg</pkg-ref>
    105     </installer-gui-script>" >> distribution.xml
    106     
    107     # Build
    108     installerPkgName="$driverVartiantName-$version.pkg"
    109     productbuild \
    110       --sign $devTeamID \
    111       --distribution distribution.xml \
    112       --resources . \
    113       --package-path $driverName.pkg $installerPkgName
    114     rm distribution.xml
    115     rm -f $driverName.pkg
    116     
    117     # Notarize and Staple
    118     if [ "$notarize" = true ]; then
    119         xcrun \
    120           notarytool submit $installerPkgName \
    121           --team-id $devTeamID \
    122           --progress \
    123           --wait \
    124           --keychain-profile $notarizeProfile
    125         
    126         xcrun stapler staple $installerPkgName
    127     fi
    128 
    129     cd ..
    130 done