halcc: Move execution of halcc from generator to sysinit.target 82/319282/10
authorYoungjae Cho <y0.cho@samsung.com>
Mon, 21 Oct 2024 02:48:21 +0000 (11:48 +0900)
committerYoungjae Cho <y0.cho@samsung.com>
Wed, 23 Oct 2024 01:16:22 +0000 (10:16 +0900)
systemd generator is executed in serialized order, not in parallel
like systemd services. So the time consumed by a program run by
systemd generator will throughly added up to the overall booting time.
Therefore, convert hal-compatibility-checker into a systemd service
and make it be pulled in by sysinit.target so it can run in parallel,
improving booting time. On top of this, as the service has change to
run as system_fw/system_fw (uid/gid), the permission of directory
/opt/etc/hal created by the service has changed to 0755 to make it
be able to write a file on that directory.

Change-Id: Ia56b8c2ed845c3321db0d9304a0cb182134f0e75
Signed-off-by: Youngjae Cho <y0.cho@samsung.com>
packaging/hal-api-common.spec
packaging/hal-compatibility-checker.service [new file with mode: 0644]
packaging/systemd-hal-compatibility-checker-generator [deleted file]
src/hal-api-compatibility-checker.c

index aba731c65069ac0ef44d21e4886862a27a8203bf..708cc995c21a4442f5e20ce46ecee2cfbffa9439 100644 (file)
@@ -13,7 +13,7 @@ Source0:    %{name}-%{version}.tar.gz
 Source1:    %{name}.manifest
 Source2:    libhal-api.conf
 Source3:    systemd-hal-firmware-generator
-Source4:    systemd-hal-compatibility-checker-generator
+Source4:    hal-compatibility-checker.service
 Source5:    macros.hal-api
 Source6:    haltest.target
 Source7:    reboot-haltest
@@ -71,10 +71,12 @@ make %{?jobs:-j%jobs}
 rm -rf %{buildroot}
 %make_install
 
+mkdir -p %{buildroot}%{_unitdir}
+cp %{SOURCE4} %{buildroot}%{_unitdir}
+
 mkdir -p %{buildroot}/hal
 install -D -m 0644 %{SOURCE2} %{buildroot}%{_sysconfdir}/ld.so.conf.d/libhal-api.conf
 install -D -m 0755 %{SOURCE3} %{buildroot}%{_systemdgeneratordir}/systemd-hal-firmware-generator
-install -D -m 0755 %{SOURCE4} %{buildroot}%{_systemdgeneratordir}/systemd-hal-compatibility-checker-generator
 install -D -m 0644 %{SOURCE5} %{buildroot}%{_sysconfdir}/rpm/macros.hal-api
 install -D -m 0644 %{SOURCE6} %{buildroot}%{_unitdir}/haltest.target
 install -D -m 0755 %{SOURCE7} %{buildroot}%{_bindir}/reboot-haltest
@@ -86,9 +88,11 @@ rm -rf %{buildroot}
 
 %post
 /sbin/ldconfig
+ln -sf %{_unitdir}/hal-compatibility-checker.service %{_unitdir}/sysinit.target.wants/
 
 %postun
 /sbin/ldconfig
+rm -f %{_unitdir}/sysinit.target.wants/hal-compatibility-checker.service
 
 ### contain files to package #########
 %files -n %{name}
@@ -101,7 +105,7 @@ rm -rf %{buildroot}
 %{_bindir}/hal-compatibility-checker
 %{_sysconfdir}/ld.so.conf.d/libhal-api.conf
 %{_systemdgeneratordir}/systemd-hal-firmware-generator
-%{_systemdgeneratordir}/systemd-hal-compatibility-checker-generator
+%{_unitdir}/hal-compatibility-checker.service
 %{_datadir}/upgrade/scripts/500.%{name}.sh
 
 %files -n %{devel_name}
diff --git a/packaging/hal-compatibility-checker.service b/packaging/hal-compatibility-checker.service
new file mode 100644 (file)
index 0000000..819c3e2
--- /dev/null
@@ -0,0 +1,16 @@
+[Unit]
+Description=Generate compatibility information between platform and hal
+DefaultDependencies=no
+Before=sysinit.target
+ConditionPathExists=!/opt/etc/hal/.hal-backend-compatibility
+
+[Service]
+Type=oneshot
+SmackProcessLabel=System
+ExecStart=/usr/bin/hal-compatibility-checker --skip-if-result-exist
+RemainAfterExit=yes
+User=system_fw
+Group=system_fw
+
+[Install]
+WantedBy=sysinit.target
diff --git a/packaging/systemd-hal-compatibility-checker-generator b/packaging/systemd-hal-compatibility-checker-generator
deleted file mode 100644 (file)
index 089071c..0000000
+++ /dev/null
@@ -1,5 +0,0 @@
-#!/bin/sh
-
-PATH=/bin:/usr/bin:/sbin:/usr/sbin
-
-hal-compatibility-checker --skip-if-result-exist
index c9411039eb32127c04f3d9b92fb1472f138d9377..65ea562f7beea0cd8c0971766d01638ab647ee9b 100644 (file)
@@ -291,7 +291,7 @@ static int create_directory(const char *path)
                        break;
 
                *p = '\0';
-               ret = mkdir_one(directory_path, 0644);
+               ret = mkdir_one(directory_path, 0755);
                if (ret < 0)
                        return ret;
                *p = '/';
@@ -299,7 +299,7 @@ static int create_directory(const char *path)
                p = strchr(p + 1, '/');
        }
 
-       return mkdir_one(directory_path, 0644);
+       return mkdir_one(directory_path, 0755);
 
 }