Scalar::Util qw( weaken )

classic Classic list List threaded Threaded
8 messages Options
Reply | Threaded
Open this post in threaded view
|

Scalar::Util qw( weaken )

Alex Efros-2
Hi!

I've no idea is installing perl modules from CPAN using
cpan/cpansite/manually instead of using emerge is supported by Gentoo, but
the truth is, dev-perl/ has only 772 packages now while CPAN has much much
more and so it's unavoidable to install a lot of modules from CPAN using
cpan/cpansite/manually if you do a lot of perl development.

    Probably g-cpan tool may help here, but I've not tried it yet.
    Is it able to:
    - automatically resolve and install deep perl module dependencies
    - handle interactive Makefile.PL
    - run tests for all modules by default (without forcing make test on all
      other packages in portage)
    - force install on failed tests
    - local cpan overlays (like cpansite from CPAN::Site)
    ?

After installing many modules using cpan/cpansite/manually you find
yourself managing some perl modules using emerge and others using cpan -
that's not ease and finally you'll unmerge all modules and will
install/update *all* modules using cpan/cpansite. (You will have to add
some perl modules to /etc/portage/profile/package.provided to stop portage
from emerging them.)


Now, we've a problem. After (re-)emerging perl, module Scalar::Util become
broken (and so many other modules which need weaken() function):

    $ perl -e 'use Scalar::Util; print "ok\n"'
    ok

    $ perl -e 'use Scalar::Util qw( weaken ); print "ok\n"'
    Weak references are not implemented in the version of perl at -e line 1
    BEGIN failed--compilation aborted at -e line 1.

    $ perl -e 'use Compress::Zlib; print "ok\n"'
     is only avaliable with the XS version at /usr/lib/perl5/site_perl/5.8.8/Compress/Zlib.pm line 9
    BEGIN failed--compilation aborted at /usr/lib/perl5/site_perl/5.8.8/Compress/Zlib.pm line 9.
    Compilation failed in require at -e line 1.
    BEGIN failed--compilation aborted at -e line 1.

This bug probably related to http://bugs.gentoo.org/show_bug.cgi?id=247585

Because of broken Compress::Zlib we can't use cpan command anymore to
reinstall Scalar::Util, and have to download/unpack/install it manually.

So, it looks like only way to work around this issue is use hook in
/etc/portage/bashrc to reinstall Scalar::Util on "postinst" EBUILD_PHASE
for dev-lang/perl package. Is there any better solution exists?


