Previously, the JSON-based cask config loader was untested.
This commit changes the interface to accept a string, making the loader
easier to test. The commit also adds a test.
- My editor converted some of these to spaces when I changed the lines
in the previous commit. We should be consistent, so I made all of them
into spaces.
- I suggested this for the contents of
[Linuxbrew/docker](https://github.com/Linuxbrew/docker) in
https://github.com/Linuxbrew/docker/issues/75. People agreed, and
Shaun asked me to do the same here.
- This adds a step to CI to lint the Dockerfile, via
[hadolint](https://github.com/hadolint/hadolint), on Ubuntu.
- The linting errors it surfaced on this Dockerfile were:
```
Dockerfile:4 DL3008 Pin versions in apt get install. Instead of `apt-get install <package>` use `apt-get install <package>=<version>`
Dockerfile:30 DL3020 Use COPY instead of ADD for files and folders
Dockerfile:32 DL3003 Use WORKDIR to switch to a directory
```
- [DL3008](https://github.com/hadolint/hadolint/wiki/DL3008) - pinning
versions in `apt-get install` - is at odds with what we recommend in the
normal Homebrew on Linux dependency install instructions. We don't
want the dependency management of having to check each of these
Dockerfiles periodically for the latest version numbers of packages
and have to update them. So I've disabled this lint.
- [DL3003](https://github.com/hadolint/hadolint/wiki/DL3003) - use
WORKDIR to `cd` - is disabled in this case due to [review
comments](https://github.com/Homebrew/brew/pull/7433/files#r415098255).
This commit fixes an issue where we added a new global artifact
and then updated a cask to make use of that new artifact.
This caused a number of `brew cask` commands to fail for users
who had the cask installed before the artifact was added.
When loading the definition of an installed cask, we configure it
using a snapshot from install time, e. g. `/usr/local/Caskroom/markdownmdimporter/.metadata/config.json`.
The snapshot looks like this:
```
{
"default": {
"appdir": "/Applications",
"prefpanedir": "/Users/claudia/Library/PreferencePanes",
"qlplugindir": "/Users/claudia/Library/QuickLook",
"dictionarydir": "/Users/claudia/Library/Dictionaries",
"fontdir": "/Users/claudia/Library/Fonts",
"colorpickerdir": "/Users/claudia/Library/ColorPickers",
"servicedir": "/Users/claudia/Library/Services",
"input_methoddir": "/Users/claudia/Library/Input Methods",
"internet_plugindir": "/Users/claudia/Library/Internet Plug-Ins",
"audio_unit_plugindir": "/Users/claudia/Library/Audio/Plug-Ins/Components",
"vst_plugindir": "/Users/claudia/Library/Audio/Plug-Ins/VST",
"vst3_plugindir": "/Users/claudia/Library/Audio/Plug-Ins/VST3",
"screen_saverdir": "/Users/claudia/Library/Screen Savers"
},
"env": {},
"explicit": {}
}
```
Note that there is no `mdimporterdir` because the cask was installed
before the artifact was added.
The root cause is that the cask loading code still expects the snapshot
to contain directory configuration for all artifact types.
Since the snapshot never learned about the new artifact type, cask
loading would fail.
The fix applied in this commit is to fall back to the global default
whenever the `default` directory map of a configuration snapshot is
incomplete.
See also:
- https://github.com/Homebrew/brew/pull/7286#issuecomment-613376568
- https://discourse.brew.sh/t/cask-definition-is-invalid-invalid-mdimporter-stanza-key-not-found-mdimporterdir