[Rpm-maint] [PATCH] plugins/systed_inhibit.c: do not load the plugin if not booted with systemd.
Dimitri John Ledkov
dimitri.j.ledkov at intel.com
Mon Oct 20 10:16:43 UTC 2014
Signed-off-by: Dimitri John Ledkov <dimitri.j.ledkov at intel.com>
---
This thus prevents "failed to acquire inhibit lock" error messages in chroots, docker
containers and OBS builders, during package installation.
plugins/systemd_inhibit.c | 17 +++++++++++++++++
1 file changed, 17 insertions(+)
diff --git a/plugins/systemd_inhibit.c b/plugins/systemd_inhibit.c
index a34d7d9..b05d3d2 100644
--- a/plugins/systemd_inhibit.c
+++ b/plugins/systemd_inhibit.c
@@ -1,4 +1,7 @@
#include <dbus/dbus.h>
+#include <sys/types.h>
+#include <sys/stat.h>
+#include <unistd.h>
#include <rpm/rpmlog.h>
#include <rpm/rpmts.h>
#include "lib/rpmplugin.h"
@@ -55,6 +58,19 @@ static int inhibit(void)
return fd;
}
+static rpmRC systemd_inhibit_init(rpmPlugin plugin, rpmts ts)
+{
+ struct stat st;
+
+ if (lstat("/run/systemd/system/", &st) == 0) {
+ if (S_ISDIR(st.st_mode)) {
+ return RPMRC_OK;
+ }
+ }
+
+ return RPMRC_NOTFOUND;
+}
+
static rpmRC systemd_inhibit_tsm_pre(rpmPlugin plugin, rpmts ts)
{
if (rpmtsFlags(ts) & (RPMTRANS_FLAG_TEST|RPMTRANS_FLAG_BUILD_PROBS))
@@ -83,6 +99,7 @@ static rpmRC systemd_inhibit_tsm_post(rpmPlugin plugin, rpmts ts, int res)
}
struct rpmPluginHooks_s systemd_inhibit_hooks = {
+ .init = systemd_inhibit_init,
.tsm_pre = systemd_inhibit_tsm_pre,
.tsm_post = systemd_inhibit_tsm_post,
};
--
2.1.0
More information about the Rpm-maint
mailing list