2 ############################################################################ ###
3 #@Copyright Copyright (c) Imagination Technologies Ltd. All Rights Reserved
4 #@License Dual MIT/GPLv2
6 # The contents of this file are subject to the MIT license as set out below.
8 # Permission is hereby granted, free of charge, to any person obtaining a copy
9 # of this software and associated documentation files (the "Software"), to deal
10 # in the Software without restriction, including without limitation the rights
11 # to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
12 # copies of the Software, and to permit persons to whom the Software is
13 # furnished to do so, subject to the following conditions:
15 # The above copyright notice and this permission notice shall be included in
16 # all copies or substantial portions of the Software.
18 # Alternatively, the contents of this file may be used under the terms of
19 # the GNU General Public License Version 2 ("GPL") in which case the provisions
20 # of GPL are applicable instead of those above.
22 # If you wish to allow use of your version of this file only under the terms of
23 # GPL, and not to allow others to use your version of this file under the terms
24 # of the MIT license, indicate your decision by deleting the provisions above
25 # and replace them with the notice and other provisions required by GPL as set
26 # out in the file called "GPL-COPYING" included in this distribution. If you do
27 # not delete the provisions above, a recipient may use your version of this file
28 # under the terms of either the MIT license or GPL.
30 # This License is also included in this distribution in the file called
33 # EXCEPT AS OTHERWISE STATED IN A NEGOTIATED AGREEMENT: (A) THE SOFTWARE IS
34 # PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING
35 # BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR
36 # PURPOSE AND NONINFRINGEMENT; AND (B) IN NO EVENT SHALL THE AUTHORS OR
37 # COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
38 # IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
39 # CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
40 #### ###########################################################################
41 # Help on how to invoke
44 echo "usage: $0 [options...]"
46 echo "Options: -v Verbose mode."
47 echo " -n Dry-run mode."
48 echo " -u Uninstall-only mode."
49 echo " --root <path> Use <path> as the root of the install file system."
50 echo " (Overrides the DISCIMAGE environment variable.)"
55 SCRIPT_ROOT=`dirname $0`
58 PVRVERSION=[PVRVERSION]
60 PRIMARY_ARCH="[PRIMARY_ARCH]"
61 ARCHITECTURES="[ARCHITECTURES]"
63 # These destination directories are the same for 32- or 64-bit binaries.
64 # zxl: change module's path from /system/modules/ to /system/lib/modules/
65 MOD_DESTDIR=/system/lib/modules
66 BIN_DESTDIR=/system/vendor/bin
67 DATA_DESTDIR=${BIN_DESTDIR}
69 # Exit with an error messages.
73 if [ ! -z "$1" ]; then
78 echo "Installation failed" >&2
82 # Copy all the required files into their appropriate places on the local machine.
83 function install_locally {
84 # Define functions required for local installs
86 # basic installation function
87 # $1=fromfile, $2=destfilename, $3=blurb, $4=chmod-flags, $5=chown-flags
89 function install_file {
90 if [ -z "$DDK_INSTALL_LOG" ]; then
91 bail "INTERNAL ERROR: Invoking install without setting logfile name"
93 DESTFILE=${DISCIMAGE}$2
94 DESTDIR=`dirname $DESTFILE`
97 [ -n "$VERBOSE" ] && echo "skipping file $1 -> $2"
101 # Destination directory - make sure it's there and writable
103 if [ -d "${DESTDIR}" ]; then
104 if [ ! -w "${DESTDIR}" ]; then
105 bail "${DESTDIR} is not writable."
108 $DOIT mkdir -p ${DESTDIR} || bail "Couldn't mkdir -p ${DESTDIR}"
109 [ -n "$VERBOSE" ] && echo "Created directory `dirname $2`"
112 # Delete the original so that permissions don't persist.
114 $DOIT rm -f $DESTFILE
116 $DOIT cp -f $1 $DESTFILE || bail "Couldn't copy $1 to $DESTFILE"
117 $DOIT chmod $4 ${DESTFILE}
119 echo "$3 `basename $1` -> $2"
120 $DOIT echo "file $2" >> $DDK_INSTALL_LOG
123 # Android-specific targetfs mkdir workarounds
124 if [ ! -d ${DISCIMAGE}/data ]; then
125 mkdir ${DISCIMAGE}/data
126 chown 1000:1000 ${DISCIMAGE}/data
127 chmod 0771 ${DISCIMAGE}/data
129 if [ ! -d ${DISCIMAGE}/data/app ]; then
130 mkdir ${DISCIMAGE}/data/app
131 chown 1000:1000 ${DISCIMAGE}/data/app
132 chmod 0771 ${DISCIMAGE}/data/app
135 for arch in $ARCHITECTURES; do
136 if [ ! -d $arch ]; then
137 echo "Unknown architecture $arch. Aborting"
143 SHLIB_DESTDIR=/system/vendor/lib64
146 SHLIB_DESTDIR=/system/vendor/lib
148 EGL_DESTDIR=${SHLIB_DESTDIR}/egl
150 pushd $arch > /dev/null
151 # Install UM components
152 if [ -f install_um.sh ]; then
153 DDK_INSTALL_LOG=$UMLOG
154 echo "Installing User components for architecture $arch"
155 $DOIT echo "version $PVRVERSION" > $DDK_INSTALL_LOG
162 pushd $PRIMARY_ARCH > /dev/null
163 # Install KM components
164 if [ -f install_km.sh ]; then
165 DDK_INSTALL_LOG=$KMLOG
166 echo "Installing Kernel components for architecture $PRIMARY_ARCH"
167 $DOIT echo "version $PVRVERSION" > $DDK_INSTALL_LOG
173 $DOIT mkdir -p ${DISCIMAGE}/system/lib/egl
174 $DOIT cat >${DISCIMAGE}/system/lib/egl/egl.cfg <<EOF
177 $DOIT echo "file /system/lib/egl/egl.cfg" >> $DDK_INSTALL_LOG
179 # Create an OLDLOG so old versions of the driver can uninstall.
180 $DOIT echo "version $PVRVERSION" > $OLDLOG
181 if [ -f $KMLOG ]; then
182 tail -n +2 $KMLOG >> $OLDLOG
184 if [ -f $UMLOG ]; then
185 tail -n +2 $UMLOG >> $OLDLOG
188 # Make sure new logs are newer than $OLDLOG
189 touch -m -d "last sunday" $OLDLOG
192 # Read the appropriate install log and delete anything therein.
193 function uninstall_locally {
194 # Function to uninstall something.
195 function do_uninstall {
198 if [ ! -f $LOG ]; then
199 echo "Nothing to un-install."
205 while read type data; do
208 echo "Uninstalling existing version $data"
212 if [ -z "$VERSION" ]; then
214 echo "No version record at head of $LOG"
215 elif ! $DOIT rm -f ${DISCIMAGE}${data}; then
218 [ -n "$VERBOSE" ] && echo "Deleted $type $data"
226 if [ $BAD = 0 ]; then
227 echo "Uninstallation completed."
230 echo "Uninstallation failed!!!"
234 if [ -z "$OLDLOG" -o -z "$KMLOG" -o -z "$UMLOG" ]; then
235 bail "INTERNAL ERROR: Invoking uninstall without setting logfile name"
238 # Uninstall anything installed using the old-style install scripts.
240 if [ -f $OLDLOG ]; then
241 if [ -f $KMLOG -a $KMLOG -nt $OLDLOG ]; then
242 # Last install was new scheme.
244 elif [ -f $UMLOG -a $UMLOG -nt $OLDLOG ]; then
245 # Last install was new scheme.
248 echo "Uninstalling all components from legacy log."
255 if [ $LEGACY_LOG = 0 ]; then
256 # Uninstall KM components if we are doing a KM install.
257 if [ -f install_km.sh -a -f $KMLOG ]; then
258 echo "Uninstalling Kernel components"
262 # Uninstall UM components if we are doing a UM install.
263 if [ -f install_um.sh -a -f $UMLOG ]; then
264 echo "Uninstalling User components"
271 # Work out if there are any special instructions.
295 if [ ! -z "$DISCIMAGE" ]; then
297 if [ ! -d "$DISCIMAGE" ]; then
298 bail "$0: $DISCIMAGE does not exist."
302 if [ $DISCIMAGE == "/" ]; then
303 echo "Installing PowerVR '$PVRVERSION ($PVRBUILD)' locally"
305 echo "Installing PowerVR '$PVRVERSION ($PVRBUILD)' on $DISCIMAGE"
308 echo "File system installation root is $DISCIMAGE"
311 OLDLOG=$DISCIMAGE/powervr_ddk_install.log
312 KMLOG=$DISCIMAGE/powervr_ddk_install_km.log
313 UMLOG=$DISCIMAGE/powervr_ddk_install_um.log
317 if [ "$UNINSTALL_ONLY" != "y" ]; then
322 bail "DISCIMAGE must be set for installation to be possible."