public inbox for isar-users@googlegroups.com
 help / color / mirror / Atom feed
From: Adriaan Schmidt <adriaan.schmidt@siemens.com>
To: isar-users@googlegroups.com
Cc: Adriaan Schmidt <adriaan.schmidt@siemens.com>
Subject: [PATCH] meta: add dpkg-prebuilt.bbclass
Date: Tue, 21 Sep 2021 09:53:00 +0200	[thread overview]
Message-ID: <20210921075300.25327-1-adriaan.schmidt@siemens.com> (raw)

This puts the existing example pattern to inject prebuilt deb packages
(prebuilt-deb recipe) into a class, and adds two new features:
  * `unpack=false` is added automatically.
  * dpkg_build is removed using `deltask` instead of replacing with nop.
    This way also other dependent tasks (patch, prepare_build, ...) are skipped.

The existing example recipe is changed to use the new class.

Signed-off-by: Adriaan Schmidt <adriaan.schmidt@siemens.com>
---
 .../prebuilt-deb/prebuilt-deb_0.1.bb          |  9 ++-------
 meta/classes/dpkg-prebuilt.bbclass            | 20 +++++++++++++++++++
 2 files changed, 22 insertions(+), 7 deletions(-)
 create mode 100644 meta/classes/dpkg-prebuilt.bbclass

diff --git a/meta-isar/recipes-app/prebuilt-deb/prebuilt-deb_0.1.bb b/meta-isar/recipes-app/prebuilt-deb/prebuilt-deb_0.1.bb
index 2f1b699..35a0da3 100644
--- a/meta-isar/recipes-app/prebuilt-deb/prebuilt-deb_0.1.bb
+++ b/meta-isar/recipes-app/prebuilt-deb/prebuilt-deb_0.1.bb
@@ -3,18 +3,13 @@
 #
 # SPDX-License-Identifier: MIT
 
-inherit dpkg-base
+inherit dpkg-prebuilt
 
 # NOTE: The deb packages should almost never be stored in the repo itself but
 #       rather fetched from a binary-serving location. For this example, local
 #       storage was just simpler to maintain across all archs and distros.
-#
-# 2nd NOTE: "unpack=false" is important, bitbake unpacks deb files otherwise
-SRC_URI = "file://example-prebuilt_1.0.0-0_all.deb;unpack=false"
+SRC_URI = "file://example-prebuilt_1.0.0-0_all.deb"
 
 # Only needed if recipe name != package name, as in this case. Or multiple
 # packages are provided by a single recipe.
 PROVIDES += "example-prebuilt"
-
-do_dpkg_build() {
-}
diff --git a/meta/classes/dpkg-prebuilt.bbclass b/meta/classes/dpkg-prebuilt.bbclass
new file mode 100644
index 0000000..c32224b
--- /dev/null
+++ b/meta/classes/dpkg-prebuilt.bbclass
@@ -0,0 +1,20 @@
+# This software is a part of ISAR.
+# Copyright (C) 2021 Siemens AG
+#
+# SPDX-License-Identifier: MIT
+
+inherit dpkg-base
+
+python do_unpack_prepend() {
+    # enforce unpack=false
+    src_uri = (d.getVar('SRC_URI', True) or '').split()
+    if len(src_uri) == 0:
+        return
+    def ensure_unpack_false(uri):
+        return ';'.join([x for x in uri.split(';') if not x.startswith('unpack=')] + ['unpack=false'])
+    src_uri = [ensure_unpack_false(uri) for uri in src_uri]
+    d.setVar('SRC_URI', ' '.join(src_uri))
+}
+
+deltask dpkg_build
+addtask unpack before do_deploy_deb
-- 
2.20.1


             reply	other threads:[~2021-09-21  7:53 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-09-21  7:53 Adriaan Schmidt [this message]
2021-09-22  7:54 ` Henning Schild
2021-10-01 12:25   ` Schmidt, Adriaan
2021-10-04 11:07     ` Henning Schild
2021-10-15 15:42 ` Anton Mikanovich

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=20210921075300.25327-1-adriaan.schmidt@siemens.com \
    --to=adriaan.schmidt@siemens.com \
    --cc=isar-users@googlegroups.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