Skip to content

Commit 7eddadf

Browse files
authored
Merge pull request openSUSE#1641 from dmach/fix-build-local-package-.osc
Fix crash in 'build' command when building with --local-package --alternative-project from a locally initialized .osc package
2 parents 430ffcf + b0b8588 commit 7eddadf

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
@@ -919,7 +919,7 @@ def main(apiurl, store, opts, argv):
919919
bc_file = None
920920
bi_filename = '_buildinfo-%s-%s.xml' % (repo, arch)
921921
bc_filename = '_buildconfig-%s-%s' % (repo, arch)
922-
if store.is_package and os.access(core.store, os.W_OK):
922+
if store is not None and store.is_package and os.access(core.store, os.W_OK):
923923
bi_filename = os.path.join(os.getcwd(), core.store, bi_filename)
924924
bc_filename = os.path.join(os.getcwd(), core.store, bc_filename)
925925
elif not os.access('.', os.W_OK):

osc/commandline.py

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

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

0 commit comments

Comments
 (0)