b71d7c20b1498bfd8a06c37b0e0257f8f5abd24e
[busybox-power] / debian / busybox-power.preinst
1 #!/bin/sh
2
3 test "$1" = install || exit 0 # upgrades are fine
4
5 # Detect environment
6 if test -d /scratchbox; then
7   echo "busybox-power: Scratchbox environment detected"
8   ENVIRONMENT="SDK"
9 else
10   if test -e /proc/component_version; then
11     PROD=$(cat /proc/component_version | grep product | cut -d" " -f 6)
12   else
13     PROD=$(/usr/bin/sysinfoclient --get /component/product | awk '{ print $3 }')
14   fi
15
16   case $PROD in
17     RX-34|RX-44)
18       echo "busybox-power: Maemo4 (N8x0) environment detected"
19       ENVIRONMENT="DIABLO"
20       ;;
21     RX-51)
22       echo "busybox-power: Maemo5 (N900) environment detected"
23       ENVIRONMENT="FREMANTLE"
24       ;;
25     RM-680|RM-696)
26       echo "busybox-power: MeeGo/Harmattan (N9/50) environment detected"
27       ENVIRONMENT="HARMATTAN"
28       ;;
29     *)
30       echo "busybox-power: unsupported environment: $PROD"
31       exit 1
32       ;;
33   esac
34 fi
35
36 # Don't show the warning message when the user wants an unattended installation
37 # or if $DISPLAY is not set
38 if test -z "$DISPLAY" || test -e /tmp/.bbp-unattended; then exit 0; fi
39
40 # Warning message
41 case $ENVIRONMENT in
42   SDK)
43     # Extra warning doesn't apply to SDK, just exit
44     exit 0
45     ;;
46   DIABLO|FREMANTLE)
47     f=/tmp/busybox-power-msg
48     cat > $f <<EOF
49 Warning: This package touches an essential system binary!
50 Even though installation should be safe, a reflash might be required
51 if something does go wrong (i.e. worst-case scenario).
52
53 Files overwritten by this package:
54 bin/busybox
55 EOF
56     echo "Please confirm the text on the screen of your device"
57     maemo-confirm-text "Installation notes" $f
58     res=$?
59     rm -f $f
60     exit $res
61     ;;
62   HARMATTAN)
63     f=/tmp/busybox-power-msg
64     cat > $f <<EOF
65 Warning: This package touches an essential system binary!
66 Even though installation should be safe, a reflash might be required if something does go wrong (i.e. worst-case scenario).
67
68 Please back up all your valuable data before installing busybox-power.
69
70 Files overwritten by this package:
71 bin/busybox
72 EOF
73     echo "Please confirm the text on the screen of your device"
74     meego-confirm-text "Installation notes" $f > /dev/null 2>&1
75     res=$?
76     rm -f $f
77     exit $res
78     ;;
79 esac
80