haltest: Add haltest.target to support HAL TEST mode 43/255743/9 accepted/tizen/unified/20210330.111243 submit/tizen/20210325.061957 submit/tizen/20210330.004535
authorChanwoo Choi <cw00.choi@samsung.com>
Tue, 23 Mar 2021 08:25:16 +0000 (17:25 +0900)
committerChanwoo Choi <cw00.choi@samsung.com>
Thu, 25 Mar 2021 05:00:22 +0000 (14:00 +0900)
In order to support HAL TEST Mode, add haltest.target which requires
the least running processes for only haltest such as sdbd service.
So that haltest.target is based on getty.target to support the console
and then add deviced.service/ac.service for supporting sdbd service.

And reboot-haltest/reboot-normal scripts are for switching between normal
mode and HALTEST mode.

[Essential service list in haltest.target]
- dbus.service for /usr/bin/dbus-daemon
- serial-getty@.service for console
- dlog_logger.service for /usr/bin/dlog_logger
- systemd-udevd.service for /usr/lib/sytemd/sytemd-udevd
- systemd-journald.service for /usr/bin/systemd/systemd-journald
- ac.service for /usr/bin/amd is requied for deviced.service
- deviced.service for /usr/bin/deviced is required for sdbd.service
- sdbd.service for /usr/sbin/sdbd

[Script commands to switch between Normal and HALTEST mode]
- reboot-haltest switches from Normal to HALTEST mode.
- reboot-normal switches from HALTEST to Normal mode.

Change-Id: If8fdd240003cf3509cec5f83bf8aacb3bc1a5ec6
Signed-off-by: Chanwoo Choi <cw00.choi@samsung.com>
packaging/hal-api-common.spec
packaging/haltest.target [new file with mode: 0644]
packaging/reboot-haltest [new file with mode: 0644]
packaging/reboot-normal [new file with mode: 0644]

index 223887f..1844696 100644 (file)
@@ -14,6 +14,9 @@ Source1:    %{name}.manifest
 Source2:    libhal-api.conf
 Source3:    systemd-hal-firmware-generator
 Source4:    macros.hal-api
+Source5:    haltest.target
+Source6:    reboot-haltest
+Source7:    reboot-normal
 
 Requires(post): /sbin/ldconfig
 Requires(postun): /sbin/ldconfig
@@ -67,6 +70,9 @@ 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 0644 %{SOURCE4} %{buildroot}%{_sysconfdir}/rpm/macros.hal-api
+install -D -m 0644 %{SOURCE5} %{buildroot}%{_unitdir}/haltest.target
+install -D -m 0755 %{SOURCE6} %{buildroot}%{_bindir}/reboot-haltest
+install -D -m 0755 %{SOURCE7} %{buildroot}%{_bindir}/reboot-normal
 
 %clean
 rm -rf %{buildroot}
@@ -101,3 +107,6 @@ fi
 
 %files -n %{test_name}
 %{_bindir}/hal/common-haltests
+%{_unitdir}/haltest.target
+%{_bindir}/reboot-haltest
+%{_bindir}/reboot-normal
diff --git a/packaging/haltest.target b/packaging/haltest.target
new file mode 100644 (file)
index 0000000..0b35a53
--- /dev/null
@@ -0,0 +1,6 @@
+[Unit]
+Description=HALTEST Mode
+Requires=basic.target ac.service deviced.service getty.target
+Conflicts=rescue.service rescue.target
+After=basic.target rescue.service rescue.target ac.service deviced.service getty.target
+AllowIsolate=yes
diff --git a/packaging/reboot-haltest b/packaging/reboot-haltest
new file mode 100644 (file)
index 0000000..622939c
--- /dev/null
@@ -0,0 +1,41 @@
+#!/bin/bash
+PATH=/bin:/usr/bin:/sbin:/usr/sbin
+
+user=`whoami`
+default=`systemctl get-default`
+dmverity_path="/usr/bin/verityctl"
+dmverity_cmd=`verityctl get-mode root`
+dmverity_log="dm-verity is disabled (Normal boot)"
+
+if ! [ "$user" = "root" ]
+then
+       echo "HALTEST: Need 'root' permission for switching mode"
+       exit
+fi
+
+if [ -f $dmverity_path ]
+then
+       if ! [ "$dmverity_cmd" = "$dmverity_log" ]
+       then
+               echo "HALTEST: Need to disable DM-VERITY to use HALTEST Mode "
+               echo "HALTEST: Disable DM-VERITY and reboot target "
+               echo "HALTEST: After rebooting, need to execure reboot-haltest again "
+               verityctl disable
+               echo "HALTEST: Rebooting ..."
+               reboot -f
+       fi
+fi
+
+if ! [ "$default" = "haltest.target" ]
+then
+       echo "HALTEST: Switch to HALTEST Mode from Normal Mode"
+       echo "HALTEST: Change default.target from $default to haltest.target"
+       mount -o remount,rw /
+       systemctl set-default haltest.target
+       sync
+       echo "HALTEST: Rebooting ..."
+       reboot -f
+else
+       echo "HALTEST: HALTEST Mode is already enabled (default: $default)"
+fi
+
diff --git a/packaging/reboot-normal b/packaging/reboot-normal
new file mode 100644 (file)
index 0000000..09fafa9
--- /dev/null
@@ -0,0 +1,26 @@
+#!/bin/bash
+
+PATH=/bin:/usr/bin:/sbin:/usr/sbin
+
+user=`whoami`
+default=`systemctl get-default`
+
+if ! [ "$user" = "root" ]
+then
+       echo "HALTEST: Need 'root' permission for switching mode"
+       exit
+fi
+
+if ! [ "$default" = "graphical.target" ]
+then
+       echo "HALTEST: Switch to Normal Mode from HALTEST Mode"
+       echo "HALTEST: Change default.target from $default to graphical.target"
+       mount -o remount,rw /
+       systemctl set-default graphical.target
+       sync
+       echo "HALTEST: Rebooting ..."
+       reboot -f
+else
+       echo "HALTEST: Normal Mode is already enabled (default: $default)"
+fi
+