Skip to content

Commit

Permalink
- fixed #122 ("osc chroot fails to use the osc build buildroot direct…
Browse files Browse the repository at this point in the history
…ory")

Renamed osc chroot's "--root" option to "--login-as-root" (kept the short
option "-r"). Added new "--root /path/to/buildroot" option (this is consistent
with "osc build --root...").
  • Loading branch information
marcus-h committed Nov 14, 2014
1 parent 87021e4 commit ad92e8a
Showing 1 changed file with 16 additions and 11 deletions.
27 changes: 16 additions & 11 deletions osc/commandline.py
Expand Up @@ -5798,8 +5798,10 @@ def rsync_dirs_2host(hostargs, short_name, long_name, dirs):
help='specify the used build target project')
@cmdln.option('--noinit', '--no-init', action='store_true',
help='do not guess/verify specified repository')
@cmdln.option('-r', '--root', action='store_true',
@cmdln.option('-r', '--login-as-root', action='store_true',
help='login as root instead of abuild')
@cmdln.option('--root', metavar='ROOT',
help='Path to the buildroot')
@cmdln.option('-o', '--offline', action='store_true',
help='Use cached data without contacting the api server')
def do_chroot(self, subcmd, opts, *args):
Expand All @@ -5823,17 +5825,20 @@ def do_chroot(self, subcmd, opts, *args):
sys.exit(1)

user = 'abuild'
if opts.root:
if opts.login_as_root:
user = 'root'
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]
else:
package = store_read_package('.')
apihost = urlsplit(self.get_api_url())[1]
buildroot = os.environ.get('OSC_BUILD_ROOT', conf.config['build-root']) \
% {'repo': repository, 'arch': arch, 'project': project, 'package': package, 'apihost': apihost}
buildroot = opts.root
if buildroot is None:
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]
else:
package = store_read_package('.')
apihost = urlsplit(self.get_api_url())[1]
if buildroot is None:
buildroot = os.environ.get('OSC_BUILD_ROOT', conf.config['build-root']) \
% {'repo': repository, 'arch': arch, 'project': project, 'package': package, 'apihost': apihost}
if not os.path.isdir(buildroot):
raise oscerr.OscIOError(None, '\'%s\' is not a directory' % buildroot)

Expand Down

0 comments on commit ad92e8a

Please sign in to comment.