This commit is contained in:
TriForceX
2019-09-25 20:51:37 -03:00
commit 6203ff3e7c
11215 changed files with 428258 additions and 0 deletions

View File

@@ -0,0 +1,65 @@
From 95a2b9961119aac80aea1eeabbc1cd52b72d876a Mon Sep 17 00:00:00 2001
From: James Hilliard <james.hilliard1@gmail.com>
Date: Sat, 4 May 2019 11:38:37 -0600
Subject: [PATCH] archive handler: set locale for libarchive
Signed-off-by: James Hilliard <james.hilliard1@gmail.com>
[Backported from: 95a2b9961119aac80aea1eeabbc1cd52b72d876a]
Signed-off-by: Pierre-Jean Texier <pjtexier@koncepto.io>
---
handlers/archive_handler.c | 18 ++++++++++++++++++
1 file changed, 18 insertions(+)
diff --git a/handlers/archive_handler.c b/handlers/archive_handler.c
index 7f12761..993bc10 100644
--- a/handlers/archive_handler.c
+++ b/handlers/archive_handler.c
@@ -6,6 +6,7 @@
*/
#include <sys/types.h>
+#include <locale.h>
#include <stdio.h>
#include <sys/stat.h>
#include <unistd.h>
@@ -68,6 +69,8 @@ copy_data(struct archive *ar, struct archive *aw)
static void *
extract(void *p)
{
+ locale_t archive_locale;
+ locale_t old_locale;
struct archive *a;
struct archive *ext = NULL;
struct archive_entry *entry = NULL;
@@ -77,6 +80,20 @@ extract(void *p)
flags = data->flags;
int exitval = -EFAULT;
+ /*
+ * Enable system locale - change from the standard (C) to system locale.
+ * This allows libarchive (in case it is activated) to handle filenames.
+ * We only change LC_CTYPE since libarchive only needs the charset set.
+ * We don't use LC_ALL because it causes problems on some systems.
+ * We restore the original LC_CTYPE after extraction to avoid side effects.
+ * We use uselocale instead of setlocale to avoid setting LC_CTYPE globally.
+ * See on libarchive Website for a more complete description of the issue:
+ * https://github.com/libarchive/libarchive/issues/587
+ * https://github.com/libarchive/libarchive/wiki/Filenames
+ */
+ archive_locale = newlocale(LC_CTYPE_MASK, "", (locale_t)0);
+ old_locale = uselocale(archive_locale);
+
a = archive_read_new();
if (!a) {
goto out;
@@ -155,6 +172,7 @@ out:
archive_read_free(a);
}
+ uselocale(old_locale);
data->exitval = exitval;
pthread_exit(NULL);
}
--
2.7.4

View File

