* [PATCH v2] dpkg: Restore support for replacing pre-installed packages in sbuild-chroot
@ 2024-01-02 7:55 Jan Kiszka
2024-01-03 16:44 ` Jan Kiszka
0 siblings, 1 reply; 2+ messages in thread
From: Jan Kiszka @ 2024-01-02 7:55 UTC (permalink / raw)
To: isar-users
From: Jan Kiszka <jan.kiszka@siemens.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 from already configured sources, not those specified via
--extra-repository. We therefore have to switch back to configuring
isar-apt during sbuild-chroot creation.
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 explicitly,
but only for isar-apt.
Signed-off-by: Jan Kiszka <jan.kiszka@siemens.com>
---
Changes in v2:
- fix regressions caused by adding isar-apt to more schroots than
needed
meta/classes/dpkg-base.bbclass | 22 ++++++++++---------
meta/classes/dpkg.bbclass | 5 +++--
.../sbuild-chroot/sbuild-chroot.inc | 2 --
3 files changed, 15 insertions(+), 14 deletions(-)
diff --git a/meta/classes/dpkg-base.bbclass b/meta/classes/dpkg-base.bbclass
index 7b054d3f..6a6964b2 100644
--- a/meta/classes/dpkg-base.bbclass
+++ b/meta/classes/dpkg-base.bbclass
@@ -19,8 +19,6 @@ DEPENDS:append:riscv64 = "${@' crossbuild-essential-riscv64' if d.getVar('ISAR_C
DEB_BUILD_PROFILES ?= ""
DEB_BUILD_OPTIONS ?= ""
-ISAR_APT_REPO ?= "deb [trusted=yes] file:///home/builder/${PN}/isar-apt/${DISTRO}-${DISTRO_ARCH}/apt/${DISTRO} ${DEBDISTRONAME} main"
-
python do_adjust_git() {
import subprocess
@@ -221,8 +219,17 @@ def isar_export_build_settings(d):
os.environ['DEB_BUILD_OPTIONS'] = isar_deb_build_options(d)
os.environ['DEB_BUILD_PROFILES'] = isar_deb_build_profiles(d)
+dpkg_schroot_create_configs() {
+ schroot_create_configs
+ sudo -s <<'EOSUDO'
+ sbuild_fstab="${SBUILD_CONF_DIR}/fstab"
+ fstab_isarapt="${WORKDIR}/isar-apt/${DISTRO}-${DISTRO_ARCH}/apt/${DISTRO} /isar-apt none rw,bind 0 0"
+ grep -qxF "${fstab_isarapt}" ${sbuild_fstab} || echo "${fstab_isarapt}" >> ${sbuild_fstab}
+EOSUDO
+}
+
python do_dpkg_build() {
- bb.build.exec_func('schroot_create_configs', d)
+ bb.build.exec_func('dpkg_schroot_create_configs', d)
try:
bb.build.exec_func("dpkg_runbuild", d)
finally:
@@ -297,11 +304,9 @@ python do_devshell() {
bb.build.exec_func('schroot_configure_ccache', d)
schroot = d.getVar('SBUILD_CHROOT')
- isar_apt = d.getVar('ISAR_APT_REPO')
pkg_arch = d.getVar('PACKAGE_ARCH')
build_arch = d.getVar('BUILD_ARCH')
pp_pps = os.path.join(d.getVar('PP'), d.getVar('PPS'))
- debdistroname = d.getVar('DEBDISTRONAME')
install_deps = ":" if d.getVar('BB_CURRENTTASK') == "devshell_nodeps" else f"mk-build-deps -i \
--host-arch {pkg_arch} --build-arch {build_arch} \
@@ -310,15 +315,12 @@ python do_devshell() {
termcmd = "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={3}\nPin-Priority: 1000\" > /etc/apt/preferences.d/isar-apt; \
- echo \"APT::Get::allow-downgrades 1;\" > /etc/apt/apt.conf.d/50isar-apt; \
apt-get -y -q update; \
- {4}; \
+ {2}; \
export PATH=$PATH_PREPEND:$PATH; \
$SHELL -i \
'"
- oe_terminal(termcmd.format(schroot, pp_pps, isar_apt, debdistroname, install_deps), "Isar devshell", d)
+ oe_terminal(termcmd.format(schroot, pp_pps, install_deps), "Isar devshell", d)
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=$(dpkg-parsechangelog --show-field Source --file ${WORKDIR}/${PPS}/debian/changelog)
DSC_FILE=$(find ${WORKDIR} -name "${DEB_SOURCE_NAME}*.dsc" -maxdepth 1 -print)
- sbuild -A -n -c ${SBUILD_CHROOT} --extra-repository="${ISAR_APT_REPO}" \
+ sbuild -A -n -c ${SBUILD_CHROOT} \
--host=${PACKAGE_ARCH} --build=${BUILD_ARCH} ${profiles} \
--no-run-lintian --no-run-piuparts --no-run-autopkgtest --resolve-alternatives \
--bd-uninstallable-explainer=apt \
- --no-apt-update \
+ --no-apt-update --apt-distupgrade \
--chroot-setup-commands="echo \"Package: *\nPin: release n=${DEBDISTRONAME}\nPin-Priority: 1000\" > /etc/apt/preferences.d/isar-apt" \
--chroot-setup-commands="echo \"APT::Get::allow-downgrades 1;\" > /etc/apt/apt.conf.d/50isar-apt" \
--chroot-setup-commands="rm -f /var/log/dpkg.log" \
--chroot-setup-commands="mkdir -p ${deb_dir}" \
--chroot-setup-commands="ln -sf ${ext_deb_dir}/*.deb -t ${deb_dir}/" \
+ --chroot-setup-commands="apt-get update -o Dir::Etc::SourceList=\"sources.list.d/isar-apt.list\" -o Dir::Etc::SourceParts=\"-\" -o APT::Get::List-Cleanup=\"0\"" \
--finished-build-commands="rm -f ${deb_dir}/sbuild-build-depends-main-dummy_*.deb" \
--finished-build-commands="[ -z "$(find ${deb_dir} -maxdepth 1 -name '*.deb' -print -quit)" ] || cp ${CP_FLAGS} ${deb_dir}/*.deb -t ${ext_deb_dir}/" \
--finished-build-commands="cp /var/log/dpkg.log ${ext_root}/dpkg_partial.log" \
diff --git a/meta/recipes-devtools/sbuild-chroot/sbuild-chroot.inc b/meta/recipes-devtools/sbuild-chroot/sbuild-chroot.inc
index 39ced80b..2f07de82 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 = "${WORKDIR}/rootfs"
ROOTFSDIR = "${SBUILD_CHROOT_DIR}"
ROOTFS_PACKAGES = "${SBUILD_CHROOT_PREINSTALL}"
-# We don't need /etc/apt/sources.list.d/isar-apt.list' while it's handled by sbuild
-ROOTFS_CONFIGURE_COMMAND:remove = "rootfs_configure_isar_apt"
ROOTFS_POSTPROCESS_COMMAND:remove = "rootfs_cleanup_isar_apt"
# Do not cleanup base-apt
--
2.35.3
^ permalink raw reply [flat|nested] 2+ messages in thread
* Re: [PATCH v2] dpkg: Restore support for replacing pre-installed packages in sbuild-chroot
2024-01-02 7:55 [PATCH v2] dpkg: Restore support for replacing pre-installed packages in sbuild-chroot Jan Kiszka
@ 2024-01-03 16:44 ` Jan Kiszka
0 siblings, 0 replies; 2+ messages in thread
From: Jan Kiszka @ 2024-01-03 16:44 UTC (permalink / raw)
To: isar-users; +Cc: Srinuvasan Arjunan
On 02.01.24 08:55, 'Jan Kiszka' via isar-users wrote:
> From: Jan Kiszka <jan.kiszka@siemens.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
This patch does more than I originally expected: It is currently not
even possible to pull additional packages into an sbuild-chroot from
isar-apt. As that feature is a precondition for replacing packages, it
comes implicitly with these changes - widely obsoleting the approach
Srinu was taking in
https://groups.google.com/g/isar-users/c/TAtC1wA68mA/m/lI-ci5LrAgAJ.
Jan
> sbuild call. But that is not enough because sbuild will only upgrade
> packages from already configured sources, not those specified via
> --extra-repository. We therefore have to switch back to configuring
> isar-apt during sbuild-chroot creation.
>
> 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 explicitly,
> but only for isar-apt.
>
> Signed-off-by: Jan Kiszka <jan.kiszka@siemens.com>
> ---
>
> Changes in v2:
> - fix regressions caused by adding isar-apt to more schroots than
> needed
>
> meta/classes/dpkg-base.bbclass | 22 ++++++++++---------
> meta/classes/dpkg.bbclass | 5 +++--
> .../sbuild-chroot/sbuild-chroot.inc | 2 --
> 3 files changed, 15 insertions(+), 14 deletions(-)
>
> diff --git a/meta/classes/dpkg-base.bbclass b/meta/classes/dpkg-base.bbclass
> index 7b054d3f..6a6964b2 100644
> --- a/meta/classes/dpkg-base.bbclass
> +++ b/meta/classes/dpkg-base.bbclass
> @@ -19,8 +19,6 @@ DEPENDS:append:riscv64 = "${@' crossbuild-essential-riscv64' if d.getVar('ISAR_C
> DEB_BUILD_PROFILES ?= ""
> DEB_BUILD_OPTIONS ?= ""
>
> -ISAR_APT_REPO ?= "deb [trusted=yes] file:///home/builder/${PN}/isar-apt/${DISTRO}-${DISTRO_ARCH}/apt/${DISTRO} ${DEBDISTRONAME} main"
> -
> python do_adjust_git() {
> import subprocess
>
> @@ -221,8 +219,17 @@ def isar_export_build_settings(d):
> os.environ['DEB_BUILD_OPTIONS'] = isar_deb_build_options(d)
> os.environ['DEB_BUILD_PROFILES'] = isar_deb_build_profiles(d)
>
> +dpkg_schroot_create_configs() {
> + schroot_create_configs
> + sudo -s <<'EOSUDO'
> + sbuild_fstab="${SBUILD_CONF_DIR}/fstab"
> + fstab_isarapt="${WORKDIR}/isar-apt/${DISTRO}-${DISTRO_ARCH}/apt/${DISTRO} /isar-apt none rw,bind 0 0"
> + grep -qxF "${fstab_isarapt}" ${sbuild_fstab} || echo "${fstab_isarapt}" >> ${sbuild_fstab}
> +EOSUDO
> +}
> +
> python do_dpkg_build() {
> - bb.build.exec_func('schroot_create_configs', d)
> + bb.build.exec_func('dpkg_schroot_create_configs', d)
> try:
> bb.build.exec_func("dpkg_runbuild", d)
> finally:
> @@ -297,11 +304,9 @@ python do_devshell() {
> bb.build.exec_func('schroot_configure_ccache', d)
>
> schroot = d.getVar('SBUILD_CHROOT')
> - isar_apt = d.getVar('ISAR_APT_REPO')
> pkg_arch = d.getVar('PACKAGE_ARCH')
> build_arch = d.getVar('BUILD_ARCH')
> pp_pps = os.path.join(d.getVar('PP'), d.getVar('PPS'))
> - debdistroname = d.getVar('DEBDISTRONAME')
>
> install_deps = ":" if d.getVar('BB_CURRENTTASK') == "devshell_nodeps" else f"mk-build-deps -i \
> --host-arch {pkg_arch} --build-arch {build_arch} \
> @@ -310,15 +315,12 @@ python do_devshell() {
>
> termcmd = "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={3}\nPin-Priority: 1000\" > /etc/apt/preferences.d/isar-apt; \
> - echo \"APT::Get::allow-downgrades 1;\" > /etc/apt/apt.conf.d/50isar-apt; \
> apt-get -y -q update; \
> - {4}; \
> + {2}; \
> export PATH=$PATH_PREPEND:$PATH; \
> $SHELL -i \
> '"
> - oe_terminal(termcmd.format(schroot, pp_pps, isar_apt, debdistroname, install_deps), "Isar devshell", d)
> + oe_terminal(termcmd.format(schroot, pp_pps, install_deps), "Isar devshell", d)
>
> 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=$(dpkg-parsechangelog --show-field Source --file ${WORKDIR}/${PPS}/debian/changelog)
> DSC_FILE=$(find ${WORKDIR} -name "${DEB_SOURCE_NAME}*.dsc" -maxdepth 1 -print)
>
> - sbuild -A -n -c ${SBUILD_CHROOT} --extra-repository="${ISAR_APT_REPO}" \
> + sbuild -A -n -c ${SBUILD_CHROOT} \
> --host=${PACKAGE_ARCH} --build=${BUILD_ARCH} ${profiles} \
> --no-run-lintian --no-run-piuparts --no-run-autopkgtest --resolve-alternatives \
> --bd-uninstallable-explainer=apt \
> - --no-apt-update \
> + --no-apt-update --apt-distupgrade \
> --chroot-setup-commands="echo \"Package: *\nPin: release n=${DEBDISTRONAME}\nPin-Priority: 1000\" > /etc/apt/preferences.d/isar-apt" \
> --chroot-setup-commands="echo \"APT::Get::allow-downgrades 1;\" > /etc/apt/apt.conf.d/50isar-apt" \
> --chroot-setup-commands="rm -f /var/log/dpkg.log" \
> --chroot-setup-commands="mkdir -p ${deb_dir}" \
> --chroot-setup-commands="ln -sf ${ext_deb_dir}/*.deb -t ${deb_dir}/" \
> + --chroot-setup-commands="apt-get update -o Dir::Etc::SourceList=\"sources.list.d/isar-apt.list\" -o Dir::Etc::SourceParts=\"-\" -o APT::Get::List-Cleanup=\"0\"" \
> --finished-build-commands="rm -f ${deb_dir}/sbuild-build-depends-main-dummy_*.deb" \
> --finished-build-commands="[ -z "$(find ${deb_dir} -maxdepth 1 -name '*.deb' -print -quit)" ] || cp ${CP_FLAGS} ${deb_dir}/*.deb -t ${ext_deb_dir}/" \
> --finished-build-commands="cp /var/log/dpkg.log ${ext_root}/dpkg_partial.log" \
> diff --git a/meta/recipes-devtools/sbuild-chroot/sbuild-chroot.inc b/meta/recipes-devtools/sbuild-chroot/sbuild-chroot.inc
> index 39ced80b..2f07de82 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 = "${WORKDIR}/rootfs"
> ROOTFSDIR = "${SBUILD_CHROOT_DIR}"
> ROOTFS_PACKAGES = "${SBUILD_CHROOT_PREINSTALL}"
>
> -# We don't need /etc/apt/sources.list.d/isar-apt.list' while it's handled by sbuild
> -ROOTFS_CONFIGURE_COMMAND:remove = "rootfs_configure_isar_apt"
> ROOTFS_POSTPROCESS_COMMAND:remove = "rootfs_cleanup_isar_apt"
>
> # Do not cleanup base-apt
--
Siemens AG, Technology
Linux Expert Center
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2024-01-03 16:45 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2024-01-02 7:55 [PATCH v2] dpkg: Restore support for replacing pre-installed packages in sbuild-chroot Jan Kiszka
2024-01-03 16:44 ` Jan Kiszka
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox