Commit 80c1db26 authored by Stefan Tauner's avatar Stefan Tauner
Browse files

Add scripts to install script prerequisites via CPAN

parent 34625949
@echo off
:: This is the ugliest code I was ever forced to create, sorry.
:: It first evaluates the output of perl -Mlocal::lib=--deactivate-all
:: to reset related environment variables.
:: Then it tries to install the perl packages listed in the variable
:: 'string' below via CPAN.
::
:: For XS packages (using C modules underneath) also a Visual Studio
:: SDK needs to be installed *and set up for command line usage*. The
:: latter requires setting up various environment variables (PATH, LIB,
:: INCLUDE) correctly to make the the build environment accessible.
:: There is in theory a batch file that does that temporarily but its
:: path is not constant between VS versions...
:: This work would never been possible without stackexchange (is that a
:: good thing?).
:: http://stackoverflow.com/questions/8493493/how-to-loop-through-tokens-in-a-string
:: http://stackoverflow.com/questions/3294599/do-batch-files-support-multiline-variables
::
:: Other indispensable resources:
:: http://www.perlmonks.org/?node_id=249803
:: https://social.msdn.microsoft.com/Forums/en-US/2a3c57c5-de79-43e6-9769-35043f732d68/mspdb80dll-was-not-found-#046cb526-e5b3-461d-9fbb-3ec8bf64c8a6
set string= ^
Switch ^
Log::Log4perl ^
Scalar::Util ^
Config::Simple ^
Time::HiRes ^
Digest::CRC ^
Win32::SerialPort
:: Unix version of the latter: Device::SerialPort
::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
:: No need to look further... and I pity you if you do. ::
::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
:: The first iteration of this script used local::lib to compile and
:: install all packages into the local subdirectory defined in variable
:: 'libdir'. This has not worked out and therefore it is not used
:: anymore and everything related is commented out below.
:: set libdir=extlib
:: set f=oreaiptresao.bat
:: if exist %f% del %f%
::
:: for /f "tokens=*" %%i in ('perl ^-Mlocal^:^:lib^=^-^-deactivate^-all') do (
:: echo %%i>>%f%
:: )
::
:: if exist %f% (
:: call %f%
:: del %f%
:: echo Variables deleted
:: ) else (
:: echo Error evaluating perl -Mlocal::lib output
:: goto end
:: )
for %%x in (%string:^= %) do (
echo Trying to install %%x
perl -MCPAN -e "CPAN::Shell->notest('install', '%%x')"
)
:: no comments within for loops...
:: We use notest above because SerialPort tests require a working serial
:: port at build time and the tests require quite some time.
:: Alternatively this could be used instead:
:: perl -MCPAN -e "CPAN::Install('%%x')"
:: The local::lib version is shown below:
:: perl -MCPAN -mlocal::lib -Mlib::core::only -Mlocal::lib=%libdir% -e "CPAN::Shell->notest('install', '%%x')"
:end
#!/bin/bash -e
# Install all required packages from CPAN (root rights via sudo required).
#
# The first iteration of this script used local::lib to compile and
# install all packages into the local subdirectory defined in variable
# 'libdir'. The created packages were not usable across operating
# systems and therefore it is not used anymore and everything related is
# commented out below.
#
# Other ways to deploy Perl applications are fatpack and PAR, but both
# have severe drawbacks as well.
# eval $(perl -Mlocal::lib=--deactivate-all)
packages=$(cat <<'END'
Switch
Log::Log4perl
Scalar::Util
Config::Simple
Time::HiRes
Digest::CRC
Device::SerialPort
END
)
for p in $packages ; do
sudo perl -MCPAN -e "CPAN::Shell->notest('install', '$p')"
# perl -MCPAN -mlocal::lib -Mlib::core::only -Mlocal::lib=extlib -e "CPAN::Shell->notest('install', '$p')"
done
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment