Skip to content

Commit

Permalink
Fix: PACKAGE get back zypper search
Browse files Browse the repository at this point in the history
Fix: TEST get back opensuse
  • Loading branch information
naparuba committed Sep 22, 2024
1 parent 2a1cb5b commit 0027fd4
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 49 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/distro-tests-arm64.yml
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ jobs:
- ALPINE
- AMAZONLINUX
- DEBIAN
#- OPENSUSE # no currently test, need to find if still alive
- OPENSUSE
- ORACLELINUX
- REDHAT
- UBUNTU
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/distro-tests-x64.yml
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ jobs:
- ALPINE
- AMAZONLINUX
- DEBIAN
#- OPENSUSE # no currently test, need to find if still alive
- OPENSUSE
- ORACLELINUX
- REDHAT
- UBUNTU
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -485,10 +485,9 @@ compliance:
# / /_/ / /_/ / __/ / / (__ ) /_/ (__ ) __/
# \____/ .___/\___/_/ /_/____/\__,_/____/\___/
# /_/

# Open suse 15.4 have specific packages names
- name : opensuse_15_04
if : "({{variables.is_opensuse}} and {{collector.system.os.linux.major_version}} == 15) and ({{collector.system.os.linux.minor_version}} == 4)"
# Open suse 15.+
- name : opensuse_15_plus
if : "({{variables.is_opensuse}} and {{collector.system.os.linux.major_version}} == 15) and ({{collector.system.os.linux.minor_version}} >= 4)"
parameters:
packages:
- python3-rpm
Expand All @@ -502,40 +501,6 @@ compliance:
- python3-setproctitle
- python3-pyaml


# Open suse 15 have specific packages names
- name : opensuse_15
if : "{{variables.is_opensuse}} and {{collector.system.os.linux.major_version}} == 15"
parameters:
packages:
- python2-rpm
- python2-Jinja2
- python2-pycrypto
- python2-simplejson
- python2-setuptools
- python2-leveldb
- bash-completion # Bash completion to enable the CLI completion
- python2-psutil
- python2-setproctitle
- python2-pyaml


# Older open source (42.x)
- name : opensuse
if : "{{variables.is_opensuse}}"
parameters:
packages:
- rpm-python
- python-Jinja2
- python-pycrypto
- python-simplejson
- python-setuptools
- python-leveldb
- python-psutil
- python-setproctitle
- python-yaml
- bash-completion # Bash completion to enable the CLI completion


### Amazon
# ___
Expand Down
19 changes: 10 additions & 9 deletions opsbro/system_backends/system_backend_zypper.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import subprocess
import threading
import traceback

from .linux_system_backend import LinuxBackend
from opsbro.log import LoggerFactory
Expand All @@ -13,18 +14,18 @@ def __init__(self):
self.lock = threading.RLock()


# rpm -q -a --queryformat "%{NAME}\n"
# zypper search --installed-only --match-exact XXXXXXX
def has_package(self, package):
with self.lock:
logger.debug('ZYPPER :: has package: %s' % package)
p = subprocess.Popen(['rpm', '-q', '-a', '--queryformat', r'%{NAME}\n'], stdout=subprocess.PIPE, stderr=subprocess.PIPE)
stdout, stderr = p.communicate()
# Return code is enouth to know that
if p.returncode != 0:
raise Exception('ZYPPER: Cannot list package %s' % (stdout + stderr))
packages = stdout.splitlines()
logger.debug('Zypper packages:', packages)
r = package in packages
try:
p = subprocess.Popen(['zypper', 'search', '--installed-only', '--match-exact', package], stdout=subprocess.PIPE, stderr=subprocess.PIPE)
_, _ = p.communicate()
except Exception:
err = f'ZYPPER: cannot check for package {package}: {traceback.format_exc()}'
logger.error(err)
raise Exception(err)
r = p.returncode == 0
logger.debug('Zypper have package %s => %s' % (package, r))
return r

Expand Down

0 comments on commit 0027fd4

Please sign in to comment.