mirror of
https://github.com/ansible-collections/community.general.git
synced 2024-09-14 20:13:21 +02:00
* slackpkg: fix name matching in package installation (#450) * Escape re parameters and optimize matching as suggested in code review. Co-authored-by: Felix Fontein <felix@fontein.de> * Update changelogs/fragments/450-slackpkg-package-matching.yml Co-authored-by: Andrew Klychkov <aaklychkov@mail.ru> Co-authored-by: Felix Fontein <felix@fontein.de> Co-authored-by: Andrew Klychkov <aaklychkov@mail.ru>
This commit is contained in:
parent
7fd989f7f0
commit
519162443f
2 changed files with 6 additions and 3 deletions
2
changelogs/fragments/450-slackpkg-package-matching.yml
Normal file
2
changelogs/fragments/450-slackpkg-package-matching.yml
Normal file
|
@ -0,0 +1,2 @@
|
|||
bugfixes:
|
||||
- slackpkg - fix name matching in package installation (https://github.com/ansible-collections/community.general/issues/450).
|
|
@ -67,12 +67,13 @@ from ansible.module_utils.basic import AnsibleModule
|
|||
|
||||
def query_package(module, slackpkg_path, name):
|
||||
|
||||
import glob
|
||||
import platform
|
||||
import os
|
||||
import re
|
||||
|
||||
machine = platform.machine()
|
||||
packages = glob.glob("/var/log/packages/%s-*-[%s|noarch]*" % (name,
|
||||
machine))
|
||||
pattern = re.compile('^%s-[^-]+-(%s|noarch)-[^-]+$' % (re.escape(name), re.escape(machine)))
|
||||
packages = [f for f in os.listdir('/var/log/packages') if pattern.match(f)]
|
||||
|
||||
if len(packages) > 0:
|
||||
return True
|
||||
|
|
Loading…
Reference in a new issue