Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add zypper arguments to snapshot description #315

Open
wants to merge 10 commits into
base: master
Choose a base branch
from
8 changes: 8 additions & 0 deletions data/zypp-plugin.conf
Original file line number Diff line number Diff line change
Expand Up @@ -15,5 +15,13 @@
<solvable match="w" important="true">udev</solvable>
<solvable match="w">*</solvable>
</solvables>

<!-- Set enabled to "true" in order to save zypper commandline arguments in snapshot descriptions.
by default arguments following zypp(zypper) are truncated at 32 chars. change to 0 for unlimited output -->

<description>
<zypper-extended-description enabled="false">32</zypper-extended-description>
</description>


</snapper-zypp-plugin-conf>
30 changes: 28 additions & 2 deletions scripts/zypp-plugin.py
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,8 @@ class Config:

def __init__(self):
self.solvables = []
self.self.zypper_extended_description_enabled = False
self.self.zypper_extended_description_length = 0
self.load_file("/etc/snapper/zypp-plugin.conf")


Expand Down Expand Up @@ -90,6 +92,19 @@ def load_dom(self, dom):

except:
pass
try:
for tmp3 in dom.getElementsByTagName("description"):
for tmp4 in tmp3.getElementsByTagName("zypper-extended-description"):
string_size = tmp4.childNodes[0].data
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Convert to int here instead of below.

description_enabled = tmp4.getAttribute("enabled")
if not description_enabled in [ "true", "false" ]:
loggin.error("unknown extended-config enabled attribute %s" % description_enabled)
continue
if description_enabled == "true":
self.zypper_extended_description_enabled = True
self.zypper_extended_description_length = int(string_size)
except:
pass



Expand Down Expand Up @@ -145,15 +160,26 @@ def match_solvables(self, names):
if found and important:
return True, True
return found, important

def zypper_arguments(self):
if basename(readlink("/proc/%d/exe" % getppid())) == "zypper":
argument = " " + " ".join(open("/proc/%s/cmdline" % getppid()).read().split('\x00')[1:])
else:
return ""
if config.zypper_extended_description_length == 0:
return argument
else:
return argument[0:config.zypper_extended_description_length]


def PLUGINBEGIN(self, headers, body):

logging.info("PLUGINBEGIN")

logging.debug("headers: %s" % headers)

self.description = "zypp(%s)" % basename(readlink("/proc/%d/exe" % getppid()))
self.description = "zypp(%s)" % basename(readlink("/proc/%d/exe" % getppid()))
if config.zypper_extended_description_enabled == True:
self.description.append(self.zypper_arguments())
self.userdata = self.get_userdata(headers)

self.ack()
Expand Down