From mboxrd@z Thu Jan 1 00:00:00 1970 X-GM-THRID: 7313604901749129216 Date: Sun, 17 Dec 2023 21:39:00 -0800 (PST) From: Srinuvasan Arjunan To: isar-users Message-Id: <60303f69-20ca-4592-b058-8b652339dcd3n@googlegroups.com> In-Reply-To: References: Subject: Re: [PATCH] dpgk: Restore support for replacing pre-installed packages in sbuild-chroot MIME-Version: 1.0 Content-Type: multipart/mixed; boundary="----=_Part_85348_1613523017.1702877940659" X-TUID: IpAr2w6PSQBK ------=_Part_85348_1613523017.1702877940659 Content-Type: multipart/alternative; boundary="----=_Part_85349_421799430.1702877940659" ------=_Part_85349_421799430.1702877940659 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable On Sunday, December 17, 2023 at 10:12:16=E2=80=AFPM UTC+5:30 Jan Kiszka wro= te: From: Jan Kiszka =20 During the migration to sbuild, support for using self-built packages in=20 the build environment was lost if those were already part of the=20 sbuild-chroot. This restores it by adding --apt-distupgrade to the=20 sbuild call. But that is not enough because sbuild will only upgrade=20 packages the already configured sources, not those specified via=20 --extra-repository.=20 We therefore switch back to configuring isar-apt during sbuild-chroot=20 creation which is actually slightly simpler than using=20 --extra-repository.=20 As rootfs_configure_isar_apt configures the isar repo under /isar-apt,=20 we bind-mount the one in /home/builder/${PN} to that folder.=20 Another difference is that we now need to run apt-get update explicitly,=20 but only for isar-apt.=20 Signed-off-by: Jan Kiszka =20 ---=20 My original plan was to use linux-libc-dev as test case for this, but we=20 have some todos to make that work in cross-build scenarios (IOW,=20 KERNEL_LIBC_DEV_DEPLOY is broken for cross).=20 Clara, this avoids your workaround for xenomai-images that hard-codes=20 the linux-libc-dev version in order to enforce an upgrade.=20 Srinu, this does not fill an SBUILD_FLAVOR with self-built packages yet,=20 but it should simplify it, obsoleting the need for any extra class. I hope this will not fill my requirements, this would be helpful in=20 case if any package depends on self-built package during package generation via SBUILD, but most of the time am=20 installing local packages directly in the SCHROOT during image generation part.=20 meta/classes/dpkg-base.bbclass | 11 ++---------=20 meta/classes/dpkg.bbclass | 5 +++--=20 meta/classes/sbuild.bbclass | 3 +++=20 meta/recipes-devtools/sbuild-chroot/sbuild-chroot.inc | 2 --=20 4 files changed, 8 insertions(+), 13 deletions(-)=20 diff --git a/meta/classes/dpkg-base.bbclass=20 b/meta/classes/dpkg-base.bbclass=20 index 7b054d3f..5c1f55c4 100644=20 --- a/meta/classes/dpkg-base.bbclass=20 +++ b/meta/classes/dpkg-base.bbclass=20 @@ -19,8 +19,6 @@ DEPENDS:append:riscv64 =3D "${@'=20 crossbuild-essential-riscv64' if d.getVar('ISAR_C=20 DEB_BUILD_PROFILES ?=3D ""=20 DEB_BUILD_OPTIONS ?=3D ""=20 -ISAR_APT_REPO ?=3D "deb [trusted=3Dyes]=20 file:///home/builder/${PN}/isar-apt/${DISTRO}-${DISTRO_ARCH}/apt/${DISTRO}= =20 ${DEBDISTRONAME} main"=20 -=20 python do_adjust_git() {=20 import subprocess=20 @@ -297,11 +295,9 @@ python do_devshell() {=20 bb.build.exec_func('schroot_configure_ccache', d)=20 schroot =3D d.getVar('SBUILD_CHROOT')=20 - isar_apt =3D d.getVar('ISAR_APT_REPO')=20 pkg_arch =3D d.getVar('PACKAGE_ARCH')=20 build_arch =3D d.getVar('BUILD_ARCH')=20 pp_pps =3D os.path.join(d.getVar('PP'), d.getVar('PPS'))=20 - debdistroname =3D d.getVar('DEBDISTRONAME')=20 install_deps =3D ":" if d.getVar('BB_CURRENTTASK') =3D=3D "devshell_nodeps"= else=20 f"mk-build-deps -i \=20 --host-arch {pkg_arch} --build-arch {build_arch} \=20 @@ -310,15 +306,12 @@ python do_devshell() {=20 termcmd =3D "schroot -d / -c {0} -u root -- sh -c ' \=20 cd {1}; \=20 - echo {2} > /etc/apt/sources.list.d/isar_apt.list; \=20 - echo \"Package: *\nPin: release n=3D{3}\nPin-Priority: 1000\" >=20 /etc/apt/preferences.d/isar-apt; \=20 - echo \"APT::Get::allow-downgrades 1;\" > /etc/apt/apt.conf.d/50isar-apt;= =20 \=20 apt-get -y -q update; \=20 - {4}; \=20 + {2}; \=20 export PATH=3D$PATH_PREPEND:$PATH; \=20 $SHELL -i \=20 '"=20 - oe_terminal(termcmd.format(schroot, pp_pps, isar_apt, debdistroname,=20 install_deps), "Isar devshell", d)=20 + oe_terminal(termcmd.format(schroot, pp_pps, install_deps), "Isar=20 devshell", d)=20 bb.build.exec_func('schroot_delete_configs', d)=20 }=20 diff --git a/meta/classes/dpkg.bbclass b/meta/classes/dpkg.bbclass=20 index 1d684e98..0cdb5792 100644=20 --- a/meta/classes/dpkg.bbclass=20 +++ b/meta/classes/dpkg.bbclass=20 @@ -110,16 +110,17 @@ dpkg_runbuild() {=20 DEB_SOURCE_NAME=3D$(dpkg-parsechangelog --show-field Source --file=20 ${WORKDIR}/${PPS}/debian/changelog)=20 DSC_FILE=3D$(find ${WORKDIR} -name "${DEB_SOURCE_NAME}*.dsc" -maxdepth 1=20 -print)=20 - sbuild -A -n -c ${SBUILD_CHROOT} --extra-repository=3D"${ISAR_APT_REPO}" = \=20 + sbuild -A -n -c ${SBUILD_CHROOT} \=20 --host=3D${PACKAGE_ARCH} --build=3D${BUILD_ARCH} ${profiles} \=20 --no-run-lintian --no-run-piuparts --no-run-autopkgtest=20 --resolve-alternatives \=20 --bd-uninstallable-explainer=3Dapt \=20 - --no-apt-update \=20 + --no-apt-update --apt-distupgrade \=20 --chroot-setup-commands=3D"echo \"Package: *\nPin: release=20 n=3D${DEBDISTRONAME}\nPin-Priority: 1000\" > /etc/apt/preferences.d/isar-ap= t"=20 \=20 --chroot-setup-commands=3D"echo \"APT::Get::allow-downgrades 1;\" >=20 /etc/apt/apt.conf.d/50isar-apt" \=20 --chroot-setup-commands=3D"rm -f /var/log/dpkg.log" \=20 --chroot-setup-commands=3D"mkdir -p ${deb_dir}" \=20 --chroot-setup-commands=3D"ln -sf ${ext_deb_dir}/*.deb -t ${deb_dir}/" \=20 + --chroot-setup-commands=3D"apt-get update -o=20 Dir::Etc::SourceList=3D\"sources.list.d/isar-apt.list\" -o=20 Dir::Etc::SourceParts=3D\"-\" -o APT::Get::List-Cleanup=3D\"0\"" \=20 --finished-build-commands=3D"rm -f=20 ${deb_dir}/sbuild-build-depends-main-dummy_*.deb" \=20 --finished-build-commands=3D"[ -z "$(find ${deb_dir} -maxdepth 1 -name=20 '*.deb' -print -quit)" ] || cp ${CP_FLAGS} ${deb_dir}/*.deb -t=20 ${ext_deb_dir}/" \=20 --finished-build-commands=3D"cp /var/log/dpkg.log=20 ${ext_root}/dpkg_partial.log" \=20 diff --git a/meta/classes/sbuild.bbclass b/meta/classes/sbuild.bbclass=20 index 995f7a54..3e9bf38b 100644=20 --- a/meta/classes/sbuild.bbclass=20 +++ b/meta/classes/sbuild.bbclass=20 @@ -49,6 +49,9 @@ EOF=20 fstab_downloads=3D"${DL_DIR} /downloads none rw,bind 0 0"=20 grep -qxF "${fstab_downloads}" ${sbuild_fstab} || echo "${fstab_downloads}"= =20 >> ${sbuild_fstab}=20 fi=20 +=20 + fstab_isarapt=3D"${WORKDIR}/isar-apt/${DISTRO}-${DISTRO_ARCH}/apt/${DISTR= O}=20 /isar-apt none rw,bind 0 0"=20 + grep -qxF "${fstab_isarapt}" ${sbuild_fstab} || echo "${fstab_isarapt}"= =20 >> ${sbuild_fstab}=20 EOSUDO=20 }=20 diff --git a/meta/recipes-devtools/sbuild-chroot/sbuild-chroot.inc=20 b/meta/recipes-devtools/sbuild-chroot/sbuild-chroot.inc=20 index 938b8334..3634ad05 100644=20 --- a/meta/recipes-devtools/sbuild-chroot/sbuild-chroot.inc=20 +++ b/meta/recipes-devtools/sbuild-chroot/sbuild-chroot.inc=20 @@ -56,8 +56,6 @@ SBUILD_CHROOT_DIR =3D "${WORKDIR}/rootfs"=20 ROOTFSDIR =3D "${SBUILD_CHROOT_DIR}"=20 ROOTFS_PACKAGES =3D "${SBUILD_CHROOT_PREINSTALL}"=20 -# We don't need /etc/apt/sources.list.d/isar-apt.list' while it's handled= =20 by sbuild=20 -ROOTFS_CONFIGURE_COMMAND:remove =3D "rootfs_configure_isar_apt"=20 ROOTFS_POSTPROCESS_COMMAND:remove =3D "rootfs_cleanup_isar_apt"=20 DEPLOY_SCHROOT =3D "${@d.getVar('SCHROOT_' +=20 d.getVar('SBUILD_VARIANT').upper() + '_DIR')}${SBUILD_SCHROOT_SUFFIX}"=20 --=20 2.35.3=20 ------=_Part_85349_421799430.1702877940659 Content-Type: text/html; charset=utf-8 Content-Transfer-Encoding: quoted-printable

