From ad197ff4c5f726fabf2ce495f7ef67f0fcea1a1e Mon Sep 17 00:00:00 2001 From: Roland Walker Date: Tue, 28 Jan 2014 20:20:29 -0500 Subject: [PATCH] add devscript list_recent_pkg_ids Another way to get pkg ids -- which recent installs are most recent. --- developer/bin/list_recent_pkg_ids | 36 +++++++++++++++++++++++++++++++ 1 file changed, 36 insertions(+) create mode 100755 developer/bin/list_recent_pkg_ids diff --git a/developer/bin/list_recent_pkg_ids b/developer/bin/list_recent_pkg_ids new file mode 100755 index 0000000000..3bf92ed376 --- /dev/null +++ b/developer/bin/list_recent_pkg_ids @@ -0,0 +1,36 @@ +#!/bin/bash +# +# list_recent_pkg_ids +# + +set -e; # exit on any uncaught error +set +o histexpand; # don't expand history expressions +shopt -s nocasematch; # case-insensitive regular expressions + +_list_recent_pkg_ids () { + /bin/ls -t /var/db/receipts | \ + /usr/bin/egrep '\.plist$' | \ + /usr/bin/perl -pe 's{\A.*/([^/]+)\.plist\Z}{$1}sg' | \ + /usr/bin/egrep -v '^com\.apple\.' | \ + /usr/bin/head -10 +} + +if [[ $1 =~ ^-+h(elp)?$ ]]; then + printf "list_recent_pkg_ids + +Print pkg receipt IDs for the 10 most-recently-installed packages, +which may be useful in a Cask uninstall stanza, eg + + uninstall :pkgutil => 'pkg.receipt.id.goes.here' + +Package IDs attributed to Apple are excluded from the output. + +See CONTRIBUTING.md for more information. + +" + exit +fi + +_list_recent_pkg_ids "$@"; + +#