From 1082864f96033a2e17586921c60be65eff6f7e7d Mon Sep 17 00:00:00 2001 From: Andreas Romeyke <art1@andreas-romeyke.de> Date: Mon, 25 Oct 2021 17:21:30 +0200 Subject: [PATCH] - init --- build_flat_perl_file.sh | 40 ++++++++++++++++++++++++++++++++++++++++ 1 file changed, 40 insertions(+) create mode 100644 build_flat_perl_file.sh diff --git a/build_flat_perl_file.sh b/build_flat_perl_file.sh new file mode 100644 index 0000000..e97c40c --- /dev/null +++ b/build_flat_perl_file.sh @@ -0,0 +1,40 @@ +#!/bin/bash +# Script to bundle *local* Perl-Module with Script +# by Andreas Romeyke @ SLUB Dresden +WHAT_TO_BUNDLE=bin/slubsipbuilderbagit.pl +LIB_TO_BUNDLE="lib/" +BUNDLE_NAME=slubsipbuilder_bundled.pl +BUNDLE_LOG=bundle.log +echo "#!/usr/bin/env perl" > ${BUNDLE_NAME}; +echo "detecting all *.pm modules in $LIB_TO_BUNDLE and cat them to bundle ${BUNDLE_NAME}" > ${BUNDLE_LOG} +find $LIB_TO_BUNDLE -name "*.pm" -exec cat \{\} \; >> ${BUNDLE_NAME}; +echo "patching main package to bundle ${BUNDLE_NAME}" >> ${BUNDLE_LOG}; +echo "######################################" >> ${BUNDLE_NAME}; +cat <<__MAIN >> ${BUNDLE_NAME} +package main; +BEGIN{ + if ($^O eq 'MSWin32') { + require Win32::Console::ANSI; + Win32::Console::ANSI->import(); + } + ## no critic + # HINT: enhance \$INC foreach module in lib/-dir! + \$INC{'SLUB/LZA/SIPBuilderBagIt.pm'} = 1; # needed because inlined module + ## use critic +} +return 1 if caller; # avoids main code running if module stuff is needed +__MAIN +echo "######################################" >> ${BUNDLE_NAME}; +echo "adding main script to bundle ${BUNDLE_NAME}" >> ${BUNDLE_LOG} +cat ${WHAT_TO_BUNDLE} >> ${BUNDLE_NAME}; +echo "checking bundle ${BUNDLE_NAME} if compiled successfully" >> ${BUNDLE_LOG} +perl -c ${BUNDLE_NAME} >> ${BUNDLE_LOG} +if [[ $? -eq 0 ]]; then + echo "fine :)" + echo "Successfully build bundles in ${BUNDLE_NAME}" + rm -f ${BUNDLE_LOG} +else + echo "failed! :'(" + echo "Something was wrong in bundling to ${BUNDLE_NAME}" + echo "Check ${BUNDLE_LOG} for details" +fi -- GitLab