Skip to content

Instantly share code, notes, and snippets.

@nikolay-n
Created January 14, 2021 13:12
Show Gist options
  • Save nikolay-n/1aa315a24428b76a7b3372668eb2a141 to your computer and use it in GitHub Desktop.
Save nikolay-n/1aa315a24428b76a7b3372668eb2a141 to your computer and use it in GitHub Desktop.
Simple tool to find and check pkgs, if there are pkgutil crash reports in ~/Library/Logs/DiagnosticReports
#!/usr/bin/env bash
exec 3>&2
trap 'exec 2>>/dev/null' DEBUG
exec 2>&3
for pkg in $(mdfind "kMDItemContentTypeTree=public.archive" | grep -E "\.pkg$" | sort | uniq)
do
if [[ -f "$pkg" ]]
then
fname=$(basename "$pkg")
tmp_path="/tmp/pkg-unpacked-$fname-$RANDOM"
# trying to unpack package
echo -n "Unpacking $pkg ... "
pkgutil --expand-full "$pkg" "$tmp_path" >/dev/null 2>&1
retVal=$?
if [ $retVal -ne 0 ]; then
echo "error"
else
echo "ok"
fi
rm -fR "$tmp_path"
fi
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment