cast 0 so comparisons with pointers doesn't generate a compiler warning
[gnash.git] / packaging / install-gnash.sh
blob842974e5f5e0c32892a2241f6d9815ff1c53a6af
1 #!/bin/sh
2 #
3 # Copyright (C) 2008, 2009, 2010 Free Software Foundation, Inc.
4 #
5 # This program is free software; you can redistribute it and/or modify
6 # it under the terms of the GNU General Public License as published by
7 # the Free Software Foundation; either version 3 of the License, or
8 # (at your option) any later version.
9 #
10 # This program is distributed in the hope that it will be useful,
11 # but WITHOUT ANY WARRANTY; without even the implied warranty of
12 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 # GNU General Public License for more details.
14 # You should have received a copy of the GNU General Public License
15 # along with this program; if not, write to the Free Software
16 # Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
20 # install script for Gnash binary tarballs.
23 genericdeps="boost gstreamer libpng libjpeg libxml2 libstdc++ curl agg"
24 gtkdeps="gtk2 gtkglext pango atk"
25 kdedeps="kdebase qt"
26 missing=""
28 os=`./config.guess`
30 case $os in
31 *i*86-*-linux*)
33 *64-*-openbsd*|i*86-*-openbsd*)
34 if [ x${BASH} = x ]; then
35 echo "Sorry, you need a more modern shell like bash to run this script"
36 exit
38 genericdeps="boost gstreamer png jpeg libxml-2 libstdc++ curl agg"
42 esac
44 # set to any command to execute to make the shell commands not
45 # make any actual changes on disk. 'echo' is the usual value here
46 # for this, as it just displays the commands to the screen.
47 debug=
49 # set 'yes' to 'yes', and you don't get asked for prompts. Set to 'no'
50 # for the default behaviour. Use with care!!!
51 yes=no
54 # aliases for a few commands to force debug mode while still leaving
55 # the rest of this code readable.
56 COPY="$debug cp -f"
57 REMOVE="$debug rm -f"
58 MOVE="$debug mv -f"
61 # Find an executable file that needs to be in our shell PATH.
63 findbin ()
65 ret=0
67 newpath=`echo $PATH | tr : ' '`
68 for i in ${newpath}; do
69 if [ -x $i/$1 ]; then
70 ret=1
71 break
73 done
75 echo $ret
76 return
80 # See if we can figure out which GNU/Linux or BSD distribution we are running
82 findrelease ()
84 # Ubuntu uses /etc/lsb-release
85 if [ -f /etc/lsb-release ]; then
86 release_name="`grep DISTRIB_ID /etc/lsb-release`"
87 release_version="`grep DISTRIB_RELEASE /etc/lsb-release`"
88 return
91 # Redhat, Fedora, and Centos all use /etc/redhat-release
92 if [ -f /etc/redhat-release ]; then
93 release_name="`cat /etc/redhat-release | cut -d ' ' -f 1`"
94 release_version="`cat /etc/redhat-release | cut -d ' ' -f 3`"
95 return
98 # Debian uses /etc/issue. Fedora uses /etc/issue too, but we
99 # don't need it now.
100 if [ -f /etc/issue ]; then
101 release_name="`cat /etc/issue | cut -d ' ' -f 1`"
102 release_version="`cat /etc/issue | cut -d ' ' -f 3`"
103 return
106 # OpenBSD doesn't appear to use anything, but by default motd does
107 # have the distro name and version, so we try that as most people
108 # never bother to change their motd message anyway.
109 if [ -f /etc/motd ]; then
110 release_name="`cat /etc/motd | head -1 | cut -d ' ' -f 1`"
111 release_version="`cat /etc/motd | head -1 | cut -d ' ' -f 2`"
112 return
117 # This script has a split personality in that it works in an
118 # unconfigured tree, as well as a version with the paths munged
119 # by the normal Gnash configuration process. This way we can
120 # have the final version as included in the tarball have the
121 # paths Gnash was configured with for that build, which seems
122 # a good idea. Running this unconfigured is mostly a maintainer
123 # feature, it's much faster to be avbke to rerun this script than
124 # constantely reconfiguring gnash, which isn't real fast...
125 checkdirs ()
127 # unfortunately the field used for the user name varies depending
128 # on the system.
129 field=0
131 # Root directory used to look for pre existing installations,
132 # as well as were these files get installed to.
133 rootdir="@prefix@"
134 if [ x"${rootdir}" = x"@prefix@" ]; then
135 rootdir="/usr"
138 # This is where the NSAPI (any Geeko based browser like Mozilla,
139 # Netscape, Firefox, Galeon, Ephipany, XO Web Activity, gets
140 # installed. Most browsers, whether proprietary or open software
141 # support NSAPI, but your mileage may vary...
142 nsapidir="@FIREFOX_PLUGINS@"
143 if [ x"${nsapidir}" = x"@FIREFOX_PLUGINS@" ]; then
144 # OpenBSD 4.2, at the least. uses this path for the plugin
145 if [ -d /usr/local/mozilla-firefox/plugins ]; then
146 nsapidir="/usr/local/mozilla-firefox/plugin"s
147 field=4
149 # this is the standard defalt path, common on most GNU/Linux distros
150 if [ -d /usr/lib/mozilla/plugins ]; then
151 nsapidir="/usr/lib/mozilla/plugins"
152 field=3
155 if [ ! -w ${nsapidir} ]; then
156 needstobe="`ls -ld ${nsapidir} | cut -f ${field} -d ' ' 2>&1`"
157 echo "Sorry, you need to be have write permissions to \"${nsapidir}\" to install the Gnash NSAPI plugin"
158 echo "Or be the user \"${needstobe}\""
159 $debug exit
162 # This is where the Kparts plugin gets installed.
163 kpartsplugindir="@KDE_PLUGINDIR@"
164 if [ x"${kpartsplugindir}" = x"@KDE_PLUGINDIR@" ]; then
165 kpartsplugindir="/usr/lib/kde3"
167 if [ -d ${kpartsplugindir} -a ! -w ${kpartsplugindir} ]; then
168 needstobe="`ls -ld ${kpartsplugindir} | cut -f ${field} -d ' ' 2>&1`"
169 echo "Sorry, you need to be have write permissions to \"${kpartsplugindir}\" to install the Gnash Kparts plugin"
170 echo "Or be the user \"${needstobe}\""
171 $debug exit
174 # This is where the Kparts services gets installed.
175 kpartsservicesdir="@KDE_SERVICESDIR@"
176 if [ x"${kpartsservicesdir}" = x"@KDE_SERVICESDIR@" ]; then
177 kpartsservicesdir="/usr/share/services"
179 if [ -d ${kpartsservicesdir} -a ! -w ${kpartsservicesdir} ]; then
180 needstobe="`ls -ld ${kpartsservicesdir} | cut -f ${field} -d ' ' 2>&1`"
181 echo "Sorry, you need to be have write permissions to \"${kpartsservicesdir}\" to install the Gnash Kparts services"
182 echo "Or be the user \"${needstobe}\""
183 $debug exit
186 # This is where the Kparts config gets installed.
187 kpartsconfigdir="@KDE_CONFIGDIR@"
188 if [ x"${kpartsconfigdir}" = x"@KDE_CONFIGDIR@" ]; then
189 kpartsconfigdir="/etc/kde3"
191 if [ -d ${kpartsconfigdir} -a ! -w ${kpartsconfigdir} ]; then
192 needstobe="`ls -ld ${kpartsconfigdir} | cut -f ${field} -d ' ' 2>&1`"
193 echo "Sorry, you need to be have write permissions to \"${kpartsconfigdir}\" to install the Gnash Kparts Config Data"
194 echo "Or be the user \"${needstobe}\""
195 $debug exit
198 # This is where the Kparts appdata gets installed.
199 kpartappsdir="@KDE_APPSDATADIR@"
200 if [ x"${kpartappsdir}" = x"@KDE_APPSDATADIR@" ]; then
201 kpartappsdir="/usr/share/apps/klash"
203 if [ -d ${kpartappsdir} -a ! -w ${kpartappsdir} ]; then
204 needstobe="`ls -ld ${kpartappsdir} | cut -f ${field} -d ' ' 2>&1`"
205 echo "Sorry, you need to be have write permissions to \"${kpartappsdir}\" to install the Gnash Kparts Application Data"
206 echo "Or be the user \"${needstobe}\""
207 $debug exit
210 if [ x"${debug}" != x ]; then
211 echo "NOTE: You have debug mode set to \"${debug}\", no real commands will be executed"
214 if [ ! -w ${rootdir} ]; then
215 needstobe="`ls -ld ${rootdir} | cut -f ${field} -d ' ' 2>&1`"
216 if [ x`whoami` != xroot ]; then
217 echo "Sorry dude, you need to be have write permissions to \"${rootdir}\" to install Gnash"
218 echo "Or be the user \"${needstobe}\""
219 $debug exit
223 # sodir=/etc/ld.so.conf.d
224 # if [ ! -w ${sodir} ]; then
225 # needstobe="`ls -ld ${sodir} | cut -f ${field} -d ' ' 2>&1`"
226 # if [ x`whoami` != xroot ]; then
227 # echo "Sorry dude, you need to be have write permissions to \"${sodir}\" to install Gnash"
228 # echo "Or be the user \"${needstobe}\""
229 # $debug exit
230 # fi
231 # fi
233 # documentation gets installed here
234 docdir="/usr/share/doc"
236 if [ ! -w ${docdir} ]; then
237 needstobe="`ls -ld ${docdir} | cut -f ${field} -d ' ' 2>&1`"
238 if [ x`whoami` != xroot ]; then
239 echo "Sorry dude, you need to be have write permissions to \"${docdir}\" to install Gnash"
240 echo "Or be the user \"${needstobe}\""
241 $debug exit
246 # look for existing installtions of snapshots. As these are date stamped,
247 # it's possible to get many of them from repeated weekly installs of
248 # these Gnash snapshots. So Look for them, and let the user remove pieces
249 # of them to return to a stable state.
250 preexisting ()
252 if [ -d ${rootdir}/lib/gnash -o -d ${rootdir}/lib ]; then
253 existing=`ls -d ${rootdir}/lib/gnash/libgnashbase*.so* ${rootdir}/lib/libgnashbase*.so 2> /dev/null`
254 if [ -n "${existing}" ]; then
255 echo ""
256 echo "You have previous installations of Gnash"
257 file=""
258 for i in $existing; do
259 files="$files `echo $i | sed -e 's:.*gnashbase-::' -e 's:.so::'`"
260 done
261 echo "version: $files"
262 echo "These should to be removed for the best stability of Gnash"
263 if [ x$yes != xyes ]; then
264 read -p "Do you wish to remove these old versions ? [yes] " answer
266 if [ x$answer = xyes -o x$answer = xy ]; then
267 for i in $files; do
268 if [ x$yes != xyes ]; then
269 read -p "Remove Gnash version \"$i\"? [yes] " answer
271 if [ x$answer = xyes -o x$answer = xy ]; then
272 ${REMOVE} $rootdir/lib/libgnash*
274 done
277 existing=`ls -d ${rootdir}/bin/*-gnash 2> /dev/null`
278 if [ -n "${existing}" ]; then
279 echo "You have previous installations of the Gnash GUI"
280 files=""
281 for i in $existing; do
282 files="$files `echo $i | sed -e 's:-gnash::' -e "s:${rootdir}/bin/::"`"
283 done
284 echo "GUIS: $files"
285 echo "These should to be removed for the best stability of Gnash"
286 if [ x$yes != xyes ]; then
287 read -p "Do you wish to remove these old versions ? [yes] " answer
289 if [ x$answer = xyes -o x$answer = xy ]; then
290 for i in $files; do
291 if [ x$yes != xyes ]; then
292 read -p "Remove Gnash GUI \"$i\"? [yes] " answer
294 if [ x$answer = xyes -o x$answer = xy ]; then
295 ${REMOVE} $rootdir/bin/$i-gnash
297 done
299 if [ x$yes != xyes ]; then
300 read -p "Do you wish to remove the gnash shell script too ? [yes] " answer
302 if [ x$answer = xyes -o x$answer = xy ]; then
303 ${REMOVE} $rootdir/bin/gnash
306 else
307 echo "Cool, you don\'t have any preexisting installations of Gnash"
310 return `true`
313 # install all the files to their proper location.
314 # this basically dumplicates what "make install install-plugin"
315 # does, but it's more oriented towards developers than end users.
316 # so this is the more user friendly way to install a binary tarball.
317 install ()
319 # install the NSAPI (Mozilla/Firefox) plugin
320 if [ -e plugins/libgnashplugin.so -o x$yes = xyes ]; then
321 ${COPY} plugins/libgnashplugin.so ${nsapidir}
322 else
323 echo "You don't have the NSAPI plugin, installation can't continue"
324 exit
327 # install the Kparts (KDE/Konqueror) plugin
328 if [ -e lib/kde3/libklashpart.so -o x$yes = xyes ]; then
329 ${COPY} lib/kde3/libklashpart.so ${kpartsplugindir}
330 else
331 echo "You don't have the Kparts plugin, installation can't continue"
332 exit
335 # install the libraries
336 if [ -e lib/gnash/libgnashbase.so -o x$yes = xyes ]; then
337 for i in lib/gnash/libgnash*trunk.so; do
338 ${COPY} $i /usr/lib/
339 linkname=`echo $i | sed -e 's:\-.*.so:.so:' -e 's:\.3.*::'`
340 linkname=`basename ${linkname}`
341 ln -fs /usr/lib/`basename $i` /usr/lib/${linkname}
342 done
343 ${COPY} lib/gnash/libltdl.so.3.* /usr/lib/
344 ln -fs /usr/lib/libltdl.so.3.1.4 /usr/lib/libltdl.so.3
345 ln -fs /usr/lib/libltdl.so.3.1.4 /usr/lib/libltdl.so
346 else
347 echo "You don't have the Gnash libraries, installation can't continue"
348 exit
351 # install the executables
352 if [ -e bin/gtk-gnash -o x$yes = xyes ]; then
353 ${COPY} bin/*gnash bin/gprocessor bin/dumpshm bin/soldumper /usr/bin/
354 else
355 echo "You don't have the Gnash executable, installation can't continue"
356 exit
359 # copy the ld.so.conf file
360 # if [ ! -f /etc/ld.so.conf.d/gnash.conf ]; then
361 # echo " /usr/lib/gnash" > /etc/ld.so.conf.d/gnash.conf
362 # fi
364 # # run ldconfig so the shared libraries can be found.
365 ldconfig
369 # Here's where we make an attempt to see if the dependant
370 # packages Gnash needs are installed. This has a pile of
371 # system dependant code in it, so for now we can only support
372 # the more popular packaging types, namely rpm,.deb, ipkg, and
373 # BSD packages.
375 checkdeps()
377 # first see which packaging system we have to deal with.
378 # First we go through and see what program we can use to
379 # check for installed packages. Note that this does not
380 # currently support finding packages you've built from
381 # source, or installed via a tarball, because neither will
382 # have entries into the package DB.
383 pkginfo="rpm dpkg ipkg pkg_info"
384 for i in $pkginfo; do
385 ret=`findbin $i`
386 if [ $ret -eq 1 ]; then
387 pkginfo=$i
388 echo "Yes, found $i, so we'll use that for listing packages"
389 break
391 done
393 if [ ${pkginfo} = "pkg_info" ]; then
394 # BSD needs PKG_PATH set to load anything over the net.
395 if [ x${PKG_PATH} = x ]; then
396 echo "Pleaase set the environment variable PKG_PATH and try again."
397 exit 1
400 # Usually the program that installs packages isn't the same one
401 # that we can use to check the packaging DB.
402 pkgnet="yum apt-get ipkg pkg_add"
403 for i in ${pkgnet}; do
404 ret=`findbin $i`
405 if [ $ret -eq 1 ]; then
406 pkgnet=$i
407 echo "Yes, found $i, so we'll use that to install packages"
408 break
410 done
412 echo "Looking for dependent packages for GTK2 and KDE..."
413 # first find the packages all configurations of Gnash need
414 for i in ${genericdeps} ${gtkdeps} ${kdedeps}; do
415 case $pkginfo in
416 dpkg)
417 deps="`dpkg -l "*$i*" | grep -- "^ii" | cut -d ' ' -f 3`"
419 rpm)
420 deps="`rpm -q $i`"
422 pkg_info)
423 deps="`pkg_info | grep "$i" | sed -e 's: .*$::'`"
425 ipkg)
426 deps="todo"
429 echo "ERROR: No package manager found!"
430 exit 1
432 esac
433 found=`echo ${deps} | grep -v 'not installed' | grep -c "${i}" 2>&1`
434 if [ $found -gt 0 ]; then
435 echo "Yes, found $i"
436 else
437 echo "Nope, $i appears to not be installed"
438 missing="${missing} $i"
440 done
442 if [ -n "${missing}" ]; then
443 echo "package(s)\"${missing}\" are missing!"
444 echo "You will need sudo priviledges to install the packages"
445 if [ x$yes = xno ]; then
446 $debug sudo ${pkgnet} install ${missing}
447 else
448 $debug sudo ${pkgnet} -y install ${missing}
454 # Get codecs
456 getcodecs()
458 # sudo apt-get install gstreamer0.10-ffmpegsudo apt-get install gstreamer0.10-ffmpeg gstreamer0.10-gl gstreamer0.10-plugins-base gstreamer0.10-plugins-good gstreamer0.10-plugins-bad gstreamer0.10-plugins-bad-multiverse gstreamer0.10-plugins-ugly gstreamer0.10-plugins-ugly-multiverse libxine-extracodecs w32codecs
459 # deb http://archive.ubuntu.com/ubuntu dapper universe multiverse
460 # deb-src http://archive.ubuntu.com/ubuntu dapper universe multiverse
464 echo $0
468 # Here's where all the actions happens
471 # if we have any argument, process them
472 while [ ! -z $1 ]; do
473 case "$1" in
474 rootdir=*)
475 rootdir=`echo $1 | sed -e 's:rootdir=::'`
476 if [ -z "${rootdir}" ]; then
477 echo "ERROR: You need to specify an argument for rootdir="
480 uninstall)
481 checkdirs
482 preexisting
483 exit 0
485 dump)
486 yes=yes
487 findrelease
488 echo "Release name is: ${release_name}"
489 echo "Release version is: ${release_version}"
490 checkdirs
491 echo ""
492 echo "Default paths are: "
493 echo " Root directory is: ${rootdir}"
494 echo " NSAPI directory is: ${nsapidir}"
495 echo " Kparts plugin directory is: ${kpartsplugindir}"
496 echo " Kparts services directory is: ${kpartsservicesdir}"
497 echo " Kparts config data directory is: ${kpartsconfigdir}"
498 echo " Kparts application data directory is: ${kpartappsdir}"
499 echo ""
500 echo "The 'debug' option is set to: \"${debug}\""
501 echo "The 'yes' option is set to: \"${yes}\""
502 echo "The 'COPY' command is set to: \"${COPY}\""
503 echo "The 'REMOVE' command is set to: \"${REMOVE}\""
504 echo "The 'MOVE' command is set to: \"${MOVE}\""
505 exit 0
507 deps)
508 checkdeps
509 exit 1
512 echo "Usage: $0 [rootdir=path dump deps]"
513 echo " \"$1\" isn't a supported option"
514 exit 1
516 esac
517 done
520 # Here's where everything actually gets executed
523 # Check the directory permissions first
524 checkdirs
526 # Look for preexisting installations of Gnash. letting the user
527 # remove them if they so choose
528 preexisting
530 # Install Gnash
531 install