@@ -0,0 +1,42 @@
From ee17493d470ae7fd7b34241f263cfa6d790ce1b3 Mon Sep 17 00:00:00 2001
From: Christian Storm <christian.storm@siemens.com>
Date: Tue, 21 May 2019 14:45:51 +0200
Subject: [PATCH] Lua: fix segfault in image property handling
table2image() calls lua_dump_table() with the 'key' parameter being
NULL and the 'img' parameter set. Subsequently, dict_insert_value() is
called with key == NULL if the Lua stack key's type is string or number,
segfaulting SWUpdate.
Signed-off-by: Christian Storm <christian.storm@siemens.com>
Reported-by: Akihiro Suzuki <akihiro27.suzuki@toshiba.co.jp>
Acked-by: Stefano Babic <sbabic@denx.de>
[Backported from: ee17493d470ae7fd7b34241f263cfa6d790ce1b3]
Signed-off-by: Pierre-Jean Texier <pjtexier@koncepto.io>
---
corelib/lua_interface.c | 8 ++++----
1 file changed, 4 insertions(+), 4 deletions(-)
diff --git a/corelib/lua_interface.c b/corelib/lua_interface.c
index d4ebe4a..443f149 100644
--- a/corelib/lua_interface.c
+++ b/corelib/lua_interface.c
@@ -80,11 +80,11 @@ static void lua_dump_table(lua_State *L, char *str, struct img_type *img, const
lua_tostring(L, -1),
lua_tostring(L, -2));
if (img) {
- TRACE("Inserting property %s[%s] = %s",
- key,
- lua_tostring(L, -1),
+ TRACE("Inserting property %s = %s",
+ key ? key : lua_tostring(L, -1),
lua_tostring(L, -2));
- dict_insert_value(&img->properties, key,
+ dict_insert_value(&img->properties,
+ key ? key : lua_tostring(L, -1),
lua_tostring(L, -2));
}
break;
--
2.7.4

View File

@@ -0,0 +1,44 @@
From f811c91c06bffe32f46472524059914987e653ba Mon Sep 17 00:00:00 2001
From: Christian Storm <christian.storm@siemens.com>
Date: Tue, 21 May 2019 16:20:02 +0200
Subject: [PATCH] u-boot: fix script format when !CONFIG_UBOOT_NEWAPI
When !CONFIG_UBOOT_NEWAPI and hence linking against U-Boot's
tools/env/lib.a, SWUpdate's bootloader/uboot.c calls lib.a's
fw_parse_script() which expects input to be in format, quoting:
...
* Each line has a couple with name, value:
* <white spaces>variable_name<white spaces>variable_value
This was changed in SWUpdate by commit dab1b70 "Unify bootloader
script format" to be '='-separated instead of space-separated,
hence breaking the integration with the "old" libubootenv binding.
Signed-off-by: Christian Storm <christian.storm@siemens.com>
Reported-by: Akihiro Suzuki <akihiro27.suzuki@toshiba.co.jp>
Acked-by: Stefano Babic <sbabic@denx.de>
[Backported from: f811c91c06bffe32f46472524059914987e653ba]
Signed-off-by: Pierre-Jean Texier <pjtexier@koncepto.io>
---
corelib/installer.c | 4 ++++
1 file changed, 4 insertions(+)
diff --git a/corelib/installer.c b/corelib/installer.c
index edfcb6a..2dda40a 100644
--- a/corelib/installer.c
+++ b/corelib/installer.c
@@ -169,7 +169,11 @@ static int update_bootloader_env(struct swupdate_cfg *cfg, const char *script)
if (!key || !value)
continue;
+#if defined(CONFIG_UBOOT) && !defined(CONFIG_UBOOT_NEWAPI)
+ snprintf(buf, sizeof(buf), "%s %s\n", key, value);
+#else
snprintf(buf, sizeof(buf), "%s=%s\n", key, value);
+#endif
if (write(fd, buf, strlen(buf)) != (ssize_t)strlen(buf)) {
TRACE("Error saving temporary bootloader environment file");
close(fd);
--
2.7.4

View File

@@ -0,0 +1,68 @@
config BR2_PACKAGE_SWUPDATE
bool "swupdate"
depends on BR2_TOOLCHAIN_HAS_THREADS
depends on BR2_USE_MMU # fork()
# swupdate requires a parser and uses libconfig as default
select BR2_PACKAGE_LIBCONFIG if !BR2_PACKAGE_JSON_C && \
!BR2_PACKAGE_HAS_LUAINTERPRETER
help
swupdate provides a reliable way to update the software on
an embedded system.
swupdate is highly configurable to fit the targets
requirements and to minimize the footprint. The provided
default configuration file BR2_PACKAGE_SWUPDATE_CONFIG will
enable swupdate with an embedded webserver, a parser and a
handler for raw NAND or NOR flash.
The default configuration file builds a reasonable firmware
update system with minimal external dependencies in mind.
If you like to use your own modified configuration,
you have to select the necessary packages manually:
* Select BR2_PACKAGE_LUA or BR2_PACKAGE_LUAJIT if you want
want to have Lua support.
* Select BR2_LIBCURL if you want to use the download
feature.
* Select BR2_PACKAGE_OPENSSL is you want to add encryption
support.
* Select BR2_PACKAGE_MTD if you want to use swupdate with
UBI partitions.
* Select BR2_PACKAGE_ZLIB if you want to deal with gzip
compressed archives.
* Select BR2_PACKAGE_UBOOT_TOOLS and BR2_PACKAGE_ZLIB to add
support for setting the U-Boot environment.
* Select BR2_PACKAGE_ZEROMQ to add support for using a
remote handler.
* Select BR2_PACKAGE_LIBRSYNC to add support for using
rdiff handler.
* Select BR2_PACKAGE_LIBUBOOTENV to add support for setting
the U-Boot environment with the new API.
https://sbabic.github.io/swupdate
if BR2_PACKAGE_SWUPDATE
config BR2_PACKAGE_SWUPDATE_CONFIG
string "swupdate configuration file"
default "package/swupdate/swupdate.config"
help
Path to the swupdate configuration file.
I you wish to use your own modified swupdate configuration
file specify the config file location with this option.
config BR2_PACKAGE_SWUPDATE_INSTALL_WEBSITE
bool "install default website"
default y
help
Install the provided website to /var/www/swupdate.
This is necessary if you want to run swupdate with the
embedded webserver and do not provide an own website to be
installed to /var/www/swupdate.
endif
comment "swupdate needs a toolchain w/ threads"
depends on BR2_USE_MMU
depends on !BR2_TOOLCHAIN_HAS_THREADS

View File

@@ -0,0 +1,123 @@
#
# Automatically generated file; DO NOT EDIT.
# Swupdate Configuration
#
CONFIG_HAVE_DOT_CONFIG=y
#
# Swupdate Settings
#
#
# General Configuration
#
# CONFIG_CURL is not set
# CONFIG_CURL_SSL is not set
# CONFIG_SYSTEMD is not set
CONFIG_SCRIPTS=y
# CONFIG_HW_COMPATIBILITY is not set
CONFIG_SW_VERSIONS_FILE="/etc/sw-versions"
#
# Socket Paths
#
CONFIG_SOCKET_CTRL_PATH="/tmp/sockinstctrl"
CONFIG_SOCKET_PROGRESS_PATH="/tmp/swupdateprog"
CONFIG_SOCKET_REMOTE_HANDLER_DIRECTORY="/tmp/"
#
# MTD support needs libmtd
#
#
# Lua support needs a Lua interpreter
#
# CONFIG_FEATURE_SYSLOG is not set
#
# Build Options
#
CONFIG_CROSS_COMPILE=""
CONFIG_SYSROOT=""
CONFIG_EXTRA_CFLAGS=""
CONFIG_EXTRA_LDFLAGS=""
CONFIG_EXTRA_LDLIBS=""
#
# Debugging Options
#
# CONFIG_DEBUG is not set
# CONFIG_WERROR is not set
# CONFIG_NOCLEANUP is not set
# CONFIG_BOOTLOADER_EBG is not set
CONFIG_BOOTLOADER_NONE=y
# CONFIG_BOOTLOADER_GRUB is not set
#
# U-Boot support needs libubootenv, libz
#
#
# Image downloading support needs libcurl
#
#
# Hash verification needs libssl
#
#
# Image verification (signed images) needs libssl
#
#
# Image encryption needs libssl
#
# CONFIG_SURICATTA is not set
CONFIG_WEBSERVER=y
CONFIG_MONGOOSE=y
CONFIG_MONGOOSEIPV6=y
#
# SSL support needs libcrypto, libssl
#
CONFIG_GUNZIP=y
#
# Parser Features
#
CONFIG_LIBCONFIG=y
CONFIG_PARSERROOT=""
#
# JSON config parser support needs json-c
#
# CONFIG_SETSWDESCRIPTION is not set
#
# Image Handlers
#
#
# ubivol support needs libubi
#
CONFIG_RAW=y
# CONFIG_RDIFFHANDLER is not set
# CONFIG_SHELLSCRIPTHANDLER is not set
#
# archive support needs libarchive
#
#
# remote handler needs zeromq
#
#
# swuforward handler needs json-c and curl
#
#
# SWU forwarder requires libcurl
#
# CONFIG_BOOTLOADERHANDLER is not set
# CONFIG_UCFWHANDLER is not set

View File

@@ -0,0 +1,6 @@
# Locally calculated
sha256 96b2c59558e847ddb7c23b666c1bbe61e03ab90a64c30d233bd5e9029df8519b swupdate-2019.04.tar.gz
sha256 43492b377cf2fb67942d1dd231146bd4e6578646ad13ef289297c9dd75cbc478 Licenses/Exceptions
sha256 8177f97513213526df2cf6184d8ff986c675afb514d4e68a404010521b880643 Licenses/gpl-2.0.txt
sha256 dc626520dcd53a22f727af3ee42c770e56c97a64fe3adb063799d8ab032fe551 Licenses/lgpl-2.1.txt
sha256 89807acf2309bd285f033404ee78581602f3cd9b819a16ac2f0e5f60ff4a473e Licenses/mit.txt

View File

@@ -0,0 +1,152 @@
################################################################################
#
# swupdate
#
################################################################################
SWUPDATE_VERSION = 2019.04
SWUPDATE_SITE = $(call github,sbabic,swupdate,$(SWUPDATE_VERSION))
SWUPDATE_LICENSE = GPL-2.0+ with OpenSSL exception, LGPL-2.1+, MIT
SWUPDATE_LICENSE_FILES = Licenses/Exceptions Licenses/gpl-2.0.txt \
Licenses/lgpl-2.1.txt Licenses/mit.txt
# swupdate uses $CROSS-cc instead of $CROSS-gcc, which is not
# available in all external toolchains, and use CC for linking. Ensure
# TARGET_CC is used for both.
SWUPDATE_MAKE_ENV = CC="$(TARGET_CC)" LD="$(TARGET_CC)"
# swupdate bundles its own version of mongoose (version 6.11)
ifeq ($(BR2_PACKAGE_JSON_C),y)
SWUPDATE_DEPENDENCIES += json-c
SWUPDATE_MAKE_ENV += HAVE_JSON_C=y
else
SWUPDATE_MAKE_ENV += HAVE_JSON_C=n
endif
ifeq ($(BR2_PACKAGE_LIBARCHIVE),y)
SWUPDATE_DEPENDENCIES += libarchive
SWUPDATE_MAKE_ENV += HAVE_LIBARCHIVE=y
else
SWUPDATE_MAKE_ENV += HAVE_LIBARCHIVE=n
endif
ifeq ($(BR2_PACKAGE_LIBCONFIG),y)
SWUPDATE_DEPENDENCIES += libconfig
SWUPDATE_MAKE_ENV += HAVE_LIBCONFIG=y
else
SWUPDATE_MAKE_ENV += HAVE_LIBCONFIG=n
endif
ifeq ($(BR2_PACKAGE_LIBCURL),y)
SWUPDATE_DEPENDENCIES += libcurl
SWUPDATE_MAKE_ENV += HAVE_LIBCURL=y
else
SWUPDATE_MAKE_ENV += HAVE_LIBCURL=n
endif
ifeq ($(BR2_PACKAGE_HAS_LUAINTERPRETER):$(BR2_STATIC_LIBS),y:)
SWUPDATE_DEPENDENCIES += luainterpreter host-pkgconf
# defines the base name for the pkg-config file ("lua" or "luajit")
define SWUPDATE_SET_LUA_VERSION
$(call KCONFIG_SET_OPT,CONFIG_LUAPKG,$(BR2_PACKAGE_PROVIDES_LUAINTERPRETER),$(SWUPDATE_BUILD_CONFIG))
endef
SWUPDATE_MAKE_ENV += HAVE_LUA=y
else
SWUPDATE_MAKE_ENV += HAVE_LUA=n
endif
ifeq ($(BR2_PACKAGE_MTD),y)
SWUPDATE_DEPENDENCIES += mtd
SWUPDATE_MAKE_ENV += HAVE_LIBMTD=y
SWUPDATE_MAKE_ENV += HAVE_LIBUBI=y
else
SWUPDATE_MAKE_ENV += HAVE_LIBMTD=n
SWUPDATE_MAKE_ENV += HAVE_LIBUBI=n
endif
ifeq ($(BR2_PACKAGE_OPENSSL),y)
SWUPDATE_DEPENDENCIES += openssl
SWUPDATE_MAKE_ENV += HAVE_LIBSSL=y
SWUPDATE_MAKE_ENV += HAVE_LIBCRYPTO=y
else
SWUPDATE_MAKE_ENV += HAVE_LIBSSL=n
SWUPDATE_MAKE_ENV += HAVE_LIBCRYPTO=n
endif
ifeq ($(BR2_PACKAGE_UBOOT_TOOLS),y)
SWUPDATE_DEPENDENCIES += uboot-tools
SWUPDATE_MAKE_ENV += HAVE_LIBUBOOTENV=y
else ifeq ($(BR2_PACKAGE_LIBUBOOTENV),y)
SWUPDATE_DEPENDENCIES += libubootenv
SWUPDATE_MAKE_ENV += HAVE_LIBUBOOTENV=y
else
SWUPDATE_MAKE_ENV += HAVE_LIBUBOOTENV=n
endif
ifeq ($(BR2_PACKAGE_ZEROMQ),y)
SWUPDATE_DEPENDENCIES += zeromq
SWUPDATE_MAKE_ENV += HAVE_LIBZEROMQ=y
else
SWUPDATE_MAKE_ENV += HAVE_LIBZEROMQ=n
endif
ifeq ($(BR2_PACKAGE_ZLIB),y)
SWUPDATE_DEPENDENCIES += zlib
SWUPDATE_MAKE_ENV += HAVE_ZLIB=y
else
SWUPDATE_MAKE_ENV += HAVE_ZLIB=n
endif
ifeq ($(BR2_PACKAGE_LIBRSYNC),y)
SWUPDATE_DEPENDENCIES += librsync
endif
SWUPDATE_BUILD_CONFIG = $(@D)/.config
SWUPDATE_KCONFIG_FILE = $(call qstrip,$(BR2_PACKAGE_SWUPDATE_CONFIG))
SWUPDATE_KCONFIG_EDITORS = menuconfig xconfig gconfig nconfig
ifeq ($(BR2_STATIC_LIBS),y)
define SWUPDATE_PREFER_STATIC
$(call KCONFIG_ENABLE_OPT,CONFIG_STATIC,$(SWUPDATE_BUILD_CONFIG))
endef
endif
define SWUPDATE_SET_BUILD_OPTIONS
$(call KCONFIG_SET_OPT,CONFIG_CROSS_COMPILE,"$(TARGET_CROSS)", \
$(SWUPDATE_BUILD_CONFIG))
$(call KCONFIG_SET_OPT,CONFIG_SYSROOT,"$(STAGING_DIR)", \
$(SWUPDATE_BUILD_CONFIG))
$(call KCONFIG_SET_OPT,CONFIG_EXTRA_CFLAGS,"$(TARGET_CFLAGS)", \
$(SWUPDATE_BUILD_CONFIG))
$(call KCONFIG_SET_OPT,CONFIG_EXTRA_LDFLAGS,"$(TARGET_LDFLAGS)", \
$(SWUPDATE_BUILD_CONFIG))
endef
define SWUPDATE_KCONFIG_FIXUP_CMDS
$(SWUPDATE_PREFER_STATIC)
$(SWUPDATE_SET_BUILD_OPTIONS)
$(SWUPDATE_SET_LUA_VERSION)
endef
define SWUPDATE_BUILD_CMDS
$(TARGET_MAKE_ENV) $(SWUPDATE_MAKE_ENV) $(MAKE) -C $(@D)
endef
define SWUPDATE_INSTALL_TARGET_CMDS
$(INSTALL) -D -m 0755 $(@D)/swupdate $(TARGET_DIR)/usr/bin/swupdate
$(if $(BR2_PACKAGE_SWUPDATE_INSTALL_WEBSITE), \
mkdir -p $(TARGET_DIR)/var/www/swupdate; \
cp -dpfr $(@D)/examples/www/v2/* $(TARGET_DIR)/var/www/swupdate)
endef
# Checks to give errors that the user can understand
# Must be before we call to kconfig-package
ifeq ($(BR2_PACKAGE_SWUPDATE)$(BR_BUILDING),yy)
ifeq ($(call qstrip,$(BR2_PACKAGE_SWUPDATE_CONFIG)),)
$(error No Swupdate configuration file specified, check your BR2_PACKAGE_SWUPDATE_CONFIG setting)
endif
endif
$(eval $(kconfig-package))