PERL_RUN_DEPENDS and PERL_BUILD_DEPENDS

Edwin Groothuis edwin at mavetju.org
Thu Oct 13 19:17:09 PDT 2005


On Thu, Oct 13, 2005 at 04:40:19PM +0400, Sergey Skvortsov wrote:
> Edwin Groothuis wrote:
> >>>The syntax is:
> >>>   PERL_BUILD_DEPENDS=	MIME-Lite:${PORTSDIR}/mail/p5-MIME-Lite
> >>>It checks the for the existence of MIME::Lite with the "perl -e
> >>>'use MIME::Lite'" command.
> >>Obviously this approach will cause great performance degrade.
> >>stat(2) is much more faster than loading perl.
> >
> >Minimal compared with the time it takes to fetch distfiles and to
> >build. That's the only time it is checked.
> 
> Loading some module (via "use") can take even more time than simply 
> detecting corresponding .pm file because all code is compiled into 
> bytecode-tree. PERL_BUILD_DEPEND is an useless syntax sugar.

To extend the abilities for individual users:

- RUN_DEPENDS=foo:${PORTSDIR}/bar/foo
  If foo isn't in LOCALBASE or X11PREFIX, you can add the directory
  to the PATH  variable and the executable is found.

- LIB_DEPENDS=foo.1:${PORTSDIR}/bar/foo
  If libfoo.so.1 isn't in LOCALBASE/lib or X11PREFIX/lib, you can
  use the ldconfig tool to add the path and the library is found.

Now what if I'm a user who doesn't have root-priveleges on a machine
and still need one or two perl modules which the administrator
doesn't want or isn't able to add new modules.

I could setup a private PREFIX with all the modules there, but the
whole ports building system will choke when checking for dependencies:

    Image a port depending on MIME::Lite and Net::DNS. MIME::Lite
    is in the /usr/local/, Net::DNS is in /home/edwin.

    RUN_DEPENDS=${SITE_PERL}/MIME/Lite.pm \
		${SITE_PERL}/Net/DNS.pm

    And SITE_PERL is ${LOCALBASE}/lib/perl5/...

    Running with PREFIX=LOCALBASE=/usr/local, the first gets detected
    properly but the second not and the installation of it will
    fail.

    Running with PREFIX=/home/edwin, LOCALBASE=/usr/local, the first
    one will be detected and the second one will be installed in
    /home/edwin. Everybody looks happy. Except the next time you
    build this port because it can't find Net::DNS and it will
    attempt to install it again.

    Running with PREFIX=LOCALBASE=/home/edwin, all the modules will
    be installed /home/edwin. That while we only needed one module.

Perl has a environment variable called PERL5LIB which can be used
to override the standard locations modules are being searched for.
Using this variable, the user can just set this variable and only
the missing modules get installed:

    PERL_RUN_DEPENDS=	MIME::Lite \
			Net::DNS

    Running with PREFIX=/home/edwin, the first one gets detected
    because it is in /usr/local/lib/perl5, the second one gets
    detected because it's in the /home/edwin. And next installation
    attempt everything gets properly detected again.

And everybody was happy.

> FYI: "perl -MMIME::Lite -e 0" is right way to check module.

Thank you for that.

Edwin
-- 
Edwin Groothuis      |            Personal website: http://www.mavetju.org
edwin at mavetju.org    |          Weblog: http://weblog.barnet.com.au/edwin/


More information about the freebsd-ports mailing list