(last.package_cache_dir_or_default() / "cache" / subdir).mkdir(parents=True, exist_ok=True)
+ def needs_sync(config: Config) -> bool:
+ if config.cacheonly != Cacheonly.auto:
+ return config.cacheonly == Cacheonly.never
+
+ return not have_cache(config)
+
# Sync repository metadata unless explicitly disabled.
- if last.cacheonly == Cacheonly.never or (
- last.cacheonly == Cacheonly.auto and not any(have_cache(config) for config in images)
- ):
+ if any(needs_sync(config) for config in images):
with setup_workspace(args, last) as workspace:
context = Context(
args,
default=Cacheonly.auto,
help="Only use the package cache when installing packages",
choices=Cacheonly.choices(),
- scope=SettingScope.multiversal,
+ scope=SettingScope.inherit,
),
ConfigSetting(
dest="sandbox_trees",
as the package cache is already fully populated. If set to `metadata`,
the package manager can still download packages, but we won't sync the
repository metadata. If set to `auto`, the repository metadata is
- synced unless we have a cached image (see `Incremental=`) and packages
- can be downloaded during the build. If set to `never`, repository
- metadata is always synced and packages can be downloaded during
- the build.
+ synced unless the image is cached (see `Incremental=`) and packages can
+ be downloaded during the build. If set to `never`, repository metadata
+ is always synced and packages can be downloaded during the build.
`SandboxTrees=`, `--sandbox-tree=`
: Takes a comma-separated list of colon-separated path pairs. The first
- `RepositoryKeyCheck=`
- `RepositoryKeyFetch=`
- `SourceDateEpoch=`
-- `CacheOnly=`
- `WorkspaceDirectory=`
- `PackageCacheDirectory=`
- `BuildSources=`
in the main image config. Currently the following settings are passed
down to subimages but can be overridden:
+- `CacheOnly=`
- `Profiles=`
- `ImageId=`
- `ImageVersion=`