2 # Author: Elan Ruusamäe <glen@pld-linux.org>
3 # Date: 2006-09-13, Initial revision
4 # Date: 2006-10-31, Added arch checking
6 # For more information see browser-plugins.README
9 # - implement uninstall
11 sysconfdir='/etc/browser-plugins'
12 browsersdir="$sysconfdir/browsers.d"
13 blacklistdir="$sysconfdir/blacklist.d"
14 plugindirs='/usr/lib/browser-plugins /usr/lib64/browser-plugins'
16 # bool in_blacklist(char *blacklistfile, char *pluginfile)
17 # returns true if pluginfile is listed in blacklistfile
19 local blacklistfile="$1"
22 if [[ "$glob" = \#* ]] || [[ "$glob" = "" ]]; then
25 if [[ "$pluginfile" = $glob ]]; then
26 echo >&3 " $pluginfile blacklisted with $glob ($blacklistfile)"
34 # bool arch_compatible(char *browser, char *plugindir)
35 # returns true if browser and plugindir are from same arch
40 if ([[ "$browser" = *.x86_64 ]] && [[ "$plugindir" != */lib64/* ]]) || \
41 ([[ "$browser" != *.x86_64 ]] && [[ "$plugindir" = */lib64/* ]]); then
42 echo >&3 " $browser not compatible with $plugindir"
48 # bool blacklisted(char *browser, char *pluginfile)
49 # returns true if pluginfile is blacklisted for browser
50 # returns also true if pluginfile is from incompatible arch
54 # check browser blacklist file
55 if [ -f "$blacklistdir/$browser.blacklist" ]; then
56 if in_blacklist "$blacklistdir/$browser.blacklist" "$pluginfile"; then
64 # char **get_browsers(void)
65 # returns list of installed browsers
67 for dir in "$browsersdir"/*.*; do
68 if [ -L "$dir" ]; then
69 if [ ! -d "$dir" ]; then
70 echo >&2 "$0: WARNING: plugindir $dir is not pointing to directory, browser ignored"
73 dir="${dir#$browsersdir/}"
74 browsers="$browsers $dir"
78 echo >&3 "browsers: $browsers"
81 # void update_nspluginwrapper(void)
82 # update nspluginwrapper links
83 update_nspluginwrapper() {
84 [ -x /usr/bin/nspluginwrapper ] || return
87 # call it always in install mode, as update mode does not update existing links
88 /usr/bin/nspluginwrapper -a -i
90 # this will remove oudated plugins
91 for a in /usr/lib64/browser-plugins/npwrapper.*.so; do
93 /usr/bin/nspluginwrapper -v -u $a
96 # run install again after nsplugin wrappers
100 # char *browserplugindir(char *)
101 # returns plugin directory for browser
105 dir=$(readlink "$browsersdir/$browser")
106 if [ ! -d "$dir" -o -z "$dir" ]; then
107 echo >&2 "$0: ERROR: could not resolve plugindir for $browser"
113 # kill dead links to plugins from browser dirs.
114 # dead links appear if plugin is removed or if newer plugin version no longer
115 # includes previously packaged file
117 for browser in $browsers; do
118 find $(browserplugindir "$browser") -type l | while read link; do
119 if [ ! -f "$link" ]; then
120 echo "Removing $link"
129 for plugindir in $plugindirs; do
131 echo >&3 "check $plugindir"
133 # skip non-existing plugindirs
134 [ -d "$plugindir" ] || continue
137 find -type f -o -type l | while read line; do
138 pluginfile="${line#./}"
139 echo >&3 "pluginfile: $pluginfile"
140 for browser in $browsers; do
141 echo >&3 " check $pluginfile for $browser"
142 browserplugindir=$(browserplugindir "$browser")
143 link="$browserplugindir/$pluginfile"
145 if ! arch_compatible "$browser" "$plugindir"; then
149 if blacklisted "$browser" "$pluginfile"; then
150 # just in case unlink it
151 if [ -f "$link" ]; then
152 echo "Removing $pluginfile from $browserplugindir"
156 # skip existing links
157 [ ! -L $link ] || continue
158 if [[ "$pluginfile" = */* ]]; then
159 # FIXME: what's the proper handling for this?
160 echo >&2 "$0: Warning: pluginfile $pluginfile includes subdir, file ignored"
163 echo "Installing $pluginfile to $browserplugindir"
164 ln -s "$plugindir/$pluginfile" "$link"
171 if [[ "$*" = *debug* ]]; then
181 update_nspluginwrapper