This adds support for --preload (=loading packages into the cache) and
--offline (=using only cached packages + buildinfo) for chroot setup to
osc build.
Next topic for this: if no buildinfo from the server is present/stored,
recalc ourselves if possible with local cache.
Signed-off-by: Jan-Simon Möller
---
NEWS | 3 +++
osc/build.py | 16 ++++++++++++----
osc/commandline.py | 19 ++++++++++++++++---
osc/fetch.py | 8 ++++++--
4 files changed, 37 insertions(+), 9 deletions(-)
diff --git a/NEWS b/NEWS
index 1d73798..b032b80 100644
--- a/NEWS
+++ b/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
diff --git a/osc/build.py b/osc/build.py
index 7c97700..9d221c1 100644
--- a/osc/build.py
+++ b/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'
@@ -669,7 +676,6 @@ def main(opts, argv):
print 'WARNING: deb packages get not verified, they can compromise your system !'
else:
print 'WARNING: unknown packages get not verified, they can compromise your system !'
-
print 'Writing build configuration'
rpmlist = [ '%s %s\n' % (i.name, i.fullfilename) for i in bi.deps if not i.noinstall ]
@@ -722,7 +728,9 @@ def main(opts, argv):
vm_options += ' --vmdisk-rootsize ' + config['build-vmdisk-rootsize']
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'],
diff --git a/osc/commandline.py b/osc/commandline.py
index ab410f0..1825b88 100644
--- a/osc/commandline.py
+++ b/osc/commandline.py
@@ -3258,7 +3258,6 @@ Please submit there instead, or use --nodevelproject to force direct submission.
arg_repository, arg_arch, arg_descr = args
arg_arch = arg_arch or osc.build.hostarch
-
if not noinit:
project = alternative_project or store_read_project('.')
repositories = get_repositories_of_project(store_read_apiurl('.'), project)
@@ -3296,6 +3295,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 +3416,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 +3431,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 +3451,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 +3476,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]
diff --git a/osc/fetch.py b/osc/fetch.py
index 0e39925..fe1c348 100644
--- a/osc/fetch.py
+++ b/osc/fetch.py
@@ -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
--
1.7.0.3
--
To unsubscribe, e-mail: opensuse-buildservice+unsubscribe@opensuse.org
For additional commands, e-mail: opensuse-buildservice+help@opensuse.org