push sheeet
Some checks failed
Periodic Merges (6h) / master → staging-nixos (push) Failing after 12m50s
Periodic Merges (6h) / master → staging-next (push) Failing after 12m54s
Periodic Merges (24h) / merge-base(master,staging) → haskell-updates (push) Failing after 11m54s
Periodic Merges (6h) / staging-next → staging (push) Failing after 12m13s
Periodic Merges (24h) / staging-next-25.05 → staging-25.05 (push) Failing after 13m24s
Periodic Merges (24h) / release-25.05 → staging-next-25.05 (push) Failing after 14m28s

This commit is contained in:
Dark Steveneq
2025-10-09 14:15:47 +02:00
commit 646b892680
49168 changed files with 5897842 additions and 0 deletions

View File

@@ -0,0 +1,5 @@
{ kicad }:
{
kikit = kicad.callPackage ./kikit.nix { addonName = "kikit"; };
kikit-library = kicad.callPackage ./kikit.nix { addonName = "kikit-library"; };
}

View File

@@ -0,0 +1,57 @@
# For building the multiple addons that are in the kikit repo.
{
stdenv,
bc,
kikit,
zip,
python3,
addonName,
addonPath,
}:
let
# This python is only used when building the package, it's not the python
# environment that will ultimately run the code packaged here. The python env defined
# in KiCad will import the python code packaged here when KiCad starts up.
python = python3.withPackages (ps: with ps; [ click ]);
kikit-module = python3.pkgs.toPythonModule (kikit.override { inherit python3; });
# The following different addons can be built from the same source.
targetSpecs = {
"kikit" = {
makeTarget = "pcm-kikit";
resultZip = "pcm-kikit.zip";
description = "KiCad plugin and a CLI tool to automate several tasks in a standard KiCad workflow";
};
"kikit-library" = {
makeTarget = "pcm-lib";
resultZip = "pcm-kikit-lib.zip";
description = "KiKit uses these symbols and footprints to annotate your boards (e.g., to place a tab in a panel)";
};
};
targetSpec = targetSpecs.${addonName};
in
stdenv.mkDerivation {
pname = "kicadaddon-${addonName}";
inherit (kikit-module) src version;
nativeBuildInputs = [
python
bc
zip
];
propagatedBuildInputs = [ kikit-module ];
buildPhase = ''
patchShebangs scripts/setJson.py
make ${targetSpec.makeTarget}
'';
installPhase = ''
mkdir $out
mv build/${targetSpec.resultZip} $out/${addonPath}
'';
meta = kikit-module.meta // {
description = targetSpec.description;
};
}

View File

