From 5571d5c7a37e043ac60eeb3ec559b99fd2ae905a Mon Sep 17 00:00:00 2001 From: Jue Date: Fri, 11 Mar 2022 11:24:43 +0100 Subject: [PATCH] pkg/tinyvcdiff: add package --- CODEOWNERS | 1 + pkg/Kconfig | 1 + pkg/tinyvcdiff/Kconfig | 22 +++++++++++++ pkg/tinyvcdiff/Makefile | 9 +++++ pkg/tinyvcdiff/Makefile.include | 10 ++++++ pkg/tinyvcdiff/doc.txt | 58 +++++++++++++++++++++++++++++++++ pkg/tinyvcdiff/tinyvcdiff.mk | 3 ++ 7 files changed, 104 insertions(+) create mode 100644 pkg/tinyvcdiff/Kconfig create mode 100644 pkg/tinyvcdiff/Makefile create mode 100644 pkg/tinyvcdiff/Makefile.include create mode 100644 pkg/tinyvcdiff/doc.txt create mode 100644 pkg/tinyvcdiff/tinyvcdiff.mk diff --git a/CODEOWNERS b/CODEOWNERS index d587e15629..1a82e38c39 100644 --- a/CODEOWNERS +++ b/CODEOWNERS @@ -108,6 +108,7 @@ /pkg/openthread/ @Hyungsin @jia200x /pkg/semtech-loramac/ @aabadie @jia200x /pkg/tinydtls/ @rfuentess @leandrolanzieri +/pkg/tinyvcdiff/ @jue89 /pkg/u8g2/ @basilfx /pkg/ucglib/ @basilfx /pkg/wakaama/ @leandrolanzieri diff --git a/pkg/Kconfig b/pkg/Kconfig index 2de9bb54d2..2514a26af7 100644 --- a/pkg/Kconfig +++ b/pkg/Kconfig @@ -64,6 +64,7 @@ rsource "tiny-asn1/Kconfig" rsource "tinycbor/Kconfig" rsource "tinycrypt/Kconfig" rsource "tinydtls/Kconfig" +rsource "tinyvcdiff/Kconfig" rsource "tlsf/Kconfig" rsource "tweetnacl/Kconfig" rsource "u8g2/Kconfig" diff --git a/pkg/tinyvcdiff/Kconfig b/pkg/tinyvcdiff/Kconfig new file mode 100644 index 0000000000..41222ba111 --- /dev/null +++ b/pkg/tinyvcdiff/Kconfig @@ -0,0 +1,22 @@ +# Copyright (c) 2022 Juergen Fitschen +# +# This file is subject to the terms and conditions of the GNU Lesser +# General Public License v2.1. See the file LICENSE in the top level +# directory for more details. + +menuconfig PACKAGE_TINYVCDIFF + bool "Tiny VCDIFF" + depends on TEST_KCONFIG + +if PACKAGE_TINYVCDIFF + +config TINYVCDIFF_BUFFER_SIZE + int "Buffer size" + default 128 + help + For VCDIFF copy and run instruction the library requires a buffer. + The best performance is achieved for sizes of typical page sizes of + the underlying MTD or VFS backend. But a size of just 1 byte would + work, too. + +endif # PACKAGE_TINYVCDIFF diff --git a/pkg/tinyvcdiff/Makefile b/pkg/tinyvcdiff/Makefile new file mode 100644 index 0000000000..4817cd813f --- /dev/null +++ b/pkg/tinyvcdiff/Makefile @@ -0,0 +1,9 @@ +PKG_NAME=tinyvcdiff +PKG_URL=https://github.com/jue89/tiny-vcdiff.git +PKG_VERSION=e1a679f36d0212f2b84057a70c72f6e9deda45b3 +PKG_LICENSE=MIT + +include $(RIOTBASE)/pkg/pkg.mk + +all: + $(QQ)"$(MAKE)" -C $(PKG_SOURCE_DIR)/src -f $(CURDIR)/$(PKG_NAME).mk diff --git a/pkg/tinyvcdiff/Makefile.include b/pkg/tinyvcdiff/Makefile.include new file mode 100644 index 0000000000..58ccc70e9e --- /dev/null +++ b/pkg/tinyvcdiff/Makefile.include @@ -0,0 +1,10 @@ +# Buffer size for vcdiff +CONFIG_TINYVCDIFF_BUFFER_SIZE ?= 128 +CFLAGS += -DVCDIFF_BUFFER_SIZE=$(CONFIG_TINYVCDIFF_BUFFER_SIZE) + +# Disable debugging if DEVELHELP is turned off +ifneq ($(DEVELHELP),1) + CFLAGS += -DVCDIFF_NDEBUG +endif + +INCLUDES += -I$(PKGDIRBASE)/tinyvcdiff/include diff --git a/pkg/tinyvcdiff/doc.txt b/pkg/tinyvcdiff/doc.txt new file mode 100644 index 0000000000..8473e1819d --- /dev/null +++ b/pkg/tinyvcdiff/doc.txt @@ -0,0 +1,58 @@ +/** + * @defgroup pkg_tinyvcdiff Tiny VCDIFF + * @ingroup pkg + * @brief Decoder for interleaved VCDIFF deltas + * + * # Introduction + * + * tiny-vcdiff is a decoder for binary delta files that have been generated by + * [open-vcdiff](https://github.com/google/open-vcdiff) in the interleaved format. + * + * # Usage + * + * Every delta requires a source (the known data) and a target (the reconstructed + * data). This implementation provides backends for the @ref drivers_mtd and + * @ref sys_vfs storage drivers. + * + * # Example + * + * The example down below uses a @ref drivers_mtd device as known source data and + * writes the resulting target data into a @ref sys_vfs file. + * + * ```c + * #include "vcdiff.h" + * #include "vcdiff_mtd.h" + * #include "vcdiff_vfs.h" + * + * int apply_delta (const uint8_t *data, size_t data_len, + * mtd_dev_t *source_mtd, + * int traget_fd) + * { + * int rc; + * vcdiff_t vcdiff; + * vcdiff_init(&vcdiff); + * + * /* make sure source_mtd is already powered on */ + * vcdiff_mtd_t source = VCDIFF_MTD_INIT(source_mtd); + * vcdiff_set_source_driver(&vcdiff, &vcdiff_mtd_driver, &source); + * + * /* make sure the vfs file is already opened for writing */ + * vcdiff_vfs_t target = VCDIFF_VFS_INIT(fd_target); + * vcdiff_set_target_driver(&vcdiff, &vcdiff_vfs_driver, &target); + * + * rc = vcdiff_apply_delta(&vcdiff, data, data_len); + * if (rc != 0) { + * return rc; + * } + * + * rc = vcdiff_finish(&vcdiff); + * return rc; + * } + * ``` + * + * # License + * + * Licensed under MIT. + * + * @see https://github.com/jue89/tiny-vcdiff.git + */ diff --git a/pkg/tinyvcdiff/tinyvcdiff.mk b/pkg/tinyvcdiff/tinyvcdiff.mk new file mode 100644 index 0000000000..6cc1cbef06 --- /dev/null +++ b/pkg/tinyvcdiff/tinyvcdiff.mk @@ -0,0 +1,3 @@ +MODULE = tinyvcdiff + +include $(RIOTBASE)/Makefile.base