kernel-power v48 -> kernel-bfs
[kernel-bfs] / kernel-bfs-2.6.28 / debian / kernel-bfs-uninstall
1 #!/bin/sh
2 tmp=/tmp/kernel-deinstall
3 cat > $tmp <<EOF
4 This program will remove the BFS Linux kernel
5 and restore the original Nokia kernel.
6 Warning: This method is currently experimental and
7 could lead to a bricked device. For a safe but manual
8 method please visit http://wiki.maemo.org/Kernel_Power
9
10 This program only uninstalls "Linux kernel for BFS user".
11 Other packages can be uninstalled in Application Manager.
12
13 Before uninstalling please make sure that you are connected to
14 the Internet and that Application Manager is not running.
15
16 If you want keep the Linux kernel for BFS user installed,
17 cancel this by tapping the blurred area above this dialog.
18 Otherwise confirm the dialog to revert back Nokia kernel.
19
20 After the uninstallation, you need to unplug the USB cable,
21 completely shutdown your device, and start it again.
22 EOF
23 maemo-confirm-text "Linux kernel for BFS/power user" $tmp
24 res=$?
25 rm -f $tmp
26 dbus="run-standalone.sh dbus-send --type=method_call --dest=org.freedesktop.Notifications /org/freedesktop/Notifications"
27 dbusmsg () { $dbus org.freedesktop.Notifications.SystemNoteInfoprint string:"$1"; }
28 dbusbox () { $dbus org.freedesktop.Notifications.SystemNoteDialog string:"$1" uint32:0 string:OK; }
29
30 if test "$res" != 0; then
31     dbusmsg "User has cancelled uninstallation of Linux kernel for BFS user. No changes were made."
32     exit 1
33 fi
34
35 if pgrep -f /usr/bin/hildon-application-manager > /dev/null; then
36     dbusbox "Error: Application Manager is running. Please close it before uninstallation."
37     exit 1
38 fi
39 if pgrep -f apt-worker > /dev/null || pgrep -f apt-get; then
40     dbusbox "Error: apt is running. Please wait and try again later."
41     exit 1
42 fi
43
44 dbusmsg "Please wait while Nokia kernel will be restored..."
45
46 apt-get install --reinstall -y kernel kernel-flasher > $tmp
47 ok=$?
48 cat $tmp
49 if grep -qE "(Could not resolve host|cannot be downloaded)" $tmp; then
50     dbusbox "Error during uninstallation: Could not download Nokia kernel. Please make sure the internet connection is working."
51     rm $tmp
52     exit 1
53 fi
54 if test $ok = 0 && grep -q "Image flashed successfully" $tmp; then :
55 else
56     dbusbox "Error during deinstallation: Could not install Nokia kernel."
57     rm $tmp
58     exit 1
59 fi
60 dbusmsg "Nokia kernel was restored. Removing package \"Linux kernel for BFS user\"..."
61 apt-get remove --auto-remove -y kernel-bfs-flasher > $tmp
62 ok=$?
63 cat $tmp
64 if test $ok = 0; then
65     dbusbox "Linux kernel for BFS user was sucessfully uninstalled. Nokia kernel was restored."
66 else
67     dbusbox "Warning: Nokia kernel was restored but removing package \"Linux kernel for BFS user\" failed."
68 fi
69 rm $tmp
70 exit $ok