Port from sysV rc script based to systemd based
authorYin Kangkai <kangkai.yin@intel.com>
Fri, 27 Jul 2012 02:19:04 +0000 (10:19 +0800)
committerKarol Lewandowski <k.lewandowsk@samsung.com>
Wed, 5 Dec 2012 15:49:02 +0000 (16:49 +0100)
To port to systemd based, these changes made:

1. config/* remove all the extra "export" keyword, since "EnvironmentFile" in
   systemd does not need that;
2. Remove the run-chg-ani.in and its link in rc2, we will babysit
   charging-animation by systemd.
3. Add charging-mode.service and charging-mode.target, also create a link of
   charging-mode.service in charging-mode.target.wants

Signed-off-by: Yin Kangkai <kangkai.yin@intel.com>
[Polishes and fixes]
4. We will keep all the sysV rc srcripts;
5. Separate platform specific environment variables into
   /etc/sysconfig/charging-animation;
Signed-off-by: Jacek Migacz <j.migacz@samsung.com>
Signed-off-by: Karol Lewandowski <k.lewandowsk@samsung.com>
config/common.cfg
config/tizen.cfg
packaging/charging-animation.changes [new file with mode: 0644]
packaging/charging-animation.spec
packaging/charging-mode.service [new file with mode: 0644]
packaging/charging-mode.target [new file with mode: 0644]
run-chg-ani.in

index 7c42ae3..ebda2ac 100755 (executable)
@@ -1,23 +1,10 @@
-
-export CHG_ENV_BATT_CAP=/sys/class/power_supply/battery/capacity
-export CHG_ENV_BATT_VOL_NOW=/sys/class/power_supply/battery/voltage_now
-export CHG_ENV_BATT_CHG_NOW=/sys/class/power_supply/battery/charge_now
-export CHG_ENV_BATT_TEMP=/sys/class/power_supply/battery/temp
-export CHG_ENV_BATT_CHG_FULL=/sys/class/power_supply/battery/charge_full
-export CHG_ENV_BATT_ONLINE=/sys/class/power_supply/battery/online
-export CHG_ENV_BATT_HEALTH=/sys/class/power_supply/battery/health
-export CHG_ENV_BATT_PRESENT=/sys/class/power_supply/battery/present
-
-export CHG_ENV_POWER_STATE=/sys/power/state
-
-PATH_BRIGHT=
-for file in /sys/class/backlight/*; do
-       if [ -e $file ]; then
-               PATH_BRIGHT=$file
-               break
-       fi
-done
-
-export CHG_ENV_LCD_BRIGHT=${PATH_BRIGHT}/brightness
-
-
+CHG_ENV_BATT_CAP=/sys/class/power_supply/battery/capacity
+CHG_ENV_BATT_VOL_NOW=/sys/class/power_supply/battery/voltage_now
+CHG_ENV_BATT_CHG_NOW=/sys/class/power_supply/battery/charge_now
+CHG_ENV_BATT_TEMP=/sys/class/power_supply/battery/temp
+CHG_ENV_BATT_CHG_FULL=/sys/class/power_supply/battery/charge_full
+CHG_ENV_BATT_ONLINE=/sys/class/power_supply/battery/online
+CHG_ENV_BATT_HEALTH=/sys/class/power_supply/battery/health
+CHG_ENV_BATT_PRESENT=/sys/class/power_supply/battery/present
+
+CHG_ENV_POWER_STATE=/sys/power/state
index ed824e9..b89f00d 100755 (executable)
@@ -1,20 +1,19 @@
+CHG_ENV_SUPPORT_FB=0
+CHG_ENV_SUPPORT_DRM=1
 
-export CHG_ENV_SUPPORT_FB=0
-export CHG_ENV_SUPPORT_DRM=1
+CHG_ENV_DEV_FB=
+CHG_ENV_DEV_DRM_NAME=exynos
 
-export CHG_ENV_DEV_FB=
-export CHG_ENV_DEV_DRM_NAME=exynos
+CHG_ENV_LCD_BRIGHT=/sys/class/backlight/s6e8aa0-bl/brightness
+CHG_ENV_LCD_BR_DIMM_VAL=0
+CHG_ENV_LCD_BR_NORM_VAL=10
 
-export CHG_ENV_LCD_BR_DIMM_VAL=0
-export CHG_ENV_LCD_BR_NORM_VAL=10
+CHG_ENV_LCD_BL_ONOFF=/sys/class/graphics/fb3/blank
+CHG_ENV_LCD_BL_ON_VAL=0
+CHG_ENV_LCD_BL_OFF_VAL=4
+CHG_ENV_LCD_BL_NORM_VAL=
 
-export CHG_ENV_LCD_BL_ONOFF=/sys/class/graphics/fb3/blank
-export CHG_ENV_LCD_BL_ON_VAL=0
-export CHG_ENV_LCD_BL_OFF_VAL=4
-export CHG_ENV_LCD_BL_NORM_VAL=
-
-export CHG_ENV_LCD_XRES=720
-export CHG_ENV_LCD_YRES=1280
-
-export CHG_ENV_KEY_EVENT=/dev/event1
+CHG_ENV_LCD_XRES=720
+CHG_ENV_LCD_YRES=1280
 
+CHG_ENV_KEY_EVENT=/dev/event1
diff --git a/packaging/charging-animation.changes b/packaging/charging-animation.changes
new file mode 100644 (file)
index 0000000..5b3116c
--- /dev/null
@@ -0,0 +1,2 @@
+* Fri Jul 28 2012 Yin Kangkai <kangkai.yin@intel.com>
+- Port from sysV rc script based to systemd based.
index 0b7ee16..891d7d6 100755 (executable)
@@ -6,6 +6,8 @@ Release:    1
 Group:      misc
 License:    Flora Software License
 Source0:    %{name}-%{version}.tar.gz
+Source100:  charging-mode.target
+Source101:  charging-mode.service
 
 BuildRequires: cmake
 
@@ -32,6 +34,13 @@ make %{?jobs:-j%jobs}
 cd cmake_tmp
 %make_install
 
+# systemd related
+mkdir -p %{buildroot}%{_libdir}/systemd/system/
+install -m 0644 %{SOURCE100} %{buildroot}%{_libdir}/systemd/system/
+install -m 0644 %{SOURCE101} %{buildroot}%{_libdir}/systemd/system/
+mkdir -p %{buildroot}%{_libdir}/systemd/system/charging-mode.target.wants
+ln -s ../charging-mode.service %{buildroot}%{_libdir}/systemd/system/charging-mode.target.wants/charging-mode.service
+
 %post
 chmod 755 /etc/rc.d/init.d/run-chg-ani
 mkdir -p /etc/rc.d/rc2.d
@@ -39,8 +48,9 @@ ln -s /etc/rc.d/init.d/run-chg-ani /etc/rc.d/rc2.d/S01charging-animation
 
 %files
 %defattr(-,root,root,-)
-%{_prefix}/bin/*
-%{_prefix}/share/*
-/etc/*
-
-
+%attr(755,-,-) %{_sysconfdir}/rc.d/init.d/run-chg-ani
+%{_sysconfdir}/*
+%{_bindir}/*
+%dir %{_libdir}/systemd/system/charging-mode.target.wants
+%{_libdir}/systemd/system/*
+%{_datadir}/*
diff --git a/packaging/charging-mode.service b/packaging/charging-mode.service
new file mode 100644 (file)
index 0000000..c074f6a
--- /dev/null
@@ -0,0 +1,12 @@
+[Unit]
+Description=Charging Mode Service
+OnFailure=basic.target
+
+[Service]
+Type=simple
+EnvironmentFile=-/usr/share/charging-animation/config/common.cfg
+EnvironmentFile=-/etc/sysconfig/charging-animation
+ExecStartPre=-/bin/bash -c '/bin/echo powersave > /sys/devices/system/cpu/cpu0/cpufreq/scaling_governor'
+ExecStart=/usr/bin/charging-animation
+Restart=always
+RestartSec=5
diff --git a/packaging/charging-mode.target b/packaging/charging-mode.target
new file mode 100644 (file)
index 0000000..901502a
--- /dev/null
@@ -0,0 +1,7 @@
+[Unit]
+Description=Charging Mode
+Conflicts=graphical.target
+AllowIsolate=yes
+
+[Install]
+Alias=default.target
index 10c2366..13e988b 100755 (executable)
@@ -2,6 +2,8 @@
 #
 # For Charging Boot
 
+set -a
+
 do_charging_ani() {
        echo "charging animation ..."
 
@@ -15,6 +17,9 @@ do_charging_ani() {
 
        source @CFGDIR@/common.cfg
 
+       # export the platform specific variables
+       source /etc/sysconfig/charging-animation
+
        if [ "${CHG_ENV_SUPPORT_DRM}" = "1" ]; then
                /sbin/udevd --daemon
                /sbin/udevadm trigger --subsystem-match=drm