Last active
July 18, 2018 16:21
-
-
Save lsiden/92b0c08cc841dc4f01a3e4246fca28c5 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 | |
# Make CPAN package. | |
# Usage: mkcpanpkg $dirname | |
# Run this in the parent directory of $dirname. | |
# $dirname must be a Git repository. | |
# It will create a file $dirname-$version.tar.gz containing all files tracked by Git. | |
function modname() { | |
perl -e "print join(q{::}, split(/-/, qw{$1}))" | |
} | |
function version() { | |
local -r PKG=$1 | |
local -r MODULE=$2 | |
perl -I $PKG/lib -M${MODULE} -e "print \$${MODULE}::VERSION" | |
} | |
function lsFiles() { | |
local -r PKG=$1 | |
sed -e "s/^/$PKG\//" < $PKG/MANIFEST | |
} | |
if [ $# -lt 1 ]; then | |
>&2 echo "Usage: $(basename $0) name version" | |
exit 1 | |
fi | |
PKG=$1 | |
MODULE=$(modname $PKG) | |
VERSION=$(version $PKG $MODULE) | |
if [ -z $VERSION ]; then | |
>&2 echo "First define \$${MODULE}::VERSION." | |
exit 1 | |
fi | |
set -x | |
lsFiles $PKG | tar -cvzf ${PKG}-${VERSION}.tar.gz --exclude=.git/ --files-from - |
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 | |
# Print a list of Perl modules used by files and all sub-directories. | |
# See grep -r ... | |
if [ $# -lt 1 ] ; then | |
>2& echo "Usage: $(basename $0) files..." | |
exit 1 | |
fi | |
function strip() { | |
sed -E -e 's/^[^:]*:use ([a-zA-Z0-9:]*).*/\1/' | |
} | |
function filter() { | |
egrep -v -e '\buse (strict|warnings|lib)' | |
} | |
grep -e '^use ' -R $* | filter | strip | sort -u |
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 | |
# Print the version number of an installed Perl module. | |
# This may depend on having PERL5LIB defined in your environment. | |
readonly MODULE=$1 | |
perl -M$MODULE -le "print \$${MODULE}::VERSION" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment