zeus migration: systemd: update recipe to v243.2

https://jira.digi.com/browse/DEL-7013

Signed-off-by: Arturo Buzarra <arturo.buzarra@digi.com>
This commit is contained in:
Arturo Buzarra 2020-04-06 14:29:36 +02:00
parent 1ab348ce89
commit 1efd3f9ba8
8 changed files with 14 additions and 552 deletions

View File

@ -1,7 +0,0 @@
# Copyright (C) 2019 by Digi International Inc.
FILESEXTRAPATHS_prepend := "${THISDIR}/${BPN}:"
SRC_URI += "\
file://0001-system.conf-reduce-default-stop-timeout-to-15-second.patch \
"

View File

@ -1,29 +0,0 @@
From: Gabriel Valcazar <gabriel.valcazar@digi.com>
Date: Thu, 17 Oct 2019 09:45:31 +0200
Subject: [PATCH] system.conf: reduce default stop timeout to 15 seconds
We currently don't have any services that, under normal circumstances, take
over 10 seconds to stop. In exceptional cases where services hang when stopping
due to unknown circumstances, make the timeout happen earlier to avoid stalling
the entire poweroff process for 90 seconds.
https://jira.digi.com/browse/DEL-6794
Signed-off-by: Gabriel Valcazar <gabriel.valcazar@digi.com>
---
src/core/system.conf.in | 2 ++
1 file changed, 2 insertions(+)
diff --git a/src/core/system.conf.in b/src/core/system.conf.in
index f0a59a7..c25257d 100644
--- a/src/core/system.conf.in
+++ b/src/core/system.conf.in
@@ -35,6 +35,8 @@
#DefaultStandardError=inherit
#DefaultTimeoutStartSec=90s
#DefaultTimeoutStopSec=90s
+# Digi-specific
+DefaultTimeoutStopSec=15s
#DefaultRestartSec=100ms
#DefaultStartLimitIntervalSec=10s
#DefaultStartLimitBurst=5

View File

@ -0,0 +1,3 @@
[Manager]
# Digi-specific
DefaultTimeoutStopSec=15s

View File

@ -0,0 +1,11 @@
# Copyright (C) 2019,2020 by Digi International Inc.
FILESEXTRAPATHS_prepend := "${THISDIR}/${BPN}:"
SRC_URI_append = " \
file://system.conf-imx \
"
do_install_append() {
install -D -m0644 ${WORKDIR}/system.conf-imx ${D}${systemd_unitdir}/system.conf.d/01-${PN}.conf
}

View File

