Skip to content

Commit

Permalink
Merge pull request PowerDNS#14691 from Habbie/dnf-sbom-version
Browse files Browse the repository at this point in the history
dnf sbom: use same logic for our version number too
  • Loading branch information
Habbie authored Sep 20, 2024
2 parents 98863d5 + 154ac01 commit 0de9aac
Showing 1 changed file with 8 additions and 3 deletions.
11 changes: 8 additions & 3 deletions builder-support/helpers/generate-sbom-dnf.py
Original file line number Diff line number Diff line change
Expand Up @@ -45,9 +45,9 @@ def addDependencyToSBOM(sbom, appInfos, pkg):
bomRef = 'lib:' + pkg.name
component = { 'name': pkg.name, 'bom-ref': bomRef, 'type': 'library'}
if pkg.release:
component['version'] = (pkg.version if pkg.epoch == 0 else str(pkg.epoch) + ':' + pkg.version) + '-' + pkg.release
component['version'] = (pkg.version if pkg.epoch == 0 else str(pkg.epoch) + ':' + pkg.version) + '-' + pkg.release + '.' + pkg.arch
else:
component['version'] = (pkg.version if pkg.epoch == 0 else str(pkg.epoch) + ':' + pkg.version)
component['version'] = (pkg.version if pkg.epoch == 0 else str(pkg.epoch) + ':' + pkg.version) + '.' + pkg.arch
if hasattr(pkg, 'vendor') and pkg.vendor is not None:
component['supplier'] = {'name': pkg.vendor}
if hasattr(pkg, 'publisher') and pkg.publisher is not None:
Expand Down Expand Up @@ -132,7 +132,12 @@ def generateSBOM(packageName, additionalDeps):
appName = packageName
appInfos = getPackageInformations(pkgDB, packageName)
component = { 'name': appName, 'bom-ref': 'pkg:' + appName, 'type': 'application'}
component['version'] = appInfos.version

if appInfos.release:
component['version'] = (appInfos.version if appInfos.epoch == 0 else str(appInfos.epoch) + ':' + appInfos.version) + '-' + appInfos.release + '.' + appInfos.arch
else:
component['version'] = (appInfos.version if appInfos.epoch == 0 else str(appInfos.epoch) + ':' + appInfos.version) + '.' + appInfos.arch

component['supplier'] = {'name': appInfos.vendor if appInfos.vendor != '<NULL>' else 'PowerDNS.COM BV', 'url': ['https://www.powerdns.com']}
component['licenses'] = [{'license': {'id': licenseToSPDXIdentifier(appInfos.license)}}]
depRelations['pkg:' + appName] = []
Expand Down

0 comments on commit 0de9aac

Please sign in to comment.