P.S. Here is my /etc/portage/bashrc.d/dev-lang/perl.postinst:
---cut---
#!/bin/bash
ewarn "Reinstalling Scalar::Util!"
latest=$(lynx -dump -listonly http://cpan.org/modules/by-module/Scalar/ |
    grep '/Scalar-List-Utils-.*\.tar\.gz' |
    awk '{print $2}' |
    perl -Mversion -ne '
        ($n)=/-([\d.]+)/; ($p,$s)=($n,$_) if qv($p)<qv($n); END{print$s}
    ')
if [ "x$latest" != "x" ]; then
    mkdir /tmp/perl-$$/
    wget -q -O - "$latest" | tar xzf - -C /tmp/perl-$$/
    ( cd /tmp/perl-$$/* && perl Makefile.PL && make && make install )
    rm -rf /tmp/perl-$$/
fi
---cut---

--
                        WBR, Alex.

Reply | Threaded
Open this post in threaded view
|

Re: Scalar::Util qw( weaken )

Michele Beltrame
Hi Alex!

I suggest you not use CPAN directly as, as you aready noticed, you'll end in a mess.

If the module you want to install is not in Portage, you can try looking for it
in the perl-experimental overlay (install layman, git, and synchronize the
overlay): there are about 300 commonly-used extra modules there.

If your module isn't there as well, consider asking for  it to be added:
basically you can do that on this list.
Another option is to use CPANPLUS-Dist-Gentoo, which does a better job that
g-cpan as of now.

Hope this helps.

Talk to you soon,
Michele.

--
Michele Beltrame
http://www.italpro.net/
ICQ 76660101 - SkyPe arthas77

Reply | Threaded
Open this post in threaded view
|

Re: Scalar::Util qw( weaken )

Alex Efros-2
Hi!

On Wed, Mar 25, 2009 at 10:35:35AM +0100, Michele Beltrame wrote:
> I suggest you not use CPAN directly as, as you aready noticed, you'll
> end in a mess.

I'd love to use emerge for all my cpan needs, but it's hard to believe
that's possible. :(

> If your module isn't there as well, consider asking for  it to be added:
> basically you can do that on this list.

It's usual for me to take some module from CPAN just to evaluate it in
several minutes and drop. Installing it manually isn't an option because
it may need up to 20-30 other modules as dependencies. Ask in list to add
them in portage has a little sense because chances are I'll not need it
after a day and it's hard to wait for several days until it will be added.

> Another option is to use CPANPLUS-Dist-Gentoo, which does a better job that
> g-cpan as of now.

Thanks, I'll check it. But, in my experience, cpan is still works better
than cpanplus. Also I need to use local overlay with our internal modules,
and so I've to use cpansite instead of cpan/cpanplus.


I've not checked that, but I expect even with modules installed by portage
we still have to manually re-emerge perl-core/Scalar-List-Utils after
re-emerging dev-lang/perl to work around that bug...

--
                        WBR, Alex.

Reply | Threaded
Open this post in threaded view
|

Re: Scalar::Util qw( weaken )

Bugzilla from yuval@gentoo.org
In reply to this post by Alex Efros-2
Alex Efros wrote:
> Because of broken Compress::Zlib we can't use cpan command anymore to
> reinstall Scalar::Util, and have to download/unpack/install it manually.
>  
Both of these modules are actually in portage (perl-core/Compress-Zlib &
perl-core/Scalar-List-Utils), so try re-emerging them first.

And next time do use g-cpan, it will tell you when a corresponding
package exists in portage (and yes, will also resolve dependencies).

Hope this helps -- keep us posted,

   ~Y

Reply | Threaded
Open this post in threaded view
|

Re: Scalar::Util qw( weaken )

Michele Beltrame
In reply to this post by Alex Efros-2
Hi!

> I'd love to use emerge for all my cpan needs, but it's hard to believe
> that's possible. :(

Well, at least not for now. ;)

> It's usual for me to take some module from CPAN just to evaluate it in
> several minutes and drop. Installing it manually isn't an option because
> it may need up to 20-30 other modules as dependencies. Ask in list to add
> them in portage has a little sense because chances are I'll not need it
> after a day and it's hard to wait for several days until it will be added.

It won't be added to portage, but to the perl-experimental overlay. However, if
it depends on 20-30 modules it would be difficult, as someone would need to
maintain it then.

Talk to you soon,
Michele.

--
Michele Beltrame
http://www.italpro.net/
ICQ 76660101 - SkyPe arthas77

Reply | Threaded
Open this post in threaded view
|

Re: Scalar::Util qw( weaken )

Bugzilla from yuval@gentoo.org
In reply to this post by Alex Efros-2
Alex Efros wrote:
> It's usual for me to take some module from CPAN just to evaluate it in
> several minutes and drop. Installing it manually isn't an option because
> it may need up to 20-30 other modules as dependencies. Ask in list to add
> them in portage has a little sense because chances are I'll not need it
> after a day and it's hard to wait for several days until it will be added.
>  

Try g-cpan, it should help you in situations like the one you've mentioned.
Eventually the module + deps turn into ebuilds and are installed with
emerge...

HTH,

  ~Y

Reply | Threaded
Open this post in threaded view
|

Re: Scalar::Util qw( weaken )

Bugzilla from yuval@gentoo.org
In reply to this post by Alex Efros-2
Alex Efros wrote:
> This bug probably related to http://bugs.gentoo.org/show_bug.cgi?id=247585
>
> Because of broken Compress::Zlib we can't use cpan command anymore to
> reinstall Scalar::Util, and have to download/unpack/install it manually.
>
> So, it looks like only way to work around this issue is use hook in
> /etc/portage/bashrc to reinstall Scalar::Util on "postinst" EBUILD_PHASE
> for dev-lang/perl package. Is there any better solution exists?
>  
Oh, almost forgot:
The bug/fix is only relevant when switching between threaded and
unthreaded `perl` (the paths change...).

I could be wrong, but maybe you have/had 2 different installations of
Compress::Zlib/Scalar::Util, one from portage and one directly from cpan?
Just guessing...

Regards,

  ~Y

Reply | Threaded
Open this post in threaded view
|

Re: Scalar::Util qw( weaken )

Steven Lembark
In reply to this post by Alex Efros-2

>     Probably g-cpan tool may help here, but I've not tried it yet.
>     Is it able to:
>     - automatically resolve and install deep perl module dependencies
>     - handle interactive Makefile.PL
>     - run tests for all modules by default (without forcing make test on all
>       other packages in portage)
>     - force install on failed tests
>     - local cpan overlays (like cpansite from CPAN::Site)
>     ?

I've found that it's easier to keep a separate
copy of perl (say "/opt/perl") with my own
development environment. I use different gcc
switches for it and use CPAN to maintain the
contents via "perl -MCPAN -e shell". The
"r" and "upgrade" options make it easy enough
to keep it all up to date.

The system's perl (in /usr/bin/perl) I maintain
via emerge, but only to the extent that any
system programs need it.

That leaves me able to install new modules for
development easily enough and bundle them for
use in production via CPAN (or just use CPAN
with a here-script or use #!perl code with
CPAN.pm) to sync production with necessary
modules. I don't have to worry about breaking
any system code since that uses /usr/bin/perl
and its emerged modules.


--
Steven Lembark                                            85-09 90th St.
Workhorse Computing                                 Woodhaven, NY, 11421
[hidden email]                                      +1 888 359 3508