On Sunday, December 17, 2023 at 10:12:16= =E2=80=AFPM UTC+5:30 Jan Kiszka wrote:
From: Jan Kiszka <jan.k...@siem= ens.com>

During the migration to sbuild, support for using self-built packages= in
the build environment was lost if those were already part of the
sbuild-chroot. This restores it by adding --apt-distupgrade to the
sbuild call. But that is not enough because sbuild will only upgrade
packages the already configured sources, not those specified via
--extra-repository.

We therefore switch back to configuring isar-apt during sbuild-chroot
creation which is actually slightly simpler than using
--extra-repository.

As rootfs_configure_isar_apt configures the isar repo under /isar-apt= ,
we bind-mount the one in /home/builder/${PN} to that folder.

Another difference is that we now need to run apt-get update explicit= ly,
but only for isar-apt.

Signed-off-by: Jan Kiszka <jan.k...@= siemens.com>
---

My original plan was to use linux-libc-dev as test case for this, but= we=20
have some todos to make that work in cross-build scenarios (IOW,
KERNEL_LIBC_DEV_DEPLOY is broken for cross).

Clara, this avoids your workaround for xenomai-images that hard-codes= =20
the linux-libc-dev version in order to enforce an upgrade.

Srinu, this does not fill an SBUILD_FLAVOR with self-built packages y= et,=20
but it should simplify it, obsoleting the need for any extra class.

