add alpine apk package manager to package_facts [wip] (#70587)

* add alpine apk package manager to package_facts
This commit is contained in:
Julien 2020-07-15 12:40:25 -04:00 committed by GitHub
parent e1a33a6a84
commit 57b548598c
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 26 additions and 1 deletions

View file

@ -0,0 +1,2 @@
bugfixes:
- add support for alpine linux 'apk' package manager in package_facts

View file

@ -19,8 +19,9 @@ options:
- The package manager used by the system so we can query the package information. - The package manager used by the system so we can query the package information.
- Since 2.8 this is a list and can support multiple package managers per system. - Since 2.8 this is a list and can support multiple package managers per system.
- The 'portage' and 'pkg' options were added in version 2.8. - The 'portage' and 'pkg' options were added in version 2.8.
- The 'apk' option was added in version 2.11.
default: ['auto'] default: ['auto']
choices: ['auto', 'rpm', 'apt', 'portage', 'pkg', 'pacman'] choices: ['auto', 'rpm', 'apt', 'portage', 'pkg', 'pacman', 'apk']
required: False required: False
type: list type: list
strategy: strategy:
@ -376,6 +377,28 @@ class PORTAGE(CLIMgr):
return dict(zip(self.atoms, package.split())) return dict(zip(self.atoms, package.split()))
class APK(CLIMgr):
CLI = 'apk'
atoms = ['name', 'version']
def list_installed(self):
rc, out, err = module.run_command([self._cli, 'info', '-v'])
if rc != 0 or err:
raise Exception("Unable to list packages rc=%s : %s" % (rc, err))
return out.splitlines()
def get_package_details(self, package):
raw_pkg_details = {}
for line in package.splitlines():
m = re.match(r"([\w ].*?)-([0-9-\.]+[0-9a-z-\.]*-r[0-9]+)", to_native(line))
if m:
raw_pkg_details['name'] = m.group(1)
raw_pkg_details['version'] = m.group(2)
return raw_pkg_details
def main(): def main():
# get supported pkg managers # get supported pkg managers