Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

BUGFIX: don't try autocleanup inside system dirs #2672

Merged
merged 1 commit into from
Mar 3, 2014
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
229 changes: 228 additions & 1 deletion lib/cask/pkg.rb
Original file line number Diff line number Diff line change
@@ -1,4 +1,231 @@
class Cask::Pkg
SYSTEM_DIRS = [
'/',
'/Applications',
'/Applications/Utilities',
'/Incompatible Software',
'/Library',
'/Library/Application Support',
'/Library/Audio',
'/Library/Caches',
'/Library/ColorPickers',
'/Library/ColorSync',
'/Library/Components',
'/Library/Compositions',
'/Library/Contextual Menu Items',
'/Library/CoreMediaIO',
'/Library/Desktop Pictures',
'/Library/Developer',
'/Library/Dictionaries',
'/Library/DirectoryServices',
'/Library/Documentation',
'/Library/Extensions',
'/Library/Filesystems',
'/Library/Fonts',
'/Library/Frameworks',
'/Library/Graphics',
'/Library/Image Capture',
'/Library/Input Methods',
'/Library/Internet Plug-Ins',
'/Library/Java',
'/Library/Keyboard Layouts',
'/Library/Keychains',
'/Library/LaunchAgents',
'/Library/LaunchDaemons',
'/Library/Logs',
'/Library/Messages',
'/Library/Modem Scripts',
'/Library/OpenDirectory',
'/Library/PDF Services',
'/Library/Perl',
'/Library/PreferencePanes',
'/Library/Preferences',
'/Library/Printers',
'/Library/PrivilegedHelperTools',
'/Library/Python',
'/Library/QuickLook',
'/Library/QuickTime',
'/Library/Receipts',
'/Library/Ruby',
'/Library/Sandbox',
'/Library/Screen Savers',
'/Library/ScriptingAdditions',
'/Library/Scripts',
'/Library/Security',
'/Library/Speech',
'/Library/Spelling',
'/Library/Spotlight',
'/Library/StartupItems',
'/Library/SystemProfiler',
'/Library/Updates',
'/Library/User Pictures',
'/Library/Video',
'/Library/WebServer',
'/Library/Widgets',
'/Library/iTunes',
'/Network',
'/System',
'/System/Library',
'/System/Library/Accessibility',
'/System/Library/Accounts',
'/System/Library/Address Book Plug-Ins',
'/System/Library/Assistant',
'/System/Library/Automator',
'/System/Library/BridgeSupport',
'/System/Library/Caches',
'/System/Library/ColorPickers',
'/System/Library/ColorSync',
'/System/Library/Colors',
'/System/Library/Components',
'/System/Library/Compositions',
'/System/Library/CoreServices',
'/System/Library/DTDs',
'/System/Library/DirectoryServices',
'/System/Library/Displays',
'/System/Library/Extensions',
'/System/Library/Filesystems',
'/System/Library/Filters',
'/System/Library/Fonts',
'/System/Library/Frameworks',
'/System/Library/Graphics',
'/System/Library/IdentityServices',
'/System/Library/Image Capture',
'/System/Library/Input Methods',
'/System/Library/InternetAccounts',
'/System/Library/Java',
'/System/Library/KerberosPlugins',
'/System/Library/Keyboard Layouts',
'/System/Library/Keychains',
'/System/Library/LaunchAgents',
'/System/Library/LaunchDaemons',
'/System/Library/LinguisticData',
'/System/Library/LocationBundles',
'/System/Library/LoginPlugins',
'/System/Library/Messages',
'/System/Library/Metadata',
'/System/Library/MonitorPanels',
'/System/Library/OpenDirectory',
'/System/Library/OpenSSL',
'/System/Library/Password Server Filters',
'/System/Library/PerformanceMetrics',
'/System/Library/Perl',
'/System/Library/PreferencePanes',
'/System/Library/Printers',
'/System/Library/PrivateFrameworks',
'/System/Library/QuickLook',
'/System/Library/QuickTime',
'/System/Library/QuickTimeJava',
'/System/Library/Recents',
'/System/Library/SDKSettingsPlist',
'/System/Library/Sandbox',
'/System/Library/Screen Savers',
'/System/Library/ScreenReader',
'/System/Library/ScriptingAdditions',
'/System/Library/ScriptingDefinitions',
'/System/Library/Security',
'/System/Library/Services',
'/System/Library/Sounds',
'/System/Library/Speech',
'/System/Library/Spelling',
'/System/Library/Spotlight',
'/System/Library/StartupItems',
'/System/Library/SyncServices',
'/System/Library/SystemConfiguration',
'/System/Library/SystemProfiler',
'/System/Library/Tcl',
'/System/Library/TextEncodings',
'/System/Library/User Template',
'/System/Library/UserEventPlugins',
'/System/Library/Video',
'/System/Library/WidgetResources',
'/User Information',
'/Users',
'/Volumes',
'/bin',
'/boot',
'/cores',
'/dev',
'/etc',
'/etc/X11',
'/etc/opt',
'/etc/sgml',
'/etc/xml',
'/home',
'/libexec',
'/lost+found',
'/media',
'/mnt',
'/net',
'/opt',
'/private',
'/private/etc',
'/private/tftpboot',
'/private/tmp',
'/private/var',
'/proc',
'/root',
'/sbin',
'/srv',
'/tmp',
'/usr',
'/usr/X11R6',
'/usr/bin',
'/usr/etc',
'/usr/include',
'/usr/lib',
'/usr/libexec',
'/usr/local',
'/usr/local/Cellar',
'/usr/local/Frameworks',
'/usr/local/Library',
'/usr/local/bin',
'/usr/local/etc',
'/usr/local/include',
'/usr/local/lib',
'/usr/local/libexec',
'/usr/local/opt',
'/usr/local/share',
'/usr/local/share/man',
'/usr/local/share/man/man1',
'/usr/local/share/man/man2',
'/usr/local/share/man/man3',
'/usr/local/share/man/man4',
'/usr/local/share/man/man5',
'/usr/local/share/man/man6',
'/usr/local/share/man/man7',
'/usr/local/share/man/man8',
'/usr/local/share/man/man9',
'/usr/local/share/man/mann',
'/usr/local/var',
'/usr/local/var/lib',
'/usr/local/var/lock',
'/usr/local/var/run',
'/usr/sbin',
'/usr/share',
'/usr/share/man',
'/usr/share/man/man1',
'/usr/share/man/man2',
'/usr/share/man/man3',
'/usr/share/man/man4',
'/usr/share/man/man5',
'/usr/share/man/man6',
'/usr/share/man/man7',
'/usr/share/man/man8',
'/usr/share/man/man9',
'/usr/share/man/mann',
'/usr/src',
'/var',
'/var/cache',
'/var/lib',
'/var/lock',
'/var/log',
'/var/mail',
'/var/run',
'/var/spool',
'/var/spool/mail',
'/var/tmp',
].map{|x| Pathname.new(x)}

def self.all_matching(regexp, command)
command.run(%Q(/usr/sbin/pkgutil --pkgs="#{regexp}")).split("\n").map do |package_id|
new(package_id.chomp, command)
Expand All @@ -17,7 +244,7 @@ def uninstall
@command.run('/bin/rm', :args => file_slice.unshift('-f'), :sudo => true)
end
_deepest_path_first(list('dirs')).each do |dir|
if dir.exist?
if dir.exist? and !SYSTEM_DIRS.include?(dir)
_with_full_permissions(dir) do
_clean_broken_symlinks(dir)
_clean_ds_store(dir)
Expand Down