From c562409930d9b142b75a824441809ece8117c528 Mon Sep 17 00:00:00 2001
From: Thierry Escande <thierry.escande@huawei.com>
Date: Wed, 10 Aug 2022 14:17:21 +0200
Subject: [PATCH] openharmony-standard-3.0: Add deviceauth service

Signed-off-by: Thierry Escande <thierry.escande@huawei.com>
---
 .../openharmony/files/deviceauth.service            | 13 +++++++++++++
 .../openharmony/files/deviceauth.service.license    |  3 +++
 .../openharmony/openharmony-standard_3.0.bb         |  8 ++++++++
 3 files changed, 24 insertions(+)
 create mode 100644 recipes-openharmony/openharmony/files/deviceauth.service
 create mode 100644 recipes-openharmony/openharmony/files/deviceauth.service.license

diff --git a/recipes-openharmony/openharmony/files/deviceauth.service b/recipes-openharmony/openharmony/files/deviceauth.service
new file mode 100644
index 00000000..09c7d134
--- /dev/null
+++ b/recipes-openharmony/openharmony/files/deviceauth.service
@@ -0,0 +1,13 @@
+[Unit]
+Description=OpenHarmony Device Authentication daemon
+Requires=samgr.service
+After=samgr.service
+
+[Service]
+Type=exec
+# Delay execution by 2 secs after samgr.service
+ExecStartPre=/bin/sleep 2
+ExecStart=/usr/bin/deviceauth_service
+
+[Install]
+WantedBy=multi-user.target
diff --git a/recipes-openharmony/openharmony/files/deviceauth.service.license b/recipes-openharmony/openharmony/files/deviceauth.service.license
new file mode 100644
index 00000000..98a0b3f4
--- /dev/null
+++ b/recipes-openharmony/openharmony/files/deviceauth.service.license
@@ -0,0 +1,3 @@
+# SPDX-FileCopyrightText: Huawei Inc.
+#
+# SPDX-License-Identifier: Apache-2.0
diff --git a/recipes-openharmony/openharmony/openharmony-standard_3.0.bb b/recipes-openharmony/openharmony/openharmony-standard_3.0.bb
index ac628db5..3f67a774 100644
--- a/recipes-openharmony/openharmony/openharmony-standard_3.0.bb
+++ b/recipes-openharmony/openharmony/openharmony-standard_3.0.bb
@@ -926,6 +926,14 @@ RDEPENDS:${PN}-ptest += "${PN}-security-huks-ptest"
 
 # //base/security/deviceauth
 PACKAGES =+ "${PN}-security-deviceauth"
+SYSTEMD_PACKAGES += "${PN}-security-deviceauth"
+SYSTEMD_SERVICE:${PN}-security-deviceauth = "deviceauth.service"
+SRC_URI += "file://deviceauth.service"
+do_install:append() {
+    install -d ${D}/${systemd_unitdir}/system
+    install -m 644 ${WORKDIR}/deviceauth.service ${D}${systemd_unitdir}/system/
+    rm -f ${D}${sysconfdir}/openharmony/init/deviceauth_service.cfg
+}
 FILES:${PN}-security-deviceauth = " \
     ${bindir}/deviceauth_service \
     ${libdir}/libdeviceauth*${SOLIBS} \
-- 
GitLab