aboutsummaryrefslogtreecommitdiff
path: root/infra/libkookie/nixpkgs/pkgs/applications/science/electronics/kicad
diff options
context:
space:
mode:
authorMx Kookie <kookie@spacekookie.de>2020-10-31 19:35:09 +0100
committerMx Kookie <kookie@spacekookie.de>2020-10-31 19:35:09 +0100
commitc4625b175f8200f643fd6e11010932ea44c78433 (patch)
treebce3f89888c8ac3991fa5569a878a9eab6801ccc /infra/libkookie/nixpkgs/pkgs/applications/science/electronics/kicad
parent49f735974dd103039ddc4cb576bb76555164a9e7 (diff)
parentd661aa56a8843e991261510c1bb28fdc2f6975ae (diff)
Add 'infra/libkookie/' from commit 'd661aa56a8843e991261510c1bb28fdc2f6975ae'
git-subtree-dir: infra/libkookie git-subtree-mainline: 49f735974dd103039ddc4cb576bb76555164a9e7 git-subtree-split: d661aa56a8843e991261510c1bb28fdc2f6975ae
Diffstat (limited to 'infra/libkookie/nixpkgs/pkgs/applications/science/electronics/kicad')
-rw-r--r--infra/libkookie/nixpkgs/pkgs/applications/science/electronics/kicad/base.nix157
-rw-r--r--infra/libkookie/nixpkgs/pkgs/applications/science/electronics/kicad/default.nix273
-rw-r--r--infra/libkookie/nixpkgs/pkgs/applications/science/electronics/kicad/i18n.nix18
-rw-r--r--infra/libkookie/nixpkgs/pkgs/applications/science/electronics/kicad/libraries.nix31
-rwxr-xr-xinfra/libkookie/nixpkgs/pkgs/applications/science/electronics/kicad/update.sh193
-rw-r--r--infra/libkookie/nixpkgs/pkgs/applications/science/electronics/kicad/versions.nix52
6 files changed, 724 insertions, 0 deletions
diff --git a/infra/libkookie/nixpkgs/pkgs/applications/science/electronics/kicad/base.nix b/infra/libkookie/nixpkgs/pkgs/applications/science/electronics/kicad/base.nix
new file mode 100644
index 000000000000..3d83e905103b
--- /dev/null
+++ b/infra/libkookie/nixpkgs/pkgs/applications/science/electronics/kicad/base.nix
@@ -0,0 +1,157 @@
+{ stdenv
+, fetchFromGitLab
+, cmake
+, libGLU
+, libGL
+, zlib
+, wxGTK
+, libX11
+, gettext
+, glew
+, glm
+, cairo
+, curl
+, openssl
+, boost
+, pkgconfig
+, doxygen
+, pcre
+, libpthreadstubs
+, libXdmcp
+, fetchpatch
+, lndir
+, callPackage
+
+, stable
+, baseName
+, kicadSrc
+, kicadVersion
+, i18n
+, withOCE
+, opencascade
+, withOCC
+, opencascade-occt
+, withNgspice
+, libngspice
+, withScripting
+, swig
+, python
+, wxPython
+, debug
+, valgrind
+, withI18n
+, gtk3
+}:
+
+assert stdenv.lib.asserts.assertMsg (!(withOCE && stdenv.isAarch64)) "OCE fails a test on Aarch64";
+assert stdenv.lib.asserts.assertMsg (!(withOCC && withOCE))
+ "Only one of OCC and OCE may be enabled";
+let
+ inherit (stdenv.lib) optional optionals;
+in
+stdenv.mkDerivation rec {
+ pname = "kicad-base";
+ version = kicadVersion;
+
+ src = kicadSrc;
+
+ # quick fix for #72248
+ # should be removed if a a more permanent fix is published
+ patches = [
+ (
+ fetchpatch {
+ url = "https://github.com/johnbeard/kicad/commit/dfb1318a3989e3d6f9f2ac33c924ca5030ea273b.patch";
+ sha256 = "00ifd3fas8lid8svzh1w67xc8kyx89qidp7gm633r014j3kjkgcd";
+ }
+ )
+ ];
+
+ # tagged releases don't have "unknown"
+ # kicad nightlies use git describe --dirty
+ # nix removes .git, so its approximated here
+ # "-1" appended to indicate we're adding a patch
+ postPatch = ''
+ substituteInPlace CMakeModules/KiCadVersion.cmake \
+ --replace "unknown" "${builtins.substring 0 10 src.rev}-1" \
+ --replace "${version}" "${version}-1"
+ '';
+
+ makeFlags = optional (debug) [ "CFLAGS+=-Og" "CFLAGS+=-ggdb" ];
+
+ cmakeFlags =
+ optionals (withScripting) [
+ "-DKICAD_SCRIPTING=ON"
+ "-DKICAD_SCRIPTING_MODULES=ON"
+ "-DKICAD_SCRIPTING_PYTHON3=ON"
+ "-DKICAD_SCRIPTING_WXPYTHON_PHOENIX=ON"
+ ]
+ ++ optional (!withScripting)
+ "-DKICAD_SCRIPTING=OFF"
+ ++ optional (withNgspice) "-DKICAD_SPICE=ON"
+ ++ optional (!withOCE) "-DKICAD_USE_OCE=OFF"
+ ++ optional (!withOCC) "-DKICAD_USE_OCC=OFF"
+ ++ optionals (withOCE) [
+ "-DKICAD_USE_OCE=ON"
+ "-DOCE_DIR=${opencascade}"
+ ]
+ ++ optionals (withOCC) [
+ "-DKICAD_USE_OCC=ON"
+ "-DOCC_INCLUDE_DIR=${opencascade-occt}/include/opencascade"
+ ]
+ ++ optionals (debug) [
+ "-DCMAKE_BUILD_TYPE=Debug"
+ "-DKICAD_STDLIB_DEBUG=ON"
+ "-DKICAD_USE_VALGRIND=ON"
+ ]
+ ;
+
+ nativeBuildInputs = [ cmake doxygen pkgconfig lndir ];
+
+ buildInputs = [
+ libGLU
+ libGL
+ zlib
+ libX11
+ wxGTK
+ pcre
+ libXdmcp
+ gettext
+ glew
+ glm
+ libpthreadstubs
+ cairo
+ curl
+ openssl
+ boost
+ gtk3
+ ]
+ ++ optionals (withScripting) [ swig python wxPython ]
+ ++ optional (withNgspice) libngspice
+ ++ optional (withOCE) opencascade
+ ++ optional (withOCC) opencascade-occt
+ ++ optional (debug) valgrind
+ ;
+
+ # debug builds fail all but the python test
+ # 5.1.x fails the eeschema test
+ doInstallCheck = !debug && !stable;
+ installCheckTarget = "test";
+
+ dontStrip = debug;
+
+ postInstall = optional (withI18n) ''
+ mkdir -p $out/share
+ lndir ${i18n}/share $out/share
+ '';
+
+ meta = {
+ description = "Just the built source without the libraries";
+ longDescription = ''
+ Just the build products, optionally with the i18n linked in
+ the libraries are passed via an env var in the wrapper, default.nix
+ '';
+ homepage = "https://www.kicad-pcb.org/";
+ license = stdenv.lib.licenses.agpl3;
+ platforms = stdenv.lib.platforms.all;
+ };
+}
diff --git a/infra/libkookie/nixpkgs/pkgs/applications/science/electronics/kicad/default.nix b/infra/libkookie/nixpkgs/pkgs/applications/science/electronics/kicad/default.nix
new file mode 100644
index 000000000000..7290503311d3
--- /dev/null
+++ b/infra/libkookie/nixpkgs/pkgs/applications/science/electronics/kicad/default.nix
@@ -0,0 +1,273 @@
+{ stdenv
+, fetchFromGitLab
+, gnome3
+, wxGTK30
+, wxGTK31
+, makeWrapper
+, gsettings-desktop-schemas
+, hicolor-icon-theme
+, callPackage
+, callPackages
+, librsvg
+, cups
+
+, pname ? "kicad"
+, stable ? true
+, oceSupport ? false
+, withOCE ? false
+, opencascade
+, withOCCT ? false
+, withOCC ? true
+, opencascade-occt
+, ngspiceSupport ? false
+, withNgspice ? true
+, libngspice
+, scriptingSupport ? false
+, withScripting ? true
+, swig
+, python3
+, debug ? false
+, valgrind
+, with3d ? true
+, withI18n ? true
+, srcs ? { }
+}:
+
+# The `srcs` parameter can be used to override the kicad source code
+# and all libraries (including i18n), which are otherwise inaccessible
+# to overlays since most of the kicad build expression has been
+# refactored into base.nix, most of the library build expressions have
+# been refactored into libraries.nix, and most the i18n build
+# expression has been refactored into i18n.nix. Overrides are only
+# applied when building `kicad-unstable`. The `srcs` parameter has no
+# effect for stable `kicad`. `srcs` takes an attribute set in which
+# any of the following attributes are meaningful (though none are
+# mandatory): "kicad", "kicadVersion", "i18n", "symbols", "templates",
+# "footprints", "packages3d", and "libVersion". "kicadVersion" and
+# "libVersion" should be set to a string with the desired value for
+# the version attribute in kicad's `mkDerivation` and the version
+# attribute in any of the library's or i18n's `mkDerivation`,
+# respectively. "kicad", "i18n", "symbols", "templates", "footprints",
+# and "packages3d" should be set to an appropriate fetcher (e.g.,
+# `fetchFromGitLab`). So, for example, a possible overlay for kicad
+# is:
+#
+# final: prev:
+
+# {
+# kicad-unstable = (prev.kicad-unstable.override {
+# srcs = {
+# kicadVersion = "2020-10-08";
+# kicad = prev.fetchFromGitLab {
+# group = "kicad";
+# owner = "code";
+# repo = "kicad";
+# rev = "fd22fe8e374ce71d57e9f683ba996651aa69fa4e";
+# sha256 = "sha256-F8qugru/jU3DgZSpQXQhRGNFSk0ybFRkpyWb7HAGBdc=";
+# };
+# };
+# });
+# }
+
+assert withNgspice -> libngspice != null;
+assert stdenv.lib.assertMsg (!ngspiceSupport)
+ "`nspiceSupport` was renamed to `withNgspice` for the sake of consistency with other kicad nix arguments.";
+assert stdenv.lib.assertMsg (!oceSupport)
+ "`oceSupport` was renamed to `withOCE` for the sake of consistency with other kicad nix arguments.";
+assert stdenv.lib.assertMsg (!scriptingSupport)
+ "`scriptingSupport` was renamed to `withScripting` for the sake of consistency with other kicad nix arguments.";
+assert stdenv.lib.assertMsg (!withOCCT)
+ "`withOCCT` was renamed to `withOCC` for the sake of consistency with upstream cmake options.";
+let
+ baseName = if (stable) then "kicad" else "kicad-unstable";
+ versionsImport = import ./versions.nix;
+
+ # versions.nix does not provide us with version, src and rev. We
+ # need to turn this into approprate fetcher calls.
+ kicadSrcFetch = fetchFromGitLab {
+ group = "kicad";
+ owner = "code";
+ repo = "kicad";
+ rev = versionsImport.${baseName}.kicadVersion.src.rev;
+ sha256 = versionsImport.${baseName}.kicadVersion.src.sha256;
+ };
+
+ i18nSrcFetch = fetchFromGitLab {
+ group = "kicad";
+ owner = "code";
+ repo = "kicad-i18n";
+ rev = versionsImport.${baseName}.libVersion.libSources.i18n.rev;
+ sha256 = versionsImport.${baseName}.libVersion.libSources.i18n.sha256;
+ };
+
+ libSrcFetch = name: fetchFromGitLab {
+ group = "kicad";
+ owner = "libraries";
+ repo = "kicad-${name}";
+ rev = versionsImport.${baseName}.libVersion.libSources.${name}.rev;
+ sha256 = versionsImport.${baseName}.libVersion.libSources.${name}.sha256;
+ };
+
+ # only override `src` or `version` if building `kicad-unstable` with
+ # the appropriate attribute defined in `srcs`.
+ srcOverridep = attr: (!stable && builtins.hasAttr attr srcs);
+
+ # use default source and version (as defined in versions.nix) by
+ # default, or use the appropriate attribute from `srcs` if building
+ # unstable with `srcs` properly defined.
+ kicadSrc =
+ if srcOverridep "kicad" then srcs.kicad
+ else kicadSrcFetch;
+ kicadVersion =
+ if srcOverridep "kicadVersion" then srcs.kicadVersion
+ else versionsImport.${baseName}.kicadVersion.version;
+
+ i18nSrc = if srcOverridep "i18n" then srcs.i18n else i18nSrcFetch;
+ i18nVersion =
+ if srcOverridep "i18nVersion" then srcs.i18nVersion
+ else versionsImport.${baseName}.libVersion.version;
+
+ libSrc = name: if srcOverridep name then srcs.${name} else libSrcFetch name;
+ # TODO does it make sense to only have one version for all libs?
+ libVersion =
+ if srcOverridep "libVersion" then srcs.libVersion
+ else versionsImport.${baseName}.libVersion.version;
+
+ wxGTK =
+ if (stable)
+ # wxGTK3x may default to withGtk2 = false, see #73145
+ then
+ wxGTK30.override
+ {
+ withGtk2 = false;
+ }
+ # wxGTK31 currently introduces an issue with opening the python interpreter in pcbnew
+ # but brings high DPI support?
+ else
+ wxGTK31.override {
+ withGtk2 = false;
+ };
+
+ python = python3;
+ wxPython = python.pkgs.wxPython_4_0;
+
+ inherit (stdenv.lib) concatStringsSep flatten optionalString optionals;
+in
+stdenv.mkDerivation rec {
+
+ # Common libraries, referenced during runtime, via the wrapper.
+ passthru.libraries = callPackages ./libraries.nix { inherit libSrc libVersion; };
+ passthru.i18n = callPackage ./i18n.nix {
+ src = i18nSrc;
+ version = i18nVersion;
+ };
+ base = callPackage ./base.nix {
+ inherit stable baseName;
+ inherit kicadSrc kicadVersion;
+ inherit (passthru) i18n;
+ inherit wxGTK python wxPython;
+ inherit debug withI18n withOCC withOCE withNgspice withScripting;
+ };
+
+ inherit pname;
+ version = kicadVersion;
+
+ src = base;
+ dontUnpack = true;
+ dontConfigure = true;
+ dontBuild = true;
+ dontFixup = true;
+
+ pythonPath = optionals (withScripting)
+ [ wxPython python.pkgs.six ];
+
+ nativeBuildInputs = [ makeWrapper ]
+ ++ optionals (withScripting)
+ [ python.pkgs.wrapPython ];
+
+ # We are emulating wrapGAppsHook, along with other variables to the
+ # wrapper
+ makeWrapperArgs = with passthru.libraries; [
+ "--prefix XDG_DATA_DIRS : ${base}/share"
+ "--prefix XDG_DATA_DIRS : ${hicolor-icon-theme}/share"
+ "--prefix XDG_DATA_DIRS : ${gnome3.defaultIconTheme}/share"
+ "--prefix XDG_DATA_DIRS : ${wxGTK.gtk}/share/gsettings-schemas/${wxGTK.gtk.name}"
+ "--prefix XDG_DATA_DIRS : ${gsettings-desktop-schemas}/share/gsettings-schemas/${gsettings-desktop-schemas.name}"
+ # wrapGAppsHook did these two as well, no idea if it matters...
+ "--prefix XDG_DATA_DIRS : ${cups}/share"
+ "--prefix GIO_EXTRA_MODULES : ${gnome3.dconf}/lib/gio/modules"
+
+ "--set-default KISYSMOD ${footprints}/share/kicad/modules"
+ "--set-default KICAD_SYMBOL_DIR ${symbols}/share/kicad/library"
+ "--set-default KICAD_TEMPLATE_DIR ${templates}/share/kicad/template"
+ "--prefix KICAD_TEMPLATE_DIR : ${symbols}/share/kicad/template"
+ "--prefix KICAD_TEMPLATE_DIR : ${footprints}/share/kicad/template"
+ ]
+ ++ optionals (with3d) [ "--set-default KISYS3DMOD ${packages3d}/share/kicad/modules/packages3d" ]
+ ++ optionals (withNgspice) [ "--prefix LD_LIBRARY_PATH : ${libngspice}/lib" ]
+
+ # infinisil's workaround for #39493
+ ++ [ "--set GDK_PIXBUF_MODULE_FILE ${librsvg}/lib/gdk-pixbuf-2.0/2.10.0/loaders.cache" ]
+ ;
+
+ # why does $makeWrapperArgs have to be added explicitly?
+ # $out and $program_PYTHONPATH don't exist when makeWrapperArgs gets set?
+ # kicad-ogltest's source seems to indicate that crashing is expected behaviour...
+ installPhase =
+ let
+ tools = [ "kicad" "pcbnew" "eeschema" "gerbview" "pcb_calculator" "pl_editor" "bitmap2component" ];
+ utils = [ "dxf2idf" "idf2vrml" "idfcyl" "idfrect" "kicad2step" "kicad-ogltest" ];
+ in
+ (concatStringsSep "\n"
+ (flatten [
+ (optionalString (withScripting) "buildPythonPath \"${base} $pythonPath\" \n")
+
+ # wrap each of the directly usable tools
+ (map
+ (tool: "makeWrapper ${base}/bin/${tool} $out/bin/${tool} $makeWrapperArgs"
+ + optionalString (withScripting) " --set PYTHONPATH \"$program_PYTHONPATH\""
+ )
+ tools)
+
+ # link in the CLI utils
+ (map (util: "ln -s ${base}/bin/${util} $out/bin/${util}") utils)
+ ])
+ )
+ ;
+
+ # 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 = rec {
+ description = (if (stable)
+ then "Open Source Electronics Design Automation suite"
+ else "Open Source EDA suite, development build")
+ + (if (!with3d) then ", without 3D models" else "");
+ homepage = "https://www.kicad-pcb.org/";
+ longDescription = ''
+ KiCad is an open source software suite for Electronic Design Automation.
+ The Programs handle Schematic Capture, and PCB Layout with Gerber output.
+ '';
+ license = stdenv.lib.licenses.agpl3;
+ # berce seems inactive...
+ maintainers = with stdenv.lib.maintainers; [ evils kiwi berce ];
+ # kicad is cross platform
+ platforms = stdenv.lib.platforms.all;
+ # despite that, nipkgs' wxGTK for darwin is "wxmac"
+ # and wxPython_4_0 does not account for this
+ # adjusting this package to downgrade to python2Packages.wxPython (wxPython 3),
+ # seems like more trouble than fixing wxPython_4_0 would be
+ # additionally, libngspice is marked as linux only, though it should support darwin
+
+ hydraPlatforms = if (with3d) then [ ] else platforms;
+ # We can't download the 3d models on Hydra,
+ # they are a ~1 GiB download and they occupy ~5 GiB in store.
+ # as long as the base and libraries (minus 3d) are build,
+ # this wrapper does not need to get built
+ # the kicad-*small "packages" cause this to happen
+ };
+}
diff --git a/infra/libkookie/nixpkgs/pkgs/applications/science/electronics/kicad/i18n.nix b/infra/libkookie/nixpkgs/pkgs/applications/science/electronics/kicad/i18n.nix
new file mode 100644
index 000000000000..95cea4fd7fc4
--- /dev/null
+++ b/infra/libkookie/nixpkgs/pkgs/applications/science/electronics/kicad/i18n.nix
@@ -0,0 +1,18 @@
+{ stdenv
+, cmake
+, gettext
+, src
+, version
+}:
+
+stdenv.mkDerivation {
+ inherit src version;
+
+ pname = "kicad-i18n";
+
+ nativeBuildInputs = [ cmake gettext ];
+ meta = with stdenv.lib; {
+ license = licenses.gpl2; # https://github.com/KiCad/kicad-i18n/issues/3
+ platforms = platforms.all;
+ };
+}
diff --git a/infra/libkookie/nixpkgs/pkgs/applications/science/electronics/kicad/libraries.nix b/infra/libkookie/nixpkgs/pkgs/applications/science/electronics/kicad/libraries.nix
new file mode 100644
index 000000000000..b045a7d1068b
--- /dev/null
+++ b/infra/libkookie/nixpkgs/pkgs/applications/science/electronics/kicad/libraries.nix
@@ -0,0 +1,31 @@
+{ stdenv
+, cmake
+, gettext
+, libSrc
+, libVersion
+}:
+let
+ mkLib = name:
+ stdenv.mkDerivation {
+ pname = "kicad-${name}";
+ version = libVersion;
+
+ src = libSrc name;
+
+ nativeBuildInputs = [ cmake ];
+
+ meta = rec {
+ license = stdenv.lib.licenses.cc-by-sa-40;
+ platforms = stdenv.lib.platforms.all;
+ # the 3d models are a ~1 GiB download and occupy ~5 GiB in store.
+ # this would exceed the hydra output limit
+ hydraPlatforms = if (name == "packages3d") then [ ] else platforms;
+ };
+ };
+in
+{
+ symbols = mkLib "symbols";
+ templates = mkLib "templates";
+ footprints = mkLib "footprints";
+ packages3d = mkLib "packages3d";
+}
diff --git a/infra/libkookie/nixpkgs/pkgs/applications/science/electronics/kicad/update.sh b/infra/libkookie/nixpkgs/pkgs/applications/science/electronics/kicad/update.sh
new file mode 100755
index 000000000000..8c154c302c84
--- /dev/null
+++ b/infra/libkookie/nixpkgs/pkgs/applications/science/electronics/kicad/update.sh
@@ -0,0 +1,193 @@
+#!/usr/bin/env nix-shell
+#!nix-shell -i bash -p coreutils git nix curl
+
+set -e
+
+# 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
+
+# by default nix-prefetch-url uses XDG_RUNTIME_DIR as tmp
+# which is /run/user/1000, which defaults to 10% of your RAM
+# unless you have over 64GB of ram that'll be insufficient
+# resulting in "tar: no space left on device" for packages3d
+# hence:
+export TMPDIR=/tmp
+
+# 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?
+# won't work when running in parallel?
+# 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 --utc)
+
+file="${here}/versions.nix"
+# just in case this runs in parallel
+tmp="${here}/,versions.nix.${RANDOM}"
+
+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="
+
+# 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)"
+ 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")"
+ if [[ -n ${has_rev} && -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=$((count+1))
+ 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)"
+ 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")"
+ if [[ -n ${has_rev} && -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=$((count+1))
+ fi
+
+ for lib in "${libs[@]}"; do
+ echo "Checking ${lib}" >&2
+ url="${gitlab}/libraries/kicad-${lib}.git"
+ lib_rev="$(${get_rev} "${url}" "${version}" | cut -f1 | head -n1)"
+ 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")"
+ if [[ -n ${has_rev} && -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} "https://gitlab.com/api/v4/projects/kicad%2Flibraries%2Fkicad-${lib}/repository/archive.tar.gz?sha=${lib_rev}")"
+ count=$((count+1))
+ 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}"
+
+if grep '""' "${tmp}"; then
+ echo "empty value detected, out of space?" >&2
+ exit "1"
+fi
+
+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
diff --git a/infra/libkookie/nixpkgs/pkgs/applications/science/electronics/kicad/versions.nix b/infra/libkookie/nixpkgs/pkgs/applications/science/electronics/kicad/versions.nix
new file mode 100644
index 000000000000..1afb33b6fbd8
--- /dev/null
+++ b/infra/libkookie/nixpkgs/pkgs/applications/science/electronics/kicad/versions.nix
@@ -0,0 +1,52 @@
+# This file was generated by update.sh
+
+{
+ "kicad" = {
+ kicadVersion = {
+ version = "5.1.6";
+ src = {
+ rev = "c6e7f7de7df655fd59b57823499efc443009de6b";
+ sha256 = "1pa3z0h0679jmgxlzc833h6q85b5paxdp69kf2h93vkaryj58622";
+ };
+ };
+ libVersion = {
+ version = "5.1.6";
+ libSources = {
+ i18n.rev = "5ad171ce5c8d90f4740517c2adecb310d8be51bd";
+ i18n.sha256 = "0qryi8xjm23ka363zfl7bbga0v5c31fr3d4nyxp3m168vkv9zhha";
+ symbols.rev = "5150eaa2a7d15cfc6bb1459c527c4ebaa66d7708";
+ symbols.sha256 = "12w3rdy085drlikkpb27n9ni7cyg9l0pqy7hnr86cxjcw3l5wcx6";
+ templates.rev = "9213d439f757e6049b7e54f3ea08272a0d0f44a9";
+ templates.sha256 = "1hppcsrkn4dk6ggby6ckh0q65qxkywrbyxa4lwpaf7pxjyv498xg";
+ footprints.rev = "a61b4e49762fb355f654e65a1c7db1aaf7bb2332";
+ footprints.sha256 = "1kmf91a5mmvj9izrv40mkaw1w36yjgn8daczd9rq2wlmd0rdp1zx";
+ packages3d.rev = "150ff1caf0b01dc04c84f4f966f4f88fedfa8f8c";
+ packages3d.sha256 = "0b9jglf77fy0n0r8xs4yqkv6zvipyfvp0z5dnqlzp32csy5aqpi1";
+ };
+ };
+ };
+ "kicad-unstable" = {
+ kicadVersion = {
+ version = "2020-10-09";
+ src = {
+ rev = "560428a70f0196fb4ade620042c5ddefc1685ebe";
+ sha256 = "0rzn83bpl06v1d49lcvwfg93nirn684bqqq536zxhmjm0ayx29ka";
+ };
+ };
+ libVersion = {
+ version = "2020-10-09";
+ libSources = {
+ i18n.rev = "d24af2da8cab4ce1081c401909a4a880514e5549";
+ i18n.sha256 = "0r0sv52k84sw4jxf10lrmzwmn58d2fv5h57fdrspnmvnh10q63xf";
+ symbols.rev = "9c50f4333bafc5a1abf7786436db5ffb6a66758d";
+ symbols.sha256 = "06ic59svz0256isy93863i5ay4k8wshvp1kspnqrc776wmq03l3k";
+ templates.rev = "41eae4ccd3ac02fdb969e3aa272c07ab51dcf5af";
+ templates.sha256 = "0xxfkpsgbnafmpaxpz1747zn7fhqp0kfl32rzjrx4vzxyp25q805";
+ footprints.rev = "50015af7e603cc499199c7e1c6daa7c85dd732ae";
+ footprints.sha256 = "16bic67klbj7sgj7cab8ha2fg3ypp9ap82gxkn6ijvpl7dka8bhb";
+ packages3d.rev = "df0dc0074491bb665b2c3ce569cbd4aa16118ad6";
+ packages3d.sha256 = "027jlcp9fpryldjkcxhb1b5bpwqna9kl6r0lnkd86x238kj3rd8v";
+ };
+ };
+ };
+}