* [Buildroot] [git commit] support/scripts/pkg-stats: strengthen version check in check_package_get_latest_version_by_distro()
@ 2022-03-16 22:04 Yann E. MORIN
2022-03-20 10:35 ` Thomas Petazzoni via buildroot
0 siblings, 1 reply; 3+ messages in thread
From: Yann E. MORIN @ 2022-03-16 22:04 UTC (permalink / raw)
To: buildroot
commit: https://git.buildroot.net/buildroot/commit/?id=c72f3f2b43f4607ed94d51a21abe5e3d909efb36
branch: https://git.buildroot.net/buildroot/commit/?id=refs/heads/master
The check_package_get_latest_version_by_distro() function analyzes the
data returned by release-monitoring.org. For two of our
packages (bento4 and qextserialport), release-monitoring.org returns
something that is a bit odd: it returns an entry with a
"stable_versions" field that contains an empty array. Our code was
ready to have or not have a "stable_versions" entry, but when it is
present, we assumed it was not an empty array. These two packages, for
some reason, break this assumption.
In order to solve this problem, this commit is more careful, and uses
the stable_versions field only if it exists and it has at least one
entry. The code is also reworked as a sequence of "if...elif...else"
to be more readable.
This fixes the following exception when running pkg-stats on the full
package set:
Task exception was never retrieved
future: <Task finished name='Task-10772' coro=<check_package_latest_version_get() done, defined at ./support/scripts/pkg-stats:532> exception=IndexError('list index out of range')>
Traceback (most recent call last):
File "./support/scripts/pkg-stats", line 535, in check_package_latest_version_get
if await check_package_get_latest_version_by_distro(session, pkg):
File "./support/scripts/pkg-stats", line 489, in check_package_get_latest_version_by_distro
version = data['stable_versions'][0] if 'stable_versions' in data else data['version'] if 'version' in data else None
IndexError: list index out of range
Signed-off-by: Thomas Petazzoni <thomas.petazzoni@bootlin.com>
[yann.morin.1998@free.fr: non-sequence tests as True]
Signed-off-by: Yann E. MORIN <yann.morin.1998@free.fr>
---
support/scripts/pkg-stats | 7 ++++++-
1 file changed, 6 insertions(+), 1 deletion(-)
diff --git a/support/scripts/pkg-stats b/support/scripts/pkg-stats
index c235d99407..8cc64a54d1 100755
--- a/support/scripts/pkg-stats
+++ b/support/scripts/pkg-stats
@@ -486,7 +486,12 @@ async def check_package_get_latest_version_by_distro(session, pkg, retry=True):
return False
data = await resp.json()
- version = data['stable_versions'][0] if 'stable_versions' in data else data['version'] if 'version' in data else None
+ if 'stable_versions' in data and data['stable_versions']:
+ version = data['stable_versions'][0]
+ elif 'version' in data:
+ version = data['version']
+ else:
+ version = None
check_package_latest_version_set_status(pkg,
RM_API_STATUS_FOUND_BY_DISTRO,
version,
_______________________________________________
buildroot mailing list
buildroot@buildroot.org
https://lists.buildroot.org/mailman/listinfo/buildroot
^ permalink raw reply related [flat|nested] 3+ messages in thread
* Re: [Buildroot] [git commit] support/scripts/pkg-stats: strengthen version check in check_package_get_latest_version_by_distro()
2022-03-16 22:04 [Buildroot] [git commit] support/scripts/pkg-stats: strengthen version check in check_package_get_latest_version_by_distro() Yann E. MORIN
@ 2022-03-20 10:35 ` Thomas Petazzoni via buildroot
2022-03-21 7:12 ` Peter Korsgaard
0 siblings, 1 reply; 3+ messages in thread
From: Thomas Petazzoni via buildroot @ 2022-03-20 10:35 UTC (permalink / raw)
To: Yann E. MORIN, Peter Korsgaard; +Cc: buildroot
Hello Peter,
Could you cherry-pick this commit into the currently maintained stable
branches?
Thanks a lot!
Thomas Petazzoni
On Wed, 16 Mar 2022 23:04:46 +0100
Yann E. MORIN <yann.morin.1998@free.fr> wrote:
> commit: https://git.buildroot.net/buildroot/commit/?id=c72f3f2b43f4607ed94d51a21abe5e3d909efb36
> branch: https://git.buildroot.net/buildroot/commit/?id=refs/heads/master
>
> The check_package_get_latest_version_by_distro() function analyzes the
> data returned by release-monitoring.org. For two of our
> packages (bento4 and qextserialport), release-monitoring.org returns
> something that is a bit odd: it returns an entry with a
> "stable_versions" field that contains an empty array. Our code was
> ready to have or not have a "stable_versions" entry, but when it is
> present, we assumed it was not an empty array. These two packages, for
> some reason, break this assumption.
>
> In order to solve this problem, this commit is more careful, and uses
> the stable_versions field only if it exists and it has at least one
> entry. The code is also reworked as a sequence of "if...elif...else"
> to be more readable.
>
> This fixes the following exception when running pkg-stats on the full
> package set:
>
> Task exception was never retrieved
> future: <Task finished name='Task-10772' coro=<check_package_latest_version_get() done, defined at ./support/scripts/pkg-stats:532> exception=IndexError('list index out of range')>
> Traceback (most recent call last):
> File "./support/scripts/pkg-stats", line 535, in check_package_latest_version_get
> if await check_package_get_latest_version_by_distro(session, pkg):
> File "./support/scripts/pkg-stats", line 489, in check_package_get_latest_version_by_distro
> version = data['stable_versions'][0] if 'stable_versions' in data else data['version'] if 'version' in data else None
> IndexError: list index out of range
>
> Signed-off-by: Thomas Petazzoni <thomas.petazzoni@bootlin.com>
> [yann.morin.1998@free.fr: non-sequence tests as True]
> Signed-off-by: Yann E. MORIN <yann.morin.1998@free.fr>
> ---
> support/scripts/pkg-stats | 7 ++++++-
> 1 file changed, 6 insertions(+), 1 deletion(-)
>
> diff --git a/support/scripts/pkg-stats b/support/scripts/pkg-stats
> index c235d99407..8cc64a54d1 100755
> --- a/support/scripts/pkg-stats
> +++ b/support/scripts/pkg-stats
> @@ -486,7 +486,12 @@ async def check_package_get_latest_version_by_distro(session, pkg, retry=True):
> return False
>
> data = await resp.json()
> - version = data['stable_versions'][0] if 'stable_versions' in data else data['version'] if 'version' in data else None
> + if 'stable_versions' in data and data['stable_versions']:
> + version = data['stable_versions'][0]
> + elif 'version' in data:
> + version = data['version']
> + else:
> + version = None
> check_package_latest_version_set_status(pkg,
> RM_API_STATUS_FOUND_BY_DISTRO,
> version,
> _______________________________________________
> buildroot mailing list
> buildroot@buildroot.org
> https://lists.buildroot.org/mailman/listinfo/buildroot
--
Thomas Petazzoni, co-owner and CEO, Bootlin
Embedded Linux and Kernel engineering and training
https://bootlin.com
_______________________________________________
buildroot mailing list
buildroot@buildroot.org
https://lists.buildroot.org/mailman/listinfo/buildroot
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [Buildroot] [git commit] support/scripts/pkg-stats: strengthen version check in check_package_get_latest_version_by_distro()
2022-03-20 10:35 ` Thomas Petazzoni via buildroot
@ 2022-03-21 7:12 ` Peter Korsgaard
0 siblings, 0 replies; 3+ messages in thread
From: Peter Korsgaard @ 2022-03-21 7:12 UTC (permalink / raw)
To: Thomas Petazzoni; +Cc: Yann E. MORIN, buildroot
>>>>> "Thomas" == Thomas Petazzoni <thomas.petazzoni@bootlin.com> writes:
> Hello Peter,
> Could you cherry-pick this commit into the currently maintained stable
> branches?
Sure, applied to 2021.02.x / 2021.11.x / 2022.02.x.
--
Bye, Peter Korsgaard
_______________________________________________
buildroot mailing list
buildroot@buildroot.org
https://lists.buildroot.org/mailman/listinfo/buildroot
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2022-03-21 7:12 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2022-03-16 22:04 [Buildroot] [git commit] support/scripts/pkg-stats: strengthen version check in check_package_get_latest_version_by_distro() Yann E. MORIN
2022-03-20 10:35 ` Thomas Petazzoni via buildroot
2022-03-21 7:12 ` Peter Korsgaard
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox