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
108 echo >&3 "check $plugindir"
110 # skip non-existing plugindirs
111 [ -d "$plugindir" ] || continue
114 find -type f -o -type l | while read line; do
115 pluginfile="${line#./}"
116 echo >&3 "pluginfile: $pluginfile"
117 for browser in $browsers; do
118 echo >&3 " check $pluginfile for $browser"
119 browserplugindir=$(browserplugindir "$browser")
120 link="$browserplugindir/$pluginfile"
122 if ! arch_compatible "$browser" "$plugindir"; then
126 if blacklisted "$browser" "$pluginfile"; then
127 # just in case unlink it
128 if [ -f "$link" ]; then
129 echo "Removing $pluginfile from $browserplugindir"
133 # skip existing links
134 [ ! -L $link ] || continue
135 if [[ "$pluginfile" = */* ]]; then
136 # FIXME: what's the proper handling for this?
137 echo >&2 "$0: Warning: pluginfile $pluginfile includes subdir, file ignored"
140 echo "Installing $pluginfile to $browserplugindir"
141 ln -s "$plugindir/$pluginfile" "$link"
148 if [[ "$*" = *debug* ]]; then