collection 교체

This commit is contained in:
정훈 변
2024-02-23 16:37:40 +09:00
parent b494779b5b
commit 3fd554eee9
38862 changed files with 220204 additions and 6600073 deletions

View File

@@ -1,13 +1,14 @@
#!/usr/bin/python
# -*- coding: utf-8 -*-
# (c) 2013, Andrew Dunham <andrew@du.nham.ca>
# (c) 2013, Daniel Jaouen <dcj24@cornell.edu>
# (c) 2015, Indrajit Raychaudhuri <irc+code@indrajit.com>
# Copyright (c) 2013, Andrew Dunham <andrew@du.nham.ca>
# Copyright (c) 2013, Daniel Jaouen <dcj24@cornell.edu>
# Copyright (c) 2015, Indrajit Raychaudhuri <irc+code@indrajit.com>
#
# Based on macports (Jimmy Tang <jcftang@gmail.com>)
#
# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt)
# GNU General Public License v3.0+ (see LICENSES/GPL-3.0-or-later.txt or https://www.gnu.org/licenses/gpl-3.0.txt)
# SPDX-License-Identifier: GPL-3.0-or-later
from __future__ import absolute_import, division, print_function
__metaclass__ = type
@@ -21,11 +22,17 @@ author:
- "Daniel Jaouen (@danieljaouen)"
- "Andrew Dunham (@andrew-d)"
requirements:
- "python >= 2.6"
- homebrew must already be installed on the target system
- homebrew must already be installed on the target system
short_description: Package manager for Homebrew
description:
- Manages Homebrew packages
extends_documentation_fragment:
- community.general.attributes
attributes:
check_mode:
support: full
diff_mode:
support: none
options:
name:
description:
@@ -35,10 +42,10 @@ options:
elements: str
path:
description:
- "A ':' separated list of paths to search for 'brew' executable.
Since a package (I(formula) in homebrew parlance) location is prefixed relative to the actual path of I(brew) command,
providing an alternative I(brew) path enables managing different set of packages in an alternative location in the system."
default: '/usr/local/bin:/opt/homebrew/bin'
- "A V(:) separated list of paths to search for C(brew) executable.
Since a package (I(formula) in homebrew parlance) location is prefixed relative to the actual path of C(brew) command,
providing an alternative C(brew) path enables managing different set of packages in an alternative location in the system."
default: '/usr/local/bin:/opt/homebrew/bin:/home/linuxbrew/.linuxbrew/bin'
type: path
state:
description:
@@ -49,15 +56,13 @@ options:
update_homebrew:
description:
- update homebrew itself first.
- Alias C(update-brew) has been deprecated and will be removed in community.general 5.0.0.
type: bool
default: no
aliases: ['update-brew']
default: false
upgrade_all:
description:
- upgrade all homebrew packages.
type: bool
default: no
default: false
aliases: ['upgrade']
install_options:
description:
@@ -72,8 +77,8 @@ options:
elements: str
version_added: '0.2.0'
notes:
- When used with a `loop:` each package will be processed individually,
it is much more efficient to pass the list directly to the `name` option.
- When used with a C(loop:) each package will be processed individually,
it is much more efficient to pass the list directly to the O(name) option.
'''
EXAMPLES = '''
@@ -82,7 +87,7 @@ EXAMPLES = '''
name: foo
state: present
# Install formula foo with 'brew' in alternate path C(/my/other/location/bin)
# Install formula foo with 'brew' in alternate path (/my/other/location/bin)
- community.general.homebrew:
name: foo
path: /my/other/location/bin
@@ -92,18 +97,18 @@ EXAMPLES = '''
- community.general.homebrew:
name: foo
state: present
update_homebrew: yes
update_homebrew: true
# Update homebrew first and upgrade formula foo to latest available with 'brew' in default path
- community.general.homebrew:
name: foo
state: latest
update_homebrew: yes
update_homebrew: true
# Update homebrew and upgrade all packages
- community.general.homebrew:
update_homebrew: yes
upgrade_all: yes
update_homebrew: true
upgrade_all: true
# Miscellaneous other examples
- community.general.homebrew:
@@ -134,7 +139,7 @@ EXAMPLES = '''
- name: Use ignore-pinned option while upgrading all
community.general.homebrew:
upgrade_all: yes
upgrade_all: true
upgrade_options: ignore-pinned
'''
@@ -160,6 +165,7 @@ changed_pkgs:
version_added: '0.2.0'
'''
import json
import os.path
import re
@@ -179,6 +185,10 @@ def _create_regex_group_complement(s):
chars = filter(None, (line.split('#')[0].strip() for line in lines))
group = r'[^' + r''.join(chars) + r']'
return re.compile(group)
def _check_package_in_json(json_output, package_type):
return bool(json_output.get(package_type, []) and json_output[package_type][0].get("installed"))
# /utils ------------------------------------------------------------------ }}}
@@ -474,17 +484,13 @@ class Homebrew(object):
cmd = [
"{brew_path}".format(brew_path=self.brew_path),
"info",
"--json=v2",
self.current_package,
]
rc, out, err = self.module.run_command(cmd)
for line in out.split('\n'):
if (
re.search(r'Built from source', line)
or re.search(r'Poured from bottle', line)
):
return True
data = json.loads(out)
return False
return _check_package_in_json(data, "formulae") or _check_package_in_json(data, "casks")
def _current_package_is_outdated(self):
if not self.valid_package(self.current_package):
@@ -877,7 +883,7 @@ def main():
elements='str',
),
path=dict(
default="/usr/local/bin:/opt/homebrew/bin",
default="/usr/local/bin:/opt/homebrew/bin:/home/linuxbrew/.linuxbrew/bin",
required=False,
type='path',
),
@@ -892,9 +898,7 @@ def main():
),
update_homebrew=dict(
default=False,
aliases=["update-brew"],
type='bool',
deprecated_aliases=[dict(name='update-brew', version='5.0.0', collection_name='community.general')],
),
upgrade_all=dict(
default=False,