mirror of
https://github.com/saltstack/salt.git
synced 2025-04-17 10:10:20 +00:00
fix: Homebrew casks default tap is null
Homebrew casks set tap value to null when tap is homebrew/cask
This commit is contained in:
parent
8890a08943
commit
482c190e20
2 changed files with 62 additions and 10 deletions
|
@ -168,26 +168,30 @@ def list_pkgs(versions_as_list=False, **kwargs):
|
|||
for package in package_info["formulae"]:
|
||||
# Brew allows multiple versions of the same package to be installed.
|
||||
# Salt allows for this, so it must be accounted for.
|
||||
versions = [v["version"] for v in package["installed"]]
|
||||
pkg_versions = [v["version"] for v in package["installed"]]
|
||||
# Brew allows for aliasing of packages, all of which will be
|
||||
# installable from a Salt call, so all names must be accounted for.
|
||||
names = package["aliases"] + [package["name"], package["full_name"]]
|
||||
pkg_names = package["aliases"] + [package["name"], package["full_name"]]
|
||||
# Create a list of tuples containing all possible combinations of
|
||||
# names and versions, because all are valid.
|
||||
combinations = [(n, v) for n in names for v in versions]
|
||||
combinations = [(n, v) for n in pkg_names for v in pkg_versions]
|
||||
|
||||
for name, version in combinations:
|
||||
__salt__["pkg_resource.add_pkg"](ret, name, version)
|
||||
for pkg_name, pkg_version in combinations:
|
||||
__salt__["pkg_resource.add_pkg"](ret, pkg_name, pkg_version)
|
||||
|
||||
for package in package_info["casks"]:
|
||||
version = package["installed"]
|
||||
names = {package["full_token"], package["token"]}
|
||||
pkg_version = package["installed"]
|
||||
pkg_names = {package["full_token"], package["token"]}
|
||||
pkg_tap = package.get("tap", None)
|
||||
# The following name is appended to maintain backward compatibility
|
||||
# with old salt formulas. Since full_token and token are the same
|
||||
# for official taps (homebrew/*).
|
||||
names.add("/".join([package["tap"], package["token"]]))
|
||||
for name in names:
|
||||
__salt__["pkg_resource.add_pkg"](ret, name, version)
|
||||
if not pkg_tap:
|
||||
# Tap is null when the package is from homebrew/cask.
|
||||
pkg_tap = "homebrew/cask"
|
||||
pkg_names.add("/".join([pkg_tap, package["token"]]))
|
||||
for pkg_name in pkg_names:
|
||||
__salt__["pkg_resource.add_pkg"](ret, pkg_name, pkg_version)
|
||||
|
||||
__salt__["pkg_resource.sort_pkglist"](ret)
|
||||
__context__["pkg.list_pkgs"] = copy.deepcopy(ret)
|
||||
|
|
|
@ -115,6 +115,52 @@ def custom_call_brew(*cmd, failhard=True):
|
|||
"tap": "custom/tap",
|
||||
"url": "https://iterm2.com/downloads/stable/iTerm2-3_4_3.zip",
|
||||
"version": "3.4.3"
|
||||
},
|
||||
{
|
||||
"token": "discord",
|
||||
"full_token": "discord",
|
||||
"tap": null,
|
||||
"name": [
|
||||
"Discord"
|
||||
],
|
||||
"desc": "Voice and text chat software",
|
||||
"homepage": "https://discord.com/",
|
||||
"url": "https://dl.discordapp.net/apps/osx/0.0.268/Discord.dmg",
|
||||
"appcast": null,
|
||||
"version": "0.0.268",
|
||||
"versions": {
|
||||
},
|
||||
"installed": "0.0.266",
|
||||
"outdated": false,
|
||||
"sha256": "dfe12315b717ed06ac24d3eaacb700618e96cbb449ed63d2afadcdb70ad09c55",
|
||||
"artifacts": [
|
||||
{
|
||||
"app": [
|
||||
"Discord.app"
|
||||
]
|
||||
},
|
||||
{
|
||||
"zap": [
|
||||
{
|
||||
"trash": [
|
||||
"~/Library/Application Support/discord",
|
||||
"~/Library/Caches/com.hnc.Discord",
|
||||
"~/Library/Caches/com.hnc.Discord.ShipIt",
|
||||
"~/Library/Cookies/com.hnc.Discord.binarycookies",
|
||||
"~/Library/Preferences/com.hnc.Discord.helper.plist",
|
||||
"~/Library/Preferences/com.hnc.Discord.plist",
|
||||
"~/Library/Saved Application State/com.hnc.Discord.savedState"
|
||||
]
|
||||
}
|
||||
]
|
||||
}
|
||||
],
|
||||
"caveats": null,
|
||||
"depends_on": {
|
||||
},
|
||||
"conflicts_with": null,
|
||||
"container": null,
|
||||
"auto_updates": true
|
||||
}
|
||||
],
|
||||
"formulae": [
|
||||
|
@ -426,6 +472,8 @@ def test_list_pkgs_homebrew_cask_pakages():
|
|||
expected_pkgs = {
|
||||
"homebrew/cask/day-o": "3.0.1",
|
||||
"day-o": "3.0.1",
|
||||
"homebrew/cask/discord": "0.0.266",
|
||||
"discord": "0.0.266",
|
||||
"custom/tap/iterm2": "3.4.3",
|
||||
"iterm2": "3.4.3",
|
||||
"jq": "1.6",
|
||||
|
|
Loading…
Add table
Reference in a new issue