feat: add lint task, check for required stages

refs #9
This commit is contained in:
xyhhx 2024-04-02 00:47:57 -04:00
parent 6428ed19a9
commit ae19f8d228
No known key found for this signature in database
GPG key ID: 0960B11DB1AC1C5D
2 changed files with 26 additions and 0 deletions

View file

@ -32,6 +32,10 @@ all: \
compat:
./src/compat.sh
.PHONY: lint
lint:
./src/lint.sh
.PHONY: preseed
preseed:
./src/preseed.sh

22
src/lint.sh Executable file
View file

@ -0,0 +1,22 @@
#!/bin/bash
set -eu
has-stage () {
grep -rnw ./packages/*/Containerfile -e "^FROM.*${1}$" | awk -F"/" '{ print $3 }' | sort
}
check-stages () {
all_packages=$(ls -1 ./packages | sort)
stages="base fetch build install test package"
for stage in $stages; do
missing=$(comm -13 <(has-stage "${stage}") <(ls -1 ./packages | sort))
if [ $(printf "${missing}" | wc -l) -gt "0" ]; then
echo "${missing}" | xargs printf "%s is missing '${stage}' stage\n"
fi
done
}
check-stages