Created
April 24, 2020 13:40
-
-
Save willangley/7baa25360d29465afa6b7f102c03831a to your computer and use it in GitHub Desktop.
find_package_files.bash: Shows files installed by package PKGID that are currently present on the system.
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
#!/bin/bash | |
# Copyright 2020 Google LLC. | |
# SPDX-License-Identifier: Apache-2.0 | |
function usage { | |
cat <<EOF | |
Usage: | |
$(basename $0) PKGID | |
Shows files installed by package PKGID that are currently present on the system. | |
EOF | |
exit 2 | |
} | |
function find_package_files { | |
PKGID="$1" | |
PKGUTIL_INFO=$(mktemp) | |
pkgutil --pkg-info-plist "$PKGID" >"$PKGUTIL_INFO.plist" || exit $? | |
VOLUME=$(defaults read "$PKGUTIL_INFO" volume) | |
LOCATION=$(defaults read "$PKGUTIL_INFO" install-location) | |
pkgutil --files "$PKGID" | while read file | |
do | |
if [ -f "$VOLUME$LOCATION/$file" ]; then | |
echo "$VOLUME$LOCATION/$file" | |
fi | |
done | |
} | |
[ -z "$1" ] && { usage; } | |
find_package_files "$1" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment