Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

cmdlib: Ensure bare-user tmpdir is in $workdir/tmp #2905

Merged
merged 1 commit into from
Jun 4, 2022
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 3 additions & 2 deletions src/cosalib/cmdlib.py
Original file line number Diff line number Diff line change
Expand Up @@ -265,8 +265,9 @@ def extract_image_json(workdir, commit):
#
# Call this function to ensure that the ostree commit for a given build is in tmp/repo.
def import_ostree_commit(workdir, buildpath, buildmeta, force=False):
tmpdir = os.path.join(workdir, 'tmp')
with Lock(os.path.join(workdir, 'tmp/repo.import.lock')):
repo = os.path.join(workdir, 'tmp/repo')
repo = os.path.join(tmpdir, 'repo')
commit = buildmeta['ostree-commit']
tarfile = os.path.join(buildpath, buildmeta['images']['ostree']['path'])
# create repo in case e.g. tmp/ was cleared out; idempotent
Expand Down Expand Up @@ -298,7 +299,7 @@ def import_ostree_commit(workdir, buildpath, buildmeta, force=False):
gid = os.getgid()
subprocess.check_call(['sudo', 'chown', '-hR', f"{uid}:{gid}", repo])
else:
with tempfile.TemporaryDirectory() as tmpd:
with tempfile.TemporaryDirectory(dir=tmpdir) as tmpd:
subprocess.check_call(['ostree', 'init', '--repo', tmpd, '--mode=bare-user'])
subprocess.check_call(['ostree', 'container', 'import', '--repo', tmpd,
'--write-ref', buildmeta['buildid'],
Expand Down