Created
June 20, 2019 06:38
-
-
Save lebensterben/45f8029508200c45f4aff9dbbfc9757b to your computer and use it in GitHub Desktop.
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
#-*- 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