Skip to content

Instantly share code, notes, and snippets.

@lebensterben
Created June 20, 2019 06:38
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save lebensterben/45f8029508200c45f4aff9dbbfc9757b to your computer and use it in GitHub Desktop.
Save lebensterben/45f8029508200c45f4aff9dbbfc9757b to your computer and use it in GitHub Desktop.
#-*- mode: shell-script -*-
# list files included in a list of bundle
swupd-list () {
local myname usage opts file i
local -a output
local OPTARG OPTIND
read -r -d '' usage <<EOT
Usage:
swupd-list [-o OUTPUTFILE] BUNDLE [BUNDLE2 ...]
List files installed by bundles specified by the user.
EOT
while getopts ":o:" opts; do
case "${opts}" in
o )
file=${OPTARG}
(
set -e
[[ ! -a $file ]] && touch ${file}
)
;;
\? )
print "Invalid option: $OPTARG"
print $usage
return 1;;
: )
print "Invalid option: Option $OPTARG requires an argument"
print $usage
return 1;;
esac
done
shift $((OPTIND -1))
for i in $@; do
if [ ! -r /usr/share/clear/allbundles/"$i" ]; then
echo "Bundle Doesn't Exist: $1"
else
output+="$(cat /usr/share/clear/allbundles/$1 | jq --raw-output '.Files | keys[]')"
fi
done
if [ -n "$file" ]; then
cat <<< $output | sort | uniq > $file
else
cat <<< $output | sort | uniq | less
fi
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment