public inbox for isar-users@googlegroups.com
 help / color / mirror / Atom feed
From: Jan Kiszka <jan.kiszka@siemens.com>
To: isar-users <isar-users@googlegroups.com>
Cc: Felix Moessbauer <felix.moessbauer@siemens.com>,
	stefan-koch@siemens.com,
	Adriaan Schmidt <adriaan.schmidt@siemens.com>,
	Anton Mikanovich <amikan@ilbers.de>
Subject: [PATCH v2 5/5] dpkg-source: Build source package only once
Date: Wed, 15 May 2024 13:08:19 +0200	[thread overview]
Message-ID: <eea267eef54fb9a0797ce9ce1497b3bb0c97808a.1715771298.git.jan.kiszka@siemens.com> (raw)
In-Reply-To: <cover.1715771298.git.jan.kiszka@siemens.com>

From: Jan Kiszka <jan.kiszka@siemens.com>

Avoid building the source package multiple times, possibly even
inconsistently. This is achieved by delegating this task to to the base
package and installing the source package from isar-apt in the native
and compat package variants.

Signed-off-by: Jan Kiszka <jan.kiszka@siemens.com>
---
 meta/classes/dpkg-source.bbclass | 44 ++++++++++++++++++++++++++++++--
 1 file changed, 42 insertions(+), 2 deletions(-)

diff --git a/meta/classes/dpkg-source.bbclass b/meta/classes/dpkg-source.bbclass
index 560f536b..6a36081b 100644
--- a/meta/classes/dpkg-source.bbclass
+++ b/meta/classes/dpkg-source.bbclass
@@ -18,7 +18,7 @@ do_dpkg_source() {
     find ${WORKDIR} -maxdepth 1 -name "${DEBIAN_SOURCE}_*.dsc" -delete
     sh -c "cd ${WORKDIR}; dpkg-source ${DPKG_SOURCE_EXTRA_ARGS} -b ${PPS}"
 }
-addtask dpkg_source after do_prepare_build before do_dpkg_build
+addtask dpkg_source after do_prepare_build
 
 do_deploy_source[depends] += "isar-apt:do_cache_config"
 do_deploy_source[lockfiles] = "${REPO_ISAR_DIR}/isar.lock"
@@ -34,4 +34,44 @@ do_deploy_source() {
             "${DSC_FILE}"
     fi
 }
-addtask deploy_source after do_dpkg_source before do_dpkg_build
+addtask deploy_source after do_dpkg_source
+
+do_dpkg_build[depends] += "${BPN}:do_deploy_source"
+
+SCHROOT_MOUNTS = "${WORKDIR}:/work ${REPO_ISAR_DIR}/${DISTRO}:/isar-apt"
+
+do_fetch_common_source[depends] += "${SCHROOT_DEP} ${BPN}:do_deploy_source"
+do_fetch_common_source[network] = "${TASK_USE_SUDO}"
+do_fetch_common_source() {
+    schroot_create_configs
+    insert_mounts
+
+    session_id=$(schroot -q -b -c ${SBUILD_CHROOT})
+    echo "Started session: ${session_id}"
+
+    schroot_cleanup() {
+        schroot -q -f -e -c ${session_id} > /dev/null 2>&1
+        remove_mounts > /dev/null 2>&1
+        schroot_delete_configs
+    }
+    trap 'exit 1' INT HUP QUIT TERM ALRM USR1
+    trap 'schroot_cleanup' EXIT
+
+    schroot -r -c ${session_id} -d / -u root -- \
+        apt-get update -o Dir::Etc::SourceList="sources.list.d/isar-apt.list" -o Dir::Etc::SourceParts="-" -o APT::Get::List-Cleanup="0"
+    schroot -r -c ${session_id} -d / -- \
+        sh -c '
+            cd /work
+            apt-get -y --download-only --only-source -o Acquire::Source-Symlinks="false" source ${DEBIAN_SOURCE}'
+
+    schroot -e -c ${session_id}
+    remove_mounts
+    schroot_delete_configs
+}
+addtask fetch_common_source after do_unpack
+
+def is_native_or_compat(d):
+    overrides = d.getVar('OVERRIDES').split(':')
+    return 'class-native' in overrides or 'class-compat' in overrides
+
+do_dpkg_build[depends] += "${@'${PN}:do_fetch_common_source' if is_native_or_compat(d) else ''}"
-- 
2.35.3


  parent reply	other threads:[~2024-05-15 11:08 UTC|newest]

Thread overview: 13+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-05-15 11:08 [PATCH v2 0/5] More kbuild improvements, single-build source packages, cross profile fix Jan Kiszka
2024-05-15 11:08 ` [PATCH v2 1/5] dpkg-base: Fix enabling of cross build profile Jan Kiszka
2024-05-16  6:06   ` Schmidt, Adriaan
2024-05-16  6:15     ` Jan Kiszka
2024-05-15 11:08 ` [PATCH v2 2/5] linux-custom: Model cross-built kbuild package separately Jan Kiszka
2024-05-15 11:08 ` [PATCH v2 3/5] linux-custom: Resolve native source package differences Jan Kiszka
2024-05-15 11:08 ` [PATCH v2 4/5] dpkg: Retrieve Debian source name from variable Jan Kiszka
2024-05-15 11:08 ` Jan Kiszka [this message]
2024-05-17 12:21   ` [PATCH v2 5/5] dpkg-source: Build source package only once Jan Kiszka
2024-05-15 13:47 ` [PATCH v2 0/5] More kbuild improvements, single-build source packages, cross profile fix Koch, Stefan
2024-05-15 17:40   ` Jan Kiszka
2024-05-16 16:37     ` Jan Kiszka
2024-05-17  9:03       ` Koch, Stefan

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=eea267eef54fb9a0797ce9ce1497b3bb0c97808a.1715771298.git.jan.kiszka@siemens.com \
    --to=jan.kiszka@siemens.com \
    --cc=adriaan.schmidt@siemens.com \
    --cc=amikan@ilbers.de \
    --cc=felix.moessbauer@siemens.com \
    --cc=isar-users@googlegroups.com \
    --cc=stefan-koch@siemens.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox