Skip to content

Commit

Permalink
Add support for SUSE distributions using DNF
Browse files Browse the repository at this point in the history
SUSE distributions are able to use the DNF package manager with tracer
through the plugin, so we should have support for it.

SUSE distributions also relocate the persistent state data from /var/lib
to /usr/lib/sysimage for the Btrfs system snapshot setup.
  • Loading branch information
Conan-Kudo authored and FrostyX committed Mar 19, 2021
1 parent 0976530 commit a70893a
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 5 deletions.
16 changes: 12 additions & 4 deletions tracer/packageManagers/dnf.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
import os.path

from tracer.resources.system import System
if System.distribution() in ["rhel", "fedora", "mageia"]:
if System.distribution() in ["rhel", "fedora", "mageia", "suse"]:

import subprocess
from tracer.packageManagers.rpm import Rpm
Expand All @@ -30,14 +30,22 @@ class Dnf(Rpm):

def __init__(self, **kwargs):
super(Dnf, self).__init__(**kwargs)
if os.path.exists('/var/lib/dnf/history.sqlite'):
if os.path.exists('/usr/lib/sysimage/dnf'):
self.opts['sysimage_persistdir'] = True
if os.path.exists('/usr/lib/sysimage/dnf/history.sqlite') or os.path.exists('/var/lib/dnf/history.sqlite'):
self.opts['modern_swdb'] = True

@property
def history_path(self):
if self.opts.get('modern_swdb'):
return '/var/lib/dnf/history.sqlite'
return '/var/lib/dnf/history/'
if self.opts.get('sysimage_persistdir'):
return '/usr/lib/sysimage/dnf/history.sqlite'
else:
return '/var/lib/dnf/history.sqlite'
if self.opts.get('sysimage_persistdir'):
return '/usr/lib/sysimage/dnf/history/'
else:
return '/var/lib/dnf/history/'

def package_files(self, pkg_name):
if self._is_installed(pkg_name):
Expand Down
3 changes: 2 additions & 1 deletion tracer/resources/system.py
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ def distribution():
if os.path.isfile("/etc/os-release"):
with open("/etc/os-release") as os_release_file:
os_release_data = {}
distros = ["gentoo", "debian", "rhel", "centos", "ol", "mageia", "arch", "archarm", "fedora"]
distros = ["gentoo", "debian", "rhel", "centos", "ol", "mageia", "arch", "archarm", "fedora", "suse"]

# Remove empty lines and trailing spaces
lines = [line.rstrip() for line in os_release_file if line.rstrip()]
Expand Down Expand Up @@ -85,6 +85,7 @@ def get_instance(pair):
("tracer.packageManagers.dnf", "Dnf"),
("tracer.packageManagers.yum", "Yum"),
],
"suse": [("tracer.packageManagers.dnf", "Dnf")],
}

distro = System.distribution()
Expand Down

0 comments on commit a70893a

Please sign in to comment.