Skip to content

Commit

Permalink
fix(cli): crash when RPM spec file not found
Browse files Browse the repository at this point in the history
Make fatbuildrctl report artifact error instead of crashing when
building an RPM package and RPM spec file is not found.

fix #165
  • Loading branch information
rezib committed Jul 10, 2024
1 parent ee68202 commit f586721
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 9 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -191,6 +191,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
execution error to report in task journal.
- Check container image and build environment exist or fail with appropriate
error at the beginning of build tasks (#17).
- Fix `fatbuildrctl` crash when RPM spec file is not found (#165).
- docs:
- Add missing path parameter in REST API to retrieve artifact information.
- Add missing optional `architectures` parameter in instances pipelines
Expand Down
26 changes: 17 additions & 9 deletions fatbuildr/artifact.py
Original file line number Diff line number Diff line change
Expand Up @@ -275,16 +275,24 @@ def architecture_dependent(self):
To determine the value, the BuildArch parameter is checked in RPM spec
file. Unless BuildArch is set to noarch, the source package is
considered architecture dependent."""
considered architecture dependent.
Raise FatbuildrArtifactError if RPM spec file not found."""
check_file = self.place.joinpath(self.format, f"{self.artifact}.spec")
with open(check_file, 'r') as fh:
for line in fh:
if (
line.replace(' ', '')
.replace('\t', '')
.startswith('BuildArch:noarch')
):
return False
try:
with open(check_file, 'r') as fh:
for line in fh:
if (
line.replace(' ', '')
.replace('\t', '')
.startswith('BuildArch:noarch')
):
return False
except FileNotFoundError:
raise FatbuildrArtifactError(
f"RPM spec file {check_file} not found, unable to determine if "
"package is architecture dependent"
)
return True

@property
Expand Down

0 comments on commit f586721

Please sign in to comment.