Skip to content

Commit

Permalink
osbuild: ensure a usable /var/tmp is available inside the buildroot
Browse files Browse the repository at this point in the history
Colin asked for this in
osbuild/bootc-image-builder#223 and
it's easy enough.
  • Loading branch information
mvo5 committed Mar 7, 2024
1 parent 144b056 commit 5163ff0
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 1 deletion.
6 changes: 6 additions & 0 deletions osbuild/buildroot.py
Original file line number Diff line number Diff line change
Expand Up @@ -138,6 +138,12 @@ def __enter__(self):

self.var = os.path.join(self.tmp, "var")
os.makedirs(self.var, exist_ok=True)
# Ensure /var/tmp is available, see
# https://github.com/osbuild/bootc-image-builder/issues/223
try:
os.symlink("/tmp", os.path.join(self.var, "tmp"))
except FileExistsError:
pass

proc = os.path.join(self.tmp, "proc")
os.makedirs(proc)
Expand Down
10 changes: 9 additions & 1 deletion test/mod/test_buildroot.py
Original file line number Diff line number Diff line change
Expand Up @@ -44,11 +44,19 @@ def test_basic(tempdir, runner):

# Test we can use `.run` multiple times
r = root.run(["/usr/bin/true"], monitor)
assert r.returncode == 0
assert r.returncode == 0, f"{r.stdout} {r.stderr}"

r = root.run(["/usr/bin/false"], monitor)
assert r.returncode != 0

# Test that fs setup looks correct
r = root.run(["readlink", "-f", "/var/tmp"], monitor)
assert r.returncode == 0
assert r.stdout.strip().split("\n")[-1] == "/tmp"
r = root.run(["stat", "-L", "--format=%a", "/var/tmp"], monitor)
assert r.returncode == 0
assert r.stdout.strip().split("\n")[-1] == "1777"


@pytest.mark.skipif(not TestBase.can_bind_mount(), reason="root only")
def test_runner_fail(tempdir):
Expand Down

0 comments on commit 5163ff0

Please sign in to comment.