diff --git a/builder/alpine/install.sh b/builder/alpine/install.sh index c964f38..a726448 100755 --- a/builder/alpine/install.sh +++ b/builder/alpine/install.sh @@ -2,9 +2,14 @@ COMMANDS=$1 PACKAGES= # @todo why can I not make the IFS work here?! +apk update while read COMMAND; do PACKAGE=$(curl -sSfL "https://command-not-found.com/-/api/package/alpine/$COMMAND") - if apk info | grep -qE "^${PACKAGE}$" >/dev/null; then + if [ -z "${PACKAGE}" ] && apk info ${COMMAND} 1>&2 2>/dev/null; then + PACKAGE=${COMMAND} + fi + + if [ -n "${PACKAGE}" ] && apk info | grep -qE "^${PACKAGE}$" >/dev/null; then echo "Notice: Package already installed" exit 0 fi @@ -16,5 +21,6 @@ if [ -z "$PACKAGES" ]; then echo "Error: Nothing to install" exit 1 fi -apk --no-cache add ${PACKAGES} +apk add ${PACKAGES} +rm -rf /var/cache/apk/* exit 0