summarylogtreecommitdiffstats
path: root/arch.py
diff options
context:
space:
mode:
authorJulian Phillips2018-01-28 17:08:50 -0800
committerJulian Phillips2018-01-28 17:08:50 -0800
commit76a70b545094b0b10eb8dfb268f63d2cfc2095a9 (patch)
tree3e66777f91bc704e3f3ca77fd7cd4f9c3236202a /arch.py
parent4d075b99eba0f5dc853c8ad6c153e210838ce698 (diff)
downloadaur-76a70b545094b0b10eb8dfb268f63d2cfc2095a9.tar.gz
Updated Arch policy. Reverted to default sos.conf.
Diffstat (limited to 'arch.py')
-rw-r--r--arch.py34
1 files changed, 32 insertions, 2 deletions
diff --git a/arch.py b/arch.py
index 9299a04b2d32..7cac74fd864d 100644
--- a/arch.py
+++ b/arch.py
@@ -1,6 +1,7 @@
import os
from sos.policies import PackageManager, LinuxPolicy
from sos.plugins import Plugin
+from sos.utilities import shell_out
class ArchPolicy(LinuxPolicy):
@@ -8,12 +9,41 @@ class ArchPolicy(LinuxPolicy):
vendor = "Arch Linux"
vendor_url = "https://www.archlinux.org/"
vendor_text = ""
- package_manager = PackageManager("pacman --query | awk 'BEGIN {OFS = \"|\"} {print $1,$2}'")
+ #package_manager = PackageManager("pacman --query | awk 'BEGIN {OFS = \"|\"} {print $1,$2}'")
valid_subclasses = [Plugin]
+ def __init__(self, sysroot=None):
+ super(LinuxPolicy, self).__init__(sysroot=sysroot)
+ self.package_manager = Pacman()
+
@classmethod
def check(cls):
+ """This method checks to see if we are running on Arch.
+ It returns True or False."""
try:
- return "archlinux" in open('/etc/os-release', 'r').read()
+ with open('/etc/os-release', 'r') as f:
+ return "archlinux" in f.read()
except:
return False
+
+# this subclass is only needed because sos_get_command_output()
+# in utilities.py sets shell=False so the pipe to awk in the
+# command below used to format pacman output does not work
+# pacman --query | awk 'BEGIN {OFS = \"|\"} {print $1,$2}'
+class Pacman(PackageManager):
+
+ def get_pkg_list(self):
+ cmd = "pacman --query"
+ pkg_list = shell_out(
+ cmd, timeout=0, chroot=self.chroot
+ ).splitlines()
+
+ for pkg in pkg_list:
+ name, version = pkg.split()
+ self.packages[name] = {
+ 'name': name,
+ 'version': version.split(".")
+ }
+
+ return self.packages
+