Skip to content

Instantly share code, notes, and snippets.

@sofar
Created January 28, 2016 00:04
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 sofar/0a9077d5b12b12919abf to your computer and use it in GitHub Desktop.
Save sofar/0a9077d5b12b12919abf to your computer and use it in GitHub Desktop.
ClearLinux bundle locate script.
#!/bin/bash
# grab $VERSION_ID from os-release
eval `grep VERSION_ID /usr/lib/os-release`
# fetch bundles
BUNDLES=( `awk '{print $4}' /var/lib/swupd/${VERSION_ID}/Manifest.MoM` )
NEXT=0
if [ "$1" == "-h" ] || [ "$1" == "--help" ] || [ "$1" == "" ]; then
>&2 echo "Usage: $0 [-n] [pattern]"
>&2 echo "Options:"
>&2 echo " -h | --help Display this help message"
>&2 echo " -n Do not query external manifests"
exit 1
elif [ "$1" == "-n" ]; then
NEXT=1
shift
fi
TMP=`mktemp`
>&2 echo -n "["
for BUNDLE in ${BUNDLES[@]}; do
if [ -f "/var/lib/swupd/${VERSION_ID}/Manifest.${BUNDLE}" ]; then
awk '{print $4}' /var/lib/swupd/${VERSION_ID}/Manifest.${BUNDLE} | grep "$@" | sed "s/^/${BUNDLE}\t/"
elif [ "$NEXT" != "1" ]; then
(
BV=`awk -v b=$BUNDLE '($4==b){print $3}' /var/lib/swupd/${VERSION_ID}/Manifest.MoM`
curl --fail -s "https://download.clearlinux.org/update/${BV}/Manifest.${BUNDLE}.tar" | tar xJf - -O Manifest.${BUNDLE} | awk '{print $4}' | grep "$@" | sed "s/^/${BUNDLE}\t/"
>&2 echo -n .
) &
fi
done > $TMP
wait
>&2 echo "]"
for FILE in `awk '{print $2}' $TMP | sort | uniq`; do
B=`awk -v file="${FILE}" '($2 == file){print $1}' $TMP | tr '\n' ' ' | sed 's/ $//'`
echo -e "${B}:\n\t${FILE}"
done
rm $TMP
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment