View previous topic :: View next topic |
Author |
Message |
CptFastbreak n00b
Joined: 04 Sep 2007 Posts: 16
|
Posted: Tue Jul 01, 2008 9:43 am Post subject: eselect flash-nsplugin |
|
|
I'm actually a bit unsure where this should go, but as it contains a programming-related question I just post it here. I wrote an eselect module to switch between different Flash Mozilla Plugins (see below). It seems to work quite well, at least for me on Multilib Profile, but there is one problem: since most Flash plugins install directly to the nsbrowser/plugins directory, I had to keep the actual library files somewhere else, so that only one plugin is loaded at a time. So I will have to move all files from their install locations to that path for every update - is there a preferred way of handling this? So far I thought of two solutions: (1) have an ebuild DEPEND on all Flash implementations, and move them accordingly, so that re-moving updated files will presumably be handled by revdep-rebuild, or (2) modifying the flash ebuilds so that they install to another directory, similar to the way it is done with mailwrapper. As an additional problem, I used /usr/share/eselect-flash as base directory for the storage of the plugins which seems a bit arbitrary. I wondered if there would be a better location for the libraries, maybe /usr/lib ?
This is the module, based on java-nsplugin.eselect:
Code: |
# 2008 by f.petran based on java-nsplugin
# Copyright 1999-2006 Gentoo Foundation
# Distributed under the terms of the GNU General Public License v2
# $Id: $
inherit tests multilib
DESCRIPTION="Manage the Flash plugin for Netscape-like Browsers"
MAINTAINER=""
SVN_DATE='$Date: $'
VERSION=$(svn_date_to_version "${SVN_DATE}" )
PLUGINS_HOME="${ROOT}/usr/share/eselect-flash"
SYSTEM_PLUGIN_DIR="${ROOT}/usr/lib/nsbrowser/plugins"
SYSTEM_PLUGIN_DIR_32="${ROOT}/usr/lib32/nsbrowser/plugins"
SYSTEM_PLUGIN_DIR_64="${ROOT}/usr/lib64/nsbrowser/plugins"
SYSTEM_PLUGIN="${SYSTEM_PLUGIN_DIR}/flashplugin.so"
SYSTEM_PLUGIN_32="${SYSTEM_PLUGIN_DIR_32}/flashplugin.so"
SYSTEM_PLUGIN_64="${SYSTEM_PLUGIN_DIR_64}/flashplugin.so"
libdirs=$(list_libdirs)
if has lib32 ${libdirs} && has lib64 ${libdirs}; then
IS_MULTILIB="true"
else
IS_MULTILIB="false"
fi
### show action
## {{{ show stuff
describe_show() {
echo "Show the current Flash browser plugin"
}
do_show() {
local system_name=$(get_system_plugin)
write_list_start "Current Flash browser plugin"
if [[ -z "${system_name}" ]] ; then
write_kv_list_entry "(unset)" ""
else
write_kv_list_entry "${system_name}" ""
fi
}
## }}}
### list action
## {{{ list stuff
describe_list() {
echo "List available Flash browser plugins"
}
tweak_list_item() {
local mark=""
if [[ ${1} == ${2} ]]; then
mark="${mark} $(highlight 'current')"
fi
echo "${1} ${mark}"
}
tweak_list() {
local targets=( ${@} )
system_name=$(get_system_plugin)
for (( i = 0 ; i < ${#targets[@]} ; i = i + 1 )) ; do
tweak_list_item ${targets[${i}]} ${system_name}
done
}
do_list() {
if [[ ${IS_MULTILIB} != "true" ]]; then
# TODO npn-multilib
MULTILIB_MODE="none"
local system_name=$(get_system_plugin)
local targets=( $(get_targets) )
for (( i = 0 ; i < ${#targets[@]} ; i = i + 1 )) ; do
targets[${i}]=$(tweak_list_item ${targets[${i}]} ${system_name})
done
write_list_start "Available Flash browser plugins"
write_numbered_list "${targets[@]}"
else
MULTILIB_MODE="32"
local system_name_32=$(get_system_plugin)
local targets_32=( $(get_targets) )
for (( i = 0 ; i < ${#targets_32[@]} ; i = i + 1 )) ; do
targets_32[${i}]=$(tweak_list_item ${targets_32[${i}]} ${system_name_32})
done
write_list_start "Available 32-bit Flash browser plugins"
write_numbered_list "${targets_32[@]}"
MULTILIB_MODE="64"
local system_name_64=$(get_system_plugin)
local targets_64=( $(get_targets) )
for (( i = 0 ; i < ${#targets_64[@]} ; i = i + 1 )) ; do
targets_64[${i}]=$(tweak_list_item ${targets_64[${i}]} ${system_name_64})
done
write_list_start "Available 64-bit Flash browser plugins"
write_numbered_list "${targets_64[@]}"
fi
}
## }}}
### set action
## {{{ set stuff
describe_set() {
echo "Set the system Flash browser plugin"
}
do_set() {
if [[ ${IS_MULTILIB} != "true" ]]; then
if [[ ${#} != 1 ]] ; then
die -q "Usage: set [nsplugin]"
fi
MULTILIB_MODE="none"
else
if [[ ${#} != 2 ]] ; then
die -q "Usage: set [32bit or 64bit] [nsplugin]"
fi
case ${1} in
32bit) ;;
64bit) ;;
*)
die -q "Usage: set [32bit or 64bit] [nsplugin]"
;;
esac
MULTILIB_MODE=${1%bit}
shift
fi
local plugin=${1}
if is_number "${plugin}" ; then
local targets=( $(get_targets) )
plugin=${targets[$(( ${plugin} - 1 ))]}
fi
if [[ -z ${plugin} ]] ; then
die -q "You didn't specify valid plugin number to set"
fi
local plugin="${PLUGINS_HOME}/${MULTILIB_MODE}/${plugin}.so"
if [[ ! -f ${plugin} ]]; then
write_error_msg "Expected \"${plugin}\" to exist, but it doesn't."
write_error_msg "Perhaps \"${plugin}\" isn't a valid name of a Flash implementation built with nsplugin?"
return
fi
local system_plugin
case ${MULTILIB_MODE} in
32) system_plugin=${SYSTEM_PLUGIN_32} ;;
64) system_plugin=${SYSTEM_PLUGIN_64} ;;
none) system_plugin=${SYSTEM_PLUGIN} ;;
esac
mkdir -p $(dirname ${system_plugin}) || die -q "Error creating \"$(dirname ${system_plugin})\""
if [[ -w $(dirname ${system_plugin}) ]] ; then
ln -sf ${plugin} ${system_plugin} || die -q "Error creating nsplugin symlink"
else
die -q "Sorry, you don't have enough permission to set nsplugin"
fi
}
## }}}
get_targets() {
for plugin in $(ls ${PLUGINS_HOME}/${MULTILIB_MODE}/*.so 2>/dev/null);
do
echo $(plugin_to_type ${plugin})
done
}
plugin_to_type() {
local base=$(basename ${1})
echo ${base%.so}
}
get_system_plugin() {
local plugin;
if [[ ${MULTILIB_MODE} == "32" ]]; then
plugin=$(readlink ${SYSTEM_PLUGIN_32})
elif [[ ${MULTILIB_MODE} == "64" ]]; then
plugin=$(readlink ${SYSTEM_PLUGIN_64})
else
plugin=$(readlink ${SYSTEM_PLUGIN})
fi
plugin_to_type ${plugin}
}
# vim: ts=4 sw=4 noet fdm=marker
|
|
|
Back to top |
|
|
Polynomial-C Retired Dev
Joined: 01 Jun 2003 Posts: 1432 Location: Germany
|
Posted: Tue Jul 01, 2008 5:57 pm Post subject: |
|
|
Hi,
I didn't test this module but I was in bad need of such a module while I used seamonkey-1.1.x as my preferred webbrowser.
Usually such stuff, that could extend Gentoo, belongs to https://bugs.gentoo.org/ but I'm not sure wether the devs are interested in such a module. Firefox-3 and seamonkey-2 both can en-/disable plugins seperately in their addon managers so this eselect-module could loose it usefulness, once firefox-3/seamonkey-2 become stable in Gentoo (don't misunderstand, seamonkey-2 wasn't even released yet and is still in pre-alpha state).
Cheers
Poly-C _________________ The manual said "Requires Windows10 or better" so I installed GNU/Linux...
my portage overlay
Need a stage1 tarball? (Unofficial builds) |
|
Back to top |
|
|
|
|
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum
|
|