@@ -0,0 +1,214 @@
{
lib,
stdenv,
cmake,
libGLU,
libGL,
zlib,
wxGTK,
gtk3,
libX11,
gettext,
glew,
glm,
cairo,
curl,
openssl,
boost,
pkg-config,
doxygen,
graphviz,
libpthreadstubs,
libXdmcp,
unixODBC,
libgit2,
libsecret,
libgcrypt,
libgpg-error,
ninja,
writableTmpDirAsHomeHook,
util-linuxMinimal,
libselinux,
libsepol,
libthai,
libdatrie,
libxkbcommon,
libepoxy,
dbus,
at-spi2-core,
libXtst,
pcre2,
libdeflate,
swig,
python,
wxPython,
opencascade-occt_7_6,
libngspice,
valgrind,
protobuf_29,
nng,
stable,
testing,
kicadSrc,
kicadVersion,
withNgspice,
withScripting,
withI18n,
debug,
sanitizeAddress,
sanitizeThreads,
}:
assert lib.assertMsg (
!(sanitizeAddress && sanitizeThreads)
) "'sanitizeAddress' and 'sanitizeThreads' are mutually exclusive, use one.";
assert testing -> !stable -> throw "testing implies stable and cannot be used with stable = false";
let
opencascade-occt = opencascade-occt_7_6;
inherit (lib)
cmakeBool
cmakeFeature
optionals
optionalString
;
in
stdenv.mkDerivation (finalAttrs: {
pname = "kicad-base";
version = if stable then kicadVersion else builtins.substring 0 10 finalAttrs.src.rev;
src = kicadSrc;
patches = [
# upstream issue 12941 (attempted to upstream, but appreciably unacceptable)
./writable.patch
# https://gitlab.com/kicad/code/kicad/-/issues/15687
./runtime_stock_data_path.patch
];
# tagged releases don't have "unknown"
# kicad testing and nightlies use git describe --dirty
# nix removes .git, so its approximated here
postPatch = lib.optionalString (!stable || testing) ''
substituteInPlace cmake/KiCadVersion.cmake \
--replace-fail "unknown" "${builtins.substring 0 10 finalAttrs.src.rev}"
substituteInPlace cmake/CreateGitVersionHeader.cmake \
--replace-fail "0000000000000000000000000000000000000000" "${finalAttrs.src.rev}"
'';
preConfigure = optionalString debug ''
export CFLAGS="''${CFLAGS:-} -Og -ggdb"
export CXXFLAGS="''${CXXFLAGS:-} -Og -ggdb"
'';
cmakeFlags = [
(cmakeBool "KICAD_USE_EGL" true)
(cmakeFeature "OCC_INCLUDE_DIR" "${opencascade-occt}/include/opencascade")
# https://gitlab.com/kicad/code/kicad/-/issues/17133
(cmakeFeature "CMAKE_CTEST_ARGUMENTS" "--exclude-regex;qa_spice")
(cmakeBool "KICAD_USE_CMAKE_FINDPROTOBUF" false)
(cmakeBool "KICAD_SCRIPTING_WXPYTHON" withScripting)
(cmakeBool "KICAD_BUILD_I18N" withI18n)
(cmakeBool "KICAD_BUILD_QA_TESTS" (!finalAttrs.doInstallCheck))
(cmakeBool "KICAD_STDLIB_DEBUG" debug)
(cmakeBool "KICAD_USE_VALGRIND" debug)
(cmakeBool "KICAD_SANITIZE_ADDRESS" sanitizeAddress)
(cmakeBool "KICAD_SANITIZE_THREADS" sanitizeThreads)
(cmakeBool "KICAD_SPICE" (!(stable && !withNgspice)))
]
++ optionals (stdenv.hostPlatform.isLinux && stdenv.hostPlatform.isAarch64) [
(cmakeFeature "CMAKE_CTEST_ARGUMENTS" "--exclude-regex;'qa_spice|qa_cli'")
];
cmakeBuildType = if debug then "Debug" else "Release";
nativeBuildInputs = [
cmake
ninja
doxygen
graphviz
pkg-config
libgit2
libsecret
libgcrypt
libgpg-error
]
# wanted by configuration on linux, doesn't seem to affect performance
# no effect on closure size
++ optionals (stdenv.hostPlatform.isLinux) [
util-linuxMinimal
libselinux
libsepol
libthai
libdatrie
libxkbcommon
libepoxy
dbus
at-spi2-core
libXtst
pcre2
];
buildInputs = [
libGLU
libGL
zlib
libX11
wxGTK
gtk3
libXdmcp
gettext
glew
glm
libpthreadstubs
cairo
curl
openssl
boost
swig
python
unixODBC
libdeflate
opencascade-occt
protobuf_29
# This would otherwise cause a linking requirement for mbedtls.
(nng.override { mbedtlsSupport = false; })
]
++ optionals withScripting [ wxPython ]
++ optionals withNgspice [ libngspice ]
++ optionals debug [ valgrind ];
# debug builds fail all but the python test
doInstallCheck = !debug;
installCheckTarget = "test";
nativeInstallCheckInputs = [
(python.withPackages (
ps: with ps; [
numpy
pytest
cairosvg
pytest-image-diff
]
))
writableTmpDirAsHomeHook
];
dontStrip = debug;
meta = {
description = "Just the built source without the libraries";
longDescription = ''
Just the build products, the libraries are passed via an env var in the wrapper, default.nix
'';
homepage = "https://www.kicad.org/";
license = lib.licenses.gpl3Plus;
platforms = lib.platforms.all;
broken = stdenv.hostPlatform.isDarwin;
};
})

View File

