Skip to content

Commit

Permalink
[WIP] Change artifact behavior to moving instead of symlinking (#13966)
Browse files Browse the repository at this point in the history
* Change app artifact to move instead of link

First step towards change in installation behavior mentioned in [13201]

* Fix handling of binaries linked from inside of app bundles

Also adds `appdir` method for interpolation in stanzas

* Change appdir to root Applications directory

* Update 2-app tests

* Refactor: add options, ivars to `Installer`, `Download`

In preparation for upcoming changes, this commit cleans up some code. The commit includes:

- In order to reduce unnecessary object passing, make both the `force` and `skip_cask_deps` option into instance variables of the `Installer` class

- Introduce options hashes to initializers of both the `Installer` and `Download` class

- When the `install --force` command enters the fetch phase, make it explicit in the code that fetching is never enforced in that case.

- Update tests

* Force overwrite artifacts on `--force` reinstall

This commit changes the behavior of a `Moved` artifact such that if the target already exists, `brew cask install --force` will remove the existing target before moving the staged artifact.

In that case, the warning message will say *overwriting* instead of *not moving*.

The behavior of plain `brew cask install` remains unchanged; the same goes for the warning message for that case.

* Change remaining artifacts to move instead of symlink

* Update casks to use appdir in binary paths

* Forcibly overwrite artifacts, modifying flags and using `sudo` if needed

- This commit implements [the proposed behavior for `install --force`](#13966 (comment)) when a target already exists and has either permission problems or is not owned by the user.

- The changes apply only when the `force` option is given.

- Reused the existing safeguard from the `.pkg` artifact to prevent deleting important directories by bug or mistake

- The two existing blacklists `SYSTEM_DIRS` and `UNDELETABLE_DIRS` have been consolidated into the `Hbc::MacOS` module.

- `UNDELETABLE_DIRS` now also contains all the entries from `SYSTEM_DIRS` which was a to-do anyway.

- The two blacklists are now also frozen for good measure.

- The utility method `permissions_rmtree` was moved to `Hbc::Utils`.

- The `tried_permissions` part in `Utils` now falls back correctly when there are also ownership issues at the same time.

- Introduced a separate `current_user` method for mocking.

- Added an optional feature to `FakeSystemCommand` so it can now act as a proxy to `SystemCommand`.

- Added tests for various `permissions_rmtree` cases.
  • Loading branch information
mwean authored and jawshooah committed May 31, 2016
1 parent f3421da commit 4738316
Show file tree
Hide file tree
Showing 109 changed files with 1,163 additions and 801 deletions.
2 changes: 1 addition & 1 deletion Casks/arduino.rb
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
license :gpl

app 'Arduino.app'
binary 'Arduino.app/Contents/Java/arduino-builder'
binary "#{appdir}/Arduino.app/Contents/Java/arduino-builder"

caveats do
depends_on_java
Expand Down
4 changes: 2 additions & 2 deletions Casks/atom.rb
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,8 @@
depends_on macos: '>= :mountain_lion'

app 'Atom.app'
binary 'Atom.app/Contents/Resources/app/apm/node_modules/.bin/apm', target: 'apm'
binary 'Atom.app/Contents/Resources/app/atom.sh', target: 'atom'
binary "#{appdir}/Atom.app/Contents/Resources/app/apm/node_modules/.bin/apm", target: 'apm'
binary "#{appdir}/Atom.app/Contents/Resources/app/atom.sh", target: 'atom'

postflight do
suppress_move_to_applications
Expand Down
40 changes: 20 additions & 20 deletions Casks/calibre.rb
Original file line number Diff line number Diff line change
Expand Up @@ -15,26 +15,26 @@
license :gpl

app 'calibre.app'
binary 'calibre.app/Contents/MacOS/calibre'
binary 'calibre.app/Contents/MacOS/calibre-complete'
binary 'calibre.app/Contents/MacOS/calibre-customize'
binary 'calibre.app/Contents/MacOS/calibre-debug'
binary 'calibre.app/Contents/MacOS/calibre-parallel'
binary 'calibre.app/Contents/MacOS/calibre-server'
binary 'calibre.app/Contents/MacOS/calibre-smtp'
binary 'calibre.app/Contents/MacOS/calibredb'
binary 'calibre.app/Contents/MacOS/ebook-convert'
binary 'calibre.app/Contents/MacOS/ebook-device'
binary 'calibre.app/Contents/MacOS/ebook-edit'
binary 'calibre.app/Contents/MacOS/ebook-meta'
binary 'calibre.app/Contents/MacOS/ebook-polish'
binary 'calibre.app/Contents/MacOS/ebook-viewer'
binary 'calibre.app/Contents/MacOS/fetch-ebook-metadata'
binary 'calibre.app/Contents/MacOS/lrf2lrs'
binary 'calibre.app/Contents/MacOS/lrfviewer'
binary 'calibre.app/Contents/MacOS/lrs2lrf'
binary 'calibre.app/Contents/MacOS/markdown-calibre'
binary 'calibre.app/Contents/MacOS/web2disk'
binary "#{appdir}/calibre.app/Contents/MacOS/calibre"
binary "#{appdir}/calibre.app/Contents/MacOS/calibre-complete"
binary "#{appdir}/calibre.app/Contents/MacOS/calibre-customize"
binary "#{appdir}/calibre.app/Contents/MacOS/calibre-debug"
binary "#{appdir}/calibre.app/Contents/MacOS/calibre-parallel"
binary "#{appdir}/calibre.app/Contents/MacOS/calibre-server"
binary "#{appdir}/calibre.app/Contents/MacOS/calibre-smtp"
binary "#{appdir}/calibre.app/Contents/MacOS/calibredb"
binary "#{appdir}/calibre.app/Contents/MacOS/ebook-convert"
binary "#{appdir}/calibre.app/Contents/MacOS/ebook-device"
binary "#{appdir}/calibre.app/Contents/MacOS/ebook-edit"
binary "#{appdir}/calibre.app/Contents/MacOS/ebook-meta"
binary "#{appdir}/calibre.app/Contents/MacOS/ebook-polish"
binary "#{appdir}/calibre.app/Contents/MacOS/ebook-viewer"
binary "#{appdir}/calibre.app/Contents/MacOS/fetch-ebook-metadata"
binary "#{appdir}/calibre.app/Contents/MacOS/lrf2lrs"
binary "#{appdir}/calibre.app/Contents/MacOS/lrfviewer"
binary "#{appdir}/calibre.app/Contents/MacOS/lrs2lrf"
binary "#{appdir}/calibre.app/Contents/MacOS/markdown-calibre"
binary "#{appdir}/calibre.app/Contents/MacOS/web2disk"

zap delete: [
'~/Library/Preferences/net.kovidgoyal.calibre.plist',
Expand Down
2 changes: 1 addition & 1 deletion Casks/changes.rb
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
license :commercial

app 'Changes.app'
binary 'Changes.app/Contents/Resources/chdiff'
binary "#{appdir}/Changes.app/Contents/Resources/chdiff"

zap delete: [
'~/Library/Preferences/com.bitbq.Changes.plist',
Expand Down
12 changes: 6 additions & 6 deletions Casks/cmake.rb
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,10 @@
conflicts_with formula: 'cmake'

app 'CMake.app'
binary 'CMake.app/Contents/bin/cmake'
binary 'CMake.app/Contents/bin/ccmake'
binary 'CMake.app/Contents/bin/cmakexbuild'
binary 'CMake.app/Contents/bin/cpack'
binary 'CMake.app/Contents/bin/ctest'
binary 'CMake.app/Contents/bin/cmake-gui'
binary "#{appdir}/CMake.app/Contents/bin/cmake"
binary "#{appdir}/CMake.app/Contents/bin/ccmake"
binary "#{appdir}/CMake.app/Contents/bin/cmakexbuild"
binary "#{appdir}/CMake.app/Contents/bin/cpack"
binary "#{appdir}/CMake.app/Contents/bin/ctest"
binary "#{appdir}/CMake.app/Contents/bin/cmake-gui"
end
2 changes: 1 addition & 1 deletion Casks/cocoapods.rb
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
container type: :tar

app 'CocoaPods.app'
binary 'CocoaPods.app/Contents/Helpers/pod'
binary "#{appdir}/CocoaPods.app/Contents/Helpers/pod"

postflight do
# Because Homebrew-Cask symlinks the binstub directly, stop the app from asking the user to install the binstub.
Expand Down
10 changes: 5 additions & 5 deletions Casks/emacs.rb
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,9 @@
license :oss

app 'Emacs.app'
binary 'Emacs.app/Contents/MacOS/bin/emacsclient'
binary 'Emacs.app/Contents/MacOS/bin/ctags'
binary 'Emacs.app/Contents/MacOS/bin/grep-changelog'
binary 'Emacs.app/Contents/MacOS/bin/ebrowse'
binary 'Emacs.app/Contents/MacOS/bin/etags'
binary "#{appdir}/Emacs.app/Contents/MacOS/bin/emacsclient"
binary "#{appdir}/Emacs.app/Contents/MacOS/bin/ctags"
binary "#{appdir}/Emacs.app/Contents/MacOS/bin/grep-changelog"
binary "#{appdir}/Emacs.app/Contents/MacOS/bin/ebrowse"
binary "#{appdir}/Emacs.app/Contents/MacOS/bin/etags"
end
2 changes: 1 addition & 1 deletion Casks/filebot.rb
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
license :gpl

app 'FileBot.app'
binary 'FileBot.app/Contents/MacOS/filebot.sh', target: 'filebot'
binary "#{appdir}/FileBot.app/Contents/MacOS/filebot.sh", target: 'filebot'

caveats do
depends_on_java('8')
Expand Down
2 changes: 1 addition & 1 deletion Casks/genymotion.rb
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@

app 'Genymotion.app'
app 'Genymotion Shell.app'
binary 'Genymotion Shell.app/Contents/MacOS/genyshell'
binary "#{appdir}/Genymotion Shell.app/Contents/MacOS/genyshell"

caveats do
files_in_usr_local
Expand Down
4 changes: 2 additions & 2 deletions Casks/git-annex.rb
Original file line number Diff line number Diff line change
Expand Up @@ -38,8 +38,8 @@
]

app 'git-annex.app'
binary 'git-annex.app/Contents/MacOS/git-annex'
binary 'git-annex.app/Contents/MacOS/git-annex-shell'
binary "#{appdir}/git-annex.app/Contents/MacOS/git-annex"
binary "#{appdir}/git-annex.app/Contents/MacOS/git-annex-shell"

uninstall launchctl: 'com.branchable.git-annex.assistant'

Expand Down
2 changes: 1 addition & 1 deletion Casks/github-desktop.rb
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
license :gratis

app 'GitHub Desktop.app'
binary 'GitHub Desktop.app/Contents/MacOS/github_cli', target: 'github'
binary "#{appdir}/GitHub Desktop.app/Contents/MacOS/github_cli", target: 'github'

postflight do
suppress_move_to_applications
Expand Down
2 changes: 1 addition & 1 deletion Casks/gitup.rb
Original file line number Diff line number Diff line change
Expand Up @@ -13,5 +13,5 @@
depends_on macos: '>= :mountain_lion'

app 'GitUp.app'
binary 'GitUp.app/Contents/SharedSupport/gitup'
binary "#{appdir}/GitUp.app/Contents/SharedSupport/gitup"
end
2 changes: 1 addition & 1 deletion Casks/gitx.rb
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
]

app 'GitX.app'
binary 'GitX.app/Contents/Resources/gitx'
binary "#{appdir}/GitX.app/Contents/Resources/gitx"

zap delete: [
'~/Library/Application Support/com.apple.sharedfilelist/com.apple.LSSharedFileList.ApplicationRecentDocuments/nl.frim.gitx.sfl',
Expand Down
2 changes: 1 addition & 1 deletion Casks/hockey.rb
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
license :unknown # TODO: change license and remove this comment; ':unknown' is a machine-generated placeholder

app 'HockeyApp.app'
binary 'HockeyApp.app/Contents/Resources/puck'
binary "#{appdir}/HockeyApp.app/Contents/Resources/puck"

postflight do
suppress_move_to_applications
Expand Down
2 changes: 1 addition & 1 deletion Casks/hopper-disassembler.rb
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
depends_on macos: '>= :lion'

app "Hopper Disassembler v#{version.major}.app"
binary "Hopper Disassembler v#{version.major}.app/Contents/MacOS/hopper"
binary "#{appdir}/Hopper Disassembler v#{version.major}.app/Contents/MacOS/hopper"

zap delete: [
'~/Library/Application Support/Hopper',
Expand Down
2 changes: 1 addition & 1 deletion Casks/inkscape.rb
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
depends_on x11: true

app 'Inkscape.app'
binary 'Inkscape.app/Contents/Resources/bin/inkscape'
binary "#{appdir}/Inkscape.app/Contents/Resources/bin/inkscape"

zap delete: '~/.inkscape-etc'
end
2 changes: 1 addition & 1 deletion Casks/julia.rb
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
depends_on macos: '>= :lion'

app "Julia-#{version}.app"
binary "Julia-#{version}.app/Contents/Resources/julia/bin/julia"
binary "#{appdir}/Julia-#{version}.app/Contents/Resources/julia/bin/julia"

zap delete: '~/.julia'
end
2 changes: 1 addition & 1 deletion Casks/kaleidoscope.rb
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
auto_updates true

app 'Kaleidoscope.app'
binary 'Kaleidoscope.app/Contents/Resources/bin/ksdiff'
binary "#{appdir}/Kaleidoscope.app/Contents/Resources/bin/ksdiff"

postflight do
suppress_move_to_applications
Expand Down
2 changes: 1 addition & 1 deletion Casks/kdiff3.rb
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
license :gpl

app 'kdiff3.app'
binary 'kdiff3.app/Contents/MacOS/kdiff3'
binary "#{appdir}/kdiff3.app/Contents/MacOS/kdiff3"

zap delete: '~/.kdiff3rc'
end
2 changes: 1 addition & 1 deletion Casks/kivy.rb
Original file line number Diff line number Diff line change
Expand Up @@ -11,5 +11,5 @@

# Renamed as suggested by developer: https://kivy.org/docs/installation/installation-osx.html#installation-on-os-x
app 'Kivy3.app', target: 'Kivy.app'
binary 'Kivy3.app/Contents/Resources/script', target: 'kivy'
binary "#{appdir}/Kivy3.app/Contents/Resources/script", target: 'kivy'
end
2 changes: 1 addition & 1 deletion Casks/kod.rb
Original file line number Diff line number Diff line change
Expand Up @@ -9,5 +9,5 @@
license :oss

app 'Kod.app'
binary 'Kod.app/Contents/SharedSupport/kod'
binary "#{appdir}/Kod.app/Contents/SharedSupport/kod"
end
2 changes: 1 addition & 1 deletion Casks/laullon-gitx.rb
Original file line number Diff line number Diff line change
Expand Up @@ -16,5 +16,5 @@
]

app 'GitX.app'
binary 'GitX.app/Contents/Resources/gitx'
binary "#{appdir}/GitX.app/Contents/Resources/gitx"
end
24 changes: 12 additions & 12 deletions Casks/libreoffice.rb
Original file line number Diff line number Diff line change
Expand Up @@ -17,18 +17,18 @@
key_id: 'c2839ecad9408fbe9531c3e9f434a1efafeeaea3'

app 'LibreOffice.app'
binary 'LibreOffice.app/Contents/MacOS/gengal'
binary 'LibreOffice.app/Contents/MacOS/regmerge'
binary 'LibreOffice.app/Contents/MacOS/regview'
binary 'LibreOffice.app/Contents/MacOS/senddoc'
binary 'LibreOffice.app/Contents/MacOS/soffice'
binary 'LibreOffice.app/Contents/MacOS/ui-previewer'
binary 'LibreOffice.app/Contents/MacOS/uno'
binary 'LibreOffice.app/Contents/MacOS/unoinfo'
binary 'LibreOffice.app/Contents/MacOS/unopkg'
binary 'LibreOffice.app/Contents/MacOS/urelibs'
binary 'LibreOffice.app/Contents/MacOS/uri-encode'
binary 'LibreOffice.app/Contents/MacOS/xpdfimport'
binary "#{appdir}/LibreOffice.app/Contents/MacOS/gengal"
binary "#{appdir}/LibreOffice.app/Contents/MacOS/regmerge"
binary "#{appdir}/LibreOffice.app/Contents/MacOS/regview"
binary "#{appdir}/LibreOffice.app/Contents/MacOS/senddoc"
binary "#{appdir}/LibreOffice.app/Contents/MacOS/soffice"
binary "#{appdir}/LibreOffice.app/Contents/MacOS/ui-previewer"
binary "#{appdir}/LibreOffice.app/Contents/MacOS/uno"
binary "#{appdir}/LibreOffice.app/Contents/MacOS/unoinfo"
binary "#{appdir}/LibreOffice.app/Contents/MacOS/unopkg"
binary "#{appdir}/LibreOffice.app/Contents/MacOS/urelibs"
binary "#{appdir}/LibreOffice.app/Contents/MacOS/uri-encode"
binary "#{appdir}/LibreOffice.app/Contents/MacOS/xpdfimport"

zap delete: [
'~/Library/Application Support/com.apple.sharedfilelist/com.apple.LSSharedFileList.ApplicationRecentDocuments/org.libreoffice.script.sfl',
Expand Down
2 changes: 1 addition & 1 deletion Casks/love.rb
Original file line number Diff line number Diff line change
Expand Up @@ -9,5 +9,5 @@
license :oss

app 'love.app'
binary 'love.app/Contents/MacOS/love'
binary "#{appdir}/love.app/Contents/MacOS/love"
end
2 changes: 1 addition & 1 deletion Casks/macdown.rb
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
license :mit

app 'MacDown.app'
binary 'MacDown.app/Contents/SharedSupport/bin/macdown'
binary "#{appdir}/MacDown.app/Contents/SharedSupport/bin/macdown"

zap delete: ['~/Library/Preferences/com.uranusjr.macdown.plist',
'~/Library/Application Support/MacDown']
Expand Down
2 changes: 1 addition & 1 deletion Casks/mailmate.rb
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
license :commercial

app 'MailMate.app'
binary 'MailMate.app/Contents/Resources/emate'
binary "#{appdir}/MailMate.app/Contents/Resources/emate"

caveats do
files_in_usr_local
Expand Down
2 changes: 1 addition & 1 deletion Casks/praat.rb
Original file line number Diff line number Diff line change
Expand Up @@ -16,5 +16,5 @@
license :gpl

app 'Praat.app'
binary 'Praat.app/Contents/MacOS/Praat', target: 'praat'
binary "#{appdir}/Praat.app/Contents/MacOS/Praat", target: 'praat'
end
2 changes: 1 addition & 1 deletion Casks/rowanj-gitx.rb
Original file line number Diff line number Diff line change
Expand Up @@ -23,5 +23,5 @@
depends_on arch: :intel

app 'GitX.app'
binary 'GitX.app/Contents/Resources/gitx'
binary "#{appdir}/GitX.app/Contents/Resources/gitx"
end
4 changes: 2 additions & 2 deletions Casks/sage.rb
Original file line number Diff line number Diff line change
Expand Up @@ -25,10 +25,10 @@

if MacOS.release <= :yosemite
app "Sage-#{version}.app"
binary "Sage-#{version}.app/Contents/Resources/sage/sage"
binary "#{appdir}/Sage-#{version}.app/Contents/Resources/sage/sage"
else
app "SageMath-#{version}.app"
binary "SageMath-#{version}.app/Contents/Resources/sage/sage"
binary "#{appdir}/SageMath-#{version}.app/Contents/Resources/sage/sage"
end

zap delete: [
Expand Down
6 changes: 3 additions & 3 deletions Casks/skim.rb
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,9 @@
license :bsd

app 'Skim.app'
binary 'Skim.app/Contents/SharedSupport/displayline'
binary 'Skim.app/Contents/SharedSupport/skimnotes'
binary 'Skim.app/Contents/SharedSupport/skimpdf'
binary "#{appdir}/Skim.app/Contents/SharedSupport/displayline"
binary "#{appdir}/Skim.app/Contents/SharedSupport/skimnotes"
binary "#{appdir}/Skim.app/Contents/SharedSupport/skimpdf"

zap delete: '~/Library/Preferences/net.sourceforge.skim-app.skim.plist'
end
2 changes: 1 addition & 1 deletion Casks/smartgit.rb
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
license :commercial

app 'SmartGit.app'
binary 'SmartGit.app/Contents/MacOS/SmartGit'
binary "#{appdir}/SmartGit.app/Contents/MacOS/SmartGit"

caveats do
files_in_usr_local
Expand Down
2 changes: 1 addition & 1 deletion Casks/smartsynchronize.rb
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
depends_on macos: '>= :lion'

app 'SmartSynchronize.app'
binary 'SmartSynchronize.app/Contents/MacOS/SmartSynchronize'
binary "#{appdir}/SmartSynchronize.app/Contents/MacOS/SmartSynchronize"

caveats do
files_in_usr_local
Expand Down
2 changes: 1 addition & 1 deletion Casks/sopcast.rb
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
license :gratis

app 'SopCast.app'
binary 'SopCast.app/Contents/Resources/binaries/m32/sp-sc-auth'
binary "#{appdir}/SopCast.app/Contents/Resources/binaries/m32/sp-sc-auth"

caveats do
files_in_usr_local
Expand Down
2 changes: 1 addition & 1 deletion Casks/sourcetree.rb
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
auto_updates true

app 'SourceTree.app'
binary 'SourceTree.app/Contents/Resources/stree'
binary "#{appdir}/SourceTree.app/Contents/Resources/stree"

postflight do
suppress_move_to_applications
Expand Down
2 changes: 1 addition & 1 deletion Casks/sublime-text.rb
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
license :closed

app 'Sublime Text 2.app'
binary 'Sublime Text 2.app/Contents/SharedSupport/bin/subl'
binary "#{appdir}/Sublime Text 2.app/Contents/SharedSupport/bin/subl"

zap delete: [
'~/Library/Application Support/Sublime Text 2',
Expand Down
4 changes: 2 additions & 2 deletions Casks/swi-prolog.rb
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,6 @@
license :oss

app 'SWI-Prolog.app'
binary 'SWI-Prolog.app/Contents/MacOS/swipl'
binary 'SWI-Prolog.app/Contents/MacOS/swipl-ld'
binary "#{appdir}/SWI-Prolog.app/Contents/MacOS/swipl"
binary "#{appdir}/SWI-Prolog.app/Contents/MacOS/swipl-ld"
end
Loading

0 comments on commit 4738316

Please sign in to comment.