Beefy Boxes and Bandwidth Generously Provided by pair Networks
"be consistent"
 
PerlMonks  

A cpanfile polyglot - for setting up Perl on Termux

by Corion (Patriarch)
on Dec 05, 2024 at 18:59 UTC ( [id://11163045]=perlmeditation: print w/replies, xml ) Need Help??

Recently I got myself a new phone. And, as one does, I installed Termux on it, to have a unix-ish environment for when I need it.

Then, of course, I went to configure Perl and install some modules I'd like there. As this was not my first time doing so, I thought about listing all the modules I want in a cpanfile and then using App::cpanminus to install these, making the process far more reproducible.

But that required some non-Perl prerequisites, like the C compiler, make and perl itself. And of course, also bootstrapping App::cpanminus.

Then I thought a bit on how to combine this setup into a single file. This is what I came up with. It's a cpanfile that doubles as shell script.

#!/bin/bash # This will install cpanminus and then the Perl modules # as listed at the end of this script. To run use # the following commands: # # chmod ugo+x ./cpanfile && ./cpanfile # eval ' pkg install git perl make clang if ! cpanm --help 2>&1 >/dev/null ; then curl -L https://cpanmin.us | perl - App::cpanminus fi DIR=$(dirname "$0") cpanm --installdeps --notest --cpanfile "$DIR" exit ' if 0; requires 'Mojolicious'; requires 'DBIx::Spreadsheet'; #requires 'App::sqldisplay'; # to be released on CPAN requires 'DBIx::RunSQL';

Why not the other way around? Because I could not find a way to make cpanm take a file with a different name than cpanfile :)

The cpanfile is also available on Github, if you want to copy it.

Replies are listed 'Best First'.
Re: A cpanfile polyglot - for setting up Perl on Termux
by etj (Priest) on Dec 07, 2024 at 14:47 UTC
    Would it work to run it just as bash cpanfile? That way you could eliminate the chmod step, saving precious documentation bytes.
Re: A cpanfile polyglot - for setting up Perl on Termux
by LanX (Saint) on Dec 06, 2024 at 10:03 UTC

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: perlmeditation [id://11163045]
Approved by erzuuli
Front-paged by erzuuli
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others goofing around in the Monastery: (4)
As of 2025-01-14 17:40 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    Which URL do you most often use to access this site?












    Results (43 votes). Check out past polls.