Skip to content

Instantly share code, notes, and snippets.

@kad3nce
Created November 29, 2018 19:37
Show Gist options
  • Save kad3nce/7e3b85baa60b9389570dedcaf8d14d79 to your computer and use it in GitHub Desktop.
Save kad3nce/7e3b85baa60b9389570dedcaf8d14d79 to your computer and use it in GitHub Desktop.
BM Desktop Video Uninstaller
#!/bin/sh
BASE=$(dirname "$0")
# On 10.6, perl is (finally) compiled 64bit but the Mac::Processes module is
# still 32bit only. According to the perl man page, this is the recommended
# way to get perl to run in 32bit mode.
export VERSIONER_PERL_PREFER_32_BIT=yes
# Ask Launch Services what the preferred application path is for a given
# creator code, bundle ID and application name. This is the application that
# the Finder will launch when a Premiere project is double clicked. Only one
# of the three arguments is required. Note that searching by name requires a
# string that's localised for different languages. This makes it less useful
# than the creator code and bundle ID arguments.
#
# Example usage:
#
# LSFindApplicationForInfo '' com.apple.Terminal Terminal.app
# /Applications/Utilities/Terminal.app
#
LSFindApplicationForInfo()
{
CREATOR=$1
BUNDLE_ID=$2
APP_NAME=$3
if [ -z "$CREATOR" ] && [ -z "$BUNDLE_ID" ] && [ -z "$APP_NAME"]; then
echo "usage: LSFindApplicationForInfo [<creator code>] [<bundle ID>] [<app name>]" >&2
return 1
fi
perl -MMac::Processes -e "print LSFindApplicationForInfo qq{$CREATOR}, qq{$BUNDLE_ID}, qq{$APP_NAME}"
}
# Retrieve the value for a specific key in a plist file. If the path supplied
# isn't a regular file, try looking in the standard location for a plist file
# in a bundle.
#
# Note that this function only understands simple <string></string> values. If
# the value for a key is a boolean tag such as </false> then the value line is
# simply returned intact. If the value is a structure such as an <array> or a
# <dict> then only the opening tag line for that structure is returned.
#
# Example usage:
#
# GetPlistValue /Applications/Calculator.app/Contents/Info.plist CFBundleVersion
# 4.2
#
# GetPlistValue /Applications/Preview.app CFBundleGetInfoString
# 4.0, Copyright 2002-2007 Apple Inc.
#
GetPlistValue()
{
PLIST_FILE=$1
PLIST_KEY=$2
if [ -z "$PLIST_FILE" ] || [ -z "$PLIST_KEY" ]; then
echo "usage: GetPlistValue <plist file> <key>" >&2
return 1
fi
PLIST_PATH=Contents/Info.plist
if [ -d "$PLIST_FILE" ] && [ -f "$PLIST_FILE/$PLIST_PATH" ]; then
PLIST_FILE=$PLIST_FILE/$PLIST_PATH
fi
# Use defaults to read the Info.plist file instead of grep
# because defaults will accept both XML and binary formats
defaults read "${PLIST_FILE%.plist}" "$PLIST_KEY" 2>/dev/null
}
# Find the path to a particular version of an application, given its bundle ID,
# the major component of its version number and optionally its name. If the
# name uniquely identifies the application for the requested version number and
# the name is correctly localised for the system, the application will be found
# more quickly because the file system won't need to be searched.
#
# The fourth parameter is optional and indicates whether only the app name should
# be used to find the application. If the parameter is set to "true" then only the
# exact app name will be searched for. If the parameter is not "true", or is left
# out, then a more complete search (including bundles with matching major version
# number) will be conducted.
#
# The fifth optional parameter specifies the name of the property in the plist file
# in which the version number is searched.
#
# Example usage:
#
# FindAppWithVersion <bundle> <version> <app name> <only match app name> <plist property name>
#
# FindAppWithVersion com.adobe.AdobePremierePro 3 "Adobe Premiere Pro CS3.app"
# /Volumes/Data/Applications/Adobe Premiere Pro CS3/Adobe Premiere Pro CS3.app
#
# FindAppWithVersion com.adobe.AdobePremierePro 4
# /Volumes/Data/Applications/Adobe Premiere Pro CS4/Adobe Premiere Pro CS4.app
#
# FindAppWithVersion com.adobe.AdobePremierePro 5.5 "Adobe Premiere Pro CS5.5.app" true
# /Volumes/Data/Applications/Adobe Premiere Pro CS5.5/Adobe Premiere Pro CS5.5.app
#
# The function returns non-zero on any failure including failure to find the app
#
FindAppWithVersion()
{
if [ $# -ne 5 ]; then
echo "usage: FindAppWithVersion <bundle ID> <version> <app name> <only match app name> <property to search for version number>" >&2
return 1
fi
APP_BUNDLE_ID=$1
APP_VERSION=$2
APP_NAME=$3
ONLY_MATCH_APP_NAME=$4
VERSION_PROPERTY_NAME=$5
# If the application name was provided, the caller presumably knows that it
# uniquely identifies the correct application version as long as the locale
# is correct.
if [ -n "$APP_NAME" ]; then
APP_PATH=`LSFindApplicationForInfo '' "$APP_BUNDLE_ID" "$APP_NAME"` || return $?
fi
# If the above call was unsuccessful or the caller didn't pass an
# application name, search by bundle ID. This will find the installed
# application with the newest version number.
if [ "$ONLY_MATCH_APP_NAME" != "true" ]; then
if [ -z "$APP_PATH" ]; then
APP_PATH=`LSFindApplicationForInfo '' "$APP_BUNDLE_ID" ''` || return $?
fi
fi
# If Launch Services failed to find a path from the bundle ID, bail out.
if [ -z "$APP_PATH" ]; then
return 1
fi
VERSION=`GetPlistValue "$APP_PATH" "$VERSION_PROPERTY_NAME"` || return $?
# Pull just the first digit out of the version number, e.g. "3.1.1" -> "3".
VERSION_MAJOR=${VERSION%%.*}
APP_VERSION_MAJOR=${APP_VERSION%%.*}
if [ $VERSION_MAJOR -lt $APP_VERSION_MAJOR ]; then
return 1
elif [ $VERSION_MAJOR -eq $APP_VERSION_MAJOR ]; then
echo $APP_PATH
return 0
elif [ $VERSION_MAJOR -gt $APP_VERSION_MAJOR ]; then
# See if the earlier version is also installed. Search for it by
# looking for other apps nearby that have the right bundle ID and
# version. Note that many apps are installed in their own directories
# so the search needs to start two levels above the newer app bundle.
# Keep the paths tidy by calling dirname twice rather than appending
# "/../..".
PARENT_DIR=`dirname "$APP_PATH"`
GRANDPARENT_DIR=`dirname "$PARENT_DIR"`
# To avoid the for loop splitting the output of find on spaces in file
# paths, temporarily set the input file separator to just newline
# instead of the default space, tab and newline.
OLD_IFS=$IFS
IFS=$'\n'
# Go to a maximum depth of 3, since many apps have several helper apps
# buried deep within their application bundles and there's no point
# searching them all.
for APP_PATH in `find "$GRANDPARENT_DIR" -maxdepth 3 -name '*.app'`; do
# Get this application's bundle ID.
BUNDLE_ID=`GetPlistValue "$APP_PATH" CFBundleIdentifier` || return $?
# If the bundle ID matches,
if [ "$BUNDLE_ID" = "$APP_BUNDLE_ID" ]; then
# Get this application's version number.
VERSION=`GetPlistValue "$APP_PATH" CFBundleVersion` || return $?
# Pull just the first digit out of the version number.
VERSION_MAJOR=${VERSION%%.*}
if [ $VERSION_MAJOR -eq $APP_VERSION_MAJOR ]; then
echo $APP_PATH
return 0
fi
fi
done
# Restore the input file separator
IFS=$OLD_IFS
fi
return 1
}
ExtractAdobePaths()
{
app=$1
plist="/Library/Preferences/com.Adobe.$app.paths.plist"
[ -f "$plist" ] || return
# Convert plist to XML and pipe to python's plistlib to parse the data we're interested in
plutil -convert xml1 -o - "$plist" | python -c'
import sys
import plistlib
plist = plistlib.readPlistFromString(sys.stdin.read())
for version, directories in plist.iteritems():
pluginDir = directories["CommonPluginInstallPath"] if directories.has_key("CommonPluginInstallPath") else ""
sequenceDir = directories["SequencePresetsPath"] if directories.has_key("SequencePresetsPath") else ""
print version + ":" + pluginDir + ":" + sequenceDir
'
}
echo "*** Uninstall Desktop Video"
#
/bin/rm -rf /System/Library/Extensions/Blackmagic_Multibridge_Driver.kext/
/bin/rm -rf /Library/Extensions/Blackmagic_Multibridge_Driver.kext/
/bin/rm -rf /System/Library/Extensions/DeckLinkHD_Driver.kext/
/bin/rm -rf /System/Library/Extensions/DeckLink_Driver.kext/
/bin/rm -rf /System/Library/Extensions/DeckLinkFrameBufferDriver.kext/
/bin/rm -rf /System/Library/Extensions/DeckLinkExpressDriver.kext/
/bin/rm -rf /System/Library/Extensions/Blackmagic_Driver.kext/
/bin/rm -rf /System/Library/Extensions/BlackmagicFrameLink.kext/
/bin/rm -rf /System/Library/Extensions/Intensity_Driver.kext/
/bin/rm -rf /System/Library/Extensions/BlackmagicUsbIO.kext/
/bin/rm -rf /System/Library/Extensions/BlackmagicIO.kext/
/bin/rm -rf /Library/Extensions/DeckLink_Driver.kext/
/bin/rm -rf /Library/Extensions/DeckLinkFrameBufferDriver.kext/
/bin/rm -rf /Library/Extensions/DeckLinkExpressDriver.kext/
/bin/rm -rf /Library/Extensions/Blackmagic_Driver.kext/
/bin/rm -rf /Library/Extensions/BlackmagicFrameLink.kext/
/bin/rm -rf /Library/Extensions/Intensity_Driver.kext/
/bin/rm -rf /Library/Extensions/BlackmagicIO.kext/
/bin/rm -rf /Library/Extensions/BlackmagicUsbIO.kext/
#
/bin/rm -rf /Library/Frameworks/DeckLinkAPI.framework/
#
/bin/rm -rf /System/Library/Filesystems/framelink.fs/
#
/bin/rm -rf /sbin/mount_framelink
#
/bin/rm -rf /Library/QuickTime/Blackmagic\ Codec.component/
/bin/rm -rf /Library/QuickTime/Blackmagic\ RT\ Color\ Correction.component/
/bin/rm -rf /Library/QuickTime/Blackmagic\ RT\ Dissolves.component/
/bin/rm -rf /Library/QuickTime/Blackmagic\ RT\ Image\ Control.component/
#
/bin/rm -rf /Library/StartupItems/BlackmagicDaemon/
/bin/rm -rf /Library/StartupItems/DeckLinkStartup/
/bin/rm -rf /Library/StartupItems/IntensityStartup/
#
# LaunchAgent jobs are only visible to the user they were launched for, so
# they must be removed by launchctl running as that user. Since launchctl
# ignores the effective user ID, this script with uid $USER, euid root is
# the appropriate place to unload LaunchAgents.
LABEL=com.blackmagic-design.streaming.BMDStreamingFirmwareUpdater
PLIST=/Library/LaunchAgents/$LABEL.plist
[ -f $PLIST ] && /bin/launchctl unload $PLIST
/bin/rm -rf $PLIST
LABEL=com.blackmagic-design.DesktopVideoFirmwareUpdater
PLIST=/Library/LaunchAgents/$LABEL.plist
[ -f $PLIST ] && /bin/launchctl unload $PLIST
/bin/rm -rf $PLIST
LABEL=com.blackmagic-design.DesktopVideoUpdater
PLIST=/Library/LaunchAgents/$LABEL.plist
[ -f $PLIST ] && /bin/launchctl unload $PLIST
/bin/rm -rf $PLIST
#
/bin/rm -rf /Applications/Blackmagic\ Deck\ Control.app
/bin/rm -rf /Applications/Blackmagic\ LiveKey.app
/bin/rm -rf /Applications/Blackmagic\ Media\ Express\ v1.app
/bin/rm -rf /Applications/Blackmagic\ FrameLink.app
/bin/rm -rf /Applications/Blackmagic\ On-Air.app
# Remove bundled apps
/bin/rm -rf /Applications/Blackmagic\ Media\ Express.app
/bin/rm -rf /Applications/Blackmagic\ Disk\ Speed\ Test.app
/bin/rm -rf /Applications/Blackmagic\ Desktop\ Video.app
/bin/rm -rf "/Library/PreferencePanes/Blackmagic Desktop Video.prefPane/"
#
/bin/rm -rf /Applications/Multibridge\ Utility.app # old one, before rename
/bin/rm -rf /Applications/Blackmagic\ Multibridge\ Utility.app
#
/bin/rm -rf ~/Desktop/Blackmagic\ Deck\ Control.app
/bin/rm -rf ~/Desktop/Blackmagic\ Disk\ Speed\ Test.app
/bin/rm -rf ~/Desktop/Blackmagic\ LiveKey.app
/bin/rm -rf ~/Desktop/Blackmagic\ On-Air.app
#
/bin/rm -rf /Library/Application\ Support/Final\ Cut\ Pro\ System\ Support/Custom\ Settings/Blackmagic\ Default\ Settings/
/bin/rm -rf /Library/Application\ Support/Final\ Cut\ Pro\ System\ Support/Plugins/Blackmagic\ 10\ Bit\ Enabler
/bin/rm -rf /Library/Application\ Support/Final\ Cut\ Pro\ System\ Support/Plugins/Blackmagic\ Enabler
/bin/rm -rf /Library/Application\ Support/Final\ Cut\ Pro\ System\ Support/Plugins/Blackmagic\ Enabler\ 2vuy
/bin/rm -rf /Library/Application\ Support/Final\ Cut\ Pro\ System\ Support/Plugins/Blackmagic\ Enabler\ HD
/bin/rm -rf /Library/Application\ Support/Final\ Cut\ Pro\ System\ Support/Plugins/Blackmagic\ Enabler.txt
#
/bin/rm -rf /Library/CoreMediaIO/Plug-Ins/DAL/DeckLinkCMIO.plugin
/bin/rm -rf /Library/CoreMediaIO/Plug-Ins/FCP-DAL/DeckLinkCMIO.plugin
/bin/rm -rf /Library/CoreMediaIO/Plug-Ins/FCP-DAL/DeckLinkFcpxCMIO.plugin
#
/bin/rm -rf /Library/Audio/Plug-Ins/HAL/BlackmagicAudio.driver
#
/bin/rm -rf /Library/Application\ Support/Blackmagic\ Design/Blackmagic\ DeckLink/
/bin/rm -rf /Library/Application\ Support/Blackmagic\ Design/Streaming/
/bin/rm -rf /Library/Application\ Support/Blackmagic\ Design/Cintel/
/bin/rm -rf /Library/Application\ Support/Blackmagic\ Design/Multibridge
# LEGACY: clean up Photoshop CS3 (v10)
if appdir=$(FindAppWithVersion com.adobe.Photoshop 10 "Adobe Photoshop CS3.app" false CFBundleVersion)
then
echo "*** Uninstall from Adobe Photoshop CS3"
/bin/rm -rf "$appdir/"*"/DeckLinkImportExport.plugin"
/bin/rm -f "$appdir/"*"/DeckLink Importer"
/bin/rm -f "$appdir/"*"/DeckLink Exporter"
else
echo "*** Adobe Photoshop CS3 not found"
fi
# Cleanup for Adobe CS9 and greater
for application in Premiere\ Pro After\ Effects SpeedGrade
do
ExtractAdobePaths "$application" | while IFS=":" read version pluginDir sequenceDir
do
echo "*** Uninstall Adobe $application $version"
if [ "x$sequenceDir" != x ]
then
appdir="$sequenceDir/../../.."
/bin/rm -f "$appdir/Contents/Settings/Editing Modes/Blackmagic Editing Modes.xml"
/bin/rm -f "$appdir/Contents/Settings/EncoderPresets/SequencePreview/"*"/Blackmagic"*".epr"
/bin/rm -rf "$appdir/Contents/Settings/SequencePresets/Blackmagic "*"/"
fi
/bin/rm -rf "$pluginDir/DeckLink"{Device,FileImport,Record,Transmit}".bundle"
done
done
# Clean up Photoshop CS4 (v11), CS5 (v12), CS5.5 (v12.1 named Photoshop 5.1)
for CS in 4 5 5.1 6 7 8 9 10
do
# Bug #16051: Starting with CS6, Photoshop does not stash its version nubmer under the CFBundleVersion property as the previous versions did.
# Instead, it can be found under CFBundleShortVersionString
if [ "$CS" = "6" ]
then
version_property="CFBundleShortVersionString"
else
version_property="CFBundleVersion"
fi
if [ "$CS" = "10" ]; then
photoshopBundleName="Adobe Photoshop CC 2015.5.app"
elif [ "$CS" = "9" ]; then
photoshopBundleName="Adobe Photoshop CC 2015.app"
elif [ "$CS" = "8" ]; then
photoshopBundleName="Adobe Photoshop CC 2014.app"
elif [ "$CS" = "7" ]; then
photoshopBundleName="Adobe Photoshop CC.app"
else
photoshopBundleName="Adobe Photoshop CS$CS.app"
fi
PS=$(echo "$CS + 7" | /usr/bin/bc)
if appdir=$(FindAppWithVersion com.adobe.Photoshop $PS "$photoshopBundleName" true $version_property)
then
echo "*** Uninstall from Adobe Photoshop CS$CS"
rm -rf "$appdir/../Plug-ins/Import-Export/DeckLinkImportExport.plugin" # NB: plugins are at the same level as the app, not within
rm -rf "/Library/Application Support/Adobe/Plug-Ins/CC/DeckLinkImportExport.plugin"
else
echo "*** Adobe Photoshop CS$CS not found"
fi
done
# Remove newer versions that go in a consistent location
if [ -e "/Library/Application Support/Adobe/Plug-Ins/CC/DeckLinkImportExport.plugin" ]
then
echo "*** Uninstall Adobe Photoshop Plugin"
rm -rf "/Library/Application Support/Adobe/Plug-Ins/CC/DeckLinkImportExport.plugin"
fi
# LEGACY: Premiere CS3 presets
if appdir=$(FindAppWithVersion com.adobe.AdobePremierePro 3 "Adobe Premiere Pro CS3.app" false CFBundleVersion)
then
echo "*** Uninstall from Adobe Premiere CS3"
/bin/rm -f "$appdir/Contents/Plug-ins/"*"/Editing Modes/Blackmagic Editing Modes.xml"
/bin/rm -fr "$appdir/Contents/Settings/"*"/Blackmagic"*
else
echo "*** Adobe Premiere CS3 not found"
fi
# Clean up Premiere CS{4,5,5.5,6,7} presets & plugins
for CS in 4 5 5.5 6 7 8
do
if [ "$CS" = "8" ]; then
premiereBundleName="Adobe Premiere Pro CC 2014.app"
elif [ "$CS" = "7" ]; then
premiereBundleName="Adobe Premiere Pro CC.app"
else
premiereBundleName="Adobe Premiere Pro CS$CS.app"
fi
if appdir=$(FindAppWithVersion com.adobe.AdobePremierePro $CS "${premiereBundleName}" true CFBundleVersion)
then
echo "*** Uninstall from Adobe Premiere CS$CS"
/bin/rm -f "$appdir/Contents/Settings/Editing Modes/Blackmagic Editing Modes.xml"
/bin/rm -f "$appdir/Contents/Settings/EncoderPresets/SequencePreview/"*"/Blackmagic"*".epr"
/bin/rm -rf "$appdir/Contents/Settings/SequencePresets/Blackmagic "*"/"
else
echo "*** Adobe Premiere CS$CS not found"
fi
done
# Clean up Premiere CS{4,5,5.5,6,7} presets & plugins (and LEGACY)
/bin/rm -rf "/Library/Application Support/Adobe/Common/Plug-ins/CS"{3,4,5,5.5,6}"/MediaCore/DeckLink"{Device,FileImport,Playback,Record,Transmit}".bundle"
/bin/rm -rf "/Library/Application Support/Adobe/Common/Plug-ins/"{7.0,8.0}"/MediaCore/DeckLink"{Device,FileImport,Record,Transmit}".bundle"
# Avid Media Composer
AvidPluginDir="/Library/Application Support/Avid/AVX2_Plug-ins/"
if [ -e "$AvidPluginDir" ]
then
echo "*** Uninstall from Avid Media Composer"
rm -rf "$AvidPluginDir/HWSDK_DeckLink.acf"
rm -rf "$AvidPluginDir/OpenIO_Blackmagic.acf"
rm -rf "$AvidPluginDir/Blackmagic Design"
fi
echo "*** clean receipts"
# new receipts
/bin/rm -rf /Library/Receipts/blackmagicdecklink*.pkg
# old receipts (pre 7.0)
/bin/rm -rf /Library/Receipts/BlackmagicApplications.pkg
/bin/rm -rf /Library/Receipts/BlackmagicCodec.pkg
/bin/rm -rf /Library/Receipts/BlackmagicDriver.pkg
/bin/rm -rf /Library/Receipts/BlackmagicDriverPAL.pkg
/bin/rm -rf /Library/Receipts/BlackmagicEnablers.pkg
/bin/rm -rf /Library/Receipts/BlackmagicPrefPane.pkg
/bin/rm -rf /Library/Receipts/BlackmagicSetups.pkg
/bin/rm -rf /Library/Receipts/BlackmagicStartupItems.pkg
/bin/rm -rf /Library/Receipts/BlackmagicLaunchDaemons.pkg
/bin/rm -rf /Library/Receipts/BlackmagicFCPSupport.pkg
/bin/rm -rf /Library/Receipts/BlackmagicDeckLinkSupport.pkg
/bin/rm -rf /Library/Receipts/BlackmagicFrameLinkDiskUtilities.pkg
/bin/rm -rf /Library/Receipts/BlackmagicFrameLinkFilesystem.pkg
/bin/rm -rf /Library/Receipts/BlackmagicFLDiskUtilities.pkg
/bin/rm -rf /Library/Receipts/BlackmagicFLFilesystem.pkg
/bin/rm -rf /Library/Receipts/IntensityApplications.pkg
/bin/rm -rf /Library/Receipts/IntensityCodec.pkg
/bin/rm -rf /Library/Receipts/IntensityDriver.pkg
/bin/rm -rf /Library/Receipts/IntensityFCPSupport.pkg
/bin/rm -rf /Library/Receipts/IntensityPrefPane.pkg
/bin/rm -rf /Library/Receipts/IntensityStartupItems.pkg
/bin/rm -rf /Library/Receipts/IntensityLaunchDaemons.pkg
/bin/rm -rf /Library/Receipts/IntensitySupport.pkg
/bin/rm -rf /Library/Receipts/framelink.pkg
/bin/rm -rf /Library/Receipts/MultibridgeApplications.pkg
/bin/rm -rf /Library/Receipts/MultibridgeDriver.pkg
/bin/rm -rf /Library/Receipts/MultibridgeSupport.pkg
echo "*** clean Final Cut Pro"
/bin/rm -f ~/Library/Preferences/Final\ Cut\ Pro\ User\ Data/Final\ Cut\ Pro\ [0-9.]*\ Preferences
/bin/rm -f ~/Library/Preferences/Final\ Cut\ Pro\ User\ Data/Final\ Cut\ Pro\ MOA\ Cache
/bin/rm -f ~/Library/Preferences/Final\ Cut\ Pro\ User\ Data/Final\ Cut\ Pro\ POA\ Cache
/bin/rm -f ~/Library/Preferences/Final\ Cut\ Pro\ User\ Data/Final\ Cut\ Pro\ [0-9.]*\ Prefs.fcset
/bin/rm -f ~/Library/Preferences/Final\ Cut\ Pro\ User\ Data/Final\ Cut\ Pro\ Obj\ Cache.fcmch
/bin/rm -f ~/Library/Preferences/Final\ Cut\ Pro\ User\ Data/Final\ Cut\ Pro\ Prof\ Cache.fcpch
echo "*** clean driver"
/usr/bin/touch /System/Library/Extensions
/usr/bin/touch /Library/Extensions
/usr/bin/defaults delete com.apple.loginwindow LoginHook
echo "*** done"
exit 0
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment