Skip to content

rpm: make_rpm.py fails with exit code = 0 when rpmbuild fails #1023

@wade-arista

Description

@wade-arista

Instead of failing "directly", make_rpm.py will exit 0 and then bazel will complain that the outputs were not created:

INFO: From MakeRpm MyRpm/MyRpm-1.0.6.x86_64.rpm:
some rpmbuild failure...
ERROR: /src/MyRpm/BUILD.bazel:77:12: output 'MyRpm/MyRpm-1.0.6.x86_64.rpm' was not created
ERROR: /src/MyRpm/BUILD.bazel:77:12: output 'MyRpm/MyRpm-lib-1.0.6.x86_64.rpm' was not created
ERROR: /src/MyRpm/BUILD.bazel:77:12: MakeRpm MyRpm/MyRpm-1.0.6.x86_64.rpm failed: not all outputs were created or valid

It seems better to exit non-zero on failure so that bazel can report it directly instead of just by virtue of not finding the output files, e.g.:

INFO: Analyzed target //MyRpm:rpm (1 packages loaded, 5143 targets configured).
ERROR: /src/MyRpm/BUILD.bazel:77:12: MakeRpm MyRpm/MyRpm-1.0.6.x86_64.rpm failed: (Exit 1): make_rpm failed: error executing MakeRpm command (from target //MyRpm:rpm) bazel-out/k8-opt-exec-ST-d57f47055a04/bin/external/rules_pkg+/pkg/make_rpm\
 '--name=MyRpm' '--rpmbuild=bazel-out/k8-opt-exec-ST-d57f47055a04/bin/BazAr/packaging/rpm/rpmbuild' '--debuginfo_type=centos' ... (remaining 37 arguments skipped)

Use --sandbox_debug to see verbose messages from the sandbox and retain the sandbox build root for debugging
some rpmbuild failure...
bazel: Leaving directory `/tmp/bazel_output/f8087e59fd95af1ae29e8fcb7ff1a3dc/execroot/_main/'
Target //MyRpm:rpm failed to build

The latter output is when I hacked make_rpm.py to just fail directly, e.g.

if __name__ == '__main__':
  print("some rpmbuild failure...")
  sys.exit(1)

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions