Skip to content

Commit 91a568a

Browse files
committed
feat: check correspondence between files in supportpkg and manifest
1 parent a73b9c3 commit 91a568a

File tree

1 file changed

+21
-6
lines changed

1 file changed

+21
-6
lines changed

.github/scripts/verify-manifest.sh

Lines changed: 21 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -3,17 +3,14 @@ set -euo pipefail
33

44
# Exit codes:
55
# 0 - success
6-
# 2 - usage / bad args
76
# 3 - missing dependency (jq)
87
# 4 - manifest.json not found
98
# 5 - manifest.json exists but is not a regular file
109
# 6 - manifest.json is not valid JSON
1110
# 7 - missing required JSON keys
11+
# 8 - missing files in the supportpkg
12+
# 9 - missing files in the manifest
1213

13-
usage() {
14-
echo "Usage: $0 <directory-containing-manifest.json>" >&2
15-
exit 2
16-
}
1714
if [[ ${#} -ne 1 ]]; then
1815
usage
1916
fi
@@ -75,5 +72,23 @@ if [[ ${#missing[@]} -ne 0 ]]; then
7572
exit 7
7673
fi
7774

78-
echo "OK: $manifest is valid and contains all required keys"
75+
# Check that there is a 1:1 correspondence between manifest and tarball content
76+
77+
find "${dir}" -type f -mindepth 1 | cut -c "$(( ${#dir} + 1 ))"- > find-output.txt
78+
jq -r '.commands[].output' "${dir}"/manifest.json > manifest-output.txt
79+
printf "/manifest.json\n/supportpkg.log" >> manifest-output.txt
80+
if grep -vxFf find-output.txt manifest-output.txt >/dev/null; then
81+
echo "ERROR: Manifest contains files not present in the supportpkg:"
82+
grep -vxFf find-output.txt manifest-output.txt
83+
exit 8
84+
fi
85+
if grep -vxFf manifest-output.txt find-output.txt >/dev/null; then
86+
echo "ERROR: Supportpkg contains files not present in the manifest:"
87+
grep -vxFf manifest-output.txt find-output.txt
88+
exit 9
89+
fi
90+
91+
# All good if we reached this point
92+
93+
echo "OK: $manifest is valid and consistent with the supportpkg contents"
7994
exit 0

0 commit comments

Comments
 (0)