From 2eb51575cb4e924d98d41f90b2669294dad87810 Mon Sep 17 00:00:00 2001 From: Daniel Mach Date: Mon, 29 Apr 2024 09:07:47 +0200 Subject: [PATCH] Improve 'build' and 'buildinfo' commands by uploading *.inc files to OBS for parsing BuildRequires (boo#1221340) --- behave/features/buildinfo.feature | 12 +++++++++++ behave/fixtures/pac/test-pkgA-3-inc.inc | 1 + behave/fixtures/pac/test-pkgA-3-inc.spec | 27 ++++++++++++++++++++++++ osc/build.py | 7 ++++++ 4 files changed, 47 insertions(+) create mode 100644 behave/features/buildinfo.feature create mode 100644 behave/fixtures/pac/test-pkgA-3-inc.inc create mode 100644 behave/fixtures/pac/test-pkgA-3-inc.spec diff --git a/behave/features/buildinfo.feature b/behave/features/buildinfo.feature new file mode 100644 index 000000000..0cd912486 --- /dev/null +++ b/behave/features/buildinfo.feature @@ -0,0 +1,12 @@ +Feature: `osc buildinfo` command + + +Scenario: Run `osc buildinfo` on a package with a .inc file + Given I set working directory to "{context.osc.temp}" + And I execute osc with args "co test:factory/test-pkgA" + And I set working directory to "{context.osc.temp}/test:factory/test-pkgA" + And I copy file "{context.fixtures}/pac/test-pkgA-3-inc.spec" to "{context.osc.temp}/test:factory/test-pkgA/test-pkgA.spec" + And I copy file "{context.fixtures}/pac/test-pkgA-3-inc.inc" to "{context.osc.temp}/test:factory/test-pkgA/test-pkgA.inc" + When I execute osc with args "buildinfo" + Then the exit code is 0 + And stdout contains "unresolvable: nothing provides DOES-NOT-EXIST" diff --git a/behave/fixtures/pac/test-pkgA-3-inc.inc b/behave/fixtures/pac/test-pkgA-3-inc.inc new file mode 100644 index 000000000..2b072e0c5 --- /dev/null +++ b/behave/fixtures/pac/test-pkgA-3-inc.inc @@ -0,0 +1 @@ +BuildRequires: DOES-NOT-EXIST diff --git a/behave/fixtures/pac/test-pkgA-3-inc.spec b/behave/fixtures/pac/test-pkgA-3-inc.spec new file mode 100644 index 000000000..d81621011 --- /dev/null +++ b/behave/fixtures/pac/test-pkgA-3-inc.spec @@ -0,0 +1,27 @@ +%include test-pkgA.inc + +Name: test-pkgA +Version: 4 +Release: 1 +License: GPL-2.0 +Summary: Test package +URL: https://example.com/test-package/ + + +BuildArch: noarch + + +%description +desc + + +%prep + + +%install + + +%files + + +%changelog diff --git a/osc/build.py b/osc/build.py index 22b99706d..460180e07 100644 --- a/osc/build.py +++ b/osc/build.py @@ -708,6 +708,13 @@ def create_build_descr_data( # build recipe must go first for compatibility with the older OBS versions result_data.append((os.path.basename(build_descr_path).encode("utf-8"), build_descr_data)) + if topdir: + for include_file in glob.glob(os.path.join(topdir, "*.inc")): + fn = os.path.basename(include_file) + print(f"Using local file: {fn}", file=sys.stderr) + with open(include_file, "rb") as f: + result_data.append((fn.encode("utf-8"), f.read())) + if topdir: buildenv_file = os.path.join(topdir, f"_buildenv.{repo}.{arch}") if not os.path.isfile(buildenv_file):