1
0
mirror of https://github.com/openSUSE/osc.git synced 2025-01-26 06:46:13 +01:00

Allow formatting of the sccache uri

This allows a format to be specified in the sccache uri, specifically
the file uri so that a per-package cache can be created. This way
an osc build locally doesn't ruin your cache moving between different
packages.
This commit is contained in:
William Brown 2022-03-04 14:10:44 +10:00
parent f4626dd91f
commit e25682b802
2 changed files with 21 additions and 11 deletions

View File

@ -682,16 +682,6 @@ def main(apiurl, opts, argv):
if opts.pkg_ccache:
buildargs.append('--pkg-ccache=%s' % opts.pkg_ccache)
xp.append('ccache')
if opts.sccache_uri or config['sccache_uri'] or opts.sccache or config['sccache']:
if opts.pkg_ccache or opts.ccache or config['ccache']:
raise oscerr.WrongArgs('Error: sccache and ccache can not be enabled at the same time')
if opts.sccache_uri:
buildargs.append('--sccache-uri=%s' % opts.sccache_uri)
elif config['sccache_uri']:
buildargs.append('--sccache-uri=%s' % config['sccache_uri'])
else:
buildargs.append('--sccache')
xp.append('sccache')
if opts.linksources:
buildargs.append('--linksources')
if opts.baselibs:
@ -779,6 +769,21 @@ def main(apiurl, opts, argv):
except:
pass
# We configure sccache after pacname, so that in default cases we can have an sccache for each
# package to prevent cross-cache polutions. It helps to make the local-use case a bit nicer.
if opts.sccache_uri or config['sccache_uri'] or opts.sccache or config['sccache']:
if opts.pkg_ccache or opts.ccache or config['ccache']:
raise oscerr.WrongArgs('Error: sccache and ccache can not be enabled at the same time')
sccache_arg = "--sccache-uri=/var/tmp/osbuild-sccache-{pkgname}.tar"
if opts.sccache_uri:
sccache_arg = '--sccache-uri=%s' % opts.sccache_uri
elif config['sccache_uri']:
sccache_arg = '--sccache-uri=%s' % config['sccache_uri']
# Format the package name.
sccache_arg = sccache_arg.format(pkgname=pacname)
buildargs.append(sccache_arg)
xp.append('sccache')
# define buildinfo & config local cache
bi_file = None
bc_file = None

View File

@ -304,9 +304,14 @@ apiurl = %(apiurl)s
# ccache = 1
# Enable sccache in build roots. Conflicts with ccache.
# Equivalent to sccache_uri = file:///var/tmp/osbuild-sccache-{pkgname}.tar
# sccache = 1
# Optional remote URI for sccache storage.
# Optional URI for sccache storage. Maybe a file://, redis:// or other URI supported
# by the configured sccache install. This uri MAY take {pkgname} as a special parameter
# which will be replaced with the name of the package to be built.
# sccache_uri = file:///var/tmp/osbuild-sccache-{pkgname}.tar.lzop
# sccache_uri = file:///var/tmp/osbuild-sccache-{pkgname}.tar
# sccache_uri = redis://127.0.0.1:6379
# extra packages to install when building packages locally (osc build)