Update go.mod files to go1.18, update license vendor script

This commit is contained in:
Jordan Liggitt
2022-04-12 14:21:04 -04:00
parent 39021f66ef
commit 1176b7ca28
5 changed files with 51 additions and 32 deletions

View File

@@ -186,8 +186,10 @@ if [ -f "${LICENSE_ROOT}/LICENSE" ]; then
mv "${TMP_LICENSE_FILE}" "${TMP_LICENSES_DIR}/LICENSE"
fi
# Capture all module dependencies
modules=$(go list -m -json all | jq -r .Path | sort -f)
# Loop through every vendored package
for PACKAGE in $(go list -m -json all | jq -r .Path | sort -f); do
for PACKAGE in ${modules}; do
if [[ -e "staging/src/${PACKAGE}" ]]; then
echo "${PACKAGE} is a staging package, skipping" >&2
continue
@@ -196,26 +198,16 @@ for PACKAGE in $(go list -m -json all | jq -r .Path | sort -f); do
echo "${PACKAGE} doesn't exist in ${DEPS_DIR}, skipping" >&2
continue
fi
# Skip a directory if 1) it has no files and 2) all the subdirectories contain a go.mod file.
misses_go_mod=false
DEPS_SUBDIR="${DEPS_DIR}/${PACKAGE}"
search_for_mods () {
if [[ -z "$(find "${DEPS_SUBDIR}/" -mindepth 1 -maxdepth 1 -type f)" ]]; then
while read -d "" -r SUBDIR; do
if [[ ! -e "${SUBDIR}/go.mod" ]]; then
DEPS_SUBDIR=${SUBDIR}
search_for_mods
fi
done < <(find "${DEPS_SUBDIR}/" -mindepth 1 -maxdepth 1 -type d -print0)
else
misses_go_mod=true
fi
}
search_for_mods
if [[ $misses_go_mod = false ]]; then
echo "${PACKAGE} has no files, skipping" >&2
# if there are no files vendored under this package...
if [[ -z "$(find "${DEPS_DIR}/${PACKAGE}" -mindepth 1 -maxdepth 1 -type f)" ]]; then
# and we have the same number of submodules as subdirectories...
if [[ "$(find "${DEPS_DIR}/${PACKAGE}/" -mindepth 1 -maxdepth 1 -type d | wc -l)" -eq "$(echo "${modules}" | grep -cE "^${PACKAGE}/")" ]]; then
echo "Only submodules of ${PACKAGE} are vendored, skipping" >&2
continue
fi
fi
echo "${PACKAGE}"
process_content "${PACKAGE}" LICENSE