From: Jan Kiszka <jan.kiszka@siemens.com>
To: isar-users <isar-users@googlegroups.com>
Subject: [PATCH 1/2] Add basic patch support
Date: Sun, 18 Feb 2018 20:39:19 +0100 [thread overview]
Message-ID: <389542c1-1367-2639-a13c-ebbb9318c05b@siemens.com> (raw)
From: Jan Kiszka <jan.kiszka@siemens.com>
Add a do_patch task after unpack the processes .patch files in the
SRC_URI. We likely miss some special features compared to OE, but this
covers the common case of few individual patches. Application order is
derived from appearance in SRC_URI list. Strip level can be configured
via "striplevel=N" URI parameter. The application is controlled
explicitly via the "apply=yes|no" parameter.
Signed-off-by: Jan Kiszka <jan.kiszka@siemens.com>
---
meta/classes/dpkg-base.bbclass | 5 ++++-
meta/classes/patch.bbclass | 33 +++++++++++++++++++++++++++++++++
2 files changed, 37 insertions(+), 1 deletion(-)
create mode 100644 meta/classes/patch.bbclass
diff --git a/meta/classes/dpkg-base.bbclass b/meta/classes/dpkg-base.bbclass
index 78709f9..0e2d0e2 100644
--- a/meta/classes/dpkg-base.bbclass
+++ b/meta/classes/dpkg-base.bbclass
@@ -8,9 +8,12 @@ do_adjust_git() {
fi
}
-addtask adjust_git after do_unpack before do_build
+addtask adjust_git after do_unpack before do_patch
do_adjust_git[stamp-extra-info] = "${DISTRO}-${DISTRO_ARCH}"
+inherit patch
+addtask patch after do_adjust_git before do_build
+
# Add dependency from buildchroot creation
do_build[depends] = "buildchroot:do_build"
diff --git a/meta/classes/patch.bbclass b/meta/classes/patch.bbclass
new file mode 100644
index 0000000..26a0c81
--- /dev/null
+++ b/meta/classes/patch.bbclass
@@ -0,0 +1,33 @@
+# This software is a part of ISAR.
+# Copyright (c) Siemens AG, 2018
+
+python do_patch() {
+ import subprocess
+
+ workdir = d.getVar("WORKDIR", True) + "/"
+ src_dir = workdir + (d.getVar("S", True) or "")
+
+ for src_uri in (d.getVar("SRC_URI", True) or "").split():
+ try:
+ fetcher = bb.fetch2.Fetch([src_uri], d)
+
+ apply = fetcher.ud[src_uri].parm.get("apply")
+ if apply == "no":
+ continue
+
+ basename = fetcher.ud[src_uri].basename or ""
+ if not (basename.endswith(".patch") or apply == "yes"):
+ continue
+
+ striplevel = fetcher.ud[src_uri].parm.get("striplevel") or "1"
+
+ cmd = "patch --no-backup-if-mismatch -p " + striplevel + \
+ " --directory " + src_dir + " --input " + workdir + basename
+ bb.note(cmd)
+ if subprocess.call(cmd, shell=True) != 0:
+ bb.fatal("patching failed")
+ except bb.fetch2.BBFetchException as e:
+ raise bb.build.FuncFailed(e)
+}
+
+do_patch[stamp-extra-info] = "${DISTRO}-${DISTRO_ARCH}"
--
2.13.6
next reply other threads:[~2018-02-18 19:39 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2018-02-18 19:39 Jan Kiszka [this message]
2018-02-18 19:40 ` [PATCH 2/2] example-app: Add two patches for demonstration and testing purposes Jan Kiszka
2018-02-20 11:12 ` [PATCH 1/2] Add basic patch support Alexander Smirnov
2018-02-21 9:36 ` Jan Kiszka
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=389542c1-1367-2639-a13c-ebbb9318c05b@siemens.com \
--to=jan.kiszka@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