=C2=A0 =C2=A0 I hope this will not fill my= requirements, this would be helpful in case if any package depends on self= -built package
=C2=A0 =C2=A0 during package generation via SBUILD= , but most of the time am installing local packages directly in the SCHROOT=
=C2=A0 =C2=A0 during image generation part.=C2=A0


meta/classes/dpkg-base.bbclass | 11 ++-------= --
meta/classes/dpkg.bbclass | 5 +++--
meta/classes/sbuild.bbclass | 3 +++
meta/recipes-devtools/sbuild-chroot/sbuild-chroot.inc | 2 --
4 files changed, 8 insertions(+), 13 deletions(-)

diff --git a/meta/classes/dpkg-base.bbclass b/meta/classes/dpkg-base.= bbclass
index 7b054d3f..5c1f55c4 100644
--- a/meta/classes/dpkg-base.bbclass
+++ b/meta/classes/dpkg-base.bbclass
@@ -19,8 +19,6 @@ DEPENDS:append:riscv64 =3D "${@' crossbuild-essenti= al-riscv64' if d.getVar('ISAR_C
DEB_BUILD_PROFILES ?=3D ""
DEB_BUILD_OPTIONS ?=3D ""
=20
-ISAR_APT_REPO ?=3D "deb [trusted=3Dyes] file:///home/builder/${PN}/i= sar-apt/${DISTRO}-${DISTRO_ARCH}/apt/${DISTRO} ${DEBDISTRONAME} main"
-
python do_adjust_git() {
import subprocess
=20
@@ -297,11 +295,9 @@ python do_devshell() {
bb.build.exec_func('schroot_configure_ccache', d)
=20
schroot =3D d.getVar('SBUILD_CHROOT')
- isar_apt =3D d.getVar('ISAR_APT_REPO')
pkg_arch =3D d.getVar('PACKAGE_ARCH')
build_arch =3D d.getVar('BUILD_ARCH')
pp_pps =3D os.path.join(d.getVar('PP'), d.getVar('PPS'))
- debdistroname =3D d.getVar('DEBDISTRONAME')
=20
install_deps =3D ":" if d.getVar('BB_CURRENTTASK') =3D=3D "devsh= ell_nodeps" else f"mk-build-deps -i \
--host-arch {pkg_arch} --build-arch {build_arch} \
@@ -310,15 +306,12 @@ python do_devshell() {
=20
termcmd =3D "schroot -d / -c {0} -u root -- sh -c ' \
cd {1}; \
- echo {2} > /etc/apt/sources.list.d/isar_apt.list; \
- echo \"Package: *\nPin: release n=3D{3}\nPin-Priority: 1000\= " > /etc/apt/preferences.d/isar-apt; \
- echo \"APT::Get::allow-downgrades 1;\" > /etc/apt/apt.con= f.d/50isar-apt; \
apt-get -y -q update; \
- {4}; \
+ {2}; \
export PATH=3D$PATH_PREPEND:$PATH; \
$SHELL -i \
'"
- oe_terminal(termcmd.format(schroot, pp_pps, isar_apt, debdistron= ame, install_deps), "Isar devshell", d)
+ oe_terminal(termcmd.format(schroot, pp_pps, install_deps), "Isar= devshell", d)
=20
bb.build.exec_func('schroot_delete_configs', d)
}
diff --git a/meta/classes/dpkg.bbclass b/meta/classes/dpkg.bbclass
index 1d684e98..0cdb5792 100644
--- a/meta/classes/dpkg.bbclass
+++ b/meta/classes/dpkg.bbclass
@@ -110,16 +110,17 @@ dpkg_runbuild() {
DEB_SOURCE_NAME=3D$(dpkg-parsechangelog --show-field Source --fi= le ${WORKDIR}/${PPS}/debian/changelog)
DSC_FILE=3D$(find ${WORKDIR} -name "${DEB_SOURCE_NAME}*.dsc" -ma= xdepth 1 -print)
=20
- sbuild -A -n -c ${SBUILD_CHROOT} --extra-repository=3D"${ISAR_AP= T_REPO}" \
+ sbuild -A -n -c ${SBUILD_CHROOT} \
--host=3D${PACKAGE_ARCH} --build=3D${BUILD_ARCH} ${profiles}= \
--no-run-lintian --no-run-piuparts --no-run-autopkgtest --re= solve-alternatives \
--bd-uninstallable-explainer=3Dapt \
- --no-apt-update \
+ --no-apt-update --apt-distupgrade \
--chroot-setup-commands=3D"echo \"Package: *\nPin: release n= =3D${DEBDISTRONAME}\nPin-Priority: 1000\" > /etc/apt/preferences.d/isar-= apt" \
--chroot-setup-commands=3D"echo \"APT::Get::allow-downgrades= 1;\" > /etc/apt/apt.conf.d/50isar-apt" \
--chroot-setup-commands=3D"rm -f /var/log/dpkg.log" \
--chroot-setup-commands=3D"mkdir -p ${deb_dir}" \
--chroot-setup-commands=3D"ln -sf ${ext_deb_dir}/*.deb -t ${= deb_dir}/" \
+ --chroot-setup-commands=3D"apt-get update -o Dir::Etc::Sourc= eList=3D\"sources.list.d/isar-apt.list\" -o Dir::Etc::SourceParts=3D\"-\" -= o APT::Get::List-Cleanup=3D\"0\"" \
--finished-build-commands=3D"rm -f ${deb_dir}/sbuild-build-d= epends-main-dummy_*.deb" \
--finished-build-commands=3D"[ -z "$(find ${deb_dir} -maxdep= th 1 -name '*.deb' -print -quit)" ] || cp ${CP_FLAGS} ${deb_dir}/*.deb -t $= {ext_deb_dir}/" \
--finished-build-commands=3D"cp /var/log/dpkg.log ${ext_root= }/dpkg_partial.log" \
diff --git a/meta/classes/sbuild.bbclass b/meta/classes/sbuild.bbclas= s
index 995f7a54..3e9bf38b 100644
--- a/meta/classes/sbuild.bbclass
+++ b/meta/classes/sbuild.bbclass
@@ -49,6 +49,9 @@ EOF
fstab_downloads=3D"${DL_DIR} /downloads none rw,bind 0 0= "
grep -qxF "${fstab_downloads}" ${sbuild_fstab} || echo "= ${fstab_downloads}" >> ${sbuild_fstab}
fi
+
+ fstab_isarapt=3D"${WORKDIR}/isar-apt/${DISTRO}-${DISTRO_ARCH= }/apt/${DISTRO} /isar-apt none rw,bind 0 0"
+ grep -qxF "${fstab_isarapt}" ${sbuild_fstab} || echo "${fsta= b_isarapt}" >> ${sbuild_fstab}
EOSUDO
}
=20
diff --git a/meta/recipes-devtools/sbuild-chroot/sbuild-chroot.inc b/= meta/recipes-devtools/sbuild-chroot/sbuild-chroot.inc
index 938b8334..3634ad05 100644
--- a/meta/recipes-devtools/sbuild-chroot/sbuild-chroot.inc
+++ b/meta/recipes-devtools/sbuild-chroot/sbuild-chroot.inc
@@ -56,8 +56,6 @@ SBUILD_CHROOT_DIR =3D "${WORKDIR}/rootfs"
ROOTFSDIR =3D "${SBUILD_CHROOT_DIR}"
ROOTFS_PACKAGES =3D "${SBUILD_CHROOT_PREINSTALL}"
=20
-# We don't need /etc/apt/sources.list.d/isar-apt.list' while it's ha= ndled by sbuild
-ROOTFS_CONFIGURE_COMMAND:remove =3D "rootfs_configure_isar_apt"
ROOTFS_POSTPROCESS_COMMAND:remove =3D "rootfs_cleanup_isar_apt"
=20
DEPLOY_SCHROOT =3D "${@d.getVar('SCHROOT_' + d.getVar('SBUILD_VARIAN= T').upper() + '_DIR')}${SBUILD_SCHROOT_SUFFIX}"
--=20
2.35.3
------=_Part_85349_421799430.1702877940659-- ------=_Part_85348_1613523017.1702877940659--