Module: check_mk
Branch: master
Commit: 64b80376964e8c768e2b3dce39acba978103d05a
URL:
http://git.mathias-kettner.de/git/?p=check_mk.git;a=commit;h=64b80376964e8c…
Author: Lars Michelsen <lm(a)mathias-kettner.de>
Date: Thu Nov 10 08:48:36 2016 +0100
.f12 during tests: preserve the PATH variable from outside
---
cmk_base/packaging.py | 15 +++++++++++----
tests/testlib/__init__.py | 3 ++-
2 files changed, 13 insertions(+), 5 deletions(-)
diff --git a/cmk_base/packaging.py b/cmk_base/packaging.py
index b7830b0..0fa2770 100644
--- a/cmk_base/packaging.py
+++ b/cmk_base/packaging.py
@@ -320,8 +320,8 @@ def package_pack(args):
def create_mkp_file(package, file_name=None, file_object=None):
package["version.packaged"] = cmk.__version__
- def create_info(filename, size):
- info = tarfile.TarInfo("info")
+ def create_tar_info(filename, size):
+ info = tarfile.TarInfo()
info.mtime = time.time()
info.uid = 0
info.gid = 0
@@ -332,8 +332,15 @@ def create_mkp_file(package, file_name=None, file_object=None):
return info
tar = tarfile.open(name=file_name, fileobj=file_object, mode="w:gz")
+
+ # add the regular info file (Python format)
info_file = StringIO(pprint.pformat(package))
- info = create_info("info", len(info_file.getvalue()))
+ info = create_tar_info("info", len(info_file.getvalue()))
+ tar.addfile(info, info_file)
+
+ # add the info file a second time (JSON format) for external tools
+ info_file = StringIO(json.dumps(package))
+ info = create_tar_info("info.json", len(info_file.getvalue()))
tar.addfile(info, info_file)
# Now pack the actual files into sub tars
@@ -346,7 +353,7 @@ def create_mkp_file(package, file_name=None, file_object=None):
subtarname = part + ".tar"
subdata = subprocess.check_output(["tar", "cf",
"-", "--dereference", "--force-local",
"-C", dir] + filenames)
- info = create_info(subtarname, len(subdata))
+ info = create_tar_info(subtarname, len(subdata))
tar.addfile(info, StringIO(subdata))
tar.close()
diff --git a/tests/testlib/__init__.py b/tests/testlib/__init__.py
index 7419ffb..6e69283 100644
--- a/tests/testlib/__init__.py
+++ b/tests/testlib/__init__.py
@@ -257,7 +257,8 @@ class Site(object):
if os.path.exists("%s/.f12" % path):
print("Executing .f12 in \"%s\"" % path)
assert os.system("cd \"%s\" ; "
- "sudo ONLY_COPY=1 SITE=%s bash .f12" % (path,
self.id)) >> 8 == 0
+ "sudo PATH=$PATH ONLY_COPY=1 SITE=%s bash
.f12" %
+ (path, self.id)) >> 8 == 0
def rm_if_not_reusing(self):