github.com/quay/claircore@v1.5.28/etc/debug/bin/check-alpine (about)

     1  #!/bin/sh
     2  # Takes a list of identifiers as arguments and prints where it's found in the alpine secdb.
     3  set -e
     4  
     5  needcmd() {
     6  	for cmd in "$@"; do
     7  		if ! command -v "$cmd" 1>/dev/null 2>&1; then
     8  			printf 'need command: %s\n' "$cmd" >&2
     9  			exit 99
    10  		fi
    11  	done
    12  }
    13  needcmd wget jq
    14  
    15  alpine_version=edge
    16  while getopts v: flag
    17  do
    18  	case "$flag" in
    19  	v) alpine_version="$OPTARG";;
    20  	?)
    21  		printf "Usage: %s: [-v version] ID...\n" "$0" >&2
    22  		exit 2;;
    23  	esac
    24  done
    25  shift $((OPTIND - 1))
    26  if [ "$#" -eq 0 ]; then
    27  	printf "Usage: %s: [-v version] ID...\n" "$0" >&2
    28  	exit 2
    29  fi
    30  : "$@"
    31  
    32  db_dir="/tmp/${alpine_version}/"
    33  (
    34  	mkdir -p "$db_dir"
    35  	cd "$db_dir" || exit 99
    36  	for r in main community; do
    37  		echo "https://secdb.alpinelinux.org/${alpine_version}/${r}.json"
    38  	done |
    39  		wget --quiet --input-file=- --continue
    40  )
    41  
    42  cat  "$db_dir"/*.json |
    43  	jq -cr -L "$(git rev-parse --show-toplevel)/etc/debug/lib/jq"\
    44  	'import "alpine" as alpine; alpine::find_advisories($ARGS.positional)'\
    45  	--args "$@"