* [PATCH 0/1] systemd: fix systemd-udev-hwdb-update service
@ 2014-10-24 5:58 Chen Qi
2014-10-24 5:58 ` [PATCH 1/1] " Chen Qi
0 siblings, 1 reply; 4+ messages in thread
From: Chen Qi @ 2014-10-24 5:58 UTC (permalink / raw)
To: openembedded-core
The following changes since commit 97756472d3a69eaca95d105494ffea78c6b077e0:
build-appliance-image: Update to dizzy head revision (2014-10-18 16:16:27 +0200)
are available in the git repository at:
git://git.openembedded.org/openembedded-core-contrib ChenQi/systemd-udev-hwdb-update
http://cgit.openembedded.org/cgit.cgi/openembedded-core-contrib/log/?h=ChenQi/systemd-udev-hwdb-update
Chen Qi (1):
systemd: fix systemd-udev-hwdb-update service
meta/recipes-core/systemd/systemd_216.bb | 18 +++++++++++++++---
1 file changed, 15 insertions(+), 3 deletions(-)
--
1.9.1
^ permalink raw reply [flat|nested] 4+ messages in thread
* [PATCH 1/1] systemd: fix systemd-udev-hwdb-update service
2014-10-24 5:58 [PATCH 0/1] systemd: fix systemd-udev-hwdb-update service Chen Qi
@ 2014-10-24 5:58 ` Chen Qi
2014-10-24 6:09 ` Koen Kooi
0 siblings, 1 reply; 4+ messages in thread
From: Chen Qi @ 2014-10-24 5:58 UTC (permalink / raw)
To: openembedded-core
The new version of systemd has implemented the following feature.
Opointer.de/blog/projects/stateless.html
As a result, the systemd-udev-hwdb-update.service would always run
at first boot. This will cause failure if the target device doesn't
have enough storage space. Besides, as we run `udevadm hwdb --update' as
a postinst of udev-hwdb at rootfs time, there's no need to run this
again at system start-up.
The purpose of this patch is as follows.
If `udev hwdb --update' fails at rootfs time, systemd-udev-hwdb-update.service
is executed at first boot; otherwise, the service is not executed.
This patch achieves the above goal by setting CondistonNeedsUpdate to
"/etc/udev" in the service file, and creating /etc/udev/.updated file if the
postinst succeeds.
Signed-off-by: Chen Qi <Qi.Chen@windriver.com>
---
meta/recipes-core/systemd/systemd_216.bb | 18 +++++++++++++++---
1 file changed, 15 insertions(+), 3 deletions(-)
diff --git a/meta/recipes-core/systemd/systemd_216.bb b/meta/recipes-core/systemd/systemd_216.bb
index ebf9395..cd81818 100644
--- a/meta/recipes-core/systemd/systemd_216.bb
+++ b/meta/recipes-core/systemd/systemd_216.bb
@@ -149,6 +149,10 @@ do_install() {
# Enable journal to forward message to syslog daemon
sed -i -e 's/.*ForwardToSyslog.*/ForwardToSyslog=yes/' ${D}${sysconfdir}/systemd/journald.conf
+
+ # Make systemd-udev-hwdb-update to check /etc/udev
+ cp ${D}${systemd_unitdir}/system/systemd-udev-hwdb-update.service ${D}${sysconfdir}/systemd/system
+ sed -i -e 's#ConditionNeedsUpdate=/etc#ConditionNeedsUpdate=/etc/udev#g' ${D}${sysconfdir}/systemd/system/systemd-udev-hwdb-update.service
}
do_install_ptest () {
@@ -355,10 +359,18 @@ ALTERNATIVE_PRIORITY[runlevel] ?= "300"
pkg_postinst_udev-hwdb () {
if test -n "$D"; then
- ${@qemu_run_binary(d, '$D', '${base_bindir}/udevadm')} hwdb --update \
- --root $D
+ if ${@qemu_run_binary(d, '$D', '${base_bindir}/udevadm')} hwdb --update \
+ --root $D; then
+ touch $D/etc/udev/.updated
+ else
+ exit 1
+ fi
else
- udevadm hwdb --update
+ if udevadm hwdb --update; then
+ touch $D/etc/udev/.updated
+ else
+ exit 1
+ fi
fi
}
--
1.9.1
^ permalink raw reply related [flat|nested] 4+ messages in thread
* Re: [PATCH 1/1] systemd: fix systemd-udev-hwdb-update service
2014-10-24 5:58 ` [PATCH 1/1] " Chen Qi
@ 2014-10-24 6:09 ` Koen Kooi
2014-10-24 7:37 ` ChenQi
0 siblings, 1 reply; 4+ messages in thread
From: Koen Kooi @ 2014-10-24 6:09 UTC (permalink / raw)
To: Chen Qi; +Cc: openembedded-core
> Op 24 okt. 2014, om 07:58 heeft Chen Qi <Qi.Chen@windriver.com> het volgende geschreven:
>
> The new version of systemd has implemented the following feature.
> Opointer.de/blog/projects/stateless.html
>
> As a result, the systemd-udev-hwdb-update.service would always run
> at first boot. This will cause failure if the target device doesn't
> have enough storage space. Besides, as we run `udevadm hwdb --update' as
> a postinst of udev-hwdb at rootfs time, there's no need to run this
> again at system start-up.
>
> The purpose of this patch is as follows.
> If `udev hwdb --update' fails at rootfs time, systemd-udev-hwdb-update.service
> is executed at first boot; otherwise, the service is not executed.
>
> This patch achieves the above goal by setting CondistonNeedsUpdate to
> "/etc/udev" in the service file, and creating /etc/udev/.updated file if the
> postinst succeeds.
Ehm, /etc/udev can be created by other packages, why not test for the file you create?
regards,
Koen
>
> Signed-off-by: Chen Qi <Qi.Chen@windriver.com>
> ---
> meta/recipes-core/systemd/systemd_216.bb | 18 +++++++++++++++---
> 1 file changed, 15 insertions(+), 3 deletions(-)
>
> diff --git a/meta/recipes-core/systemd/systemd_216.bb b/meta/recipes-core/systemd/systemd_216.bb
> index ebf9395..cd81818 100644
> --- a/meta/recipes-core/systemd/systemd_216.bb
> +++ b/meta/recipes-core/systemd/systemd_216.bb
> @@ -149,6 +149,10 @@ do_install() {
>
> # Enable journal to forward message to syslog daemon
> sed -i -e 's/.*ForwardToSyslog.*/ForwardToSyslog=yes/' ${D}${sysconfdir}/systemd/journald.conf
> +
> + # Make systemd-udev-hwdb-update to check /etc/udev
> + cp ${D}${systemd_unitdir}/system/systemd-udev-hwdb-update.service ${D}${sysconfdir}/systemd/system
> + sed -i -e 's#ConditionNeedsUpdate=/etc#ConditionNeedsUpdate=/etc/udev#g' ${D}${sysconfdir}/systemd/system/systemd-udev-hwdb-update.service
> }
>
> do_install_ptest () {
> @@ -355,10 +359,18 @@ ALTERNATIVE_PRIORITY[runlevel] ?= "300"
>
> pkg_postinst_udev-hwdb () {
> if test -n "$D"; then
> - ${@qemu_run_binary(d, '$D', '${base_bindir}/udevadm')} hwdb --update \
> - --root $D
> + if ${@qemu_run_binary(d, '$D', '${base_bindir}/udevadm')} hwdb --update \
> + --root $D; then
> + touch $D/etc/udev/.updated
> + else
> + exit 1
> + fi
> else
> - udevadm hwdb --update
> + if udevadm hwdb --update; then
> + touch $D/etc/udev/.updated
> + else
> + exit 1
> + fi
> fi
> }
>
> --
> 1.9.1
>
> --
> _______________________________________________
> Openembedded-core mailing list
> Openembedded-core@lists.openembedded.org
> http://lists.openembedded.org/mailman/listinfo/openembedded-core
>
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH 1/1] systemd: fix systemd-udev-hwdb-update service
2014-10-24 6:09 ` Koen Kooi
@ 2014-10-24 7:37 ` ChenQi
0 siblings, 0 replies; 4+ messages in thread
From: ChenQi @ 2014-10-24 7:37 UTC (permalink / raw)
To: Koen Kooi; +Cc: openembedded-core
On 10/24/2014 02:09 PM, Koen Kooi wrote:
>> Op 24 okt. 2014, om 07:58 heeft Chen Qi <Qi.Chen@windriver.com> het volgende geschreven:
>>
>> The new version of systemd has implemented the following feature.
>> Opointer.de/blog/projects/stateless.html
>>
>> As a result, the systemd-udev-hwdb-update.service would always run
>> at first boot. This will cause failure if the target device doesn't
>> have enough storage space. Besides, as we run `udevadm hwdb --update' as
>> a postinst of udev-hwdb at rootfs time, there's no need to run this
>> again at system start-up.
>>
>> The purpose of this patch is as follows.
>> If `udev hwdb --update' fails at rootfs time, systemd-udev-hwdb-update.service
>> is executed at first boot; otherwise, the service is not executed.
>>
>> This patch achieves the above goal by setting CondistonNeedsUpdate to
>> "/etc/udev" in the service file, and creating /etc/udev/.updated file if the
>> postinst succeeds.
> Ehm, /etc/udev can be created by other packages, why not test for the file you create?
>
> regards,
>
> Koen
>
Hi Koen,
The tested path must be a directory. If we test a file, then condition
will always be true.
Below are the related codes from systemd:
<code_snippet>
static bool condition_test_needs_update(Condition *c) {
const char *p;
struct stat usr, other;
assert(c);
assert(c->parameter);
assert(c->type == CONDITION_NEEDS_UPDATE);
/* If the file system is read-only we shouldn't suggest an
update */
if (path_is_read_only_fs(c->parameter) > 0)
return c->negate;
/* Any other failure means we should allow the condition to be
true,
* so that we rather invoke too many update tools then too
* few. */
if (!path_is_absolute(c->parameter))
return !c->negate;
p = strappenda(c->parameter, "/.updated");
if (lstat(p, &other) < 0)
return !c->negate;
if (lstat("/usr/", &usr) < 0)
return !c->negate;
return (usr.st_mtim.tv_sec > other.st_mtim.tv_sec ||
(usr.st_mtim.tv_sec == other.st_mtim.tv_sec &&
usr.st_mtim.tv_nsec > other.st_mtim.tv_nsec)) == !c->negate;
}
</code_snippet>
This patch makes use of the '.updated' trick.
Best Regards,
Chen Qi
>> Signed-off-by: Chen Qi <Qi.Chen@windriver.com>
>> ---
>> meta/recipes-core/systemd/systemd_216.bb | 18 +++++++++++++++---
>> 1 file changed, 15 insertions(+), 3 deletions(-)
>>
>> diff --git a/meta/recipes-core/systemd/systemd_216.bb b/meta/recipes-core/systemd/systemd_216.bb
>> index ebf9395..cd81818 100644
>> --- a/meta/recipes-core/systemd/systemd_216.bb
>> +++ b/meta/recipes-core/systemd/systemd_216.bb
>> @@ -149,6 +149,10 @@ do_install() {
>>
>> # Enable journal to forward message to syslog daemon
>> sed -i -e 's/.*ForwardToSyslog.*/ForwardToSyslog=yes/' ${D}${sysconfdir}/systemd/journald.conf
>> +
>> + # Make systemd-udev-hwdb-update to check /etc/udev
>> + cp ${D}${systemd_unitdir}/system/systemd-udev-hwdb-update.service ${D}${sysconfdir}/systemd/system
>> + sed -i -e 's#ConditionNeedsUpdate=/etc#ConditionNeedsUpdate=/etc/udev#g' ${D}${sysconfdir}/systemd/system/systemd-udev-hwdb-update.service
>> }
>>
>> do_install_ptest () {
>> @@ -355,10 +359,18 @@ ALTERNATIVE_PRIORITY[runlevel] ?= "300"
>>
>> pkg_postinst_udev-hwdb () {
>> if test -n "$D"; then
>> - ${@qemu_run_binary(d, '$D', '${base_bindir}/udevadm')} hwdb --update \
>> - --root $D
>> + if ${@qemu_run_binary(d, '$D', '${base_bindir}/udevadm')} hwdb --update \
>> + --root $D; then
>> + touch $D/etc/udev/.updated
>> + else
>> + exit 1
>> + fi
>> else
>> - udevadm hwdb --update
>> + if udevadm hwdb --update; then
>> + touch $D/etc/udev/.updated
>> + else
>> + exit 1
>> + fi
>> fi
>> }
>>
>> --
>> 1.9.1
>>
>> --
>> _______________________________________________
>> Openembedded-core mailing list
>> Openembedded-core@lists.openembedded.org
>> http://lists.openembedded.org/mailman/listinfo/openembedded-core
>>
>
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2014-10-24 7:36 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2014-10-24 5:58 [PATCH 0/1] systemd: fix systemd-udev-hwdb-update service Chen Qi
2014-10-24 5:58 ` [PATCH 1/1] " Chen Qi
2014-10-24 6:09 ` Koen Kooi
2014-10-24 7:37 ` ChenQi
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox