1
0
mirror of https://github.com/openSUSE/osc.git synced 2024-12-26 09:56:13 +01:00

Added '--build-uid uid:gid|caller' feature to specify abuild id in chroot

This commit is contained in:
David Greaves 2010-02-12 21:54:39 +00:00
parent 7e530dfaac
commit d95ae68724
3 changed files with 28 additions and 3 deletions

View File

@ -362,6 +362,20 @@ def main(opts, argv):
if opts.without:
for o in opts.without:
buildargs.append('--without %s' % o)
build_uid=''
if config['build-uid']:
build_uid = config['build-uid']
if opts.build_uid:
build_uid = opts.build_uid
if build_uid:
buildidre = re.compile('^[0-9]{1,5}:[0-9]{1,5}$')
if build_uid == 'caller':
buildargs.append('--uid %s:%s' % (os.getuid(), os.getgid()))
elif buildidre.match(build_uid):
buildargs.append('--uid %s' % build_uid)
else:
print >>sys.stderr, 'Error: build-uid arg must be 2 colon separated numerics: "uid:gid" or "caller"'
return 1
# FIXME: quoting
# if opts.define:
# buildargs.append('--define "%s"' % opts.define)

View File

@ -3269,6 +3269,9 @@ Please submit there instead, or use --nodevelproject to force direct submission.
help='Run build as root. The default is to build as '
'unprivileged user. Note that a line "# norootforbuild" '
'in the spec file will invalidate this option.')
@cmdln.option('--build-uid', metavar='uid:gid|"caller"',
help='specify the numeric uid:gid pair to assign to the '
'unprivileged "abuild" user or use "caller" to use the current user uid:gid')
@cmdln.option('--local-package', action='store_true',
help='build a package which does not exist on the server')
@cmdln.option('--linksources', action='store_true',
@ -3297,9 +3300,9 @@ Please submit there instead, or use --nodevelproject to force direct submission.
of the 'osc repos' output. BUILD_DESCR is either a RPM spec file, or a
Debian dsc file.
The command honours packagecachedir and build-root settings in .oscrc,
if present. You may want to set su-wrapper = 'sudo' in .oscrc, and
configure sudo with option NOPASSWD for /usr/bin/build.
The command honours packagecachedir, build-root and build-uid
settings in .oscrc, if present. You may want to set su-wrapper = 'sudo'
in .oscrc, and configure sudo with option NOPASSWD for /usr/bin/build.
If neither --clean nor --noinit is given, build will reuse an existing
build-root again, removing unneeded packages and add missing ones. This

View File

@ -71,6 +71,7 @@ DEFAULTS = { 'apiurl': 'https://api.opensuse.org',
'build-cmd': '/usr/bin/build',
'build-type': '', # may be empty for chroot, kvm or xen
'build-root': '/var/tmp/build-root',
'build-uid': '', # use the default provided by build
'build-device': '', # required for VM builds
'build-memory': '',# required for VM builds
'build-swap': '', # optional for VM builds
@ -149,6 +150,13 @@ apiurl = %(apiurl)s
# compile with N jobs (default: "getconf _NPROCESSORS_ONLN")
#build-jobs = N
# Numeric uid:gid to assign to the "abuild" user in the build-root
# or "caller" to use the current users uid:gid
# This is convenient when sharing the buildroot with ordinary userids
# on the host.
# This should not be 0
# build-uid =
# extra packages to install when building packages locally (osc build)
# this corresponds to osc build's -x option and can be overridden with that
# -x '' can also be given on the command line to override this setting, or