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