2 # Author: Elan Ruusamäe <glen@pld-linux.org>
4 # See more browser-plugins.README
7 # - implement blacklist.d/anyfile-browser.arch.blacklist support
8 # - check not to link amd64 plugins to opera.i386 dir
10 sysconfdir='/etc/browser-plugins'
11 browsersdir="$sysconfdir/browsers.d"
12 blacklistdir="$sysconfdir/blacklist.d"
13 plugindirs='/usr/lib/browser-plugins /usr/lib64/browser-plugins'
15 # bool in_blacklist(char *blacklistfile, char *pluginfile)
16 # returns true if pluginfile is listed in blacklistfile
18 local blacklistfile="$1"
21 if [[ "$glob" = \#* ]] || [[ "$glob" = "" ]]; then
24 if [[ "$pluginfile" = $glob ]]; then
25 echo >&3 " $pluginfile blacklisted with $glob ($blacklistfile)"
33 # bool blacklisted(char *browser, char *pluginfile)
34 # returns true if pluginfile is blacklisted for browser
38 # check browser blacklist file
39 if [ -f "$blacklistdir/$browser.blacklist" ]; then
40 if in_blacklist "$blacklistdir/$browser.blacklist" "$pluginfile"; then
48 # char **get_browsers(void)
49 # returns list of installed browsers
51 for dir in "$browsersdir"/*.*; do
52 dir="${dir#$browsersdir/}"
53 browsers="$browsers $dir"
56 echo >&3 "browsers: $browsers"
59 # char *browserplugindir(char *)
60 # returns plugin directory for browser
63 readlink "$browsersdir/$browser"
68 for browser in $browsers; do
69 find $(browserplugindir "$browser") -type l | while read link; do
70 [ -f "$link" ] || rm -f "$link"
77 for plugindir in $plugindirs; do
78 # skip non-existing plugindirs
79 [ -d "$plugindir" ] || continue
82 find -type f | while read line; do
83 pluginfile="${line#./}"
84 echo >&3 "pluginfile: $pluginfile"
85 for browser in $browsers; do
86 echo >&3 " check $pluginfile for $browser"
87 browserplugindir=$(browserplugindir "$browser")
88 link="$browserplugindir/$pluginfile"
89 if blacklisted "$browser" "$pluginfile"; then
90 # just in case unlink it
91 if [ -f "$link" ]; then
92 echo "Removing $pluginfile from $browserplugindir"
97 [ ! -L $link ] || continue
98 echo "Installing $pluginfile to $browserplugindir"
99 ln -s "$plugindir/$pluginfile" "$link"
106 if [[ "$*" = *debug* ]]; then