add (un)installation support for Harmattan
[busybox-power] / debian / scripts / functions
index 10bfb5e..921dad4 100644 (file)
@@ -6,8 +6,6 @@
 # By Dennis Groenen <tj.groenen@gmail.com>
 # GPLv3 licensed
 #
-# Last updated: 08-24-2012 (MM-DD-YYYY)
-# 
 
 # Verbose-aware echo
 ECHO_VERBOSE() {
@@ -20,11 +18,19 @@ CHECK_ENV() {
     if test -d /scratchbox; then
       ENVIRONMENT="SDK"
     else
-      PROD=$($EXECPWR cat /proc/component_version | $EXECPWR grep product | $EXECPWR cut -d" " -f 6)
+      if test -e /proc/component_version; then
+        PROD=$($EXECPWR cat /proc/component_version | $EXECPWR grep product | $EXECPWR cut -d" " -f 6)
+      else
+        PROD=$(/usr/bin/sysinfoclient --get /component/product | $EXECPWR awk '{ print $3 }')
+      fi
+
       case $PROD in
         RX-51)
           ENVIRONMENT="FREMANTLE"
           ;;
+        RM-680|RM-696)
+          ENVIRONMENT="HARMATTAN"
+          ;;
         *)
           # Unsupported, use the least strict environment (SDK)
           ENVIRONMENT="SDK"
@@ -33,24 +39,28 @@ CHECK_ENV() {
     fi
 }
 
-# Check whether I'm running standalone
-CHECK_STANDALONE() {
-    #if test -n "`pgrep dpkg`" -o "`pgrep apt`"
-    if ! lsof /var/lib/dpkg/lock >> /dev/null; then 
-      echo "error: you're running me as a stand-alone application"
-      echo "  do not do this, I will be called automatically when"
-      echo "  required by busybox-power"
-      exit 1
-    fi
-}
-
 # Check whether the user is root
 CHECK_ROOT() {
     if test "`$EXECPWR id -u`" -ne 0; then
-      echo "error: you're not running me as root, aborting"
-      echo "  also, DO NOT run me as a stand-alone application"
-      echo "  I will be called automatically when required by"
-      echo "  busybox-power"
+      echo "error: you're not running me as root"
       exit 1
     fi
 }
+
+# Get the version string of the package providing /bin/busybox
+GETBBVERSION() {
+    # XXX We assume the package "busybox" provides /bin/busybox
+    /usr/bin/dpkg -s busybox | $EXECPWR awk '/^Version:/ {print $2}'
+}
+
+# Get the current device mode in Harmattan. Returns "open" or "normal"
+GETDEVICEMODE() {
+    /usr/bin/accli -I | $EXECPWR awk '/^Current mode:/ {print $3}'
+}
+
+# Get the enforcement status of aegis' source origin check. Returns "1" when
+# the check is active, otherwise "0"
+GETORIGINCHECK_STATUS() {
+    /usr/sbin/aegisctl | $EXECPWR sed 's/,.*//' | $EXECPWR grep "s" | $EXECPWR wc -l
+}
+