mirror of
https://github.com/openSUSE/osc.git
synced 2025-01-13 17:16:23 +01:00
Add support for --preload and --offline to osc build.
Signed-off-by: Jan-Simon Möller <jsmoeller@linuxfoundation.org>
This commit is contained in:
parent
6ae10228b8
commit
7b5e9374d2
3
NEWS
3
NEWS
@ -25,6 +25,9 @@
|
||||
- added "--message" option to "osc branch"
|
||||
- added "osc config" command to set/get/delete a config option
|
||||
- added "--binary" and "--baseproject" options to "osc search"
|
||||
- added "-o/--offline" and "-l/--preload" options to osc build
|
||||
* osc build -l standard i586 foo.spec (to cache all dependencies)
|
||||
* osc build -o standard i586 foo.spec (to build without contacting the api)
|
||||
|
||||
0.125
|
||||
- add "osc pull" command to fetch and merge changes in the link target
|
||||
|
15
osc/build.py
15
osc/build.py
@ -499,6 +499,12 @@ def main(opts, argv):
|
||||
if not os.path.isfile(bc_filename):
|
||||
raise oscerr.WrongOptions('--noinit is not possible, no local buildconfig file')
|
||||
print 'Use local \'%s\' file as buildconfig' % bc_filename
|
||||
elif opts.offline:
|
||||
if not os.path.isfile(bi_filename):
|
||||
raise oscerr.WrongOptions('--offline is not possible, no local buildinfo file')
|
||||
print 'Use local \'%s\' file as buildinfo' % bi_filename
|
||||
if not os.path.isfile(bc_filename):
|
||||
raise oscerr.WrongOptions('--offline is not possible, no local buildconfig file')
|
||||
else:
|
||||
print 'Getting buildinfo from server and store to %s' % bi_filename
|
||||
if not bi_file:
|
||||
@ -600,7 +606,8 @@ def main(opts, argv):
|
||||
fetcher = Fetcher(cachedir = config['packagecachedir'],
|
||||
urllist = urllist,
|
||||
api_host_options = config['api_host_options'],
|
||||
offline = opts.noinit,
|
||||
noinit = opts.noinit,
|
||||
offline = opts.offline,
|
||||
http_debug = config['http_debug'],
|
||||
enable_cpio = opts.cpio_bulk_download,
|
||||
cookiejar=cookiejar)
|
||||
@ -642,7 +649,7 @@ def main(opts, argv):
|
||||
if bi.pacsuffix == 'rpm':
|
||||
if config['build-type'] == "xen" or config['build-type'] == "kvm" or config['build-type'] == "lxc":
|
||||
print 'Skipping verification of package signatures due to secure VM build'
|
||||
elif opts.no_verify or opts.noinit:
|
||||
elif opts.no_verify or opts.noinit or opts.offline:
|
||||
print 'Skipping verification of package signatures'
|
||||
else:
|
||||
print 'Verifying integrity of cached packages'
|
||||
@ -723,6 +730,10 @@ def main(opts, argv):
|
||||
if config['build-vmdisk-swapsize']:
|
||||
vm_options += ' --vmdisk-swapsize ' + config['build-vmdisk-swapsize']
|
||||
|
||||
if opts.preload:
|
||||
print "Preload done for selected repo/arch."
|
||||
sys.exit(0)
|
||||
|
||||
print 'Running build'
|
||||
cmd = '"%s" --root="%s" --rpmlist="%s" --dist="%s" %s --arch=%s %s %s "%s"' \
|
||||
% (config['build-cmd'],
|
||||
|
@ -3296,6 +3296,10 @@ Please submit there instead, or use --nodevelproject to force direct submission.
|
||||
|
||||
@cmdln.option('--clean', action='store_true',
|
||||
help='Delete old build root before initializing it')
|
||||
@cmdln.option('-o', '--offline', action='store_true',
|
||||
help='Start with cached prjconf and packages without contacting the api server')
|
||||
@cmdln.option('-l', '--preload', action='store_true',
|
||||
help='Preload all files into the chache for offline operation')
|
||||
@cmdln.option('--no-changelog', action='store_true',
|
||||
help='don\'t update the package changelog from a changes file')
|
||||
@cmdln.option('--rsync-src', metavar='RSYNCSRCPATH', dest='rsyncsrc',
|
||||
@ -3413,7 +3417,7 @@ Please submit there instead, or use --nodevelproject to force direct submission.
|
||||
if len(args) > 3:
|
||||
raise oscerr.WrongArgs('Too many arguments')
|
||||
|
||||
args = self.parse_repoarchdescr(args, opts.noinit, opts.alternative_project)
|
||||
args = self.parse_repoarchdescr(args, opts.noinit or opts.offline, opts.alternative_project)
|
||||
|
||||
# check for source services
|
||||
if not opts.noservice and not opts.noinit and os.listdir('.').count("_service"):
|
||||
@ -3428,6 +3432,14 @@ Please submit there instead, or use --nodevelproject to force direct submission.
|
||||
if opts.keep_pkgs and not os.path.isdir(opts.keep_pkgs):
|
||||
raise oscerr.WrongOptions('Preferred save location \'%s\' is not a directory' % opts.keep_pkgs)
|
||||
|
||||
if opts.noinit and opts.offline:
|
||||
raise oscerr.WrongOptions('--noinit and --offline are mutually exclusive')
|
||||
sys.exit(1)
|
||||
|
||||
if opts.offline and opts.preload:
|
||||
raise oscerr.WrongOptions('--offline and --preload are mutually exclusive')
|
||||
sys.exit(1)
|
||||
|
||||
print 'Building %s for %s/%s' % (args[2], args[0], args[1])
|
||||
return osc.build.main(opts, args)
|
||||
|
||||
@ -3440,6 +3452,8 @@ Please submit there instead, or use --nodevelproject to force direct submission.
|
||||
help='do not guess/verify specified repository')
|
||||
@cmdln.option('-r', '--root', action='store_true',
|
||||
help='login as root instead of abuild')
|
||||
@cmdln.option('-o', '--offline', action='store_true',
|
||||
help='Use cached data without contacting the api server')
|
||||
def do_chroot(self, subcmd, opts, *args):
|
||||
"""${cmd_name}: chroot into the buildchroot
|
||||
|
||||
@ -3463,7 +3477,7 @@ Please submit there instead, or use --nodevelproject to force direct submission.
|
||||
user = 'abuild'
|
||||
if opts.root:
|
||||
user = 'root'
|
||||
repository, arch, descr = self.parse_repoarchdescr(args, opts.noinit, opts.alternative_project)
|
||||
repository, arch, descr = self.parse_repoarchdescr(args, opts.noinit or opts.offline, opts.alternative_project)
|
||||
project = opts.alternative_project or store_read_project('.')
|
||||
if opts.local_package:
|
||||
package = os.path.splitext(descr)[0]
|
||||
|
@ -51,7 +51,7 @@ class OscFileGrabber:
|
||||
|
||||
class Fetcher:
|
||||
def __init__(self, cachedir = '/tmp', api_host_options = {}, urllist = [], http_debug = False,
|
||||
cookiejar = None, offline = False, enable_cpio = False):
|
||||
cookiejar = None, noinit = False, offline = False, enable_cpio = False):
|
||||
# set up progress bar callback
|
||||
if sys.stdout.isatty() and TextMeter:
|
||||
self.progress_obj = TextMeter(fo=sys.stdout)
|
||||
@ -61,6 +61,7 @@ class Fetcher:
|
||||
self.cachedir = cachedir
|
||||
self.urllist = urllist
|
||||
self.http_debug = http_debug
|
||||
self.noinit = noinit
|
||||
self.offline = offline
|
||||
self.cpio = {}
|
||||
self.enable_cpio = enable_cpio
|
||||
@ -85,7 +86,7 @@ class Fetcher:
|
||||
# for use by the failure callback
|
||||
self.curpac = pac
|
||||
|
||||
if self.offline:
|
||||
if self.noinit or self.offline:
|
||||
return True
|
||||
|
||||
MirrorGroup._join_url = join_url
|
||||
@ -163,6 +164,9 @@ class Fetcher:
|
||||
for i in buildinfo.deps:
|
||||
i.makeurls(self.cachedir, self.urllist)
|
||||
if not os.path.exists(i.fullfilename):
|
||||
if self.offline:
|
||||
print "Missing package '%s' in cache: --offline not possible." % i.fullfilename
|
||||
sys.exit(1)
|
||||
self.dirSetup(i)
|
||||
try:
|
||||
# if there isn't a progress bar, there is no output at all
|
||||
|
Loading…
Reference in New Issue
Block a user