forked from docker-library/repo-info
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add very basic initial support for scraping some amount of informatio…
…n out of APK for Alpine-based images
- Loading branch information
Showing
4 changed files
with
63 additions
and
0 deletions.
There are no files selected for viewing
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
#!/usr/bin/env bash | ||
set -Eeuo pipefail | ||
|
||
_apk() { | ||
apk --no-network "$@" 2>/dev/null | ||
} | ||
|
||
IFS=$'\n' | ||
packages=( $(_apk info | sort) ) | ||
unset IFS | ||
|
||
if [ "${#packages[@]}" -eq 0 ]; then | ||
# not Alpine-based? | ||
exit 1 | ||
fi | ||
|
||
echo | ||
echo '## `apk` (`.apk`-based packages)' | ||
|
||
# prints "$2$1$3$1...$N" | ||
join() { | ||
local sep="$1"; shift | ||
local out; printf -v out "${sep//%/%%}%s" "$@" | ||
echo "${out#$sep}" | ||
} | ||
|
||
for pkg in "${packages[@]}"; do | ||
if [ "${pkg#.}" != "$pkg" ]; then | ||
# if package name starts with a period, it's a pretty strong indicator that it's likely a user-created virtual and thus safely ignored for the purposes of this report | ||
continue | ||
fi | ||
|
||
echo | ||
echo '### `apk` package: `'"$pkg"'`' | ||
|
||
# TODO parse this output better somehow (can't find a way to get `apk info` to spit out just the value without the `xyz-VERSION license:` header) | ||
echo | ||
echo '```console' | ||
_apk info \ | ||
--description \ | ||
--license \ | ||
--size \ | ||
--webpage \ | ||
"$pkg" | ||
echo '```' | ||
done |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2,5 +2,6 @@ | |
set -e | ||
|
||
prep-env.sh | ||
gather-apk.sh || : | ||
gather-dpkg.sh || : | ||
gather-rpm.sh || : |
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
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