From 270ba2d1b7f2fc766df3fe94edd40d589d6dcf16 Mon Sep 17 00:00:00 2001 From: Will Budic Date: Wed, 17 Sep 2025 15:25:26 +1000 Subject: [PATCH] upd. to install log4perl. --- ...pan_INSTALL_PREPARE_PROJECT_SETUP_FIRST.sh | 23 +++---- install_cpan_modules_required.pl | 60 +++++++++---------- 2 files changed, 43 insertions(+), 40 deletions(-) diff --git a/install_cpan_INSTALL_PREPARE_PROJECT_SETUP_FIRST.sh b/install_cpan_INSTALL_PREPARE_PROJECT_SETUP_FIRST.sh index 2089af3..3bff163 100755 --- a/install_cpan_INSTALL_PREPARE_PROJECT_SETUP_FIRST.sh +++ b/install_cpan_INSTALL_PREPARE_PROJECT_SETUP_FIRST.sh @@ -6,7 +6,7 @@ # It requires to be in sudo to be run for some old modules. # These will be placed here ones found required there to be installed. # If have installed an utility like brew to switch different perl version, -# then locally to users home is best to install separatelly required cpann modules if switching versions. +# then locally to users home is best to install separately required cpan modules if switching versions. # This one is than linked to the brew to find the modules. # Note - Without perlbrew default local is something like: "perl.perlInc": ["/home/will/perl5/lib/perl5","/usr/share/perl/5.38.2/"], # in .config/Code/User/settings.json for vscode. @@ -18,11 +18,20 @@ # $ perl tests/testAll.pl# # As latert Perl v5.36+ version should work fine without the install of local::lib. # + +sudo apt install libanyevent-perl libclass-refresh-perl libcompiler-lexer-perl \ + libdata-dump-perl libio-aio-perl libjson-perl libmoose-perl libpadwalker-perl \ + libscalar-list-utils-perl libcoro-perl; + +sudo cpan -i CPAN::DistnameInfo; +sudo perl -MCPAN -e 'upgrade'; + sudo cpan -i local::lib; sudo cpan -i lib:relative; sudo cpan -i Term::ReadKey; sudo cpan -i Term::Term; sudo cpan -i Term::Screen; +sudo cpan -i Log::Log4perl; sudo cpan -i LWP; sudo cpan -i Text::Levenshtein::XS; @@ -36,14 +45,8 @@ sudo cpan -i DBD::mysql; sudo cpan -i CGI::Session; - -sudo apt install libanyevent-perl libclass-refresh-perl libcompiler-lexer-perl \ - libdata-dump-perl libio-aio-perl libjson-perl libmoose-perl libpadwalker-perl \ - libscalar-list-utils-perl libcoro-perl - - -sudo perl -MCPAN -Mlocal::lib -e 'CPAN::install(Coro)' -sudo perl -MCPAN -Mlocal::lib -e 'CPAN::install(IO:AIO)' -sudo perl -MCPAN -Mlocal::lib -e 'CPAN::install(Perl::LanguageServer)' +sudo cpan -i Coro; +sudo cpan -i IO:AIO; +sudo cpan -i Perl::LanguageServer #./install_cpan_modules_required.pl diff --git a/install_cpan_modules_required.pl b/install_cpan_modules_required.pl index 513170c..cfc0821 100755 --- a/install_cpan_modules_required.pl +++ b/install_cpan_modules_required.pl @@ -8,23 +8,23 @@ use warnings; use strict; # Prerequisites for this script itself. Run first: # cpan Term::ReadKey; # cpan Term::ANSIColor; -## no critic (ProhibitStringyEval) +## no critic (ProhibitStringyEval) use Term::ReadKey; use Term::ANSIColor qw(:constants); -use constant PERL_FILES_GLOB => "*local/*.pl local/*.pm system/modules/*.pm tests/*.pm tests/*.pl .pl *.pm *.cgi"; +use constant PERL_FILES_GLOB => "*local/*.pl local/*.pm system/modules/*.pm tests/*.pm tests/*.pl *.pl *.pm *.cgi"; my $project = `pwd`."/".$0; $project =~ s/\/.*.pl$//g; $project =~ s/\s$//g; my @user_glob; our $PERL_VERSION = $^V->{'original'}; my $ERR = 0; my $key; print WHITE "\n *** Project Perl Module Installer coded by ",BRIGHT_RED, "https://github.com/wbudic", WHITE,"***", qq( - \nRunning scan on project path:$project + \nRunning scan on project path:$project \nYou have Perl on $^O [$^X] version: $PERL_VERSION\n ); -print BLUE "<<@<\@INC<\n# Your default module package paths:\n", YELLOW; -local $. = 0; foreach(@INC){ - print $.++.".: $_\n"; +print BLUE "<<@<\@INC<\n# Your default module package paths:\n", YELLOW; +local $. = 0; foreach(@INC){ + print $.++.".: $_\n"; } print BLUE ">>\n", RESET; if($> > 0){ @@ -33,14 +33,14 @@ if($> > 0){ print "You are INSTALLING modules SYSTEM WIDE, are you sure about this?\n" } if(@ARGV==0){ - print qq(\nThis program will try to figure out now all the modules + print qq(\nThis program will try to figure out now all the modules required for this project, and install them if missing. This can take some time. - ); + ); print RED "Do you want to proceed (press either the 'Y'es or 'N'o key)?", RESET; do{ - ReadMode('cbreak'); + ReadMode('cbreak'); $key = ReadKey(0); print "\n"; ReadMode('normal'); exit 1 if(uc $key eq 'N'); @@ -56,16 +56,16 @@ else{ my @located = glob("$_/*.pl $_/*.pm"); print " ... found ".@located." files."; push @user_glob, @located; - + }else{ warn "Argument: $_ is not a local directory." } } } -my @locals=(); +my @locals=(); print "\nGlobing for perl modules in project $project"; -my @perl_files = glob(PERL_FILES_GLOB); +my @perl_files = glob(PERL_FILES_GLOB); print " ... found ".@perl_files." files.\n"; push @perl_files, @user_glob; my %modules; my %localPackages; @@ -74,13 +74,13 @@ foreach my $file(@perl_files){ if($file =~ /(\w*)\.pm$/){ $localPackages{$1}=$file; } - print "\nExamining:$file\n"; + print "\nExamining:$file\n"; my $res = `perl -ne '/\\s*(^use\\s([a-zA-Z:]*))\\W/ and print "\$2;"' $file`; my @list = split(/;+/,$res); foreach(@list){ if($_=~ /^\w\d\.\d+.*/){ print "\tA specified 'use $_' found in ->$file\n"; - if($PERL_VERSION ne $_){ + if($PERL_VERSION ne $_){ $_ =~s/^v//g; my @fv = split(/\./, $_); $PERL_VERSION =~s/^v//g; @@ -95,21 +95,21 @@ foreach my $file(@perl_files){ } } } - foreach(@list){ + foreach(@list){ $_ =~ s/^\s*|\s*use\s*//g; - $_ =~ s/[\'\"].*[\'\"]$//g; + $_ =~ s/[\'\"].*[\'\"]$//g; next if !$_ or $_ =~ /^[a-z]|\d*\.\d*$|^\W/; $_ =~ s/\(\)|\(.*\)|qw\(.*\)//g; $modules{$_}=$file if $_; print "$_\n"; } - if($file=~/\.pm$/){# it is presumed local package module. + if($file=~/\.pm$/){# it is presumed local package module. $locals[@locals] = `perl -ne '/\\s*(^package\\s(\\w+))/ and print "\$2" and exit' $file`; } } print WHITE "\nList of Modules required for thie project:\n"; -my @missing=(); +my @missing=(); foreach my $mod (sort keys %modules){ my $missing; eval "use $mod"; @@ -117,7 +117,7 @@ foreach my $mod (sort keys %modules){ $missing[@missing] = $mod; print MAGENTA "\t$mod \t in ", $modules{$mod}," is suspicious?\n"; }else{ - print BLUE "\t$mod\n" + print BLUE "\t$mod\n" } }foreach(@missing){ if(exists $localPackages{$_}){ @@ -132,7 +132,7 @@ if($missing_count>0){ foreach my $candidate(@missing){ foreach(@locals){ if($_ eq $candidate && not exists $skip_candidates{$_}){ - $missing_count--; + $missing_count--; $skip_candidates{$_} = 1; print GREEN, "Found the missing $candidate module in locals.\n" } @@ -141,7 +141,7 @@ if($missing_count>0){ } my $perls = `whereis perl`; print GREEN, "Following is all of ",$perls; -print YELLOW, "Reminder -> Make sure you switched to the right brew release.\n" if $perls =~ /perlbrew/; +print YELLOW, "Reminder -> Make sure you switched to the right brew release.\n" if $perls =~ /perlbrew/; print RESET, "Number of local modules:",scalar(@locals),"\n"; print RESET, "Number of external modules:",scalar(keys %modules),"\n"; print RESET, "Number of cpan modules about to be tried to install:",$missing_count,"\n"; @@ -153,7 +153,7 @@ At other times this will only check further your current status. Now (press either the 'Y'es or 'N'o key) please?), RESET; do{ -ReadMode('cbreak'); +ReadMode('cbreak'); $key = ReadKey(0); print "\n"; ReadMode('normal'); exit 1 if(uc $key eq 'N'); @@ -167,7 +167,7 @@ my @kangaroos = sort keys %skip_candidates; ## # Some modules if found to be needed to be forcefeed. can be hardcoded here my friends, why not? ## -foreach (( +foreach (( 'LWP::Simple', 'LWP::Protocol::https', 'XML::LibXML::SAX' @@ -175,7 +175,7 @@ foreach (( $modules{$_}=1; print "Forcefeed: $_\n" } -MODULES_LOOP: +MODULES_LOOP: foreach my $mod (sort keys %modules){ foreach(@kangaroos){ @@ -187,24 +187,24 @@ foreach my $mod (sort keys %modules){ ## no critic (ProhibitStringyEval) eval "use $mod"; if ($@) { - system(qq(perl -MCPAN -e 'install $mod')); + system(qq(perl -MCPAN -e 'install $mod')); if ($? == -1) { print "failed to install: $mod\n"; - }else{ + }else{ my $v = eval "\$$mod\::VERSION"; $v = $v ? "(v$v)" : ""; print "Installed module $mod $v!\n"; $mins++ - } - }else{ - $mod =~ s/\s*$//; + } + }else{ + $mod =~ s/\s*$//; my $v = eval "\$$mod\::VERSION"; $v = $v ? "(v$v)" : ""; print "Skipping module $mod $v, already installed!\n"; } } print "\nProject $project\nRequires $mcnt modules.\nInstalled New: $mins\n"; -print "WARNING! - This project requires in ($ERR) parts code that might not be compatible yet with your installed/running version of perl (v$PERL_VERSION).\n" +print "WARNING! - This project requires in ($ERR) parts code that might not be compatible yet with your installed/running version of perl (v$PERL_VERSION).\n" if $ERR; -- 2.34.1