Subject: Re: plugins.mk (doh!)
To: None <reed@reedmedia.net,>
From: Juan RP <juan@xtraeme.unixbsd.org>
List: tech-pkg
Date: 11/09/2003 10:45:32
> On Sat, 8 Nov 2003 20:54:17 -0800 (PST)
> "Jeremy C. Reed" <reed@reedmedia.net> wrote:

> > I think it would be better if was installed to one location and then use
> > symlinks for each browser. So you don't have to install multiple times for
> > each browser.

Ok, you are right, so my patch I think it's finished, this is the test:

[juan@Nocturno][/usr/pkgsrc/graphics/moz-flash][> make deinstall clean
===> Deinstalling for moz-flash
===> Becoming root@Nocturno to deinstall moz-flash.
sudo Running /usr/sbin/pkg_delete -K /var/db/pkg moz-flash-1.0nb5
===> Removing symlinks for moz-flash-1.0nb5

        o Deinstalling plugin for mozilla.
        o Deinstalling plugin for MozillaFirebird.

===> Cleaning for moz-flash-1.0nb5
[juan@Nocturno][/usr/pkgsrc/graphics/moz-flash][>

Looks good now ? :-)

You can specify the common directory which will be used to install
the plugins, later via plugins.mk all browsers will be detected and it
will make a symlink from the plugin to the right location.

For every plugin we have to declare the PLUGIN variable (pointing to
the .so plugin) and WITH_BROWSER, if it's not declared this will use
the default browser choosed by the package, the last one is the
variable PKG_PLUGDIR (by default this will be 
${PREFIX}/share/browser-plugins).

And alternatively we can declare VALID_BROWSERS to show a list of
valid browsers (informational message only).

The patch for graphics/moz-flash using plugins.mk is located here:

	http://xtraeme.unixbsd.org:81/patches/moz-flash.patch

www/mozilla/files/plugins:

---- SNIP ----

# $NetBSD$
#
# Handle the symlinks created for all browsers, used by plugins.mk.
#

BROWSERS="@BROWSERS@"
PKG_PLUGDIR="@PKG_PLUGDIR@"
PLUGIN="@PLUGIN@"

case ${STAGE} in
POST-INSTALL)
        ${ECHO} "===> Installing symlinks for ${PKGNAME}"
        ${ECHO}
        for d in ${BROWSERS}; do
                if [ -d ${PREFIX}/lib/${d} ]; then
                        ${ECHO} "       o Installing plugin for ${d}."
                        ${LN} -sf ${PKG_PLUGDIR}/${PLUGIN} \
                                ${PREFIX}/lib/${d}/plugins
                fi
        done
        ${ECHO}
        ;;
POST-DEINSTALL)
        ${ECHO} "===> Removing symlinks for ${PKGNAME}"
        ${ECHO}
        for d in ${BROWSERS}; do
                if [ -h ${PREFIX}/lib/${d}/plugins/${PLUGIN} ]; then
                        ${ECHO} "       o Deinstalling plugin for ${d}."
                        ${RM} ${PREFIX}/lib/${d}/plugins/${PLUGIN}
                fi
        done
        ${ECHO}
        ;;
esac

---- SNIP ----

www/mozilla/plugins.mk:

---- SNIP ----

# $NetBSD$
#
# Global variables:
#
#       o MASTER_PLUGDIR        (Relative path to the plugins directory)
#       o VALID_BROWSERS        (List of valid browsers)
#       o WITH_BROWSER          (Default browser to use)


.if !defined(PLUGINS_MK)
PLUGINS_MK=     # defined

.include "../../mk/bsd.prefs.mk"

BUILD_DEFS+=            MASTER_PLUGDIR VALID_BROWSERS WITH_BROWSER

PLIST_SUBST+=           MASTER_PLUGDIR=${MASTER_PLUGDIR}
PLIST_SUBST+=           PLUGIN=${PLUGIN}
FILES_SUBST+=           PKG_PLUGDIR=${PKG_PLUGDIR}
FILES_SUBST+=           PLUGIN=${PLUGIN}
FILES_SUBST+=           BROWSERS="${BROWSERS}"

MASTER_PLUGDIR?=        share/browser-plugins
PKG_PLUGDIR=            ${PREFIX}/${MASTER_PLUGDIR}

DEPENDS+=               ${WITH_BROWSER}-[0-9]*:../../www/${WITH_BROWSER}

USE_PKGINSTALL=         yes
INSTALL_EXTRA_TMPL+=    ${.CURDIR}/../../www/mozilla/files/plugins
DEINSTALL_EXTRA_TMPL+=  ${.CURDIR}/../../www/mozilla/files/plugins

OWN_DIRS=               ${PKG_PLUGDIR}

# Is it enough for now ? :-)

BROWSERS=               mozilla mozilla-linux
BROWSERS+=              MozillaFirebird MozillaFirebird-linux
BROWSERS+=              opera opera7
BROWSERS+=              netscape netscape7

.endif  # PLUGINS_MK

---- SNIP ----

That's all...

What do you think about that ?

Cheers,
-- 
Juan Romero Pardines			<juan@xtraeme.unixbsd.org>
Noticias BSD en castellano:	http://www.UnixBSD.org/
El Proyecto NetBSD:			http://www.NetBSD.org/