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 dir="${dir#$browsersdir/}"
70 browsers="$browsers $dir"
74 echo >&3 "browsers: $browsers"
77 # char *browserplugindir(char *)
78 # returns plugin directory for browser
82 dir=$(readlink "$browsersdir/$browser")
83 if [ -z "$dir" ]; then
84 echo >&2 "$0: ERROR: browser plugin dir pointing to nowhere for $browser!"
90 # kill dead links to plugins from browser dirs.
91 # dead links appear if plugin is removed or if newer plugin version no longer
92 # includes previously packaged file
94 for browser in $browsers; do
95 find $(browserplugindir "$browser") -type l | while read link; do
96 if [ ! -f "$link" ]; then
106 for plugindir in $plugindirs; do
107 # skip non-existing plugindirs
108 [ -d "$plugindir" ] || continue
111 find -type f | while read line; do
112 pluginfile="${line#./}"
113 echo >&3 "pluginfile: $pluginfile"
114 for browser in $browsers; do
115 echo >&3 " check $pluginfile for $browser"
116 browserplugindir=$(browserplugindir "$browser")
117 link="$browserplugindir/$pluginfile"
119 if ! arch_compatible "$browser" "$plugindir"; then
123 if blacklisted "$browser" "$pluginfile"; then
124 # just in case unlink it
125 if [ -f "$link" ]; then
126 echo "Removing $pluginfile from $browserplugindir"
130 # skip existing links
131 [ ! -L $link ] || continue
132 if [[ "$pluginfile" = */* ]]; then
133 # FIXME: what's the proper handling for this?
134 echo >&2 "$0: Warning: pluginfile $pluginfile includes subdir, file ignored"
137 echo "Installing $pluginfile to $browserplugindir"
138 ln -s "$plugindir/$pluginfile" "$link"
145 if [[ "$*" = *debug* ]]; then