kicad: split version.nix & add update.sh (#77003)
kicad: split version.nix & add update.sh
This commit is contained in:
commit
01d93cbbe1
3 changed files with 251 additions and 42 deletions
|
@ -21,48 +21,7 @@ let
|
|||
stable = pname != "kicad-unstable";
|
||||
baseName = if (stable) then "kicad" else "kicad-unstable";
|
||||
|
||||
versions = {
|
||||
"kicad" = {
|
||||
kicadVersion = {
|
||||
version = "5.1.5";
|
||||
src.sha256 = "15h3rwisjss3fdc9bam9n2wq94slhacc3fbg14bnzf4n5agsnv5b";
|
||||
};
|
||||
libVersion = {
|
||||
version = "5.1.5";
|
||||
libSources = {
|
||||
i18n.sha256 = "1rfpifl8vky1gba2angizlb2n7mwmsiai3r6ip6qma60wdj8sbd3";
|
||||
symbols.sha256 = "048b07ffsaav1ssrchw2p870lvb4rsyb5vnniy670k7q9p16qq6h";
|
||||
templates.sha256 = "0cs3bm3zb5ngw5ldn0lzw5bvqm4kvcidyrn76438alffwiz2b15g";
|
||||
footprints.sha256 = "1c4whgn14qhz4yqkl46w13p6rpv1k0hsc9s9h9368fxfcz9knb2j";
|
||||
packages3d.sha256 = "0cff2ms1bsw530kqb1fr1m2pjixyxzwa81mxgac3qpbcf8fnpvaz";
|
||||
};
|
||||
};
|
||||
};
|
||||
"kicad-unstable" = {
|
||||
kicadVersion = {
|
||||
version = "2019-12-31";
|
||||
src = {
|
||||
rev = "eaaa4eb63acb289047dfbb6cc275579dea58f12b";
|
||||
sha256 = "1v2hf2slphjdh14y56pmzlpi6mqidrd8198if1fi0cch72v37zch";
|
||||
};
|
||||
};
|
||||
libVersion = {
|
||||
version = "unstable";
|
||||
libSources = {
|
||||
i18n.rev = "e7439fd76f27cfc26e269c4e6c4d56245345c28b";
|
||||
i18n.sha256 = "1nqm1kx5b4f7s0f9q8bg4rdhqnp0128yp6bgnrkia1kwmfnf5gmy";
|
||||
symbols.rev = "1bc5ff11c76bcbfda227e534b0acf737edddde8f";
|
||||
symbols.sha256 = "05kv93790wi4dpbn2488p587b83yz1zw9h62lkv41h7vn2r1mmb7";
|
||||
templates.rev = "0c0490897f803ab8b7c3dad438b7eb1f80e0417c";
|
||||
templates.sha256 = "0cs3bm3zb5ngw5ldn0lzw5bvqm4kvcidyrn76438alffwiz2b15g";
|
||||
footprints.rev = "454126c125edd3fa8633f301421a7d9c4de61b77";
|
||||
footprints.sha256 = "00nli4kx2i68bk852rivbirzcgpsdlpdk34g1q892952jsbh7fy6";
|
||||
packages3d.rev = "c2b92a411adc93ddeeed74b36b542e1057f81a2a";
|
||||
packages3d.sha256 = "05znc6y2lc31iafspg308cxdda94zg6c7mwslmys76npih1pb8qc";
|
||||
};
|
||||
};
|
||||
};
|
||||
};
|
||||
versions = import ./versions.nix;
|
||||
versionConfig = versions.${baseName};
|
||||
|
||||
wxGTK = if (stable)
|
||||
|
@ -157,6 +116,13 @@ stdenv.mkDerivation rec {
|
|||
''
|
||||
;
|
||||
|
||||
# can't run this for each pname
|
||||
# stable and unstable are in the same versions.nix
|
||||
# and kicad-small reuses stable
|
||||
# with "all" it updates both, run it manually if you don't want that
|
||||
# and can't git commit if this could be running in parallel with other scripts
|
||||
passthru.updateScript = [ ./update.sh "all" ];
|
||||
|
||||
meta = {
|
||||
description = if (stable)
|
||||
then "Open Source Electronics Design Automation Suite"
|
||||
|
|
191
pkgs/applications/science/electronics/kicad/update.sh
Executable file
191
pkgs/applications/science/electronics/kicad/update.sh
Executable file
|
@ -0,0 +1,191 @@
|
|||
#!/usr/bin/env nix-shell
|
||||
#!nix-shell -i bash -p coreutils git nix curl
|
||||
|
||||
# this script will generate versions.nix in the right location
|
||||
# this should contain the versions' revs and hashes
|
||||
# the stable revs are stored only for ease of skipping
|
||||
|
||||
# if you get something like "tar: no space left on device"
|
||||
# you may need a bigger tmpfs, this can be set as such
|
||||
# services.logind.extraConfig = "RuntimeDirectorySize=8G";
|
||||
# this is most likely only needed for the packages3d
|
||||
# this can be checked without that config by manual TOFU
|
||||
# copy the generated items from ,versions.nix to versions.nix
|
||||
# then nix-build and see what it actually gets
|
||||
|
||||
# if something goes unrepairably wrong, run 'update.sh all clean'
|
||||
|
||||
# TODO
|
||||
# support parallel instances for each pname
|
||||
# currently risks reusing old data
|
||||
# no getting around manually checking if the build product works...
|
||||
# if there is, default to commiting
|
||||
# remove items left in /nix/store?
|
||||
|
||||
# get the latest tag that isn't an RC or *.99
|
||||
latest_tag="$(git ls-remote --tags --sort -version:refname \
|
||||
https://gitlab.com/kicad/code/kicad.git \
|
||||
| grep -o 'refs/tags/[0-9]*\.[0-9]*\.[0-9]*$' \
|
||||
| grep -v ".99" | head -n 1 | cut -d '/' -f 3)"
|
||||
|
||||
all_versions=( "${latest_tag}" master )
|
||||
|
||||
prefetch="nix-prefetch-url --unpack --quiet"
|
||||
|
||||
clean=""
|
||||
check_stable=""
|
||||
check_unstable=1
|
||||
commit=""
|
||||
|
||||
for arg in "$@"; do
|
||||
case "${arg}" in
|
||||
help|-h|--help) echo "Read me!" >&2; exit 1; ;;
|
||||
kicad|release|tag|stable|*small|5*|6*) check_stable=1; check_unstable="" ;;
|
||||
all|both|full) check_stable=1; check_unstable=1 ;;
|
||||
commit) commit=1 ;;
|
||||
clean|fix|*fuck) check_stable=1; check_unstable=1; clean=1 ;;
|
||||
master|*unstable|latest|now|today) check_unstable=1 ;;
|
||||
*) ;;
|
||||
esac
|
||||
done
|
||||
|
||||
here="$( cd "$( dirname "${BASH_SOURCE[0]}" )" >/dev/null 2>&1 && pwd )"
|
||||
now=$(date --iso-8601)
|
||||
|
||||
file="${here}/versions.nix"
|
||||
# just in case this runs in parallel
|
||||
rand="$(head -c 3 /dev/urandom | base64)"
|
||||
tmp="${here}/,versions.nix.${rand}"
|
||||
|
||||
# libraries currently on github, move to $gitlab/libraries planned
|
||||
libs=( symbols templates footprints packages3d )
|
||||
|
||||
get_rev="git ls-remote --heads --tags"
|
||||
|
||||
gitlab="https://gitlab.com/kicad"
|
||||
# append commit hash or tag
|
||||
gitlab_pre="https://gitlab.com/api/v4/projects/kicad%2Fcode%2Fkicad/repository/archive.tar.gz?sha="
|
||||
|
||||
# append "-$lib/archive/[hash or tag].tar.gz
|
||||
github="https://github.com/kicad/kicad"
|
||||
|
||||
# not a lib, but separate and already moved to gitlab
|
||||
i18n="${gitlab}/code/kicad-i18n.git"
|
||||
i18n_pre="https://gitlab.com/api/v4/projects/kicad%2Fcode%2Fkicad-i18n/repository/archive.tar.gz?sha="
|
||||
|
||||
count=0
|
||||
|
||||
printf "Latest tag is\t%s\n" "${latest_tag}" >&2
|
||||
|
||||
if [[ ! -f ${file} ]]; then
|
||||
echo "No existing file, generating from scratch" >&2
|
||||
check_stable=1; check_unstable=1; clean=1
|
||||
fi
|
||||
|
||||
printf "Writing %s\n" "${tmp}" >&2
|
||||
|
||||
# not a dangling brace, grouping the output to redirect to file
|
||||
{
|
||||
|
||||
printf "# This file was generated by update.sh\n\n"
|
||||
printf "{\n"
|
||||
|
||||
for version in "${all_versions[@]}"; do
|
||||
|
||||
if [[ ${version} == "master" ]]; then
|
||||
pname="kicad-unstable"
|
||||
today="${now}"
|
||||
else
|
||||
pname="kicad"
|
||||
today="${version}"
|
||||
fi
|
||||
# skip a version if we don't want to check it
|
||||
if [[ (${version} != "master" && -n ${check_stable}) \
|
||||
|| (${version} == "master" && -n ${check_unstable}) ]]; then
|
||||
|
||||
printf "\nChecking %s\n" "${pname}" >&2
|
||||
|
||||
printf "%2s\"%s\" = {\n" "" "${pname}"
|
||||
printf "%4skicadVersion = {\n" ""
|
||||
printf "%6sversion =\t\t\t\"%s\";\n" "" "${today}"
|
||||
printf "%6ssrc = {\n" ""
|
||||
|
||||
echo "Checking src" >&2
|
||||
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_hash="$(grep -sm 1 "\"${pname}\"" -A 5 "${file}" | grep -sm 1 "sha256")"
|
||||
if [[ -n ${ret} && -n ${has_hash} && -z ${clean} ]]; then
|
||||
echo "Reusing old ${pname}.src.sha256, already latest .rev" >&2
|
||||
grep -sm 1 "\"${pname}\"" -A 5 "${file}" | grep -sm 1 "rev" -A 1
|
||||
else
|
||||
printf "%8srev =\t\t\t\"%s\";\n" "" "${src_rev}"
|
||||
printf "%8ssha256 =\t\t\"%s\";\n" \
|
||||
"" "$(${prefetch} "${gitlab_pre}${src_rev}")"
|
||||
(( count++ ))
|
||||
fi
|
||||
printf "%6s};\n" ""
|
||||
printf "%4s};\n" ""
|
||||
|
||||
printf "%4slibVersion = {\n" ""
|
||||
printf "%6sversion =\t\t\t\"%s\";\n" "" "${today}"
|
||||
printf "%6slibSources = {\n" ""
|
||||
|
||||
echo "Checking i18n" >&2
|
||||
i18n_rev="$(${get_rev} "${i18n}" "${version}" | cut -f1)"
|
||||
ret="$(grep -sm 1 "\"${pname}\"" -A 11 "${file}" | grep -sm 1 "${i18n_rev}")"
|
||||
has_hash="$(grep -sm 1 "\"${pname}\"" -A 12 "${file}" | grep -sm 1 "i18n.sha256")"
|
||||
if [[ -n ${ret} && -n ${has_hash} && -z ${clean} ]]; then
|
||||
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
|
||||
else
|
||||
printf "%8si18n.rev =\t\t\"%s\";\n" "" "${i18n_rev}"
|
||||
printf "%8si18n.sha256 =\t\t\"%s\";\n" "" \
|
||||
"$(${prefetch} "${i18n_pre}${i18n_rev}")"
|
||||
(( count++ ))
|
||||
fi
|
||||
|
||||
for lib in "${libs[@]}"; do
|
||||
echo "Checking ${lib}" >&2
|
||||
url="${github}-${lib}.git"
|
||||
lib_rev="$(${get_rev} "${url}" "${version}" | cut -f1)"
|
||||
ret="$(grep -sm 1 "\"${pname}\"" -A 19 "${file}" | grep -sm 1 "${lib_rev}" -A 1)"
|
||||
has_hash="$(grep -sm 1 "\"${pname}\"" -A 20 "${file}" | grep -sm 1 "${lib}.sha256")"
|
||||
if [[ -n ${ret} && -n ${has_hash} && -z ${clean} ]]; then
|
||||
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
|
||||
else
|
||||
printf "%8s%s.rev =\t" "" "${lib}"
|
||||
case "${lib}" in
|
||||
symbols|templates) printf "\t" ;; *) ;;
|
||||
esac
|
||||
printf "\"%s\";\n" "${lib_rev}"
|
||||
printf "%8s%s.sha256 =\t\"%s\";\n" "" \
|
||||
"${lib}" "$(${prefetch} "${github}-${lib}/archive/${lib_rev}.tar.gz")"
|
||||
(( count++ ))
|
||||
fi
|
||||
done
|
||||
printf "%6s};\n" ""
|
||||
printf "%4s};\n" ""
|
||||
printf "%2s};\n" ""
|
||||
else
|
||||
printf "\nReusing old %s\n" "${pname}" >&2
|
||||
grep -sm 1 "\"${pname}\"" -A 23 "${file}"
|
||||
fi
|
||||
done
|
||||
printf "}\n"
|
||||
} > "${tmp}"
|
||||
|
||||
mv "${tmp}" "${file}"
|
||||
|
||||
printf "\nFinished\nMoved output to %s\n\n" "${file}" >&2
|
||||
|
||||
if [[ ${count} -gt 0 ]]; then
|
||||
if [[ ${count} -gt 1 ]]; then s="s"; else s=""; fi
|
||||
echo "${count} revision${s} changed" >&2
|
||||
if [[ -n ${commit} ]]; then
|
||||
git commit -am "$(printf "kicad: automatic update of %s item%s\n" "${count}" "${s}")"
|
||||
fi
|
||||
echo "Please confirm the new versions.nix works before making a PR." >&2
|
||||
else
|
||||
echo "No changes, those checked are up to date" >&2
|
||||
fi
|
52
pkgs/applications/science/electronics/kicad/versions.nix
Normal file
52
pkgs/applications/science/electronics/kicad/versions.nix
Normal file
|
@ -0,0 +1,52 @@
|
|||
# This file was generated by update.sh
|
||||
|
||||
{
|
||||
"kicad" = {
|
||||
kicadVersion = {
|
||||
version = "5.1.5";
|
||||
src = {
|
||||
rev = "52549c5d09cbfb0e807fcbcb07819bc9f7861544";
|
||||
sha256 = "15h3rwisjss3fdc9bam9n2wq94slhacc3fbg14bnzf4n5agsnv5b";
|
||||
};
|
||||
};
|
||||
libVersion = {
|
||||
version = "5.1.5";
|
||||
libSources = {
|
||||
i18n.rev = "5122cbec6563fb7c8d6f960a639ac470353af91b";
|
||||
i18n.sha256 = "1rfpifl8vky1gba2angizlb2n7mwmsiai3r6ip6qma60wdj8sbd3";
|
||||
symbols.rev = "dd122ec170b49e032179511c9d263126f52f4020";
|
||||
symbols.sha256 = "048b07ffsaav1ssrchw2p870lvb4rsyb5vnniy670k7q9p16qq6h";
|
||||
templates.rev = "94761f10d06582b33cd55ea2149d72f269f65580";
|
||||
templates.sha256 = "0cs3bm3zb5ngw5ldn0lzw5bvqm4kvcidyrn76438alffwiz2b15g";
|
||||
footprints.rev = "e076f8f271f8db96d5fec45616b7554caebb7ef7";
|
||||
footprints.sha256 = "1c4whgn14qhz4yqkl46w13p6rpv1k0hsc9s9h9368fxfcz9knb2j";
|
||||
packages3d.rev = "8d233cdcb109aa1c3b8ba4c934ee31f6a3b6e1f4";
|
||||
packages3d.sha256 = "0cff2ms1bsw530kqb1fr1m2pjixyxzwa81mxgac3qpbcf8fnpvaz";
|
||||
};
|
||||
};
|
||||
};
|
||||
"kicad-unstable" = {
|
||||
kicadVersion = {
|
||||
version = "2020-01-08";
|
||||
src = {
|
||||
rev = "ca34ade00c554157f106fde97af5f08a202808ef";
|
||||
sha256 = "0xx5qkc5pi3qdrdikgq3902ws8zilv2476fb4bbgh95d9wpgr35v";
|
||||
};
|
||||
};
|
||||
libVersion = {
|
||||
version = "2020-01-08";
|
||||
libSources = {
|
||||
i18n.rev = "e7439fd76f27cfc26e269c4e6c4d56245345c28b";
|
||||
i18n.sha256 = "1nqm1kx5b4f7s0f9q8bg4rdhqnp0128yp6bgnrkia1kwmfnf5gmy";
|
||||
symbols.rev = "ad58768b88d564fd188c6667841adec436da53f2";
|
||||
symbols.sha256 = "1rdplf04bff0hmgjwr81fbcr9nkqi21n0n88nzs5fdp73mqiywcy";
|
||||
templates.rev = "0c0490897f803ab8b7c3dad438b7eb1f80e0417c";
|
||||
templates.sha256 = "0cs3bm3zb5ngw5ldn0lzw5bvqm4kvcidyrn76438alffwiz2b15g";
|
||||
footprints.rev = "973867de7f33f202e9fd1b3455bd1f7e7fe4a074";
|
||||
footprints.sha256 = "0yvidpnqbfxjdwaiscl5bdchsg0l4d769vp456dc8h0f3802mibi";
|
||||
packages3d.rev = "c2b92a411adc93ddeeed74b36b542e1057f81a2a";
|
||||
packages3d.sha256 = "05znc6y2lc31iafspg308cxdda94zg6c7mwslmys76npih1pb8qc";
|
||||
};
|
||||
};
|
||||
};
|
||||
}
|
Loading…
Reference in a new issue