kicad: update.sh: set -e
and some more suggestions from veprbl warn if an empty item gets through anyway and use UTC time cc #82634
This commit is contained in:
parent
0f20af8bd3
commit
75963b9160
@ -1,6 +1,8 @@
|
|||||||
#!/usr/bin/env nix-shell
|
#!/usr/bin/env nix-shell
|
||||||
#!nix-shell -i bash -p coreutils git nix curl
|
#!nix-shell -i bash -p coreutils git nix curl
|
||||||
|
|
||||||
|
set -e
|
||||||
|
|
||||||
# this script will generate versions.nix in the right location
|
# this script will generate versions.nix in the right location
|
||||||
# this should contain the versions' revs and hashes
|
# this should contain the versions' revs and hashes
|
||||||
# the stable revs are stored only for ease of skipping
|
# the stable revs are stored only for ease of skipping
|
||||||
@ -50,12 +52,11 @@ for arg in "$@"; do
|
|||||||
done
|
done
|
||||||
|
|
||||||
here="$( cd "$( dirname "${BASH_SOURCE[0]}" )" >/dev/null 2>&1 && pwd )"
|
here="$( cd "$( dirname "${BASH_SOURCE[0]}" )" >/dev/null 2>&1 && pwd )"
|
||||||
now=$(date --iso-8601)
|
now=$(date --iso-8601 --utc)
|
||||||
|
|
||||||
file="${here}/versions.nix"
|
file="${here}/versions.nix"
|
||||||
# just in case this runs in parallel
|
# just in case this runs in parallel
|
||||||
rand="$(head -c 3 /dev/urandom | base64)"
|
tmp="${here}/,versions.nix.${RANDOM}"
|
||||||
tmp="${here}/,versions.nix.${rand}"
|
|
||||||
|
|
||||||
# libraries currently on github, move to $gitlab/libraries planned
|
# libraries currently on github, move to $gitlab/libraries planned
|
||||||
libs=( symbols templates footprints packages3d )
|
libs=( symbols templates footprints packages3d )
|
||||||
@ -112,16 +113,16 @@ for version in "${all_versions[@]}"; do
|
|||||||
|
|
||||||
echo "Checking src" >&2
|
echo "Checking src" >&2
|
||||||
src_rev="$(${get_rev} "${gitlab}"/code/kicad.git "${version}" | cut -f1)"
|
src_rev="$(${get_rev} "${gitlab}"/code/kicad.git "${version}" | cut -f1)"
|
||||||
ret="$(grep -sm 1 "\"${pname}\"" -A 4 "${file}" | grep -sm 1 "${src_rev}")"
|
has_rev="$(grep -sm 1 "\"${pname}\"" -A 4 "${file}" | grep -sm 1 "${src_rev}" || true)"
|
||||||
has_hash="$(grep -sm 1 "\"${pname}\"" -A 5 "${file}" | grep -sm 1 "sha256")"
|
has_hash="$(grep -sm 1 "\"${pname}\"" -A 5 "${file}" | grep -sm 1 "sha256")"
|
||||||
if [[ -n ${ret} && -n ${has_hash} && -z ${clean} ]]; then
|
if [[ -n ${has_rev} && -n ${has_hash} && -z ${clean} ]]; then
|
||||||
echo "Reusing old ${pname}.src.sha256, already latest .rev" >&2
|
echo "Reusing old ${pname}.src.sha256, already latest .rev" >&2
|
||||||
grep -sm 1 "\"${pname}\"" -A 5 "${file}" | grep -sm 1 "rev" -A 1
|
grep -sm 1 "\"${pname}\"" -A 5 "${file}" | grep -sm 1 "rev" -A 1
|
||||||
else
|
else
|
||||||
printf "%8srev =\t\t\t\"%s\";\n" "" "${src_rev}"
|
printf "%8srev =\t\t\t\"%s\";\n" "" "${src_rev}"
|
||||||
printf "%8ssha256 =\t\t\"%s\";\n" \
|
printf "%8ssha256 =\t\t\"%s\";\n" \
|
||||||
"" "$(${prefetch} "${gitlab_pre}${src_rev}")"
|
"" "$(${prefetch} "${gitlab_pre}${src_rev}")"
|
||||||
(( count++ ))
|
count=$((count+1))
|
||||||
fi
|
fi
|
||||||
printf "%6s};\n" ""
|
printf "%6s};\n" ""
|
||||||
printf "%4s};\n" ""
|
printf "%4s};\n" ""
|
||||||
@ -132,25 +133,25 @@ for version in "${all_versions[@]}"; do
|
|||||||
|
|
||||||
echo "Checking i18n" >&2
|
echo "Checking i18n" >&2
|
||||||
i18n_rev="$(${get_rev} "${i18n}" "${version}" | cut -f1)"
|
i18n_rev="$(${get_rev} "${i18n}" "${version}" | cut -f1)"
|
||||||
ret="$(grep -sm 1 "\"${pname}\"" -A 11 "${file}" | grep -sm 1 "${i18n_rev}")"
|
has_rev="$(grep -sm 1 "\"${pname}\"" -A 11 "${file}" | grep -sm 1 "${i18n_rev}" || true)"
|
||||||
has_hash="$(grep -sm 1 "\"${pname}\"" -A 12 "${file}" | grep -sm 1 "i18n.sha256")"
|
has_hash="$(grep -sm 1 "\"${pname}\"" -A 12 "${file}" | grep -sm 1 "i18n.sha256")"
|
||||||
if [[ -n ${ret} && -n ${has_hash} && -z ${clean} ]]; then
|
if [[ -n ${has_rev} && -n ${has_hash} && -z ${clean} ]]; then
|
||||||
echo "Reusing old kicad-i18n-${today}.src.sha256, already latest .rev" >&2
|
echo "Reusing old kicad-i18n-${today}.src.sha256, already latest .rev" >&2
|
||||||
grep -sm 1 "\"${pname}\"" -A 12 "${file}" | grep -sm 1 "i18n" -A 1
|
grep -sm 1 "\"${pname}\"" -A 12 "${file}" | grep -sm 1 "i18n" -A 1
|
||||||
else
|
else
|
||||||
printf "%8si18n.rev =\t\t\"%s\";\n" "" "${i18n_rev}"
|
printf "%8si18n.rev =\t\t\"%s\";\n" "" "${i18n_rev}"
|
||||||
printf "%8si18n.sha256 =\t\t\"%s\";\n" "" \
|
printf "%8si18n.sha256 =\t\t\"%s\";\n" "" \
|
||||||
"$(${prefetch} "${i18n_pre}${i18n_rev}")"
|
"$(${prefetch} "${i18n_pre}${i18n_rev}")"
|
||||||
(( count++ ))
|
count=$((count+1))
|
||||||
fi
|
fi
|
||||||
|
|
||||||
for lib in "${libs[@]}"; do
|
for lib in "${libs[@]}"; do
|
||||||
echo "Checking ${lib}" >&2
|
echo "Checking ${lib}" >&2
|
||||||
url="${github}-${lib}.git"
|
url="${github}-${lib}.git"
|
||||||
lib_rev="$(${get_rev} "${url}" "${version}" | cut -f1)"
|
lib_rev="$(${get_rev} "${url}" "${version}" | cut -f1)"
|
||||||
ret="$(grep -sm 1 "\"${pname}\"" -A 19 "${file}" | grep -sm 1 "${lib_rev}" -A 1)"
|
has_rev="$(grep -sm 1 "\"${pname}\"" -A 19 "${file}" | grep -sm 1 "${lib_rev}" || true)"
|
||||||
has_hash="$(grep -sm 1 "\"${pname}\"" -A 20 "${file}" | grep -sm 1 "${lib}.sha256")"
|
has_hash="$(grep -sm 1 "\"${pname}\"" -A 20 "${file}" | grep -sm 1 "${lib}.sha256")"
|
||||||
if [[ -n ${ret} && -n ${has_hash} && -z ${clean} ]]; then
|
if [[ -n ${has_rev} && -n ${has_hash} && -z ${clean} ]]; then
|
||||||
echo "Reusing old kicad-${lib}-${today}.src.sha256, already latest .rev" >&2
|
echo "Reusing old kicad-${lib}-${today}.src.sha256, already latest .rev" >&2
|
||||||
grep -sm 1 "\"${pname}\"" -A 20 "${file}" | grep -sm 1 "${lib}" -A 1
|
grep -sm 1 "\"${pname}\"" -A 20 "${file}" | grep -sm 1 "${lib}" -A 1
|
||||||
else
|
else
|
||||||
@ -161,7 +162,7 @@ for version in "${all_versions[@]}"; do
|
|||||||
printf "\"%s\";\n" "${lib_rev}"
|
printf "\"%s\";\n" "${lib_rev}"
|
||||||
printf "%8s%s.sha256 =\t\"%s\";\n" "" \
|
printf "%8s%s.sha256 =\t\"%s\";\n" "" \
|
||||||
"${lib}" "$(${prefetch} "${github}-${lib}/archive/${lib_rev}.tar.gz")"
|
"${lib}" "$(${prefetch} "${github}-${lib}/archive/${lib_rev}.tar.gz")"
|
||||||
(( count++ ))
|
count=$((count+1))
|
||||||
fi
|
fi
|
||||||
done
|
done
|
||||||
printf "%6s};\n" ""
|
printf "%6s};\n" ""
|
||||||
@ -175,6 +176,11 @@ done
|
|||||||
printf "}\n"
|
printf "}\n"
|
||||||
} > "${tmp}"
|
} > "${tmp}"
|
||||||
|
|
||||||
|
if grep '""' "${tmp}"; then
|
||||||
|
echo "empty value detected, out of space?" >&2
|
||||||
|
exit "1"
|
||||||
|
fi
|
||||||
|
|
||||||
mv "${tmp}" "${file}"
|
mv "${tmp}" "${file}"
|
||||||
|
|
||||||
printf "\nFinished\nMoved output to %s\n\n" "${file}" >&2
|
printf "\nFinished\nMoved output to %s\n\n" "${file}" >&2
|
||||||
|
Loading…
x
Reference in New Issue
Block a user