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

Use host ostree as localcache repo #94

Merged
merged 1 commit into from
Dec 19, 2023
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
12 changes: 12 additions & 0 deletions run-build
Original file line number Diff line number Diff line change
Expand Up @@ -95,11 +95,23 @@ class ImageBuildRoot(object):
repo_path = config['ostree']['repodir']
remote = config['ostree']['remote']
ref = config['ostree']['ref']

# If we are on an OSTree system, use the system repo as an additional cache.
# In the case of an Endless OS developer system booted into the same or similar
# ref as we are building an image of, this saves pulling over the network. In
# other cases it is harmless.
system_ostree_repo = '/ostree/repo'
if os.path.isdir(system_ostree_repo):
extra_pull_args = ['--localcache-repo', system_ostree_repo]
else:
extra_pull_args = []

log.info(f'Pulling OSTree ref {remote}:{ref}')
eib.retry(subprocess.check_call, [
'ostree',
f'--repo={repo_path}',
'pull',
*extra_pull_args,
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Does the list within the list get flattened? I wouldn't expect it, but maybe subprocess does that and I've never tried.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That's what the * does:

>>> extra_pull_args = ['--localcache-repo', "/ostree/repo"]
>>> ["ostree", "pull", *extra_pull_args, "eos", "my-cool-ref"]
['ostree', 'pull', '--localcache-repo', '/ostree/repo', 'eos', 'my-cool-ref']
>>> ["ostree", "pull", extra_pull_args, "eos", "my-cool-ref"]
['ostree', 'pull', ['--localcache-repo', '/ostree/repo'], 'eos', 'my-cool-ref']

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oh, I totally missed that. 👍

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I had no idea you could compose lists that way. That's a nice feature.

remote,
ref,
])
Expand Down
Loading