Skip to content

Commit 0027fd4

Browse files
committed
Fix: PACKAGE get back zypper search
Fix: TEST get back opensuse
1 parent 2a1cb5b commit 0027fd4

File tree

4 files changed

+15
-49
lines changed

4 files changed

+15
-49
lines changed

.github/workflows/distro-tests-arm64.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,7 @@ jobs:
7575
- ALPINE
7676
- AMAZONLINUX
7777
- DEBIAN
78-
#- OPENSUSE # no currently test, need to find if still alive
78+
- OPENSUSE
7979
- ORACLELINUX
8080
- REDHAT
8181
- UBUNTU

.github/workflows/distro-tests-x64.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,7 @@ jobs:
7474
- ALPINE
7575
- AMAZONLINUX
7676
- DEBIAN
77-
#- OPENSUSE # no currently test, need to find if still alive
77+
- OPENSUSE
7878
- ORACLELINUX
7979
- REDHAT
8080
- UBUNTU

data/core-configuration/packs/core-installation/compliance/install.yml

+3-38
Original file line numberDiff line numberDiff line change
@@ -485,10 +485,9 @@ compliance:
485485
# / /_/ / /_/ / __/ / / (__ ) /_/ (__ ) __/
486486
# \____/ .___/\___/_/ /_/____/\__,_/____/\___/
487487
# /_/
488-
489-
# Open suse 15.4 have specific packages names
490-
- name : opensuse_15_04
491-
if : "({{variables.is_opensuse}} and {{collector.system.os.linux.major_version}} == 15) and ({{collector.system.os.linux.minor_version}} == 4)"
488+
# Open suse 15.+
489+
- name : opensuse_15_plus
490+
if : "({{variables.is_opensuse}} and {{collector.system.os.linux.major_version}} == 15) and ({{collector.system.os.linux.minor_version}} >= 4)"
492491
parameters:
493492
packages:
494493
- python3-rpm
@@ -502,40 +501,6 @@ compliance:
502501
- python3-setproctitle
503502
- python3-pyaml
504503

505-
506-
# Open suse 15 have specific packages names
507-
- name : opensuse_15
508-
if : "{{variables.is_opensuse}} and {{collector.system.os.linux.major_version}} == 15"
509-
parameters:
510-
packages:
511-
- python2-rpm
512-
- python2-Jinja2
513-
- python2-pycrypto
514-
- python2-simplejson
515-
- python2-setuptools
516-
- python2-leveldb
517-
- bash-completion # Bash completion to enable the CLI completion
518-
- python2-psutil
519-
- python2-setproctitle
520-
- python2-pyaml
521-
522-
523-
# Older open source (42.x)
524-
- name : opensuse
525-
if : "{{variables.is_opensuse}}"
526-
parameters:
527-
packages:
528-
- rpm-python
529-
- python-Jinja2
530-
- python-pycrypto
531-
- python-simplejson
532-
- python-setuptools
533-
- python-leveldb
534-
- python-psutil
535-
- python-setproctitle
536-
- python-yaml
537-
- bash-completion # Bash completion to enable the CLI completion
538-
539504

540505
### Amazon
541506
# ___

opsbro/system_backends/system_backend_zypper.py

+10-9
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import subprocess
22
import threading
3+
import traceback
34

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

1516

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

0 commit comments

Comments
 (0)