aboutsummaryrefslogtreecommitdiff
path: root/bin/plmu
diff options
context:
space:
mode:
authorTom Ryder <tom@sanctum.geek.nz>2016-06-22 10:13:10 +1200
committerTom Ryder <tom@sanctum.geek.nz>2016-06-22 10:13:10 +1200
commitc83042d6701f275bd792fb15c889e780deddb14a (patch)
treecc6f6615267ce1ce8aae52e59477d8cea4dd8e73 /bin/plmu
parentRemove reference to GitHub dotfiles pages (diff)
downloaddotfiles-c83042d6701f275bd792fb15c889e780deddb14a.tar.gz
dotfiles-c83042d6701f275bd792fb15c889e780deddb14a.zip
Rename binscripts more tersely
Diffstat (limited to 'bin/plmu')
-rwxr-xr-xbin/plmu34
1 files changed, 34 insertions, 0 deletions
diff --git a/bin/plmu b/bin/plmu
new file mode 100755
index 00000000..668c4667
--- /dev/null
+++ b/bin/plmu
@@ -0,0 +1,34 @@
+#!/usr/bin/env bash
+
+# Export a sensible locale so that sort(1) behaves
+LANG=C.UTF-8
+export LANG
+
+# Check we have required programs
+hash cpanm plenv || exit
+
+# Create required temporary files
+mf=$(mktemp) || exit
+ef=$(mktemp) || exit
+cf=$(mktemp) || exit
+
+# Clean up temporary files on exit
+cleanup() {
+ rm -f -- "$mf" "$ef" "$cf"
+}
+trap cleanup EXIT
+
+# Get the list of modules, sort them, write them to a file
+plenv list-modules | sort > "$mf"
+
+# Sort the non-CPAN modules from ~/.plenv and write them to a file
+sort -- "$HOME"/.plenv/non-cpanm-modules > "$ef"
+
+# Write out the list of modules that appear in the first file, but not the
+# second
+comm -23 -- "$mf" "$ef" > "$cf"
+
+# Read the list of modules to upgrade and upgrade them one by one
+while read -r module ; do
+ cpanm --from http://cpan.inspire.net.nz --notest --quiet -- "$module"
+done < "$cf"