Skip to content

Commit b0b8588

Browse files
committed
Fix crash in 'build' command when building with --local-package --alternative-project from a locally initialized .osc package
1 parent 1fc5813 commit b0b8588

File tree

2 files changed

+11
-2
lines changed

2 files changed

+11
-2
lines changed

osc/build.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -917,7 +917,7 @@ def main(apiurl, store, opts, argv):
917917
bc_file = None
918918
bi_filename = '_buildinfo-%s-%s.xml' % (repo, arch)
919919
bc_filename = '_buildconfig-%s-%s' % (repo, arch)
920-
if store.is_package and os.access(core.store, os.W_OK):
920+
if store is not None and store.is_package and os.access(core.store, os.W_OK):
921921
bi_filename = os.path.join(os.getcwd(), core.store, bi_filename)
922922
bc_filename = os.path.join(os.getcwd(), core.store, bc_filename)
923923
elif not os.access('.', os.W_OK):

osc/commandline.py

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7408,10 +7408,19 @@ def do_build(self, subcmd, opts, *args):
74087408
pass
74097409
else:
74107410
try:
7411-
store = osc_store.get_store(os.path.dirname(Path.cwd()), print_warnings=True)
7411+
store = osc_store.get_store(Path.cwd(), print_warnings=True)
74127412
except oscerr.NoWorkingCopy:
74137413
store = None
74147414

7415+
if store is None:
7416+
try:
7417+
# if opts.local_package is set, build.main() reads project from the store and sets package to "_project"
7418+
# that's why we're ok with store from the parent directory that holds information about the project
7419+
# FIXME: the parent directory may contain a git repo that doesn't contain a project; we have no way of recognizing that!
7420+
store = osc_store.get_store(os.path.dirname(Path.cwd()), print_warnings=True)
7421+
except oscerr.NoWorkingCopy:
7422+
store = None
7423+
74157424
# HACK: avoid calling some underlying store_*() functions from parse_repoarchdescr() method
74167425
# We'll fix parse_repoarchdescr() later because it requires a larger change
74177426
if not opts.alternative_project and isinstance(store, git_scm.GitStore):

0 commit comments

Comments
 (0)