Skip to content

Commit

Permalink
fix: Find first source package name for a binary package with publish…
Browse files Browse the repository at this point in the history
…ed sources

If a changelog is not found for a binary package then iterate through list of all source package
for with binaries published of that name - not just the first source package found.

This fixes a problem with metapackages like linux-gce-edge:

```
❯ ubuntu-package-changelog --entries=1 jammy Updates linux-gcp-edge
no changelog found
```

vs (with the commit present)

```
❯ ubuntu-package-changelog --entries=1 jammy Updates linux-gcp-edge
INFO: No published sources found for linux-gcp-edge in jammy Updates
INFO:   Trying to find a binary package with that name ...
INFO:   Found source package linux-meta-gcp-6.2 for binary package linux-gcp-edge with published sources.
INFO:   Changelog for source package linux-meta-gcp-6.2 will be parsed

linux-meta-gcp-6.2 (6.2.0.1010.10~22.04.1) jammy; urgency=medium

  * Bump ABI 6.2.0-1010.10~22.04

  * Packaging resync (LP: #1786013)
    - [Packaging] resync debian/dkms-versions from main package

 -- Khalid Elmously <[email protected]>  Tue, 18 Jul 2023 04:39:30 -0400

```

The source packages are sorted by date with newest first so we will always have the latest returned.

In this instance it is a metadata package which will not have a very informative changleog but it
is more helpful than no changelog and at least it is known what the source package name is.
  • Loading branch information
Philip Roche committed Aug 4, 2023
1 parent 74d6846 commit 31dd2a2
Showing 1 changed file with 17 additions and 6 deletions.
23 changes: 17 additions & 6 deletions ubuntu_package_changelog/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,8 @@ def _lp_get_changelog_url(args, lp):
lp_series,
pocket)
if len(sources) == 0:
print(f'INFO: No published sources found for {args.package} in {args.series} {args.pocket}')
print('INFO: \tTrying to find a binary package with that name ...')
# unable to find published sources for args.package.
# Perhaps this is a binary package name so we can
# do a lookup to see if there exists a source package for
Expand All @@ -34,11 +36,19 @@ def _lp_get_changelog_url(args, lp):
if len(binaries):
# there were published binaries with this name.
# now get the source package name so we can get the changelog
source_package_name = binaries[0].source_package_name
sources = _get_published_sources(archive,
source_package_name,
lp_series,
pocket)
for binary in binaries:
source_package_name = binary.source_package_name
sources = _get_published_sources(archive,
source_package_name,
lp_series,
pocket)
if len(sources) > 0:
print(f'INFO: \tFound source package {source_package_name} for binary package '
f'{args.package} with published sources.')
print(f'INFO: \tChangelog for source package {source_package_name} will be parsed\n\n')
break
else:
print(f'INFO: \tNo published binaries found for {args.package} in {args.series} {args.pocket}\n\n')

if len(sources) == 1:
return sources[0].changelogUrl()
Expand Down Expand Up @@ -106,7 +116,8 @@ def main():

changelog_url = _lp_get_changelog_url(args, lp)
if not changelog_url:
print('no changelog found')
print('No changelog found for binary or source package "{}" in {} {}'.format(
args.package, args.series, args.pocket))
sys.exit(0)

url = lp._root_uri.append(urllib.parse.urlparse(changelog_url).path.lstrip('/'))
Expand Down

0 comments on commit 31dd2a2

Please sign in to comment.