zephyr/scripts
Chris Friedt ad611395ee scripts: west_commands: add the west patch command
In smaller projects and organizations, forking Zephyr is usually
a tenable solution for development continuity, in the case that
bug-fixes or enhancements need to be applied to Zephyr to
unblock development.

In larger organizations, perhaps in the absence of healthy patch
management, technical debt management, and open-source policies,
forking and in-tree changes can quickly get out of hand.

In other organizations, it may simply be preferable to have a
zero-forking / upstream-first policy.

Regardless of the reason, this change adds a `west patch`
command that enables users to manage patches locally in their
modules, under version control, with complete transparence.

The format of the YAML file (detailed in a previous comit)
includes fields for filename, checksum, author, email, dates,
along with pr and issue links. There are fields indicating
whether the patch is upstreamble or whether it has been merged
upstream already. There is a custom field that is not validated
and can be used for any purpose.

Workflows can be created to notify maintainers when a merged
patch may be discarded after a version or a commit bump.

In Zephyr modules, the file resides conventionally under
`zephyr/patches.yml`, and patch files reside under
`zephyr/patches/`.

Sample usage applying patches (the `-v` argument for additional
detail):
```shell
west -v patch apply
reading patch file zephyr/run-tests-with-rtt-console.patch
checking patch integrity... OK
patching zephyr... OK
reading patch file zephyr/twister-rtt-support.patch
checking patch integrity... OK
patching zephyr... OK
reading patch file zephyr/multiple_icntl.patch
checking patch integrity... OK
patching zephyr... OK
reading patch file zephyr/move-bss-to-end.patch
checking patch integrity... OK
patching zephyr... OK
4 patches applied successfully \o/
```

Cleaning previously applied patches
```shell
west patch clean
```

After manually corrupting a patch file (the `-r` option will
automatically roll-back all changes if one patch fails)
```shell
west -v patch apply -r
reading patch file zephyr/run-tests-with-rtt-console.patch
checking patch integrity... OK
patching zephyr... OK
reading patch file zephyr/twister-rtt-support.patch
checking patch integrity... OK
patching zephyr... OK
reading patch file zephyr/multiple_icntl.patch
checking patch integrity... OK
patching zephyr... OK
reading patch file zephyr/move-bss-to-end.patch
checking patch integrity... FAIL
ERROR: sha256 mismatch for zephyr/move-bss-to-end.patch:
expect: 00e42e5d89f68f8b07e355821cfcf492faa2f96b506bbe87a9b35a823fd719cb
actual: b9900e0c9472a0aaae975370b478bb26945c068497fa63ff409b21d677e5b89f
Cleaning zephyr
FATAL ERROR: failed to apply patch zephyr/move-bss-to-end.patch
```

Signed-off-by: Chris Friedt <cfriedt@tenstorrent.com>
2024-12-24 11:15:38 +01:00
..
build UF2: Enable support for Raspberry Pi RP2350 2024-12-23 23:57:57 +01:00
checkpatch scripts: checkpatch: add NRF_GPIO_Type to typedefs file 2024-11-01 12:10:12 -05:00
ci CODEOWNERS: drop CODEOWNERS file as it's not used anymore 2024-12-03 04:01:27 +01:00
coccinelle scripts: coccinelle: add errno as a reserved name 2024-08-22 14:21:53 -04:00
coredump scripts: coredump: Fix loading coredumps when thread info is enabled. 2024-12-09 22:06:23 +00:00
dts devicetree: Add DT_FOREACH_ANCESTOR macro 2024-12-18 10:17:09 +01:00
footprint ci: footprint: fix nrf5340dk/nrf5340/cpuapp board name 2024-10-25 14:08:18 +02:00
generate_usb_vif python: Format and sort imports 2024-11-25 10:07:13 +01:00
gitlint gitlint: do not allow treewide as an area in commit messages 2024-04-10 09:22:24 +02:00
kconfig kconfig: Add dt_compat_any_not_has_prop function 2024-12-16 13:09:14 +01:00
logging/dictionary scripts: logging: dictionary: fix parsing of DWARF v5 2024-12-20 12:36:46 +01:00
native_simulator native_simulator: Get latest from upstream 2024-10-24 17:01:50 +01:00
net tests|scripts/net: Change native_posix references to native_sim 2024-03-20 15:43:05 +01:00
profiling scripts: profiling: Add stackcollapse script 2024-08-13 18:28:44 -04:00
pylib twister: add dt_node_prop_enabled support 2024-12-20 18:30:43 +01:00
pylint/checkers
release scripts: drop list_issues.py 2023-07-25 16:45:15 +02:00
ruff scripts: Add helper scripts for ruff baseline excludes 2024-11-19 18:36:54 -05:00
schemas scripts: schemas: add schema for patches.yml files 2024-12-24 11:15:38 +01:00
support
tests twister: handlers: Pass harness reason to instance 2024-12-17 11:37:40 +00:00
tracing tracing: add named event trace 2024-10-17 10:46:52 -04:00
utils python: Format and sort imports 2024-11-25 10:07:13 +01:00
west_commands scripts: west_commands: add the west patch command 2024-12-24 11:15:38 +01:00
.gitignore
check_maintainers.py python: Format and sort imports 2024-11-25 10:07:13 +01:00
checkpatch.pl CODEOWNERS: drop CODEOWNERS file as it's not used anymore 2024-12-03 04:01:27 +01:00
checkstack.pl
coccicheck
dump_bugs_pickle.py
gen_gcov_files.py
get_maintainer.py scripts: get_maintainer: check maintenance status 2024-06-28 07:19:49 -04:00
github_helpers.py
list_boards.py scripts: Undo Board.{dir -> directories[0]} renames 2024-10-26 17:14:06 +02:00
list_hardware.py scripts: list_hardware: Do not check qualifiers for run once config 2024-10-26 17:14:06 +02:00
list_shields.py scripts: list_shields: add script for listing the supported shields 2024-05-21 16:47:24 -04:00
make_bugs_pickle.py ci: scripts: do not count PRs labeled as bug in snapshot 2024-07-12 16:10:13 -04:00
requirements-base.txt Revert "cmake: remove enforcement of DWARF v4" 2024-12-20 16:05:23 +01:00
requirements-build-test.txt scripts: coverage: gcovr to ignore negative counters 2023-11-03 07:57:10 -04:00
requirements-compliance.txt scripts: Update and lock ruff 2024-12-03 23:30:00 +00:00
requirements-extras.txt scripts: Remove zcbor requirement from requirements-extras.txt 2024-12-23 17:09:43 +01:00
requirements-run-test.txt scripts: Remove wrong bz package 2024-09-23 09:59:56 +02:00
requirements.txt
series-push-hook.sh
set_assignees.py ci: set_assignee: pick next area when submitter = assignee 2024-07-10 19:14:17 -04:00
snippets.py terminology: adopt CMake, python, and Kconfig code to use qualifiers 2024-03-21 15:32:17 +01:00
spelling.txt scripts: RISCV instruction SEPC 2024-08-27 10:48:58 -04:00
tags.sh
twister scripts: twister: Python Version Guard 2024-11-04 17:24:24 -05:00
valgrind.supp valgrind: Update POSIX soc no cpu cleanup suppression 2023-11-29 15:33:49 +01:00
west-commands.yml scripts: west_commands: Add packages command 2024-11-25 12:16:43 +01:00
zephyr_module.py scripts: west_commands: Add packages command 2024-11-25 12:16:43 +01:00