Skip to content

Commit

Permalink
Merge pull request #1583 from dmach/getbinaries-multibuild
Browse files Browse the repository at this point in the history
Improve 'getbinaries' command by accepting '-M' / '--multibuild-package' option outside checkouts
  • Loading branch information
dmach authored Jun 20, 2024
2 parents 110ddaf + b78b6ad commit a6c0b2c
Show file tree
Hide file tree
Showing 6 changed files with 45 additions and 17 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,10 @@ Scenario: Run `osc getbinaries <project> <package> <repo> <arch> <file>`

Scenario: Run `osc getbinaries <project> <package> <repo> <arch> <file> --multibuild-package=<flavor>`
When I execute osc with args "getbinaries test:factory multibuild-pkg standard x86_64 multibuild-pkg-flavor1-1-1.x86_64.rpm --multibuild-package=flavor1"
# the option is allowed only in a package checkout
Then the exit code is 2
Then directory listing of "{context.osc.temp}/binaries/" is
"""
multibuild-pkg-flavor1-1-1.x86_64.rpm
"""


Scenario: Run `osc getbinaries <project> <package>:<flavor> <repo> <arch> <file>` where file is a package
Expand Down
9 changes: 7 additions & 2 deletions behave/features/getbinaries-project-package-repo-arch.feature
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,13 @@ Scenario: Run `osc getbinaries <project> <package> <repo> <arch>`

Scenario: Run `osc getbinaries <project> <package> <repo> <arch> --multibuild-package=<flavor>`
When I execute osc with args "getbinaries test:factory multibuild-pkg standard x86_64 --multibuild-package=flavor1"
# the option is allowed only in a package checkout
Then the exit code is 2
Then directory listing of "{context.osc.temp}/binaries/" is
"""
multibuild-pkg-flavor1-1-1.x86_64.rpm
_buildenv
_statistics
rpmlint.log
"""


Scenario: Run `osc getbinaries <project> <package>:<flavor> <repo> <arch>`
Expand Down
9 changes: 7 additions & 2 deletions behave/features/getbinaries-project-repo-arch.feature
Original file line number Diff line number Diff line change
Expand Up @@ -35,8 +35,13 @@ Scenario: Run `osc getbinaries <project> <repo> <arch>`

Scenario: Run `osc getbinaries <project> <repo> <arch> --multibuild-package=<flavor>`
When I execute osc with args "getbinaries test:factory standard x86_64 --multibuild-package=flavor1"
# the option is allowed only in a package checkout
Then the exit code is 2
Then directory tree in "{context.osc.temp}/binaries/" is
"""
multibuild-pkg-flavor1-1-1.x86_64.rpm
multibuild-pkg:flavor1/_buildenv
multibuild-pkg:flavor1/_statistics
multibuild-pkg:flavor1/rpmlint.log
"""


Scenario: Run `osc getbinaries <project> <repo> <arch> --debuginfo`
Expand Down
9 changes: 7 additions & 2 deletions behave/features/getbinaries-repo-arch-prjcheckout.feature
Original file line number Diff line number Diff line change
Expand Up @@ -37,8 +37,13 @@ Scenario: Run `osc getbinaries <repo> <arch>` from a project checkout

Scenario: Run `osc getbinaries <repo> <arch> --multibuild-package=<flavor>` from a project checkout
When I execute osc with args "getbinaries standard x86_64 --multibuild-package=flavor1"
# the option is allowed only in a package checkout
Then the exit code is 2
Then directory tree in "{context.osc.temp}/test:factory/binaries/" is
"""
multibuild-pkg-flavor1-1-1.x86_64.rpm
multibuild-pkg:flavor1/_buildenv
multibuild-pkg:flavor1/_statistics
multibuild-pkg:flavor1/rpmlint.log
"""


Scenario: Run `osc getbinaries <repo> <arch> --sources` from a project checkout
Expand Down
10 changes: 8 additions & 2 deletions behave/features/getbinaries-repo-prjcheckout.feature
Original file line number Diff line number Diff line change
Expand Up @@ -40,8 +40,14 @@ Scenario: Run `osc getbinaries <repo>` from a project checkout

Scenario: Run `osc getbinaries <repo> --multibuild-package=<flavor>` from a project checkout
When I execute osc with args "getbinaries standard --multibuild-package=flavor1"
# the option is allowed only in a package checkout
Then the exit code is 2
Then directory tree in "{context.osc.temp}/test:factory/binaries/" is
"""
multibuild-pkg-flavor1-1-1.i586.rpm
multibuild-pkg-flavor1-1-1.x86_64.rpm
multibuild-pkg:flavor1/_buildenv
multibuild-pkg:flavor1/_statistics
multibuild-pkg:flavor1/rpmlint.log
"""


Scenario: Run `osc getbinaries <repo> --sources` from a project checkout
Expand Down
19 changes: 12 additions & 7 deletions osc/commandline.py
Original file line number Diff line number Diff line change
Expand Up @@ -8135,9 +8135,6 @@ def do_getbinaries(self, subcmd, opts, *args):
package = None
binary = None

if opts.multibuild_package and ((len(args) > 2) or (len(args) <= 2 and is_project_dir(Path.cwd()))):
self.argparse_error("The -M/--multibuild-package option can be only used from a package checkout.")

if len(args) < 1 and is_package_dir('.'):
self.print_repos()

Expand Down Expand Up @@ -8177,13 +8174,21 @@ def do_getbinaries(self, subcmd, opts, *args):
if package is None:
package_specified = False
package = meta_get_packagelist(apiurl, project, deleted=0)
if opts.multibuild_package:
# remove packages that do not have matching flavor
for i in package.copy():
package_flavor = i.rsplit(":", 1)
# package has flavor, check if the flavor is in opts.multibuild_packages
flavor_match = len(package_flavor) == 2 and package_flavor[1] in opts.multibuild_package
# package nas no flavor, check if "" is in opts.multibuild_package
no_flavor_match = len(package_flavor) == 1 and "" in opts.multibuild_package
if not flavor_match and not no_flavor_match:
package.remove(i)
else:
package_specified = True
if opts.multibuild_package:
packages = []
for subpackage in opts.multibuild_package:
packages.append(package + ":" + subpackage)
package = packages
resolver = MultibuildFlavorResolver(apiurl, project, package, use_local=False)
package = resolver.resolve_as_packages(opts.multibuild_package)
else:
package = [package]

Expand Down

0 comments on commit a6c0b2c

Please sign in to comment.