Skip to content

Commit 19dae9d

Browse files
committed
cosalib/build: Use workdir tmp/ as tempdir
We changed this behaviour during the refactor. There's quite a bit of history here on why do this. But a major one at least is that we want to be able to just `rename(2)` the final build artifacts into place. This saves a bunch of time and I/O. I noticed this due to the fact that we were losing sparsity from the output of `qemu-img convert` because `shutil.move` doesn't do the equivalent of `cp --sparse=auto`. This patch fixes that, though I think we should also be able to change that call to a simple `os.rename()` in a follow-up to make it explicit. Related: coreos/fedora-coreos-tracker#361
1 parent 44d3094 commit 19dae9d

File tree

1 file changed

+6
-2
lines changed

1 file changed

+6
-2
lines changed

src/cosalib/build.py

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -96,7 +96,12 @@ def __init__(self, *args, **kwargs):
9696

9797
self._found_files = {}
9898
self._workdir = kwargs.pop("workdir", os.getcwd())
99-
self._tmpdir = tempfile.mkdtemp(prefix="build_tmpd")
99+
tmpdir = os.path.join(self._workdir, "tmp")
100+
os.environ['TMPDIR'] = tmpdir
101+
102+
# we need to make sure we allocate in tmp/ so we're on the same
103+
# filesystem as builds/ and we can just `rename()` it there
104+
self._tmpdir = tempfile.mkdtemp(dir=tmpdir)
100105
self._image_name = None
101106

102107
# Setup the instance properties.
@@ -108,7 +113,6 @@ def __init__(self, *args, **kwargs):
108113
}
109114

110115
os.environ['workdir'] = self._workdir
111-
os.environ['TMPDIR'] = os.path.join(self._workdir, "tmp")
112116

113117
# Setup what is required for this Class.
114118
# require_cosa means that the COSA information is need

0 commit comments

Comments
 (0)