[1/1] dpkg-prebuilt: ensure fetched packages are valid debian packages

Message ID 20240626110541.94885-1-felix.moessbauer@siemens.com
State Superseded, archived
Headers show
Series [1/1] dpkg-prebuilt: ensure fetched packages are valid debian packages | expand

Commit Message

MOESSBAUER, Felix June 26, 2024, 11:05 a.m. UTC
In case of dpkg-prebuilt, we need to check if the fetched packages are
valid debian packages to only deploy valid ones into the sstate cache.
Otherwise broken packages might end up in the cache and break future
builds.

Signed-off-by: Felix Moessbauer <felix.moessbauer@siemens.com>
---
 meta/classes/dpkg-prebuilt.bbclass | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)

Comments

MOESSBAUER, Felix June 26, 2024, 1:22 p.m. UTC | #1
On Wed, 2024-06-26 at 13:05 +0200, Felix Moessbauer wrote:
> In case of dpkg-prebuilt, we need to check if the fetched packages
> are
> valid debian packages to only deploy valid ones into the sstate
> cache.
> Otherwise broken packages might end up in the cache and break future
> builds.

This does not work in case we deploy multiple debs. Will fix this in a
v2 after testing.

Felix

> 
> Signed-off-by: Felix Moessbauer <felix.moessbauer@siemens.com>
> ---
>  meta/classes/dpkg-prebuilt.bbclass | 5 ++++-
>  1 file changed, 4 insertions(+), 1 deletion(-)
> 
> diff --git a/meta/classes/dpkg-prebuilt.bbclass b/meta/classes/dpkg-
> prebuilt.bbclass
> index 7092670b..c6b66c62 100644
> --- a/meta/classes/dpkg-prebuilt.bbclass
> +++ b/meta/classes/dpkg-prebuilt.bbclass
> @@ -19,5 +19,8 @@ python do_unpack:prepend() {
>  # also breaks inherited (from dpkg-base) dependency on sbuild_chroot
>  do_dpkg_build[depends] = "${PN}:do_unpack"
>  do_dpkg_build() {
> -    true
> +    # ensure all packages we got are valid debian packages
> +    if [ -n "$(find ${WORKDIR} -maxdepth 1 -name '*.deb' -print -
> quit)" ]; then
> +        dpkg -I ${WORKDIR}/*.deb
> +    fi
>  }

Patch

diff --git a/meta/classes/dpkg-prebuilt.bbclass b/meta/classes/dpkg-prebuilt.bbclass
index 7092670b..c6b66c62 100644
--- a/meta/classes/dpkg-prebuilt.bbclass
+++ b/meta/classes/dpkg-prebuilt.bbclass
@@ -19,5 +19,8 @@  python do_unpack:prepend() {
 # also breaks inherited (from dpkg-base) dependency on sbuild_chroot
 do_dpkg_build[depends] = "${PN}:do_unpack"
 do_dpkg_build() {
-    true
+    # ensure all packages we got are valid debian packages
+    if [ -n "$(find ${WORKDIR} -maxdepth 1 -name '*.deb' -print -quit)" ]; then
+        dpkg -I ${WORKDIR}/*.deb
+    fi
 }