Clone of https://github.com/NixOS/nixpkgs.git (to stress-test knotserver)

Merge pull request #255271 from evils/kicad-testing

kicad-testing: init at 7.0-2024-01-07

authored by Peder Bergebakken Sundt and committed by GitHub c3db3ff7 e60846e9

+149 -45
+6 -3
pkgs/applications/science/electronics/kicad/base.nix
··· 43 43 , valgrind 44 44 45 45 , stable 46 + , testing 46 47 , baseName 47 48 , kicadSrc 48 49 , kicadVersion ··· 56 57 57 58 assert lib.assertMsg (!(sanitizeAddress && sanitizeThreads)) 58 59 "'sanitizeAddress' and 'sanitizeThreads' are mutually exclusive, use one."; 60 + assert testing -> !stable 61 + -> throw "testing implies stable and cannot be used with stable = false"; 59 62 60 63 let 61 64 inherit (lib) optional optionals optionalString; ··· 74 77 ]; 75 78 76 79 # tagged releases don't have "unknown" 77 - # kicad nightlies use git describe --dirty 80 + # kicad testing and nightlies use git describe --dirty 78 81 # nix removes .git, so its approximated here 79 - postPatch = lib.optionalString (!stable) '' 82 + postPatch = lib.optionalString (!stable || testing) '' 80 83 substituteInPlace cmake/KiCadVersion.cmake \ 81 84 --replace "unknown" "${builtins.substring 0 10 src.rev}" 82 85 ··· 92 95 ] 93 96 ++ optionals (stable) [ 94 97 # https://gitlab.com/kicad/code/kicad/-/issues/12491 95 - # should be resolved in the next release 98 + # should be resolved in the next major? release 96 99 "-DCMAKE_CTEST_ARGUMENTS='--exclude-regex;qa_eeschema'" 97 100 ] 98 101 ++ optional (stable && !withNgspice) "-DKICAD_SPICE=OFF"
+20 -16
pkgs/applications/science/electronics/kicad/default.nix
··· 2 2 , runCommand 3 3 , newScope 4 4 , fetchFromGitLab 5 + , makeWrapper 6 + , symlinkJoin 7 + , callPackage 8 + , callPackages 9 + 5 10 , gnome 6 11 , dconf 7 - , wxGTK32 8 12 , gtk3 9 - , makeWrapper 13 + , wxGTK32 14 + , librsvg 15 + , cups 10 16 , gsettings-desktop-schemas 11 17 , hicolor-icon-theme 12 - , callPackage 13 - , callPackages 14 - , librsvg 15 - , cups 18 + 16 19 , unzip 17 20 , jq 18 21 19 22 , pname ? "kicad" 20 23 , stable ? true 24 + , testing ? false 21 25 , withNgspice ? !stdenv.isDarwin 22 26 , libngspice 23 27 , withScripting ? true ··· 29 33 , with3d ? true 30 34 , withI18n ? true 31 35 , srcs ? { } 32 - , symlinkJoin 33 36 }: 34 37 35 38 # `addons`: https://dev-docs.kicad.org/en/addons/ ··· 75 78 # } 76 79 77 80 let 78 - baseName = if (stable) then "kicad" else "kicad-unstable"; 81 + baseName = if (testing) then "kicad-testing" 82 + else if (stable) then "kicad" 83 + else "kicad-unstable"; 79 84 versionsImport = import ./versions.nix; 80 85 81 86 # versions.nix does not provide us with version, src and rev. We ··· 154 159 passthru.libraries = callPackages ./libraries.nix { inherit libSrc; }; 155 160 passthru.callPackage = newScope { inherit addonPath python3; }; 156 161 base = callPackage ./base.nix { 157 - inherit stable baseName; 162 + inherit stable testing baseName; 158 163 inherit kicadSrc kicadVersion; 159 164 inherit wxGTK python wxPython; 160 165 inherit withNgspice withScripting withI18n; ··· 262 267 ln -s ${base}/share/metainfo $out/share/metainfo 263 268 ''; 264 269 265 - # can't run this for each pname 266 - # stable and unstable are in the same versions.nix 267 - # and kicad-small reuses stable 268 - # with "all" it updates both, run it manually if you don't want that 269 - # and can't git commit if this could be running in parallel with other scripts 270 - passthru.updateScript = [ ./update.sh "all" ]; 270 + passthru.updateScript = { 271 + command = [ ./update.sh "${pname}" ]; 272 + supportedFeatures = [ "commit" ]; 273 + }; 271 274 272 275 meta = rec { 273 276 description = (if (stable) 274 277 then "Open Source Electronics Design Automation suite" 275 - else "Open Source EDA suite, development build") 278 + else if (testing) then "Open Source EDA suite, latest on stable branch" 279 + else "Open Source EDA suite, latest on master branch") 276 280 + (lib.optionalString (!with3d) ", without 3D models"); 277 281 homepage = "https://www.kicad.org/"; 278 282 longDescription = ''
+93 -26
pkgs/applications/science/electronics/kicad/update.sh
··· 1 1 #!/usr/bin/env nix-shell 2 - #!nix-shell -i bash -p coreutils git nix curl 2 + #!nix-shell -i bash -p coreutils git nix curl jq 3 3 # shellcheck shell=bash enable=all 4 4 5 5 set -e ··· 25 25 # if there is, default to commiting? 26 26 # won't work when running in parallel? 27 27 # remove items left in /nix/store? 28 + # reuse hashes of already checked revs (to avoid redownloading testing's packages3d) 29 + 30 + # nixpkgs' update.nix passes in UPDATE_NIX_PNAME to indicate which package is being updated 31 + # assigning a default value to that as shellcheck doesn't like the use of unassigned variables 32 + : "${UPDATE_NIX_PNAME:=""}" 33 + # update.nix can also parse JSON output of this script to formulate a commit 34 + # this requires we collect the version string in the old versions.nix for the updated package 35 + old_version="" 36 + new_version="" 37 + 28 38 29 39 # get the latest tag that isn't an RC or *.99 30 40 latest_tags="$(git ls-remote --tags --sort -version:refname https://gitlab.com/kicad/code/kicad.git)" 31 41 # using a scratch variable to ensure command failures get caught (SC2312) 32 42 scratch="$(grep -o 'refs/tags/[0-9]*\.[0-9]*\.[0-9]*$' <<< "${latest_tags}")" 33 43 scratch="$(grep -ve '\.99' -e '\.9\.9' <<< "${scratch}")" 34 - scratch="$(head -n 1 <<< "${scratch}")" 44 + scratch="$(sed -n '1p' <<< "${scratch}")" 35 45 latest_tag="$(cut -d '/' -f 3 <<< "${scratch}")" 36 46 37 - all_versions=( "${latest_tag}" master ) 47 + # get the latest branch name for testing 48 + branches="$(git ls-remote --heads --sort -version:refname https://gitlab.com/kicad/code/kicad.git)" 49 + scratch="$(grep -o 'refs/heads/[0-9]*\.[0-9]*$' <<< "${branches}")" 50 + scratch="$(sed -n '1p' <<< "${scratch}")" 51 + testing_branch="$(cut -d '/' -f 3 <<< "${scratch}")" 52 + 53 + # "latest_tag" and "master" directly refer to what we want 54 + # "testing" uses "testing_branch" found above 55 + all_versions=( "${latest_tag}" testing master ) 38 56 39 57 prefetch="nix-prefetch-url --unpack --quiet" 40 58 41 59 clean="" 42 60 check_stable="" 61 + check_testing=1 43 62 check_unstable=1 44 63 commit="" 45 64 46 - for arg in "$@"; do 65 + for arg in "$@" "${UPDATE_NIX_PNAME}"; do 47 66 case "${arg}" in 48 67 help|-h|--help) echo "Read me!" >&2; exit 1; ;; 49 - kicad|release|tag|stable|*small|5*|6*) check_stable=1; check_unstable="" ;; 50 - all|both|full) check_stable=1; check_unstable=1 ;; 68 + kicad|kicad-small|release|tag|stable|5*|6*|7*|8*) check_stable=1; check_testing=""; check_unstable="" ;; 69 + *testing|kicad-testing-small) check_testing=1; check_unstable="" ;; 70 + *unstable|*unstable-small|master|main) check_unstable=1; check_testing="" ;; 71 + latest|now|today) check_unstable=1; check_testing=1 ;; 72 + all|both|full) check_stable=1; check_testing=1; check_unstable=1 ;; 73 + clean|fix|*fuck) check_stable=1; check_testing=1; check_unstable=1; clean=1 ;; 51 74 commit) commit=1 ;; 52 - clean|fix|*fuck) check_stable=1; check_unstable=1; clean=1 ;; 53 - master|*unstable|latest|now|today) check_unstable=1 ;; 54 75 *) ;; 55 76 esac 56 77 done 57 78 58 79 here="$( cd "$( dirname "${BASH_SOURCE[0]}" )" >/dev/null 2>&1 && pwd )" 59 - now=$(date --iso-8601 --utc) 80 + commit_date() { 81 + gitlab_json="$(curl -s https://gitlab.com/api/v4/projects/kicad%2Fcode%2Fkicad/repository/commits/"$1")" 82 + commit_created="$(jq .created_at --raw-output <<< "${gitlab_json}")" 83 + date --date="${commit_created}" --iso-8601 --utc 84 + } 60 85 61 86 file="${here}/versions.nix" 62 87 # just in case this runs in parallel ··· 65 90 libs=( symbols templates footprints packages3d ) 66 91 67 92 get_rev() { 68 - if [[ ${version} == "master" ]]; then 69 - git ls-remote --heads "$@" 70 - else 71 - git ls-remote --tags "$@" 72 - fi 93 + git ls-remote "$@" 73 94 } 74 95 75 96 gitlab="https://gitlab.com/kicad" ··· 78 99 lib_pre="https://gitlab.com/api/v4/projects/kicad%2Flibraries%2Fkicad-" 79 100 lib_mid="/repository/archive.tar.gz?sha=" 80 101 102 + # number of items updated 81 103 count=0 82 104 83 - printf "Latest tag is\t%s\n" "${latest_tag}" >&2 105 + printf "Latest tag is %s\n" "${latest_tag}" >&2 84 106 85 107 if [[ ! -f ${file} ]]; then 86 108 echo "No existing file, generating from scratch" >&2 87 - check_stable=1; check_unstable=1; clean=1 109 + check_stable=1; check_testing=1; check_unstable=1; clean=1 88 110 fi 89 111 90 112 printf "Writing %s\n" "${tmp}" >&2 ··· 97 119 98 120 for version in "${all_versions[@]}"; do 99 121 122 + src_version=${version}; 123 + lib_version=${version}; 124 + # testing is the stable branch on the main repo 125 + # but the libraries don't have such a branch 126 + # only the latest release tag and a master branch 127 + if [[ ${version} == "testing" ]]; then 128 + src_version=${testing_branch}; 129 + lib_version=${latest_tag}; 130 + fi 131 + 100 132 if [[ ${version} == "master" ]]; then 101 133 pname="kicad-unstable" 102 - today="${now}" 134 + elif [[ ${version} == "testing" ]]; then 135 + pname="kicad-testing" 103 136 else 104 137 pname="kicad" 105 - today="${version}" 106 138 fi 139 + 107 140 # skip a version if we don't want to check it 108 - if [[ (${version} != "master" && -n ${check_stable}) \ 109 - || (${version} == "master" && -n ${check_unstable}) ]]; then 141 + if [[ (-n ${check_stable} && ${version} != "master" && ${version} != "testing") \ 142 + || (-n ${check_testing} && ${version} == "testing") \ 143 + || (-n ${check_unstable} && ${version} == "master" ) ]]; then 144 + 145 + now=$(commit_date "${src_version}") 146 + 147 + if [[ ${version} == "master" ]]; then 148 + pname="kicad-unstable" 149 + new_version="${now}" 150 + elif [[ ${version} == "testing" ]]; then 151 + pname="kicad-testing" 152 + new_version="${testing_branch}-${now}" 153 + else 154 + pname="kicad" 155 + new_version="${version}" 156 + fi 110 157 111 158 printf "\nChecking %s\n" "${pname}" >&2 112 159 113 160 printf "%2s\"%s\" = {\n" "" "${pname}" 114 161 printf "%4skicadVersion = {\n" "" 115 - printf "%6sversion =\t\t\t\"%s\";\n" "" "${today}" 162 + printf "%6sversion =\t\t\t\"%s\";\n" "" "${new_version}" 116 163 printf "%6ssrc = {\n" "" 117 164 118 165 echo "Checking src" >&2 119 - scratch="$(get_rev "${gitlab}"/code/kicad.git "${version}")" 166 + scratch="$(get_rev "${gitlab}"/code/kicad.git "${src_version}")" 120 167 src_rev="$(cut -f1 <<< "${scratch}")" 121 168 has_rev="$(grep -sm 1 "\"${pname}\"" -A 4 "${file}" | grep -sm 1 "${src_rev}" || true)" 122 169 has_hash="$(grep -sm 1 "\"${pname}\"" -A 5 "${file}" | grep -sm 1 "sha256" || true)" 170 + old_version="$(grep -sm 1 "\"${pname}\"" -A 3 "${file}" | grep -sm 1 "version" | awk -F "\"" '{print $2}' || true)" 123 171 124 172 if [[ -n ${has_rev} && -n ${has_hash} && -z ${clean} ]]; then 125 - echo "Reusing old ${pname}.src.sha256, already latest .rev" >&2 173 + echo "Reusing old ${pname}.src.sha256, already latest .rev at ${old_version}" >&2 126 174 scratch=$(grep -sm 1 "\"${pname}\"" -A 5 "${file}") 127 175 grep -sm 1 "rev" -A 1 <<< "${scratch}" 128 176 else ··· 135 183 printf "%4s};\n" "" 136 184 137 185 printf "%4slibVersion = {\n" "" 138 - printf "%6sversion =\t\t\t\"%s\";\n" "" "${today}" 186 + printf "%6sversion =\t\t\t\"%s\";\n" "" "${new_version}" 139 187 printf "%6slibSources = {\n" "" 140 188 141 189 for lib in "${libs[@]}"; do 142 190 echo "Checking ${lib}" >&2 143 191 url="${gitlab}/libraries/kicad-${lib}.git" 144 - scratch="$(get_rev "${url}" "${version}")" 192 + scratch="$(get_rev "${url}" "${lib_version}")" 145 193 scratch="$(cut -f1 <<< "${scratch}")" 146 194 lib_rev="$(tail -n1 <<< "${scratch}")" 147 195 has_rev="$(grep -sm 1 "\"${pname}\"" -A 19 "${file}" | grep -sm 1 "${lib_rev}" || true)" 148 196 has_hash="$(grep -sm 1 "\"${pname}\"" -A 20 "${file}" | grep -sm 1 "${lib}.sha256" || true)" 149 197 if [[ -n ${has_rev} && -n ${has_hash} && -z ${clean} ]]; then 150 - echo "Reusing old kicad-${lib}-${today}.src.sha256, already latest .rev" >&2 198 + echo "Reusing old kicad-${lib}-${new_version}.src.sha256, already latest .rev" >&2 151 199 scratch="$(grep -sm 1 "\"${pname}\"" -A 20 "${file}")" 152 200 grep -sm 1 "${lib}" -A 1 <<< "${scratch}" 153 201 else ··· 191 239 else 192 240 echo "No changes, those checked are up to date" >&2 193 241 fi 242 + 243 + # using UPDATE_NIX_ATTR_PATH to detect if this is being called from update.nix 244 + # and output JSON to describe the changes 245 + if [[ -n ${UPDATE_NIX_ATTR_PATH} ]]; then 246 + 247 + if [[ ${count} -eq 0 ]]; then echo "[{}]"; exit 0; fi 248 + 249 + jq -n \ 250 + --arg attrpath "${UPDATE_NIX_PNAME}" \ 251 + --arg oldversion "${old_version}" \ 252 + --arg newversion "${new_version}" \ 253 + --arg file "${file}" \ 254 + '[{ 255 + "attrPath": $attrpath, 256 + "oldVersion": $oldversion, 257 + "newVersion": $newversion, 258 + "files": [ $file ] 259 + }]' 260 + fi
+22
pkgs/applications/science/electronics/kicad/versions.nix
··· 23 23 }; 24 24 }; 25 25 }; 26 + "kicad-testing" = { 27 + kicadVersion = { 28 + version = "7.0-2024-01-07"; 29 + src = { 30 + rev = "ace6439758f8d211001235f36f02a60488337e41"; 31 + sha256 = "0z4p2srz9rld7mq6k2y5fipz8mgsdhh2506wam4388nklzzkrccr"; 32 + }; 33 + }; 34 + libVersion = { 35 + version = "7.0-2024-01-07"; 36 + libSources = { 37 + symbols.rev = "eedf6c9ddac2816023e817d4dc91032f9d7390b9"; 38 + symbols.sha256 = "0nlgmxf9z1vf4g350dfkxql1dawgmw275wqxkgszsfxmhdfpmi9v"; 39 + templates.rev = "9ce98cc45f3778e05c404edebf0f98de5c247ffe"; 40 + templates.sha256 = "0mykfwwik7472i4r0isc5szj3dnmvd0538p0vlmzh4rcgj3pj3vm"; 41 + footprints.rev = "7061fc9847ecc1b838e60dc6826db534028494f6"; 42 + footprints.sha256 = "1az6fzh1lma71mj12bc4bblnmzjayrxhkb8w9rjvlhvvgv33cdmy"; 43 + packages3d.rev = "d7345b34daaa23acf0d4506ed937fb424b5b18cd"; 44 + packages3d.sha256 = "0xzyi4mgyifwc6dppdzh6jq294mkj0a71cwkqw2ymz1kfbksw626"; 45 + }; 46 + }; 47 + }; 26 48 "kicad-unstable" = { 27 49 kicadVersion = { 28 50 version = "2023-08-15";
+8
pkgs/top-level/all-packages.nix
··· 39704 39704 kicad = callPackage ../applications/science/electronics/kicad { }; 39705 39705 # this is the same but without the (sizable) 3D models library 39706 39706 kicad-small = kicad.override { pname = "kicad-small"; with3d = false; }; 39707 + # this is the stable branch at whatever point update.sh last updated versions.nix 39708 + kicad-testing = kicad.override { pname = "kicad-testing"; testing = true; }; 39709 + # and a small version of that 39710 + kicad-testing-small = kicad.override { 39711 + pname = "kicad-testing-small"; 39712 + testing = true; 39713 + with3d = false; 39714 + }; 39707 39715 # this is the master branch at whatever point update.sh last updated versions.nix 39708 39716 kicad-unstable = kicad.override { pname = "kicad-unstable"; stable = false; }; 39709 39717 # and a small version of that