@ -1,374 +0,0 @@
From 6c0e15dd6c65b64ca773ce756a8f0356ea5229e9 Mon Sep 17 00:00:00 2001
From: Chen Qi <Qi.Chen@windriver.com>
Date: Wed, 28 Feb 2018 21:05:39 -0800
Subject: [PATCH] Revert "udev: remove userspace firmware loading support"
This reverts commit be2ea723b1d023b3d385d3b791ee4607cbfb20ca.
Userspace firmware loading support is needed for Linux < 3.7.
Upstream-Status: Inappropriate [OE specific]
Signed-off-by: Jonathan Liu <net147@gmail.com>
Signed-off-by: Khem Raj <raj.khem@gmail.com>
Signed-off-by: Chen Qi <Qi.Chen@windriver.com>
---
README | 4 +-
TODO | 1 +
meson.build | 7 ++
meson_options.txt | 2 +
rules/meson.build | 4 +
src/udev/meson.build | 4 +
src/udev/udev-builtin-firmware.c | 154 +++++++++++++++++++++++++++++++++++++++
src/udev/udev-builtin.c | 3 +
src/udev/udev.h | 6 ++
src/udev/udevd.c | 12 +++
10 files changed, 195 insertions(+), 2 deletions(-)
create mode 100644 src/udev/udev-builtin-firmware.c
diff --git a/README b/README
index 2cde08c..c8cc573 100644
--- a/README
+++ b/README
@@ -58,8 +58,8 @@ REQUIREMENTS:
Legacy hotplug slows down the system and confuses udev:
CONFIG_UEVENT_HELPER_PATH=""
- Userspace firmware loading is not supported and should
- be disabled in the kernel:
+ Userspace firmware loading is deprecated, will go away, and
+ sometimes causes problems:
CONFIG_FW_LOADER_USER_HELPER=n
Some udev rules and virtualization detection relies on it:
diff --git a/TODO b/TODO
index ff1008a..7949333 100644
--- a/TODO
+++ b/TODO
@@ -844,6 +844,7 @@ Features:
* initialize the hostname from the fs label of /, if /etc/hostname does not exist?
* udev:
+ - remove src/udev/udev-builtin-firmware.c (CONFIG_FW_LOADER_USER_HELPER=n)
- move to LGPL
- kill scsi_id
- add trigger --subsystem-match=usb/usb_device device
diff --git a/meson.build b/meson.build
index b283d1e..39dee74 100644
--- a/meson.build
+++ b/meson.build
@@ -66,6 +66,10 @@ sysvrcnd_path = get_option('sysvrcnd-path')
conf.set10('HAVE_SYSV_COMPAT', sysvinit_path != '' and sysvrcnd_path != '',
description : 'SysV init scripts and rcN.d links are supported')
+firmware_path = get_option('firmware-path')
+conf.set10('HAVE_FIRMWARE', firmware_path != '',
+ description : 'Userspace firmware loading is supported')
+
# join_paths ignore the preceding arguments if an absolute component is
# encountered, so this should canonicalize various paths when they are
# absolute or relative.
@@ -180,6 +184,7 @@ conf.set_quoted('SYSTEM_CONFIG_UNIT_PATH', join_paths(pkgsysc
conf.set_quoted('SYSTEM_DATA_UNIT_PATH', systemunitdir)
conf.set_quoted('SYSTEM_SYSVINIT_PATH', sysvinit_path)
conf.set_quoted('SYSTEM_SYSVRCND_PATH', sysvrcnd_path)
+conf.set_quoted('FIRMWARE_PATH', firmware_path)
conf.set_quoted('RC_LOCAL_SCRIPT_PATH_START', get_option('rc-local'))
conf.set_quoted('RC_LOCAL_SCRIPT_PATH_STOP', get_option('halt-local'))
@@ -267,6 +272,7 @@ substs.set('SYSTEMCTL', join_paths(rootbin
substs.set('RANDOM_SEED', join_paths(randomseeddir, 'random-seed'))
substs.set('SYSTEM_SYSVINIT_PATH', sysvinit_path)
substs.set('SYSTEM_SYSVRCND_PATH', sysvrcnd_path)
+substs.set('FIRMWARE_PATH', firmware_path)
substs.set('RC_LOCAL_SCRIPT_PATH_START', get_option('rc-local'))
substs.set('RC_LOCAL_SCRIPT_PATH_STOP', get_option('halt-local'))
substs.set('MEMORY_ACCOUNTING_DEFAULT', memory_accounting_default ? 'yes' : 'no')
@@ -2820,6 +2826,7 @@ status = [
'rootlib directory: @0@'.format(rootlibdir),
'SysV init scripts: @0@'.format(sysvinit_path),
'SysV rc?.d directories: @0@'.format(sysvrcnd_path),
+ 'firmware path: @0@'.format(firmware_path),
'PAM modules directory: @0@'.format(pamlibdir),
'PAM configuration directory: @0@'.format(pamconfdir),
'RPM macros directory: @0@'.format(rpmmacrosdir),
diff --git a/meson_options.txt b/meson_options.txt
index a396ce3..9f7f1b1 100644
--- a/meson_options.txt
+++ b/meson_options.txt
@@ -109,6 +109,8 @@ option('tmpfiles', type : 'boolean',
description : 'support for tmpfiles.d')
option('importd', type : 'combo', choices : ['auto', 'true', 'false'],
description : 'install the systemd-importd daemon')
+option('firmware-path', type : 'string', value : '',
+ description : 'Firmware search path')
option('hwdb', type : 'boolean',
description : 'support for the hardware database')
option('rfkill', type : 'boolean',
diff --git a/rules/meson.build b/rules/meson.build
index b6a32ba..d3f3214 100644
--- a/rules/meson.build
+++ b/rules/meson.build
@@ -26,6 +26,10 @@ rules = files('''
install_data(rules,
install_dir : udevrulesdir)
+if conf.get('HAVE_FIRMWARE') == 1
+ install_data('50-firmware.rules', install_dir : udevrulesdir)
+endif
+
all_rules = rules
rules_in = '''
diff --git a/src/udev/meson.build b/src/udev/meson.build
index 3bcd2bd..0dd4022 100644
--- a/src/udev/meson.build
+++ b/src/udev/meson.build
@@ -52,6 +52,10 @@ if conf.get('HAVE_ACL') == 1
sd_login_c]
endif
+if conf.get('HAVE_FIRMWARE') == 1
+ libudev_core_sources += ['udev-builtin-firmware.c']
+endif
+
############################################################
generate_keyboard_keys_list = find_program('generate-keyboard-keys-list.sh')
diff --git a/src/udev/udev-builtin-firmware.c b/src/udev/udev-builtin-firmware.c
new file mode 100644
index 0000000..bd8c2fb
--- /dev/null
+++ b/src/udev/udev-builtin-firmware.c
@@ -0,0 +1,154 @@
+/*
+ * firmware - Kernel firmware loader
+ *
+ * Copyright (C) 2009 Piter Punk <piterpunk@slackware.com>
+ * Copyright (C) 2009-2011 Kay Sievers <kay@vrfy.org>
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License as
+ * published by the Free Software Foundation; either version 2 of the
+ * License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful, but
+ * WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * General Public License for more details:*
+ */
+
+#include <unistd.h>
+#include <stdlib.h>
+#include <string.h>
+#include <stdio.h>
+#include <getopt.h>
+#include <errno.h>
+#include <stdbool.h>
+#include <sys/utsname.h>
+#include <sys/stat.h>
+
+#include "udev.h"
+
+static bool set_loading(struct udev *udev, char *loadpath, const char *state) {
+ FILE *ldfile;
+
+ ldfile = fopen(loadpath, "we");
+ if (ldfile == NULL) {
+ log_error("error: can not open '%s'", loadpath);
+ return false;
+ };
+ fprintf(ldfile, "%s\n", state);
+ fclose(ldfile);
+ return true;
+}
+
+static bool copy_firmware(struct udev *udev, const char *source, const char *target, size_t size) {
+ char *buf;
+ FILE *fsource = NULL, *ftarget = NULL;
+ bool ret = false;
+
+ buf = malloc(size);
+ if (buf == NULL) {
+ log_error("No memory available to load firmware file");
+ return false;
+ }
+
+ log_debug("writing '%s' (%zi) to '%s'", source, size, target);
+
+ fsource = fopen(source, "re");
+ if (fsource == NULL)
+ goto exit;
+ ftarget = fopen(target, "we");
+ if (ftarget == NULL)
+ goto exit;
+ if (fread(buf, size, 1, fsource) != 1)
+ goto exit;
+ if (fwrite(buf, size, 1, ftarget) == 1)
+ ret = true;
+exit:
+ if (ftarget != NULL)
+ fclose(ftarget);
+ if (fsource != NULL)
+ fclose(fsource);
+ free(buf);
+ return ret;
+}
+
+static int builtin_firmware(struct udev_device *dev, int argc, char *argv[], bool test) {
+ struct udev *udev = udev_device_get_udev(dev);
+ static const char *searchpath[] = { FIRMWARE_PATH };
+ char loadpath[UTIL_PATH_SIZE];
+ char datapath[UTIL_PATH_SIZE];
+ char fwpath[UTIL_PATH_SIZE];
+ const char *firmware;
+ FILE *fwfile = NULL;
+ struct utsname kernel;
+ struct stat statbuf;
+ unsigned int i;
+ int rc = EXIT_SUCCESS;
+
+ firmware = udev_device_get_property_value(dev, "FIRMWARE");
+ if (firmware == NULL) {
+ log_error("firmware parameter missing");
+ rc = EXIT_FAILURE;
+ goto exit;
+ }
+
+ /* lookup firmware file */
+ uname(&kernel);
+ for (i = 0; i < ELEMENTSOF(searchpath); i++) {
+ strscpyl(fwpath, sizeof(fwpath), searchpath[i], kernel.release, "/", firmware, NULL);
+ fwfile = fopen(fwpath, "re");
+ if (fwfile != NULL)
+ break;
+
+ strscpyl(fwpath, sizeof(fwpath), searchpath[i], firmware, NULL);
+ fwfile = fopen(fwpath, "re");
+ if (fwfile != NULL)
+ break;
+ }
+
+ strscpyl(loadpath, sizeof(loadpath), udev_device_get_syspath(dev), "/loading", NULL);
+
+ if (fwfile == NULL) {
+ log_debug("did not find firmware file '%s'", firmware);
+ rc = EXIT_FAILURE;
+ /*
+ * Do not cancel the request in the initrd, the real root might have
+ * the firmware file and the 'coldplug' run in the real root will find
+ * this pending request and fulfill or cancel it.
+ * */
+ if (!in_initrd())
+ set_loading(udev, loadpath, "-1");
+ goto exit;
+ }
+
+ if (stat(fwpath, &statbuf) < 0 || statbuf.st_size == 0) {
+ if (!in_initrd())
+ set_loading(udev, loadpath, "-1");
+ rc = EXIT_FAILURE;
+ goto exit;
+ }
+
+ if (!set_loading(udev, loadpath, "1"))
+ goto exit;
+
+ strscpyl(datapath, sizeof(datapath), udev_device_get_syspath(dev), "/data", NULL);
+ if (!copy_firmware(udev, fwpath, datapath, statbuf.st_size)) {
+ log_error("error sending firmware '%s' to device", firmware);
+ set_loading(udev, loadpath, "-1");
+ rc = EXIT_FAILURE;
+ goto exit;
+ };
+
+ set_loading(udev, loadpath, "0");
+exit:
+ if (fwfile)
+ fclose(fwfile);
+ return rc;
+}
+
+const struct udev_builtin udev_builtin_firmware = {
+ .name = "firmware",
+ .cmd = builtin_firmware,
+ .help = "kernel firmware loader",
+ .run_once = true,
+};
diff --git a/src/udev/udev-builtin.c b/src/udev/udev-builtin.c
index 576d83d..e58f772 100644
--- a/src/udev/udev-builtin.c
+++ b/src/udev/udev-builtin.c
@@ -14,6 +14,9 @@ static const struct udev_builtin *builtins[] = {
[UDEV_BUILTIN_BLKID] = &udev_builtin_blkid,
#endif
[UDEV_BUILTIN_BTRFS] = &udev_builtin_btrfs,
+#if HAVE_FIRMWARE
+ [UDEV_BUILTIN_FIRMWARE] = &udev_builtin_firmware,
+#endif
[UDEV_BUILTIN_HWDB] = &udev_builtin_hwdb,
[UDEV_BUILTIN_INPUT_ID] = &udev_builtin_input_id,
[UDEV_BUILTIN_KEYBOARD] = &udev_builtin_keyboard,
diff --git a/src/udev/udev.h b/src/udev/udev.h
index 4596d0e..c800ef5 100644
--- a/src/udev/udev.h
+++ b/src/udev/udev.h
@@ -138,6 +138,9 @@ enum udev_builtin_cmd {
UDEV_BUILTIN_BLKID,
#endif
UDEV_BUILTIN_BTRFS,
+#if HAVE_FIRMWARE
+ UDEV_BUILTIN_FIRMWARE,
+#endif
UDEV_BUILTIN_HWDB,
UDEV_BUILTIN_INPUT_ID,
UDEV_BUILTIN_KEYBOARD,
@@ -166,6 +169,9 @@ struct udev_builtin {
extern const struct udev_builtin udev_builtin_blkid;
#endif
extern const struct udev_builtin udev_builtin_btrfs;
+#if HAVE_FIRMWARE
+extern const struct udev_builtin udev_builtin_firmware;
+#endif
extern const struct udev_builtin udev_builtin_hwdb;
extern const struct udev_builtin udev_builtin_input_id;
extern const struct udev_builtin udev_builtin_keyboard;
diff --git a/src/udev/udevd.c b/src/udev/udevd.c
index 34f6a95..b132db7 100644
--- a/src/udev/udevd.c
+++ b/src/udev/udevd.c
@@ -114,6 +114,9 @@ struct event {
bool is_block;
sd_event_source *timeout_warning;
sd_event_source *timeout;
+#if HAVE_FIRMWARE
+ bool nodelay;
+#endif
};
static void event_queue_cleanup(Manager *manager, enum event_state type);
@@ -604,6 +607,10 @@ static int event_queue_insert(Manager *manager, struct udev_device *dev) {
event->devnum = udev_device_get_devnum(dev);
event->is_block = streq("block", udev_device_get_subsystem(dev));
event->ifindex = udev_device_get_ifindex(dev);
+#if HAVE_FIRMWARE
+ if (streq(udev_device_get_subsystem(dev), "firmware"))
+ event->nodelay = true;
+#endif
log_debug("seq %llu queued, '%s' '%s'", udev_device_get_seqnum(dev),
udev_device_get_action(dev), udev_device_get_subsystem(dev));
@@ -687,6 +694,11 @@ static bool is_devpath_busy(Manager *manager, struct event *event) {
return true;
}
+#if HAVE_FIRMWARE
+ /* allow to bypass the dependency tracking */
+ if (event->nodelay)
+ continue;
+#endif
/* parent device event found */
if (event->devpath[common] == '/') {
event->delaying_seqnum = loop_event->seqnum;
--
2.7.4

View File

@ -1,109 +0,0 @@
From: Zbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl>
Date: Thu, 3 Jan 2019 12:31:06 +0100
Subject: [PATCH] udev: use the usual set of load paths for udev rules
This adds /usr/local/lib/udev/rules.d to the search path on non-split-usr systems.
On split-usr systems, the paths with /usr/-prefixes are added too.
In the past, on split-usr systems, it made sense to only load rules from
/lib/udev/rules.d, because /usr could be mounted late. But we don't support running
without /usr since 80758717a63, so in practice it doesn't matter whether the
rules files are in /lib/udev/rules.d or /usr/lib/udev/rules.d. Distributions
that maintain the illusion of functional split-usr are welcome to simply not put any
files in /usr/lib/udev/rules.d/.
In practice this doesn't change much, but it makes udev more consistent with the
rest of the systemd suite.
---
man/udev.xml | 26 ++++++++++++--------------
src/udev/udev-rules.c | 13 ++++---------
2 files changed, 16 insertions(+), 23 deletions(-)
diff --git a/man/udev.xml b/man/udev.xml
index 15e6d8e..955aff8 100644
--- a/man/udev.xml
+++ b/man/udev.xml
@@ -45,20 +45,18 @@
</refsect1>
<refsect1><title>Rules Files</title>
- <para>The udev rules are read from the files located in the
- system rules directory <filename>/usr/lib/udev/rules.d</filename>,
- the volatile runtime directory <filename>/run/udev/rules.d</filename>
- and the local administration directory <filename>/etc/udev/rules.d</filename>.
- All rules files are collectively sorted and processed in lexical order,
- regardless of the directories in which they live. However, files with
- identical filenames replace each other. Files in <filename>/etc</filename>
- have the highest priority, files in <filename>/run</filename> take precedence
- over files with the same name in <filename>/usr/lib</filename>. This can be
- used to override a system-supplied rules file with a local file if needed;
- a symlink in <filename>/etc</filename> with the same name as a rules file in
- <filename>/usr/lib</filename>, pointing to <filename>/dev/null</filename>,
- disables the rules file entirely. Rule files must have the extension
- <filename>.rules</filename>; other extensions are ignored.</para>
+ <para>The udev rules are read from the files located in the system rules directories
+ <filename>/usr/lib/udev/rules.d</filename> and <filename>/usr/local/lib/udev/rules.d</filename>, the
+ volatile runtime directory <filename>/run/udev/rules.d</filename> and the local administration
+ directory <filename>/etc/udev/rules.d</filename>. All rules files are collectively sorted and
+ processed in lexical order, regardless of the directories in which they live. However, files with
+ identical filenames replace each other. Files in <filename>/etc</filename> have the highest priority,
+ files in <filename>/run</filename> take precedence over files with the same name under
+ <filename>/usr</filename>. This can be used to override a system-supplied rules file with a local
+ file if needed; a symlink in <filename>/etc</filename> with the same name as a rules file in
+ <filename>/usr/lib</filename>, pointing to <filename>/dev/null</filename>, disables the rules file
+ entirely. Rule files must have the extension <filename>.rules</filename>; other extensions are
+ ignored.</para>
<para>Every line in the rules file contains at least one key-value pair.
Except for empty lines or lines beginning with <literal>#</literal>, which are ignored.
diff --git a/src/udev/udev-rules.c b/src/udev/udev-rules.c
index f029395..cd8f4ef 100644
--- a/src/udev/udev-rules.c
+++ b/src/udev/udev-rules.c
@@ -18,6 +18,7 @@
#include "alloc-util.h"
#include "conf-files.h"
+#include "def.h"
#include "dirent-util.h"
#include "escape.h"
#include "fd-util.h"
@@ -36,6 +37,7 @@
#include "util.h"
#define PREALLOC_TOKEN 2048
+#define RULES_DIRS (const char* const*) CONF_PATHS_STRV("udev/rules.d")
struct uid_gid {
unsigned int name_off;
@@ -45,13 +47,6 @@ struct uid_gid {
};
};
-static const char* const rules_dirs[] = {
- "/etc/udev/rules.d",
- "/run/udev/rules.d",
- UDEVLIBEXECDIR "/rules.d",
- NULL
-};
-
struct udev_rules {
struct udev *udev;
usec_t dirs_ts_usec;
@@ -1542,7 +1537,7 @@ struct udev_rules *udev_rules_new(struct udev *udev, int resolve_names) {
udev_rules_check_timestamp(rules);
- r = conf_files_list_strv(&files, ".rules", NULL, 0, rules_dirs);
+ r = conf_files_list_strv(&files, ".rules", NULL, 0, RULES_DIRS);
if (r < 0) {
log_error_errno(r, "failed to enumerate rules files: %m");
return udev_rules_unref(rules);
@@ -1598,7 +1593,7 @@ bool udev_rules_check_timestamp(struct udev_rules *rules) {
if (!rules)
return false;
- return paths_check_timestamp(rules_dirs, &rules->dirs_ts_usec, true);
+ return paths_check_timestamp(RULES_DIRS, &rules->dirs_ts_usec, true);
}
static int match_key(struct udev_rules *rules, struct token *token, const char *val) {

View File

@ -1,28 +0,0 @@
From 35d6d384e83ac38077603611bb791969ef95fe68 Mon Sep 17 00:00:00 2001
From: Jonathan Liu <net147@gmail.com>
Date: Thu, 19 Mar 2015 15:01:29 +1100
Subject: [PATCH 07/31] Revert "rules: remove firmware loading rules"
This reverts commit 70e7d754ddb356fb1a2942b262f8cee9650e2a19.
Userspace firmware loading support is needed for Linux < 3.7.
Upstream-Status: Inappropriate [OE specific]
Signed-off-by: Jonathan Liu <net147@gmail.com>
---
rules/50-firmware.rules | 3 +++
1 file changed, 3 insertions(+)
create mode 100644 rules/50-firmware.rules
diff --git a/rules/50-firmware.rules b/rules/50-firmware.rules
new file mode 100644
index 000000000..f0ae68451
--- /dev/null
+++ b/rules/50-firmware.rules
@@ -0,0 +1,3 @@
+# do not edit this file, it will be overwritten on update
+
+SUBSYSTEM=="firmware", ACTION=="add", RUN{builtin}="firmware"
--
2.13.0

View File

@ -1,14 +1,9 @@
FILESEXTRAPATHS_prepend := "${THISDIR}/${BPN}:"
SRC_URI += " \
file://0001-Revert-udev-remove-userspace-firmware-loading-suppor.patch \
file://0001-udev-use-the-usual-set-of-load-paths-for-udev-rules.patch \
file://0002-sd-resolve-forcefully-cancel-worker-threads-during-r.patch \
file://0007-Revert-rules-remove-firmware-loading-rules.patch \
"
EXTRA_OEMESON += "-Dfirmware-path=${nonarch_base_libdir}/firmware/ "
# Remove systemd-networkd from our images, since we already use NetworkManager
PACKAGECONFIG_remove = "networkd"