Created
May 13, 2020 16:33
-
-
Save bsnux/9ec17ee8d9411b0c67523623bb2f67d1 to your computer and use it in GitHub Desktop.
Generates a binary from a Perl file
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
#-------------------------------------------------------------- | |
# perl-compile.sh | |
# | |
# Generates a binary file for Linux from a Perl file | |
# | |
# Usage: perl-compile.sh myfile.pl | |
#-------------------------------------------------------------- | |
set -e | |
perl_file=$1 | |
output_dir="/tmp/" | |
output_file="${perl_file//\.pl/}" | |
cat > Dockerfile_pl <<EOF | |
FROM perl:5.30-slim | |
WORKDIR /app | |
RUN apt-get update && apt-get install libpar-packer-perl -y | |
EOF | |
echo 'Creating docker container...' | |
docker build . -t perl-compiler:latest -f Dockerfile_pl | |
echo 'Running pp in container...' | |
docker run --name pl -ti -v $(pwd):/app perl-compiler pp -M PAR -x -o $output_file /app/$perl_file \ | |
&& docker cp pl:/app/$output_file $output_dir \ | |
&& docker stop pl && docker rm pl |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment