From bc04bfc366ac785810a38a68a66b51a1b346d739 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Miguel=20Mart=C3=ADn?= Date: Tue, 21 Nov 2023 08:40:59 +0100 Subject: [PATCH] runners: clean up temp files before exiting the runner Clean up created temp files before exiting the runner. --- osbuild/util/runners.py | 7 ++++++- runners/org.osbuild.centos9 | 1 + runners/org.osbuild.fedora30 | 1 + runners/org.osbuild.fedora38 | 1 + runners/org.osbuild.rhel81 | 1 + runners/org.osbuild.rhel82 | 1 + 6 files changed, 11 insertions(+), 1 deletion(-) diff --git a/osbuild/util/runners.py b/osbuild/util/runners.py index 99f5de91..ec2a3fec 100644 --- a/osbuild/util/runners.py +++ b/osbuild/util/runners.py @@ -62,6 +62,10 @@ def tmpfiles(): subprocess.run(["systemd-tmpfiles", "--create"], check=False) +def remove_tmpfiles(): + subprocess.run(["systemd-tmpfiles", "--clean", "--remove"], check=False) + + def nsswitch(): # the default behavior is fine, but using nss-resolve does not # necessarily work in a non-booted container, so make sure that @@ -90,7 +94,8 @@ def sequoia(): # images). os.makedirs("/etc/crypto-policies", exist_ok=True) shutil.copytree( - "/usr/share/crypto-policies/back-ends/DEFAULT", "/etc/crypto-policies/back-ends" + "/usr/share/crypto-policies/back-ends/DEFAULT", + "/etc/crypto-policies/back-ends" ) diff --git a/runners/org.osbuild.centos9 b/runners/org.osbuild.centos9 index 3e0f60f0..b9a6c397 100755 --- a/runners/org.osbuild.centos9 +++ b/runners/org.osbuild.centos9 @@ -14,5 +14,6 @@ if __name__ == "__main__": runners.tmpfiles() runners.nsswitch() r = subprocess.run(sys.argv[1:], check=False) + runners.remove_tmpfiles() sys.exit(r.returncode) diff --git a/runners/org.osbuild.fedora30 b/runners/org.osbuild.fedora30 index 3e0f60f0..b9a6c397 100755 --- a/runners/org.osbuild.fedora30 +++ b/runners/org.osbuild.fedora30 @@ -14,5 +14,6 @@ if __name__ == "__main__": runners.tmpfiles() runners.nsswitch() r = subprocess.run(sys.argv[1:], check=False) + runners.remove_tmpfiles() sys.exit(r.returncode) diff --git a/runners/org.osbuild.fedora38 b/runners/org.osbuild.fedora38 index 2d0b8198..45a7c245 100755 --- a/runners/org.osbuild.fedora38 +++ b/runners/org.osbuild.fedora38 @@ -15,5 +15,6 @@ if __name__ == "__main__": runners.nsswitch() runners.sequoia() r = subprocess.run(sys.argv[1:], check=False) + runners.remove_tmpfiles() sys.exit(r.returncode) diff --git a/runners/org.osbuild.rhel81 b/runners/org.osbuild.rhel81 index db7fe78c..9a911dea 100755 --- a/runners/org.osbuild.rhel81 +++ b/runners/org.osbuild.rhel81 @@ -41,5 +41,6 @@ if __name__ == "__main__": os_release() runners.python_alternatives() r = subprocess.run(sys.argv[1:], check=False) + runners.remove_tmpfiles() sys.exit(r.returncode) diff --git a/runners/org.osbuild.rhel82 b/runners/org.osbuild.rhel82 index 101c5771..1c14e9da 100755 --- a/runners/org.osbuild.rhel82 +++ b/runners/org.osbuild.rhel82 @@ -16,5 +16,6 @@ if __name__ == "__main__": runners.python_alternatives() env = runners.quirks() r = subprocess.run(sys.argv[1:], env=env, check=False) + runners.remove_tmpfiles() sys.exit(r.returncode)