Mailinglist Archive: opensuse-buildservice (348 mails)

< Previous Next >
[opensuse-buildservice] [Patch] Add --offline and --preload to osc build - v1
  • From: "Jan-Simon Möller" <dl9pf@xxxxxx>
  • Date: Thu, 15 Apr 2010 23:16:35 +0200
  • Message-id: <201004152316.35160.dl9pf@xxxxxx>
Hi all!

Ever wanted to work offline e.g. in train on a package ? So after being
encased hours in such a vehicle, here it is ...

The attached patch for review and improvement adds this functionality:

osc build --preload standard i586 pkg.spec

will cache all dependencies and also the build config.

To build offline, then use

osc build --offline standard i586 pkg.spec


Also -o / -l as shortcuts.

Have phun!

Jan-Simon


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..5da39a5 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:
@@ -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..97cca30 100644
--- a/osc/commandline.py
+++ b/osc/commandline.py
@@ -3238,10 +3238,12 @@ Please submit there instead, or use --nodevelproject to
force direct submission.
print row


- def parse_repoarchdescr(self, args, noinit = False, alternative_project =
None):
+ def parse_repoarchdescr(self, args, noinit = False, alternative_project =
None, offline = False):
"""helper to parse the repo, arch and build description from args"""
import osc.build
arg_arch = arg_repository = arg_descr = None
+ if offline:
+ noinit=offline
if len(args) < 3:
for arg in args:
if arg.endswith('.spec') or arg.endswith('.dsc') or
arg.endswith('.kiwi'):
@@ -3296,6 +3298,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 +3419,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,
opts.alternative_project, opts.offline)

# check for source services
if not opts.noservice and not opts.noinit and
os.listdir('.').count("_service"):
@@ -3440,6 +3446,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 +3471,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,
opts.alternative_project, opts.offline)
project = opts.alternative_project or store_read_project('.')
if opts.local_package:
package = os.path.splitext(descr)[0]
< Previous Next >