All of lore.kernel.org
 help / color / mirror / Atom feed
From: Bartosz Golaszewski <brgl@bgdev.pl>
To: Khem Raj <raj.khem@gmail.com>,
	Armin Kuster <akuster808@gmail.com>,
	openembedded-devel@lists.openembedded.org
Cc: Bartosz Golaszewski <bgolaszewski@baylibre.com>
Subject: [meta-ota][PATCH] meta-ota: add support for binary-delta images in a new layer
Date: Fri, 28 Feb 2020 16:03:45 +0100	[thread overview]
Message-ID: <20200228150345.11829-1-brgl@bgdev.pl> (raw)

From: Bartosz Golaszewski <bgolaszewski@baylibre.com>

Over-The-Air updates are a crucial part of IoT systems based on linux.
There are several OTA update frameworks available and many offer some
sort of support in yocto (e.g. meta-mender, meta-rauc). There are certain
operations that are common to all of them such as: generating binary
delta patches, system recovery, creating provisioning images etc.

This patch proposes to add a new layer in meta-openembedded dedicated to
OTA. As the first functionality it adds a bbclass for generating binary
delta images using two popular algorithms - vcdiff and rsync.

Such images can then be easily packaged in update artifacts for different
OTA frameworks.

Signed-off-by: Bartosz Golaszewski <bgolaszewski@baylibre.com>
---
Hi,

I've noticed that when launching CE products and implementing OTA support
I find myself implementing the same functionalities over again. I recently
started abstracting them and would like to upstream them in meta-openembedded
so that at least a part of that becomes standardized.

This patch proposes to add a new layer to meta-openembedded and I'll gladly
maintain it. If accepted I intend on extending it with more functionalities
such as creating provisioning (factory) images for updatable systems, recovery
system images etc.

 meta-ota/README                       | 27 +++++++++++
 meta-ota/classes/binary-delta.bbclass | 64 +++++++++++++++++++++++++++
 meta-ota/conf/layer.conf              | 17 +++++++
 3 files changed, 108 insertions(+)
 create mode 100644 meta-ota/README
 create mode 100644 meta-ota/classes/binary-delta.bbclass
 create mode 100644 meta-ota/conf/layer.conf

