[v11,5/8] mmdebstrap: Fix missing dpkg available

Message ID 20241106082117.1089554-6-amikan@ilbers.de
State Accepted, archived
Headers show
Series Migrate to mmdebstrap | expand

Commit Message

Anton Mikanovich Nov. 6, 2024, 8:21 a.m. UTC
In some distros /var/lib/dpkg/available is required for
do_rootfs_install task.
The fix for it is present in jessie-or-older mmdebstrap hook in
Bookworm and later, but maybe-jessie-or-older wrapper do not handle
distro version check correctly.
That's why we need to check and apply hook manually or create
/var/lib/dpkg/available by hand for older distros.

Signed-off-by: Anton Mikanovich <amikan@ilbers.de>
---
 meta/recipes-core/isar-mmdebstrap/isar-mmdebstrap.inc | 9 +++++++++
 1 file changed, 9 insertions(+)

Comments

Jan Kiszka Nov. 20, 2024, 10:18 p.m. UTC | #1
On 06.11.24 09:21, Anton Mikanovich wrote:
> In some distros /var/lib/dpkg/available is required for
> do_rootfs_install task.
> The fix for it is present in jessie-or-older mmdebstrap hook in
> Bookworm and later, but maybe-jessie-or-older wrapper do not handle
> distro version check correctly.
> That's why we need to check and apply hook manually or create
> /var/lib/dpkg/available by hand for older distros.
> 
> Signed-off-by: Anton Mikanovich <amikan@ilbers.de>
> ---
>  meta/recipes-core/isar-mmdebstrap/isar-mmdebstrap.inc | 9 +++++++++
>  1 file changed, 9 insertions(+)
> 
> diff --git a/meta/recipes-core/isar-mmdebstrap/isar-mmdebstrap.inc b/meta/recipes-core/isar-mmdebstrap/isar-mmdebstrap.inc
> index 658d45be..e1c3832d 100644
> --- a/meta/recipes-core/isar-mmdebstrap/isar-mmdebstrap.inc
> +++ b/meta/recipes-core/isar-mmdebstrap/isar-mmdebstrap.inc
> @@ -17,6 +17,14 @@ DISTRO_BOOTSTRAP_BASE_PACKAGES:append:gnupg = ",gnupg"
>  DISTRO_BOOTSTRAP_BASE_PACKAGES:append:https-support = ",ca-certificates"
>  BOOTSTRAP_TMPDIR = "${WORKDIR}/tempdir"
>  
> +# Fix for /var/lib/apt/available while maybe-jessie-or-older hook do not work
> +MM_HOOK_JESSIE = "/usr/share/mmdebstrap/hooks/jessie-or-older"
> +DPKG_HOOKS ?= "${@'--hook-dir='+d.getVar('MM_HOOK_JESSIE') \
> +              if os.path.isdir(d.getVar('MM_HOOK_JESSIE')) \
> +              else '--customize-hook=\'touch /var/lib/dpkg/available\''}"
> +MMHOOKS:ubuntu-focal ?= "${DPKG_HOOKS}"
> +MMHOOKS:debian-buster ?= "${DPKG_HOOKS}"

This breaks downstream buster (or focal) when setting custom DISTRO. Fix
will follow.

Jan

> +
>  def get_distro_primary_source_entry(d):
>      for source in generate_distro_sources(d):
>          if source[0] == "deb":
> @@ -98,6 +106,7 @@ do_bootstrap() {
>      sudo TMPDIR="${BOOTSTRAP_TMPDIR}" mmdebstrap $bootstrap_args \
>                     $arch_param \
>                     --mode=unshare \
> +                   ${MMHOOKS} \
>                     ${@get_distro_components_argument(d)} \
>                     "${@get_distro_suite(d)}" \
>                     "${WORKDIR}/rootfs.tar.zst" \

Patch

diff --git a/meta/recipes-core/isar-mmdebstrap/isar-mmdebstrap.inc b/meta/recipes-core/isar-mmdebstrap/isar-mmdebstrap.inc
index 658d45be..e1c3832d 100644
--- a/meta/recipes-core/isar-mmdebstrap/isar-mmdebstrap.inc
+++ b/meta/recipes-core/isar-mmdebstrap/isar-mmdebstrap.inc
@@ -17,6 +17,14 @@  DISTRO_BOOTSTRAP_BASE_PACKAGES:append:gnupg = ",gnupg"
 DISTRO_BOOTSTRAP_BASE_PACKAGES:append:https-support = ",ca-certificates"
 BOOTSTRAP_TMPDIR = "${WORKDIR}/tempdir"
 
+# Fix for /var/lib/apt/available while maybe-jessie-or-older hook do not work
+MM_HOOK_JESSIE = "/usr/share/mmdebstrap/hooks/jessie-or-older"
+DPKG_HOOKS ?= "${@'--hook-dir='+d.getVar('MM_HOOK_JESSIE') \
+              if os.path.isdir(d.getVar('MM_HOOK_JESSIE')) \
+              else '--customize-hook=\'touch /var/lib/dpkg/available\''}"
+MMHOOKS:ubuntu-focal ?= "${DPKG_HOOKS}"
+MMHOOKS:debian-buster ?= "${DPKG_HOOKS}"
+
 def get_distro_primary_source_entry(d):
     for source in generate_distro_sources(d):
         if source[0] == "deb":
@@ -98,6 +106,7 @@  do_bootstrap() {
     sudo TMPDIR="${BOOTSTRAP_TMPDIR}" mmdebstrap $bootstrap_args \
                    $arch_param \
                    --mode=unshare \
+                   ${MMHOOKS} \
                    ${@get_distro_components_argument(d)} \
                    "${@get_distro_suite(d)}" \
                    "${WORKDIR}/rootfs.tar.zst" \