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 21, 2023
1 parent a950f5e commit 973014d
Show file tree
Hide file tree
Showing 6 changed files with 18 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 @@ -59,6 +59,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 @@ -87,7 +91,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
2 changes: 2 additions & 0 deletions runners/org.osbuild.centos9
Original file line number Diff line number Diff line change
Expand Up @@ -16,4 +16,6 @@ if __name__ == "__main__":

r = subprocess.run(sys.argv[1:], check=False)

runners.remove_tmpfiles()

sys.exit(r.returncode)
2 changes: 2 additions & 0 deletions runners/org.osbuild.fedora30
Original file line number Diff line number Diff line change
Expand Up @@ -16,4 +16,6 @@ if __name__ == "__main__":

r = subprocess.run(sys.argv[1:], check=False)

runners.remove_tmpfiles()

sys.exit(r.returncode)
3 changes: 3 additions & 0 deletions runners/org.osbuild.fedora38
Original file line number Diff line number Diff line change
Expand Up @@ -16,4 +16,7 @@ if __name__ == "__main__":
runners.sequoia()

r = subprocess.run(sys.argv[1:], check=False)

runners.remove_tmpfiles()

sys.exit(r.returncode)
3 changes: 3 additions & 0 deletions runners/org.osbuild.rhel81
Original file line number Diff line number Diff line change
Expand Up @@ -42,4 +42,7 @@ if __name__ == "__main__":
runners.python_alternatives()

r = subprocess.run(sys.argv[1:], check=False)

runners.remove_tmpfiles()

sys.exit(r.returncode)
2 changes: 2 additions & 0 deletions runners/org.osbuild.rhel82
Original file line number Diff line number Diff line change
Expand Up @@ -19,4 +19,6 @@ if __name__ == "__main__":

r = subprocess.run(sys.argv[1:], env=env, check=False)

runners.remove_tmpfiles()

sys.exit(r.returncode)

0 comments on commit 973014d

Please sign in to comment.