From 041c3c5622ec4b72107c2cea5c7eef5dfc54c9c2 Mon Sep 17 00:00:00 2001 From: "Peter H. Hoeg" Date: Sat, 26 Jul 2025 10:44:06 +0200 Subject: [PATCH] cc2538-bsl: 2.1-unstable-2025-01-14 -> 2.1-unstable-2025-03-28 --- .../cc/cc2538-bsl/do_not_run_git.patch | 22 ++++++++ pkgs/by-name/cc/cc2538-bsl/package.nix | 56 +++++++++++++------ 2 files changed, 62 insertions(+), 16 deletions(-) create mode 100644 pkgs/by-name/cc/cc2538-bsl/do_not_run_git.patch diff --git a/pkgs/by-name/cc/cc2538-bsl/do_not_run_git.patch b/pkgs/by-name/cc/cc2538-bsl/do_not_run_git.patch new file mode 100644 index 000000000000..daa7df6c2745 --- /dev/null +++ b/pkgs/by-name/cc/cc2538-bsl/do_not_run_git.patch @@ -0,0 +1,22 @@ +diff --git a/cc2538_bsl/cc2538_bsl.py b/cc2538_bsl/cc2538_bsl.py +index b62ea64..f38d872 100755 +--- a/cc2538_bsl/cc2538_bsl.py ++++ b/cc2538_bsl/cc2538_bsl.py +@@ -1050,16 +1050,7 @@ def parse_page_address_range(device, pg_range): + + + def version(): +- # Get the version using "git describe". +- try: +- p = Popen(['git', 'describe', '--tags', '--match', '[0-9]*'], +- stdout=PIPE, stderr=PIPE) +- p.stderr.close() +- line = p.stdout.readlines()[0] +- return line.decode('utf-8').strip() +- except: +- # We're not in a git repo, or git failed, use fixed version string. +- return __version__ ++ return __version__ + + + def cli_setup(): diff --git a/pkgs/by-name/cc/cc2538-bsl/package.nix b/pkgs/by-name/cc/cc2538-bsl/package.nix index 10a77623d62a..31a6adab489a 100644 --- a/pkgs/by-name/cc/cc2538-bsl/package.nix +++ b/pkgs/by-name/cc/cc2538-bsl/package.nix @@ -4,45 +4,69 @@ python3Packages, }: -python3Packages.buildPythonApplication rec { - pname = "cc2538-bsl"; - version = "2.1-unstable-2025-01-14"; - pyproject = true; +let + pypkgs = python3Packages; + + version = "2.1-unstable-2025-03-28"; src = fetchFromGitHub { owner = "JelmerT"; repo = "cc2538-bsl"; - rev = "bb6471103c2bddd319e5fda46fe4e872ce1de407"; - hash = "sha256-iVdwwZozoFsHpLMiZq3i9wldfusAsCCZy6isKfvGqKo="; + rev = "250e8616e6cb00f1b23cb251154de984ce506f7b"; + hash = "sha256-SNWHCSbaeO4s4W29Jly9bAEhFjfej9J9qn+mxxpoe30="; }; - env.SETUPTOOLS_SCM_PRETEND_VERSION = "0.1.dev0+g${lib.substring 0 7 src.rev}"; + version' = "${lib.versions.majorMinor version}.dev0+g${lib.substring 0 7 src.rev}"; - build-system = with python3Packages; [ +in +pypkgs.buildPythonApplication rec { + pname = "cc2538-bsl"; + inherit version src; + pyproject = true; + + # if you happen to run cc2538-bsl from a git repository of any kind, you will get the + # version of *that* rather than the application itself because it will run 'git describe' + patches = [ ./do_not_run_git.patch ]; + + postPatch = '' + substituteInPlace cc2538_bsl/cc2538_bsl.py \ + --replace-fail '__version__ = "2.1"' '__version__ = "${version'}"' + ''; + + env.SETUPTOOLS_SCM_PRETEND_VERSION = version'; + + build-system = with pypkgs; [ setuptools-scm ]; - dependencies = with python3Packages; [ + dependencies = with pypkgs; [ intelhex pyserial python-magic ]; - nativeCheckInputs = with python3Packages; [ + nativeCheckInputs = with pypkgs; [ pytestCheckHook scripttest ]; - postInstall = '' - # Remove .py from binary - mv $out/bin/cc2538-bsl.py $out/bin/cc2538-bsl + # we need to patch these tests to make them work inside our sandbox, so just disable them for + # now as we run this in `postInstallCheck` + disabledTests = [ + "test_help_output" + "test_version" + ]; + + # this is just to ensure that `meta.mainProgram` exists and is executable since we disable `test_help_output` + postInstallCheck = '' + $out/bin/${meta.mainProgram} --help ''; - meta = with lib; { + meta = { homepage = "https://github.com/JelmerT/cc2538-bsl"; description = "Flash TI SimpleLink chips (CC2538, CC13xx, CC26xx) over serial"; - license = licenses.bsd3; - maintainers = with maintainers; [ lorenz ]; + license = lib.licenses.bsd3; + maintainers = with lib.maintainers; [ lorenz ]; mainProgram = "cc2538-bsl"; }; }