@@ -0,0 +1,334 @@
{
lib,
stdenv,
runCommand,
newScope,
fetchFromGitLab,
makeWrapper,
symlinkJoin,
callPackage,
callPackages,
adwaita-icon-theme,
dconf,
gtk3,
wxGTK32,
librsvg,
cups,
gsettings-desktop-schemas,
hicolor-icon-theme,
unzip,
jq,
pname ? "kicad",
stable ? true,
testing ? false,
withNgspice ? !stdenv.hostPlatform.isDarwin,
libngspice,
withScripting ? true,
python3,
addons ? [ ],
debug ? false,
sanitizeAddress ? false,
sanitizeThreads ? false,
with3d ? true,
withI18n ? true,
srcs ? { },
}:
# `addons`: https://dev-docs.kicad.org/en/addons/
#
# ```nix
# kicad = pkgs.kicad.override {
# addons = with pkgs.kicadAddons; [ kikit kikit-library ];
# };
# ```
# The `srcs` parameter can be used to override the kicad source code
# and all libraries, 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. 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", "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 `mkDerivation`, respectively.
# "kicad", "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=";
# };
# };
# });
# }
let
baseName =
if testing then
"kicad-testing"
else 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 appropriate fetcher calls.
kicadSrcFetch = fetchFromGitLab {
group = "kicad";
owner = "code";
repo = "kicad";
rev = versionsImport.${baseName}.kicadVersion.src.rev;
sha256 = versionsImport.${baseName}.kicadVersion.src.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;
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 = wxGTK32;
python = python3;
wxPython = python.pkgs.wxpython;
addonPath = "addon.zip";
addonsDrvs = map (pkg: pkg.override { inherit addonPath python3; }) addons;
addonsJoined =
runCommand "addonsJoined"
{
inherit addonsDrvs;
nativeBuildInputs = [
unzip
jq
];
}
''
mkdir $out
for pkg in $addonsDrvs; do
unzip $pkg/addon.zip -d unpacked
folder_name=$(jq .identifier unpacked/metadata.json --raw-output | tr . _)
for d in unpacked/*; do
if [ -d "$d" ]; then
dest=$out/share/kicad/scripting/$(basename $d)/$folder_name
mkdir -p $(dirname $dest)
mv $d $dest
fi
done
rm -r unpacked
done
'';
inherit (lib)
concatStringsSep
flatten
optionalString
optionals
;
in
stdenv.mkDerivation rec {
# Common libraries, referenced during runtime, via the wrapper.
passthru.libraries = callPackages ./libraries.nix { inherit libSrc; };
passthru.callPackage = newScope { inherit addonPath python3; };
base = callPackage ./base.nix {
inherit stable testing;
inherit kicadSrc kicadVersion;
inherit wxGTK python wxPython;
inherit withNgspice withScripting withI18n;
inherit debug sanitizeAddress sanitizeThreads;
};
inherit pname;
version = if stable then kicadVersion else builtins.substring 0 10 src.src.rev;
src = base;
dontUnpack = true;
dontConfigure = true;
dontBuild = true;
dontFixup = true;
pythonPath =
optionals withScripting [
wxPython
python.pkgs.six
python.pkgs.requests
]
++ addonsDrvs;
nativeBuildInputs = [ makeWrapper ] ++ optionals withScripting [ python.pkgs.wrapPython ];
# KICAD7_TEMPLATE_DIR only works with a single path (it does not handle : separated paths)
# but it's used to find both the templates and the symbol/footprint library tables
# https://gitlab.com/kicad/code/kicad/-/issues/14792
template_dir = symlinkJoin {
name = "KiCad_template_dir";
paths = with passthru.libraries; [
"${templates}/share/kicad/template"
"${footprints}/share/kicad/template"
"${symbols}/share/kicad/template"
];
};
# We are emulating wrapGAppsHook3, 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 : ${adwaita-icon-theme}/share"
"--prefix XDG_DATA_DIRS : ${gtk3}/share/gsettings-schemas/${gtk3.name}"
"--prefix XDG_DATA_DIRS : ${gsettings-desktop-schemas}/share/gsettings-schemas/${gsettings-desktop-schemas.name}"
# wrapGAppsHook3 did these two as well, no idea if it matters...
"--prefix XDG_DATA_DIRS : ${cups}/share"
"--prefix GIO_EXTRA_MODULES : ${dconf}/lib/gio/modules"
# required to open a bug report link in firefox-wayland
"--set-default MOZ_DBUS_REMOTE 1"
"--set-default KICAD9_FOOTPRINT_DIR ${footprints}/share/kicad/footprints"
"--set-default KICAD9_SYMBOL_DIR ${symbols}/share/kicad/symbols"
"--set-default KICAD9_TEMPLATE_DIR ${template_dir}"
]
++ optionals (addons != [ ]) (
let
stockDataPath = symlinkJoin {
name = "kicad_stock_data_path";
paths = [
"${base}/share/kicad"
"${addonsJoined}/share/kicad"
];
};
in
[ "--set-default NIX_KICAD9_STOCK_DATA_PATH ${stockDataPath}" ]
)
++ optionals with3d [
"--set-default KICAD9_3DMODEL_DIR ${packages3d}/share/kicad/3dmodels"
]
++ 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?
installPhase =
let
bin = if stdenv.hostPlatform.isDarwin then "*.app/Contents/MacOS" else "bin";
tools = [
"kicad"
"pcbnew"
"eeschema"
"gerbview"
"pcb_calculator"
"pl_editor"
"bitmap2component"
"kicad-cli"
];
utils = [
"dxf2idf"
"idf2vrml"
"idfcyl"
"idfrect"
];
in
(concatStringsSep "\n" (flatten [
"runHook preInstall"
(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)
"runHook postInstall"
]));
postInstall = ''
mkdir -p $out/share
ln -s ${base}/share/applications $out/share/applications
ln -s ${base}/share/icons $out/share/icons
ln -s ${base}/share/mime $out/share/mime
ln -s ${base}/share/metainfo $out/share/metainfo
'';
passthru.updateScript = {
command = [
./update.sh
"${pname}"
];
supportedFeatures = [ "commit" ];
};
meta = {
description =
(
if stable then
"Open Source Electronics Design Automation suite"
else if testing then
"Open Source EDA suite, latest on stable branch"
else
"Open Source EDA suite, latest on master branch"
)
+ (lib.optionalString (!with3d) ", without 3D models");
homepage = "https://www.kicad.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 = lib.licenses.gpl3Plus;
maintainers = [ ];
platforms = lib.platforms.all;
broken = stdenv.hostPlatform.isDarwin;
mainProgram = "kicad";
};
}

View File

@@ -0,0 +1,47 @@
{
lib,
stdenv,
cmake,
libSrc,
stepreduce,
parallel,
zip,
}:
let
mkLib =
name:
stdenv.mkDerivation {
pname = "kicad-${name}";
version = builtins.substring 0 10 (libSrc name).rev;
src = libSrc name;
nativeBuildInputs = [
cmake
]
++ lib.optionals (name == "packages3d") [
stepreduce
parallel
zip
];
postInstall =
lib.optionalString (name == "packages3d") ''
find $out -type f -name '*.step' | parallel 'stepreduce {} {} && zip -9 {.}.stpZ {} && rm {}'
''
+ lib.optionalString (name == "footprints") ''
grep -rl '\.step' $out | xargs sed -i 's/\.step/.stpZ/g'
'';
meta = {
license = lib.licenses.cc-by-sa-40;
platforms = lib.platforms.all;
};
};
in
{
symbols = mkLib "symbols";
templates = mkLib "templates";
footprints = mkLib "footprints";
packages3d = mkLib "packages3d";
}

View File

@@ -0,0 +1,15 @@
diff --git a/common/paths.cpp b/common/paths.cpp
index a74cdd9..790cc58 100644
--- a/common/paths.cpp
+++ b/common/paths.cpp
@@ -151,6 +151,10 @@ wxString PATHS::GetStockDataPath( bool aRespectRunFromBuildDir )
{
wxString path;
+ if( wxGetEnv( wxT( "NIX_KICAD9_STOCK_DATA_PATH" ), &path ) ) {
+ return path;
+ }
+
if( aRespectRunFromBuildDir && wxGetEnv( wxT( "KICAD_RUN_FROM_BUILD_DIR" ), nullptr ) )
{
// Allow debugging from build dir by placing relevant files/folders in the build root

View File

@@ -0,0 +1,261 @@
#!/usr/bin/env nix-shell
#!nix-shell -i bash -p coreutils git nix curl jq nixfmt-tree
# shellcheck shell=bash enable=all
set -e
shopt -s inherit_errexit
# 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?
# reuse hashes of already checked revs (to avoid redownloading testing's packages3d)
# nixpkgs' update.nix passes in UPDATE_NIX_PNAME to indicate which package is being updated
# assigning a default value to that as shellcheck doesn't like the use of unassigned variables
: "${UPDATE_NIX_PNAME:=""}"
# update.nix can also parse JSON output of this script to formulate a commit
# this requires we collect the version string in the old versions.nix for the updated package
old_version=""
new_version=""
# get the latest tag that isn't an RC or *.99
latest_tags="$(git ls-remote --tags --sort -version:refname https://gitlab.com/kicad/code/kicad.git)"
# using a scratch variable to ensure command failures get caught (SC2312)
scratch="$(grep -o 'refs/tags/[0-9]*\.[0-9]*\.[0-9]*$' <<< "${latest_tags}")"
scratch="$(grep -ve '\.99' -e '\.9\.9' <<< "${scratch}")"
scratch="$(sed -n '1p' <<< "${scratch}")"
latest_tag="$(cut -d '/' -f 3 <<< "${scratch}")"
# get the latest branch name for testing
branches="$(git ls-remote --heads --sort -version:refname https://gitlab.com/kicad/code/kicad.git)"
scratch="$(grep -o 'refs/heads/[0-9]*\.[0-9]*$' <<< "${branches}")"
scratch="$(sed -n '1p' <<< "${scratch}")"
testing_branch="$(cut -d '/' -f 3 <<< "${scratch}")"
# "latest_tag" and "master" directly refer to what we want
# "testing" uses "testing_branch" found above
all_versions=( "${latest_tag}" testing master )
prefetch="nix-prefetch-url --unpack --quiet"
clean=""
check_stable=""
check_testing=1
check_unstable=1
commit=""
for arg in "$@" "${UPDATE_NIX_PNAME}"; do
case "${arg}" in
help|-h|--help) echo "Read me!" >&2; exit 1; ;;
kicad|kicad-small|release|tag|stable|5*|6*|7*|8*) check_stable=1; check_testing=""; check_unstable="" ;;
*testing|kicad-testing-small) check_testing=1; check_unstable="" ;;
*unstable|*unstable-small|master|main) check_unstable=1; check_testing="" ;;
latest|now|today) check_unstable=1; check_testing=1 ;;
all|both|full) check_stable=1; check_testing=1; check_unstable=1 ;;
clean|fix|*fuck) check_stable=1; check_testing=1; check_unstable=1; clean=1 ;;
commit) commit=1 ;;
*) ;;
esac
done
here="$( cd "$( dirname "${BASH_SOURCE[0]}" )" >/dev/null 2>&1 && pwd )"
commit_date() {
gitlab_json="$(curl -s https://gitlab.com/api/v4/projects/kicad%2Fcode%2Fkicad/repository/commits/"$1")"
commit_created="$(jq .created_at --raw-output <<< "${gitlab_json}")"
date --date="${commit_created}" --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 "$@"
}
gitlab="https://gitlab.com/kicad"
# append commit hash or tag
src_pre="https://gitlab.com/api/v4/projects/kicad%2Fcode%2Fkicad/repository/archive.tar.gz?sha="
lib_pre="https://gitlab.com/api/v4/projects/kicad%2Flibraries%2Fkicad-"
lib_mid="/repository/archive.tar.gz?sha="
# number of items updated
count=0
printf "Latest tag is %s\n" "${latest_tag}" >&2
if [[ ! -f ${file} ]]; then
echo "No existing file, generating from scratch" >&2
check_stable=1; check_testing=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
src_version=${version};
lib_version=${version};
# testing is the stable branch on the main repo
# but the libraries don't have such a branch
# only the latest release tag and a master branch
if [[ ${version} == "testing" ]]; then
src_version=${testing_branch};
lib_version=${latest_tag};
fi
if [[ ${version} == "master" ]]; then
pname="kicad-unstable"
elif [[ ${version} == "testing" ]]; then
pname="kicad-testing"
else
pname="kicad"
fi
# skip a version if we don't want to check it
if [[ (-n ${check_stable} && ${version} != "master" && ${version} != "testing") \
|| (-n ${check_testing} && ${version} == "testing") \
|| (-n ${check_unstable} && ${version} == "master" ) ]]; then
now=$(commit_date "${src_version}")
if [[ ${version} == "master" ]]; then
pname="kicad-unstable"
new_version="${now}"
elif [[ ${version} == "testing" ]]; then
pname="kicad-testing"
new_version="${testing_branch}-${now}"
else
pname="kicad"
new_version="${version}"
fi
printf "\nChecking %s\n" "${pname}" >&2
printf "%2s\"%s\" = {\n" "" "${pname}"
printf "%4skicadVersion = {\n" ""
printf "%6sversion =\t\t\t\"%s\";\n" "" "${new_version}"
printf "%6ssrc = {\n" ""
echo "Checking src" >&2
scratch="$(get_rev "${gitlab}"/code/kicad.git "${src_version}")"
src_rev="$(cut -f1 <<< "${scratch}")"
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" || true)"
old_version="$(grep -sm 1 "\"${pname}\"" -A 3 "${file}" | grep -sm 1 "version" | awk -F "\"" '{print $2}' || true)"
if [[ -n ${has_rev} && -n ${has_hash} && -z ${clean} ]]; then
echo "Reusing old ${pname}.src.sha256, already latest .rev at ${old_version}" >&2
scratch=$(grep -sm 1 "\"${pname}\"" -A 5 "${file}")
grep -sm 1 "rev" -A 1 <<< "${scratch}"
else
prefetched="$(${prefetch} "${src_pre}${src_rev}")"
printf "%8srev =\t\t\t\"%s\";\n" "" "${src_rev}"
printf "%8ssha256 =\t\t\"%s\";\n" "" "${prefetched}"
count=$((count+1))
fi
printf "%6s};\n" ""
printf "%4s};\n" ""
printf "%4slibVersion = {\n" ""
printf "%6sversion =\t\t\t\"%s\";\n" "" "${new_version}"
printf "%6slibSources = {\n" ""
for lib in "${libs[@]}"; do
echo "Checking ${lib}" >&2
url="${gitlab}/libraries/kicad-${lib}.git"
scratch="$(get_rev "${url}" "${lib_version}")"
scratch="$(cut -f1 <<< "${scratch}")"
lib_rev="$(tail -n1 <<< "${scratch}")"
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" || true)"
if [[ -n ${has_rev} && -n ${has_hash} && -z ${clean} ]]; then
echo "Reusing old kicad-${lib}-${new_version}.src.sha256, already latest .rev" >&2
scratch="$(grep -sm 1 "\"${pname}\"" -A 20 "${file}")"
grep -sm 1 "${lib}" -A 1 <<< "${scratch}"
else
prefetched="$(${prefetch} "${lib_pre}${lib}${lib_mid}${lib_rev}")"
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}" "${prefetched}"
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 21 "${file}"
fi
done
printf "}\n"
} > "${tmp}"
if grep '""' "${tmp}"; then
echo "empty value detected, out of space?" >&2
exit "1"
fi
mv "${tmp}" "${file}"
treefmt "${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
# using UPDATE_NIX_ATTR_PATH to detect if this is being called from update.nix
# and output JSON to describe the changes
if [[ -n ${UPDATE_NIX_ATTR_PATH} ]]; then
if [[ ${count} -eq 0 ]]; then echo "[{}]"; exit 0; fi
jq -n \
--arg attrpath "${UPDATE_NIX_PNAME}" \
--arg oldversion "${old_version}" \
--arg newversion "${new_version}" \
--arg file "${file}" \
'[{
"attrPath": $attrpath,
"oldVersion": $oldversion,
"newVersion": $newversion,
"files": [ $file ]
}]'
fi

View File

@@ -0,0 +1,70 @@
# This file was generated by update.sh
{
"kicad" = {
kicadVersion = {
version = "9.0.5";
src = {
rev = "3e59813c21b4d0a00c08978e86b5f2189ec27864";
sha256 = "0wmnkiyqv32c5nz4nvz94dld3rk5ir49nh71cycig6clvjvy11r5";
};
};
libVersion = {
version = "9.0.5";
libSources = {
symbols.rev = "884133df0afba238567e2be6c31e7d3b4a9d90be";
symbols.sha256 = "0msgq8p3zlfc3glqr1h8n0a1agk4hjdqxqdiny5b4d0hgiy6hhmx";
templates.rev = "204b42307fc78cf0b3ebec4e19eba9d710e392f4";
templates.sha256 = "0zs29zn8qjgxv0w1vyr8yxmj02m8752zagn4vcraqgik46dwg2id";
footprints.rev = "873e3e9dbad8371d664e57261efa516d42328161";
footprints.sha256 = "179y7xmz7mwsfsv4dcw2dx689xfzqk8y38d21s69yiaalyxflhh1";
packages3d.rev = "c25dce5aadce68076ac035edb0c792608f5f597c";
packages3d.sha256 = "1y7yhynrr87q80gcb8qlkyrdccz1sllsxqymrnghhxbfk4wbwwn8";
};
};
};
"kicad-testing" = {
kicadVersion = {
version = "9.0-2025-02-21";
src = {
rev = "c4c32aa7bbadd3862fb720457b71e7a19420604c";
sha256 = "01zbvg6n8kajilj3q1sp0zpaqz94bq28wrxjax1968wvwv05g0dp";
};
};
libVersion = {
version = "9.0-2025-02-21";
libSources = {
symbols.rev = "e1c3371228f97b36c6fd61b66d056184930f078e";
symbols.sha256 = "0l8da2ix917jlsj6v5zclc1cb5pvjaxwmys0gjdv55ic31hhfyyw";
templates.rev = "3ed4538b0f965d821df63a5fffc4441e723cfe7f";
templates.sha256 = "0zs29zn8qjgxv0w1vyr8yxmj02m8752zagn4vcraqgik46dwg2id";
footprints.rev = "ef91963f57028aa095f2d0c4239ba994ea822f73";
footprints.sha256 = "16zslgvjg4swgkkvnd9fmiks3wzg63364d03hixiyzcpjlgk2bbk";
packages3d.rev = "b40831fd7ea2ca8f9c7282143dbb7d2f5015cd69";
packages3d.sha256 = "0bg54lg1iw01gw06ajg34y7x4y36wm6ls3jnpjy13i18d4ik77g4";
};
};
};
"kicad-unstable" = {
kicadVersion = {
version = "2025-02-21";
src = {
rev = "878cf768d6552131494aa792dc20e6ccf67baf75";
sha256 = "0ky0a7y6gf409y8bwpngiirqin4ivbcjnk8gjdj1a6w79x559sr8";
};
};
libVersion = {
version = "2025-02-21";
libSources = {
symbols.rev = "da86acd48809fd61876223c8bf0e4e7793c52e9a";
symbols.sha256 = "1sdpg58wbyyrghjd0jqw5iw2094mjy2v9jmwn5zrj4jm6f51g1kd";
templates.rev = "3ed4538b0f965d821df63a5fffc4441e723cfe7f";
templates.sha256 = "0zs29zn8qjgxv0w1vyr8yxmj02m8752zagn4vcraqgik46dwg2id";
footprints.rev = "e515f1c3213317d436e492c8c06620ef4caca84e";
footprints.sha256 = "16zslgvjg4swgkkvnd9fmiks3wzg63364d03hixiyzcpjlgk2bbk";
packages3d.rev = "d5db5cea003fe2b4b1c9b145f5fcbd5fdb48f8ca";
packages3d.sha256 = "0bg54lg1iw01gw06ajg34y7x4y36wm6ls3jnpjy13i18d4ik77g4";
};
};
};
}

View File

@@ -0,0 +1,49 @@
commit 6a72fd032405515e468797be91b5a6ebcbbb5fd8
Author: Evils <evils.devils@protonmail.com>
Date: Wed Nov 23 19:49:13 2022 +0100
ensure new projects are writable
diff --git a/kicad/kicad_manager_frame.cpp b/kicad/kicad_manager_frame.cpp
index 7ee8090858..391514519c 100644
--- a/kicad/kicad_manager_frame.cpp
+++ b/kicad/kicad_manager_frame.cpp
@@ -638,6 +638,12 @@ void KICAD_MANAGER_FRAME::CreateNewProject( const wxFileName& aProjectFileName,
// wxFFile dtor will close the file
}
+
+ if( destFileName.IsOk() && !destFileName.IsFileWritable() )
+ {
+ destFileName.SetPermissions(0644);
+ }
+
}
}
diff --git a/kicad/project_template.cpp b/kicad/project_template.cpp
index bf951fcddb..2bef94326b 100644
--- a/kicad/project_template.cpp
+++ b/kicad/project_template.cpp
@@ -282,6 +282,21 @@ bool PROJECT_TEMPLATE::CreateProject( wxFileName& aNewProjectPath, wxString* aEr
result = false;
}
+ else if( !destFile.IsFileWritable() && !destFile.SetPermissions(0644) )
+ {
+ if( aErrorMsg )
+ {
+ if( !aErrorMsg->empty() )
+ *aErrorMsg += "\n";
+
+ wxString msg;
+
+ msg.Printf( _( "Cannot make file writable: '%s'." ), destFile.GetFullPath() );
+ *aErrorMsg += msg;
+ }
+
+ result = false;
+ }
}
return result;