Fixed emulator to not try to remount /
[webos-internals:acydlords-webos.git] / install
1 #!/bin/sh
2 USER=`whoami`
3 PATCH_NAME=$1
4 GIT_PATH=/opt/src/modifications
5
6 if [ "$USER" != "root" ]
7 then
8   echo "ERROR: Must be root, try sudo -i"
9   exit 1
10 fi
11
12 if [ ! -e $GIT_PATH ]
13 then
14   echo "ERROR: Cannot find git tree at: $GIT_PATH"
15   echo "Please visit http://www.webos-internals.org/wiki/Applying_Patches"
16   exit 1
17 fi
18
19 if [ $# -gt 1 ]
20 then 
21   echo "ERROR: Too many arguments"
22   exit 1
23 fi
24
25 cd $GIT_PATH
26 if [ $? -ne 0 ]
27 then
28   echo "ERROR: Cannot find git path: $GIT_PATH"
29   echo "Please visit http://www.webos-internals.org/wiki/Applying_Patches"
30   exit 1
31 fi
32
33 if [ $# -eq 0 ]
34 then
35   echo ""
36   echo -n "Patch name to apply? [ALL] > "
37   read PATCH_NAME
38 fi
39
40 if [ "$PATCH_NAME" = "-l" ]
41 then
42   find . -name *.patch | awk -F/ '{print $NF}'
43   exit 0
44 fi
45
46 if [ "$PATCH_NAME" != "" ]
47 then
48   echo "Looking for patch $PATCH_NAME..."
49   find . -name $PATCH_NAME | grep $PATCH_NAME
50   if [ $? -ne 0 ]
51   then
52     echo "ERROR: Could not find patch: $PATCH_NAME"
53     exit 1
54   fi
55 fi
56
57 echo "Pulling latest git tree..."
58 git pull
59 if [ $? -ne 0 ]
60 then
61   echo "FAILED"
62   echo "Please visit http://www.webos-internals.org/wiki/Applying_Patches"
63   exit 1
64 fi
65
66 cd /
67 if [ $? -ne 0 ]
68 then
69   echo "Can't cd / ??? ----> RUN!"
70   exit 1
71 fi
72
73
74 if [ "$EMULATOR" = "" ]
75 then
76   echo "Remounting / rw..."
77   mount -o rw,remount /
78   if [ $? -ne 0 ]
79   then
80     echo "ERROR: Could not remount / in rw"
81     echo "Please visit http://www.webos-internals.org/wiki/Applying_Patches"
82     exit 1
83   fi
84 fi
85
86 echo "Popping all previous patches..."
87 quilt pop -a -f
88
89 PATCH_PATH=`find ${GIT_PATH} -name ${PATCH_NAME}`
90 echo "Importing patch ${PATCH_PATH}..."
91 quilt import -f ${PATCH_PATH}
92
93 echo "Verifying patch is in quilt series..."
94 quilt series | grep $PATCH_NAME
95 if [ $? -ne 0 ]
96 then
97   echo "WARNING: Cannot find patch in series"
98   echo "Please visit http://www.webos-internals.org/wiki/Applying_Patches"
99 fi
100
101 echo "Pushing all patches..."
102 quilt push -a
103 if [ $? -ne 0 ]
104 then
105   echo "ERROR: Could not push patch"
106   echo "Please visit http://www.webos-internals.org/wiki/Applying_Patches"
107   exit 1
108 fi
109
110 echo "SUCCESS"
111
112 if [ "$EMULATOR" = "" ]
113 then
114   echo "Remounting / to read-only"
115   mount -o ro,remount /
116 fi