[v2,4/7] dpkg-base: refactor dependencies of apt_* tasks

Message ID 20220509101604.3249558-5-adriaan.schmidt@siemens.com
State Accepted, archived
Headers show
Series Sstate maintenance script | expand

Commit Message

Schmidt, Adriaan May 9, 2022, 2:16 a.m. UTC
Only recipes with `apt://` sources in their SRC_URI run the three tasks
`apt_fetch`, `apt_unpack`, and `cleanall_apt`. The current implementation
creates the tasks (and dependencies) for all recipes and sets them to
`noexec` if they are not needed.

It turns out that bitbake doesn't generate sstate signatures for `noexec`
tasks, but carries them as dependencies to other tasks, which can break
analysis with sstate-diffsigs. Also, I suspect that `noexec` may not have
been designed as "optional", to be added in this way (OE never does this).

The new implementation only adds the three tasks when they are required.
It also:
- removes the dependency of `apt_fetch after do_unpack`
- makes `install_builddeps` depend explicitly on `${BUILDCHROOT_DEP}`,
  a dependency which was previously only given via the `apt_fetch` task.

Signed-off-by: Adriaan Schmidt <adriaan.schmidt@siemens.com>
---
 meta/classes/dpkg-base.bbclass | 14 ++++++--------
 meta/classes/dpkg.bbclass      |  2 +-
 2 files changed, 7 insertions(+), 9 deletions(-)

Patch

diff --git a/meta/classes/dpkg-base.bbclass b/meta/classes/dpkg-base.bbclass
index 86933c57..fe6d46dd 100644
--- a/meta/classes/dpkg-base.bbclass
+++ b/meta/classes/dpkg-base.bbclass
@@ -95,10 +95,9 @@  python() {
     d.setVar('SRC_URI', ' '.join(new_src_uri))
     d.prependVar('SRC_APT', ' '.join(src_apt))
 
-    if d.getVar('SRC_APT').strip() == '':
-        d.setVarFlag('do_apt_fetch', 'noexec', '1')
-        d.setVarFlag('do_apt_unpack', 'noexec', '1')
-        d.setVarFlag('do_cleanall_apt', 'noexec', '1')
+    if len(d.getVar('SRC_APT').strip()) > 0:
+        bb.build.addtask('apt_unpack', 'do_patch', '', d)
+        bb.build.addtask('cleanall_apt', 'do_cleanall', '', d)
 }
 
 do_apt_fetch() {
@@ -117,11 +116,11 @@  do_apt_fetch() {
     dpkg_undo_mounts
 }
 
-addtask apt_fetch after do_unpack before do_apt_unpack
+addtask apt_fetch
 do_apt_fetch[lockfiles] += "${REPO_ISAR_DIR}/isar.lock"
 
 # Add dependency from the correct buildchroot: host or target
-do_apt_fetch[depends] = "${BUILDCHROOT_DEP}"
+do_apt_fetch[depends] += "${BUILDCHROOT_DEP}"
 
 do_apt_unpack() {
     rm -rf ${S}
@@ -142,9 +141,8 @@  do_apt_unpack() {
     dpkg_undo_mounts
 }
 
-addtask apt_unpack after do_apt_fetch before do_patch
+addtask apt_unpack after do_apt_fetch
 
-addtask cleanall_apt before do_cleanall
 do_cleanall_apt[nostamp] = "1"
 do_cleanall_apt() {
     for uri in "${SRC_APT}"; do
diff --git a/meta/classes/dpkg.bbclass b/meta/classes/dpkg.bbclass
index 320102ba..af833536 100644
--- a/meta/classes/dpkg.bbclass
+++ b/meta/classes/dpkg.bbclass
@@ -26,7 +26,7 @@  do_install_builddeps() {
 }
 
 addtask install_builddeps after do_prepare_build before do_dpkg_build
-do_install_builddeps[depends] += "isar-apt:do_cache_config"
+do_install_builddeps[depends] += "${BUILDCHROOT_DEP} isar-apt:do_cache_config"
 # apt and reprepro may not run in parallel, acquire the Isar lock
 do_install_builddeps[lockfiles] += "${REPO_ISAR_DIR}/isar.lock"