diff --git a/meta-ota/README b/meta-ota/README
new file mode 100644
index 000000000..07a1debdd
--- /dev/null
+++ b/meta-ota/README
@@ -0,0 +1,27 @@
+meta-ota
+========
+
+This layer provides support for creating Over-The-Air update images.
+
+Dependencies
+------------
+
+This layer depends on:
+
+URI: git://github.com/openembedded/oe-core.git
+subdirectory: meta
+branch: master
+revision: HEAD
+
+URI: git://github.com/openembedded/meta-oe.git
+subdirectory: meta-oe
+branch: master
+revision: HEAD
+
+Maintenance
+-----------
+
+Send patches / pull requests to openembedded-devel@lists.openembedded.org
+with '[meta-ota]' in the subject.
+
+Layer maintainer: Bartosz Golaszewski <bgolaszewski@baylibre.com>
diff --git a/meta-ota/classes/binary-delta.bbclass b/meta-ota/classes/binary-delta.bbclass
new file mode 100644
index 000000000..24fb20b1b
--- /dev/null
+++ b/meta-ota/classes/binary-delta.bbclass
@@ -0,0 +1,64 @@
+# SPDX-License-Identifier: MIT
+#
+# Copyright (C) 2020 BayLibre SAS
+# Author: Bartosz Golaszewski <bgolaszewski@baylibre.com>
+#
+# This class provides image conversions which - given a baseline partition
+# image - can generate a binary delta patch. Such patch can be applied on top
+# of a deployed baseline partition to generate an updated image.
+#
+# For now the supported algorithms are rsync and vcdiff (supplied by rdiff and
+# xdelta3 respectively). We also provide several compression methods.
+#
+# We only support binary delta on ext[2-4] and btrfs images as it doesn't make
+# much sense on high-entropy, compressed filesystems.
+
+BINARY_DELTA_BASELINE ?= ""
+
+verify_baseline() {
+    if [ -z ${BINARY_DELTA_BASELINE} ] ; then
+        bbfatal "variable BINARY_DELTA_BASELINE cannot be empty."
+    fi
+
+    if ! [ -f ${BINARY_DELTA_BASELINE} ] ; then
+        bbfatal "${BINARY_DELTA_BASELINE} doesn't exist"
+    fi
+}
+
+gen_rdiff() {
+    local IMAGE=$1
+    local SIGNATURE=$1.sig
+    local PATCH=$1.rdiff
+
+    verify_baseline
+
+    rdiff signature ${BINARY_DELTA_BASELINE} $SIGNATURE
+    rdiff delta $SIGNATURE $IMAGE $PATCH
+    rm $SIGNATURE
+}
+
+gen_vcdiff() {
+    local IMAGE=$1
+    local PATCH=$1.vcdiff
+
+    verify_baseline
+
+    xdelta3 -e -s ${BINARY_DELTA_BASELINE} $IMAGE $PATCH
+}
+
+IMAGE_TYPES += " \
+    ext2.rdiff ext3.rdiff ext4.rdiff btrfs.rdiff \
+    ext2.rdiff.gz ext3.rdiff.gz ext4.rdiff.gz btrfs.rdiff.gz \
+    ext2.rdiff.bz2 ext3.rdiff.bz2 ext4.rdiff.bz2 btrfs.rdiff.bz2 \
+    ext2.rdiff.xz ext3.rdiff.xz ext4.rdiff.xz btrfs.rdiff.xz \
+    ext2.vcdiff ext3.vcdiff ext4.vcdiff brtfs.vcdiff \
+    ext2.vcdiff.gz ext3.vcdiff.gz ext4.vcdiff.gz brtfs.vcdiff.gz \
+    ext2.vcdiff.bz2 ext3.vcdiff.bz2 ext4.vcdiff.bz2 brtfs.vcdiff.bz2 \
+    ext2.vcdiff.xz ext3.vcdiff.xz ext4.vcdiff.xz brtfs.vcdiff.xz \
+"
+
+CONVERSIONTYPES += "rdiff vcdiff"
+CONVERSION_CMD_rdiff = "gen_rdiff ${IMAGE_NAME}${IMAGE_NAME_SUFFIX}.${type}"
+CONVERSION_CMD_vcdiff = "gen_vcdiff ${IMAGE_NAME}${IMAGE_NAME_SUFFIX}.${type}"
+CONVERSION_DEPENDS_rdiff = "librsync-native"
+CONVERSION_DEPENDS_vcdiff = "xdelta3-native"
diff --git a/meta-ota/conf/layer.conf b/meta-ota/conf/layer.conf
new file mode 100644
index 000000000..05c6b0f96
--- /dev/null
+++ b/meta-ota/conf/layer.conf
@@ -0,0 +1,17 @@
+# Layer configuration for meta-ota layer
+# Copyright (C) 2020 BayLibre SAS
+
+# We have a conf and classes directory, add to BBPATH
+BBPATH .= ":${LAYERDIR}"
+
+BBFILE_COLLECTIONS += "ota"
+BBFILE_PATTERN_ota := "^${LAYERDIR}/"
+BBFILE_PRIORITY_ota = "6"
+
+# This should only be incremented on significant changes that will
+# cause compatibility issues with other layers
+LAYERVERSION_ota = "1"
+
+LAYERDEPENDS_ota = "core openembedded-layer"
+
+LAYERSERIES_COMPAT_ota = "zeus"
-- 
2.19.1



             reply	other threads:[~2020-02-28 15:04 UTC|newest]

Thread overview: 14+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-02-28 15:03 Bartosz Golaszewski [this message]
2020-03-01 13:43 ` [meta-ota][PATCH] meta-ota: add support for binary-delta images in a new layer Otavio Salvador
2020-03-02  7:37   ` Bartosz Golaszewski
2020-03-02 11:25     ` Otavio Salvador
2020-03-02 17:39       ` Bartosz Golaszewski
2020-03-02 17:48         ` Otavio Salvador
2020-03-02 18:25         ` Khem Raj
2020-03-03 13:56           ` Bartosz Golaszewski
2020-03-11  8:04             ` Bartosz Golaszewski
2020-03-11 13:28               ` Nicolas Dechesne
2020-03-11 23:03                 ` Otavio Salvador
2020-03-12 17:51                 ` Bartosz Golaszewski
2020-03-12 18:12                   ` Khem Raj
2020-03-13 15:05                     ` Bartosz Golaszewski

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=20200228150345.11829-1-brgl@bgdev.pl \
    --to=brgl@bgdev.pl \
    --cc=akuster808@gmail.com \
    --cc=bgolaszewski@baylibre.com \
    --cc=openembedded-devel@lists.openembedded.org \
    --cc=raj.khem@gmail.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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.