Beefy Boxes and Bandwidth Generously Provided by pair Networks
Keep It Simple, Stupid
 
PerlMonks  

Re^2: CPAN 2.29 stuck with Net::SSLeay

by Aldebaran (Curate)
on Mar 14, 2022 at 00:36 UTC ( [id://11142077]=note: print w/replies, xml ) Need Help??


in reply to Re: CPAN 2.29 stuck with Net::SSLeay
in thread CPAN 2.29 stuck with Net::SSLeahy

On Raspberry Pis, I personally like to use the system Perl and the system package manager to install Perl modules. This may not always give you the latest versions, but things install much faster because nothing needs to be compiled and tested. (Update: In other words, try sudo apt-get install libnet-ssleay-perl.)

Thanks for your response, haukex. I'm not quite sure what you mean with reference to the "system package manager." I find no GUI equivalent of Ubuntu's "synaptic package manager." I prefer to get things done on the command line with *nix. (My windows preference is the opposite, but I prefer not to use Windows.) I wonder if you mean something like dpkg. As it is, I used

sudo apt-get install libnet-ssleay-perl

, and then I was unstuck. Would this be an instance of using the "system package manager," as you mean it?

Update: After fighting with the same install on my droplet, I realize there were other headers that needed to be installed by the system:

sudo apt install zlib1g zlib1g-dev

The droplet had the former but not the latter, and it seems to make a difference.

It's also usually not recommended to use sudo cpan to install modules to the system Perl - use the system's package manager to install packages to the system Perl, or build your own copy of Perl (e.g. perlbrew) to install modules using a CPAN client there. Or, if using the system Perl, use something like local::lib to install modules to your home directory, so the system Perl's libraries are not affected. On Raspberry Pis, one of the first things I do is sudo apt-get install build-essential cpanminus liblocal-lib-perl perl-doc and perl -Mlocal::lib >>~/.profile - see my notes on setting up RPis. (Update: I use local::lib on RPis for those few modules that aren't available in the package repositories or where the version in the system repositories is too old.)

I think that's really solid advise for an rpi. I proceeded as you outline, forsaking sudo cpan, and with the addition of this command:

cpanm --local-lib=~/perl5 local::lib && eval $(perl -I ~/perl5/lib/perl5/ -Mlocal::lib)

cpanm has generally worked very well for my needs. I do have a sticky wicket, where I can't get cpanm to find dependencies:

$ ls requires1.pm $ cpanm --verbose --installdeps . cpanm (App::cpanminus) 1.7044 on perl 5.028001 built for arm-linux-gnu +eabihf-thread-multi-64int ... --> Working on . Entering /home/pi/Documents/curate/req Configuring /home/pi/Documents/curate/req ... N/A ! Configuring . failed. See /home/pi/.cpanm/work/1647208802.16932/buil +d.log for details. Expiring 16 work directories. $ cat requires1.pm package requires1.pm; requires 'AnyEvent::AIO' => '1.1'; requires 'Async::Interrupt' => '1.24'; requires 'Cookie::Baker::XS' => '0.09'; requires 'Device::Firmata' => '0.65'; requires 'Device::SerialPort' => '1.04'; requires 'Device::WebIO' => '0.022'; requires 'Device::WebIO::Dancer' => '0.004'; requires 'Device::WebIO::Firmata' => '0.002'; requires 'Device::WebIO::RaspberryPi' => '0.900'; requires 'DBD::SQLite' => '1.58'; requires 'DBI' => '1.641'; requires 'Guard' => '1.023'; requires 'GPS::NMEA' => '0.17'; requires 'Math::Round' => '0.07'; requires 'RPi::WiringPi' => '2.3628'; requires 'RPi::Pin' => '2.3606'; requires 'Plack::Handler::Twiggy' => '0.1025'; requires 'Starman' => '0.4014'; requires 'Time::HiRes' => '1.9758'; requires 'WWW::Form::UrlEncoded::XS' => '0.25'; 1; $

I couldn't get cpanm to find modules in typical perl .pl scripts, so I herded the requires into a barebones module in its own directory. I don't know how to serve it up any better than that.(?)

On Raspberry Pis, one of the first things I do is sudo apt-get install build-essential cpanminus liblocal-lib-perl perl-doc and perl -Mlocal::lib >>~/.profile - see my notes on setting up RPis. (Update: I use local::lib on RPis for those few modules that aren't available in the package repositories or where the version in the system repositories is too old.)

Your link for setting up rpi's has proved very useful indeed, giving me much more on my plate to come up to speed on. I'm happy to report that I think I have my first fail2ban implementation:

$ sudo fail2ban-client status sshd Status for the jail: sshd |- Filter | |- Currently failed: 0 | |- Total failed: 0 | `- File list: /var/log/auth.log `- Actions |- Currently banned: 0 |- Total banned: 0 `- Banned IP list: $

Regarding section 5,

Crontab to broadcast RPi's address and name

What is the purpose of doing this? Would this cause you to be indexed by search engines, or is it all within 50 yards (meters for bliako)?

crontab -e @reboot hostname | socat -s - UDP-DATAGRAM:255.255.255.255:12340,broad +cast 2>/dev/null * * * hostname | socat -s - UDP-DATAGRAM:255.255.255 +.255:12340,broadcast 2>/dev/null

Can you break this up into parts? I've used crontab once, so that syntax with all the asterisks is familiar. I read that

socat -s

runs it in sloppy mode, and I understand the syntax for sending stderr to the bitbucket.

2>/dev/null

I haven't cottoned onto it yet, even fiddling with  udplisten.pl

I have run:

$ sudo ufw allow in 12340/udp Rule added Rule added (v6) $

, and was astonished to get somewhere in the debugger with it:

$ pwd /home/pi/Documents/curate/req $ ls 1.udplisten.pl requires1.pm $ perl -d 1.udplisten.pl -e '/HELLO xyZ129/' Loading DB routines from perl5db.pl version 1.53 Editor support available. Enter h or 'h h' for help, or 'man perldebug' for more help. main::(1.udplisten.pl:77): $Getopt::Std::STANDARD_HELP_VERSION = 1; DB<1> b 86 + DB<2> c + main::(1.udplisten.pl:86): my $RXSZ = $opts{b}//1024; DB<2> p $EXPR + /HELLO xyZ129/ DB<3> c + 192.168.red.acted Debugged program terminated. Use q to quit or R to restart, use o inhibit_exit to avoid stopping after program termination, h q, h R or h o to get additional info. DB<3> + DB<3> save 1.udp.txt + commands saved in 1.udp.txt DB<4> q + $

, with another terminal, doing:

echo "HELLO xyZ129" | socat - UDP-DATAGRAM:255.255.255.255:12340,broad +cast
If you still want to try installing Net::SSLeay yourself, you can also use the apt command to get most programs' build dependencies; in this case, try sudo apt-get build-dep libnet-ssleay-perl.
sudo apt-get build-dep libnet-ssleay-perl

I used this with my droplet in the cloud.

In general, I would recommend cpanm over the default CPAN client. Its --verbose option will show you the whole build process, giving you the exact error messages when stuff fails.

I sure like cpanm too when I finally get the thing kickstarted.

cpanm Term::ReadKey

I always need to do this, too.

Again, thanks for your comments. Gruss aus Amiland,

Replies are listed 'Best First'.
Re^3: CPAN 2.29 stuck with Net::SSLeay (updated)
by haukex (Archbishop) on Mar 14, 2022 at 07:32 UTC
    I'm not quite sure what you mean with reference to the "system package manager." I find no GUI equivalent of Ubuntu's "synaptic package manager." I prefer to get things done on the command line with *nix. ... I wonder if you mean something like dpkg. ... sudo apt-get install libnet-ssleay-perl ... Would this be an instance of using the "system package manager," as you mean it?

    The system package manager is the Advanced Package Tool on Debian-based systems like Ubuntu and Raspbian, and the RPM Package Manager on RedHat-based systems. Synaptic is just a frontend for APT and dpkg is one of the lower-level tools used by APT. Using APT from the commandline is done with the apt* commands, so yes, the apt-get command is what I meant. I personally often use the aptitude frontend for package management from the command line.

    I do have a sticky wicket, where I can't get cpanm to find dependencies: ... Configuring . failed. See /home/pi/.cpanm/work/1647208802.16932/build.log for details.

    You'd have to look into that file for the actual error message and let us know what it is. I might suspect a missing dependency on a lower level than Perl modules, e.g. a C library.

    I herded the requires into a barebones module in its own directory. I don't know how to serve it up any better than that.(?)

    Your requires1.pm would typically be called cpanfile and not start with a package statement. See cpanfile and the corresponding discussion in your thread Using Cartons to automate module installs.

    I couldn't get cpanm to find modules in typical perl .pl scripts

    You might be interested in lazy, though as the name implies, this shouldn't be your package management solution of choice.

    Regarding section 5, Crontab to broadcast RPi's address and name, What is the purpose of doing this? Would this cause you to be indexed by search engines, or is it all within 50 yards

    UDP broadcasts are usually not forwarded by routers, especially not to the Internet, so this should stay within the local network. On some (nowadays many) local networks, the router is smart enough to add a local DNS entry so the RPi can be reached by its hostname. On other networks, this may not be available, so there, this UDP broadcast simply serves for me to discover the IP that the RPi has been assigned. I broadcast the hostname so that I can keep multiple RPi apart (which is why it's a good idea to change the default hostname).

    Update: The background for this is that I prefer a headless setup of my RPis, purely over the network, which is why my notes include instructions on how to enable WiFi and the ssh server. There is a small security risk in not changing the password from the default before the first boot, perhaps I will update my notes in that regard. Update 2: Done. Also, BitBucket wasn't rendering some of the Markdown correctly, which should now be fixed, so those crontab lines you quoted should be readable on the site now (when in doubt, refer to the source). /Update

    Can you break this up into parts

    I'm basicially just sending the hostname in a UDP broadcast packet, where the socat commandline is what I looked up for that purpose, I'm not an socat expert :-) The crontab entries cause that to happen every minute, plus one extra time at boot, and I do 2>/dev/null so I don't get tons of emails from the cron daemon.

      UDP broadcasts are usually not forwarded by routers, especially not to the Internet, so this should stay within the local network. On some (nowadays many) local networks, the router is smart enough to add a local DNS entry so the RPi can be reached by its hostname. On other networks, this may not be available, so there, this UDP broadcast simply serves for me to discover the IP that the RPi has been assigned.

      I see. I've been trying to figure out everything that's going on with your udplisten.pl. I've made some changes primarily to introduce time measurement in a way that I could use for the higher-level abstractions of DateTime. Also, I couldn't understand where the newline after mypi was coming in, but I think that's what Data::Dumper gives the string in dumpstr. Regarding this syntax:

      my $FULLMSG = !!$opts{m};

      I searched for an operator !! in perlop, and not finding it have to believe it's a double application of !, essentially "Not-not". It seems to have the effect of making LHS the same as RHS, whether RHS is defined or not. That was torturous to say; do I have it right?

      Update: The background for this is that I prefer a headless setup of my RPis, purely over the network, which is why my notes include instructions on how to enable WiFi and the ssh server. There is a small security risk in not changing the password from the default before the first boot, perhaps I will update my notes in that regard. Update 2: Done. Also, BitBucket wasn't rendering some of the Markdown correctly, which should now be fixed, so those crontab lines you quoted should be readable on the site now (when in doubt, refer to the source). /Update

      The revision in Markdown did help me make an effective crontab command with this as the result:

      $ crontab -l # Edit this file to introduce tasks to be run by cron. ... # m h dom mon dow command */17 * * * * hostname | socat -s - UDP-DATAGRAM:255.255.255.255:12340 +,broadcast 2>/dev/null $

      Source:

      #!/usr/bin/env perl use warnings; use strict; use 5.010; no feature 'switch'; =head1 SYNOPSIS Waits for message(s) on a UDP port and when a message is received, prints the IP address from which each message was received. udplisten.pl [-m] [-c COUNT] [-a] [-p PORT] [-e EXPR] [-b RXSZ] OPTIONS: -m - Output the entire message, not just the IP address -c COUNT - Exit after receiving this many messages (default=1) -a - Continuously output all messages (overrides -c) -p PORT - UDP port number (default=12340) -e EXPR - Output only messages which match this Perl expression -b RXSZ - Receive length (default=1024) =head1 DETAILS The message can be transmitted, for example, via the following L<crontab(5)> entry (note: C<sudo apt-get install socat>): * * * * * echo "HELLO xyZ129" | socat - UDP-DATAGRAM:255.255.255.255 +:12340,broadcast The string used can be completely random; the idea is for it to be uni +que to your device so you can identify it, for example: udplisten.pl -e '/HELLO xyZ129/' Two alternate ways to listen are via L<netcat(1)> or L<socat(1)> (note these will receive and print I<any> messages on that port): netcat -ul 12340 # may need to use -p12340 instead socat -u udp-recv:12340 - Don't forget to open the port for incoming UDP traffic on your local f +irewall, for example for L<UFW|https://wiki.ubuntu.com/UncomplicatedFirewall>: ufw allow in 12340/udp B<Note> that the choice of port number above is completely random. At the time of writing, this port appears to be unused (L<http://www.iana.org/assignments/port-numbers>), but if you've got other things on your network that use this port, cho +ose a different one. You're also free to, for example, use different ports for different de +vices. =head1 AUTHOR, COPYRIGHT, AND LICENSE Copyright (c) 2016 Hauke Daempfling (haukex@zero-g.net) at the Leibniz Institute of Freshwater Ecology and Inland Fisheries (I +GB), Berlin, Germany, L<http://www.igb-berlin.de/> This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program. If not, see L<http://www.gnu.org/licenses/>. =cut use Getopt::Std 'getopts'; use Pod::Usage 'pod2usage'; use IO::Socket::INET (); use Data::Dumper; use DateTime; use DateTime::Format::Duration; sub HELP_MESSAGE { pod2usage( -output => shift ); return } sub VERSION_MESSAGE { say {shift} q$udplisten.pl v2.00$; return } $Getopt::Std::STANDARD_HELP_VERSION = 1; getopts( 'mc:ap:e:b:', \my %opts ) or pod2usage; my $FULLMSG = !!$opts{m}; my $COUNT = $opts{c} // 1; pod2usage("Bad count") unless $COUNT && $COUNT =~ /^\d+$/ && $COUNT > +0; my $ALLMSGS = !!$opts{a}; my $PORT = $opts{p} // 12340; pod2usage("Bad port") unless $PORT && $PORT =~ /^\d+$/ && $PORT > 0; my $EXPR = $opts{e}; my $RXSZ = $opts{b} // 1024; pod2usage("Bad receive length") unless $RXSZ && $RXSZ =~ /^\d+$/ && $R +XSZ > 0; pod2usage("Extra arguments") if @ARGV; my $sock = IO::Socket::INET->new( LocalPort => $PORT, Proto => 'udp', ) or die "error in socket creation: $!"; my $count = 0; my $dt; my $start = DateTime->now; say "Start time is: ", $start->hms; my $later; RXLOOP: while (1) { defined $sock->recv( my $rx, $RXSZ ) or die "error during recv: $!"; my $peeraddr = $sock->peerhost; my $match = 1; if ( defined $EXPR ) { local $_ = $rx; eval "\$match = do { package CodeEval; $EXPR }; 1" or die "Perl expression failed: " . ( $@ || "Unknown error" ); } next RXLOOP unless $match; say "rx is $rx"; say $FULLMSG ? "From $peeraddr: " . dumpstr($rx) : "$peeraddr"; $dt = DateTime->now; say "Time is: ", $dt->hms; $later = $dt; last RXLOOP if !$ALLMSGS && ++$count >= $COUNT; } $sock->close; my $d = DateTime::Format::Duration->new( pattern => '%Y years, %m months, %e days, ' . '%H hours, %M minutes, %S seconds' ); my $duration_object = $later - $start; say $d->format_duration($duration_object); sub dumpstr { chomp( my $s = Data::Dumper->new( [ '' . shift ] )->Terse(1)->Useqq(1)->Dump ); return $s; }

      Slightly-redacted output:

      $ ./2.udplisten.pl -m -c 2 Start time is: 23:30:43 rx is mypi From 192.168.red.acted: "mypi\n" Time is: 23:34:01 rx is mypi From 192.168.red.acted: "mypi\n" Time is: 23:51:01 0 years, 00 months, 0 days, 00 hours, 20 minutes, 18 seconds $

      so, everything's looking pretty good, but I wanted to complete step 4 in your rpi setup, with some attempt to understand it along the way:

      man rsyslog

      On my first attempt, I just tacked it on the end:

      # patch 4/20/2022 -*.*;auth,authpriv.none -/var/log/syslog +*.*;cron,auth,authpriv.none -/var/log/syslog

      , and restarted:

       sudo systemctl restart rsyslog

      , but rsyslog did not want to parse these lines:

      Apr 20 16:41:59 mypi systemd[1]: Stopped System Logging Service. Apr 20 16:41:59 mypi systemd[1]: Starting System Logging Service... Apr 20 16:41:59 mypi rsyslogd: error during parsing file /etc/rsyslog. +conf, on or before line 94: errors occured in file '/etc/rsyslog.conf +' around line 94 [v8.1901.0 try https://www.rsyslog.com/e/2207 ] Apr 20 16:41:59 mypi rsyslogd: error during parsing file /etc/rsyslog. +conf, on or before line 95: invalid character '+' - is there an inval +id escape sequence somewhere? [v8.1901.0 try https://www.rsyslog.com/ +e/2207 ] Apr 20 16:41:59 mypi systemd[1]: Started System Logging Service.

      , so I recalled that I didn't see any notation for a leading + or -, and went with this instead in /etc/rsyslog.conf:

      ############### #### RULES #### ############### # # First some standard log files. Log by facility. # auth,authpriv.* /var/log/auth.log #*.*;auth,authpriv.none -/var/log/syslog *.*;cron,auth,authpriv.none -/var/log/syslog #cron.* /var/log/cron.log daemon.* -/var/log/daemon.log kern.* -/var/log/kern.log lpr.* -/var/log/lpr.log mail.* -/var/log/mail.log user.* -/var/log/user.log

      , and that looks more like it, the parser having no objections. The man page for rsyslog had promised an html page, which I was enjoined to find. When running

       cat /var/log/syslog

      after a successful start, this url was posted as output: www.rsyslog.com, where I finally learned what the r is for in rsyslog. (rocket-fast)

      So, yay, at the pace of a tortoise I think I've got task 4 covered. Thank you for your comments.

      Gruss aus Amiland,

        I searched for an operator !! in perlop, and not finding it have to believe it's a double application of !, essentially "Not-not". It seems to have the effect of making LHS the same as RHS, whether RHS is defined or not. That was torturous to say; do I have it right?

        Almost, but not quite. It makes the LHS the truth of the RHS, not the value. See Bang bang in perlsecret - which is also the place to look for any other combination-operator idiomata you might happen upon.


        🦛

      Your requires1.pm would typically be called cpanfile and not start with a package statement. See cpanfile and the corresponding discussion in your thread Using Cartons to automate module installs.

      Yes, indeed...thank you for the reminder, both then and now. I find myself refering back to previous write-ups when I'm facing the issues of breaking in a new system. A person tries to do the same things, but they are all a bit different. I've been able to get everything loaded except Plack::Handler::Twiggy.

      cpan shows that my version is undef, both before and after I reinstall:

      $ cpan -l | grep Twiggy Twiggy 0.1026 Twiggy::Server undef Twiggy::Server::SS undef Plack::Handler::Twiggy undef

      I try to use cpanm to reinstall:

      $ cpanm --reinstall --verbose Plack::Handler::Twiggy cpanm (App::cpanminus) 1.7044 on perl 5.028001 built for arm-linux-gnu +eabihf-thread-multi-64int ... Fetching http://www.cpan.org/authors/id/M/MI/MIYAGAWA/ ... Entering Twiggy-0.1026 ... Configuring Twiggy-0.1026 ... Checking if your kit is complete... Looks good ... All tests successful. Result: PASS ... 1 distribution installed

      But the needle hasn't moved:

      $ cpan -l | grep Twiggy Twiggy 0.1026 Twiggy::Server undef Twiggy::Server::SS undef Plack::Handler::Twiggy undef $

      , and this consigns this command to failure:

      $ cpanm --verbose --installdeps . cpanm (App::cpanminus) 1.7044 on perl 5.028001 built for arm-linux-gnu +eabihf-thread-multi-64int ... Checking if you have Plack::Handler::Twiggy 0.1025 ... No ... Checking if you have GPS::NMEA 0.17 ... Yes (1.12) ==> Found dependencies: Plack::Handler::Twiggy Searching Plack::Handler::Twiggy (0.1025) on cpanmetadb ... Found Plack::Handler::Twiggy which doesn't satisfy 0.1025. ! Installing the dependencies failed: Installed version (undef) of Pla +ck::Handler::Twiggy is not in range '0.1025' ! Bailing out the installation for .. $

      So I'm still caught in the tentacles of Charybdis with this one module, looking for tips on how to get it installed properly. How do I get Plack::Handler::Twiggy to be version 0.1026 like Twiggy?

      Cheers,

        There is a difference between a distribution and the modules that it contains. If you look at the distribution Twiggy, you'll see it contains those modules, but if you look at the source of the modules, they don't define a $VERSION, which is allowed. Though personally I would try to give every module in a distribution the same version, when it comes to the installation, you don't need to worry about what version the individual modules of a distribution have - when defining dependencies, it's enough to define a dependency on the latest version of the module Twiggy to get all of the modules in its distribution installed.

        Disturbing lack of paths in your verbosity

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://11142077]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others avoiding work at the Monastery: (3)
As of 2024-04-19 17:41 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found