Last active
June 3, 2022 11:58
-
-
Save stigtsp/48c42c9d80eda960ae1715daa35c4e92 to your computer and use it in GitHub Desktop.
This file contains 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
#!/usr/bin/env bash | |
# | |
# Quick hack to "install" pure perl modules into $PWD, very fast, by copying the .pm files from the tarball. | |
# Useful in Dockerfile, requires checksums of the tarball to be provided. | |
# | |
# Usage: | |
# $ cd lib && ../perl-installish-module.sh https://cpan.metacpan.org/authors/id/J/JH/JHTHORSEN/Mojo-mysql-1.17.tar.gz 93cd964760918a43124c3dc65d513372b6d1d00993427894e2f11a1f96662554 | |
# | |
# Caveats: | |
# - Does not run tests | |
# - Only extracts *.pm files | |
# - Does not resolve any dependencies | |
# | |
# Actually, it's just a simple wrapper for curl, sha256 and tar, so there are many reasons not to use this... | |
# | |
# You should probably use cpm or cpanminus instead | |
# | |
set -euo pipefail | |
URL=$1 | |
SHA256=$2 | |
FILE=`basename $URL` | |
INSTDIR=`pwd` | |
TMPDIR=`mktemp -d` | |
cd $TMPDIR | |
curl -sS --retry 10 -L -l -o $FILE $URL | |
echo "$SHA256 $FILE" | sha256sum -c - | |
tar --no-same-owner -xzf $FILE --strip=2 -C $INSTDIR --wildcards "*.pm" | |
find $INSTDIR -type f -iname '*.pm' -exec chmod 444 {} \; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment