# just a bash function # file: src/bash/deploy/ubuntu/ubuntu-20.04.2-lts/check-install-perl-modules.func.sh do_check_install_perl_modules(){ cd $PRODUCT_DIR # this one is pre-defined in the beginning of your bash script - the proj root dir # define the local::lib dir local_perl5dir=~/perl5 bash_opts_file=~/.bash_opts # bootstrap the cpan conf (echo yes;echo o conf prerequisites_policy follow;echo o conf commit)|cpan cat << EOF_CPAN_CONFIG | cpan o conf makepl_arg 'PREFIX=$local_perl5dir INSTALLMAN3DIR=$local_perl5dir/man/man3' o conf mbuild_arg '--install_base $local_perl5dir' o conf mbuild_install_arg '--install_base $local_perl5dir' o conf mbuildpl_arg '--install-base $local_perl5dir' o conf commit EOF_CPAN_CONFIG perl -MCPAN -e 'install local::lib' curl -L http://cpanmin.us | perl - --self-upgrade -l $local_perl5dir App::cpanminus \ && sudo chown -R $USER:$(id -gn) ~/.cpanm && sudo chown -R $USER:$(id -gn) $local_perl5dir # stored in the src/bash/deploy/ubuntu/ubuntu-20.04.2-lts/check-install-perl-modules.lst file modules="$(cat ${BASH_SOURCE/.func.sh/.lst})" while read -r module ; do use_modules="${use_modules:-} use $module ; "; done < <(echo "$modules"); perl -e "$use_modules" || { echo "deploying modules. This WILL take couple of min, but ONLY ONCE !!!" curl -L cpanmin.us | perl - Mojolicious test "$(grep -c 'Mlocal::lib' $bash_opts_file)" -eq 0 && \ echo 'eval $(perl -I$HOME/perl5/lib/perl5 -Mlocal::lib)' >> $bash_opts_file while read -r module ; do cpanm_modules="${cpanm_modules:-} $module " ; done < <(echo "$modules") cpanm --local-lib=$local_perl5dir local::lib && eval $(perl -I $local_perl5dir/lib/perl5/ -Mlocal::lib) cmd="cpanm --local-lib=$local_perl5dir $modules" set -x $cmd set +e } } #eof file: src/bash/deploy/ubuntu/ubuntu-20.04.2-lts/check-install-perl-modules.func.sh