Skip to content

Commit

Permalink
runners: clean up temp files before exiting the runner
Browse files Browse the repository at this point in the history
Clean up created temp files before exiting the runner.
  • Loading branch information
mmartinv committed Nov 22, 2023
1 parent 95a1c5b commit 795e82e
Show file tree
Hide file tree
Showing 6 changed files with 11 additions and 1 deletion.
7 changes: 6 additions & 1 deletion osbuild/util/runners.py
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,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
Expand Down Expand Up @@ -89,7 +93,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"
)


Expand Down
1 change: 1 addition & 0 deletions runners/org.osbuild.centos9
Original file line number Diff line number Diff line change
Expand Up @@ -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)
1 change: 1 addition & 0 deletions runners/org.osbuild.fedora30
Original file line number Diff line number Diff line change
Expand Up @@ -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)
1 change: 1 addition & 0 deletions runners/org.osbuild.fedora38
Original file line number Diff line number Diff line change
Expand Up @@ -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)
1 change: 1 addition & 0 deletions runners/org.osbuild.rhel81
Original file line number Diff line number Diff line change
Expand Up @@ -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)
1 change: 1 addition & 0 deletions runners/org.osbuild.rhel82
Original file line number Diff line number Diff line change
Expand Up @@ -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)

0 comments on commit 795e82e

Please sign in to comment.