annotations.git
6 months agoannotations: do not try to auto-detect JSON format main
Andrea Righi [Fri, 16 Feb 2024 10:54:34 +0000 (11:54 +0100)]
annotations: do not try to auto-detect JSON format

The script tries to automatically detect the format of the annotations
file (legacy or pure JSON).

However, if the legacy file contains a syntax error, the script will try
to parse the file as JSON (incorrectly) triggering another obscure
error, complaining that the JSON format is invalid.

This hides the capability to detect syntax errors properly in the
annotations file.

To prevent this, introduce a new option --json. In this way the caller
has complete control to decide which format needs to be used to parse
the annotations file.

Signed-off-by: Andrea Righi <andrea.righi@canonical.com>
8 months agoannotations v0.2 v0.2
Andrea Righi [Thu, 14 Dec 2023 10:22:59 +0000 (11:22 +0100)]
annotations v0.2

Signed-off-by: Andrea Righi <andrea.righi@canonical.com>
8 months agotests: test_override: drop unnecessary debugging print()
Andrea Righi [Wed, 13 Dec 2023 13:21:33 +0000 (14:21 +0100)]
tests: test_override: drop unnecessary debugging print()

Signed-off-by: Andrea Righi <andrea.righi@canonical.com>
8 months agotests: add a new unit test to verify the arch override
Andrea Righi [Tue, 12 Dec 2023 16:03:52 +0000 (17:03 +0100)]
tests: add a new unit test to verify the arch override

Signed-off-by: Andrea Righi <andrea.righi@canonical.com>
8 months agoannotations: properly update arch overrides
Andrea Righi [Tue, 12 Dec 2023 16:02:12 +0000 (17:02 +0100)]
annotations: properly update arch overrides

New rules that are overriding a whole arch should also override all the
correspondent flavours for that particular arch.

Signed-off-by: Andrea Righi <andrea.righi@canonical.com>
8 months agoannotations: move sys.dont_write_bytecode to main script
Andrea Righi [Mon, 11 Dec 2023 14:21:36 +0000 (15:21 +0100)]
annotations: move sys.dont_write_bytecode to main script

Move sys.dont_write_bytecode to the main script and put a comment that
describe why we need this to be enabled.

Signed-off-by: Andrea Righi <andrea.righi@canonical.com>
8 months agoannotations: coding style fixes
Andrea Righi [Mon, 11 Dec 2023 13:42:43 +0000 (14:42 +0100)]
annotations: coding style fixes

No functional changes, just some python / shell coding style fixes.

Signed-off-by: Andrea Righi <andrea.righi@canonical.com>
8 months agoadd an 'sanitize' helper script
Andrea Righi [Mon, 11 Dec 2023 13:48:32 +0000 (14:48 +0100)]
add an 'sanitize' helper script

Add a simple 'sanitize' script that allows to run the "sanitize binary"
from source without installing anything in the system.

Signed-off-by: Andrea Righi <andrea.righi@canonical.com>
8 months agopre-commit: add sanity checks
Andrea Righi [Mon, 11 Dec 2023 13:44:19 +0000 (14:44 +0100)]
pre-commit: add sanity checks

Add pre-commit config to perform sanity checks. It is possible to run
these checks locally via:

 $ pre-commit run --all

Signed-off-by: Andrea Righi <andrea.righi@canonical.com>
8 months agoannotations: clean up shebang
Andrea Righi [Mon, 11 Dec 2023 12:10:44 +0000 (13:10 +0100)]
annotations: clean up shebang

Get rid of the python shebang where it's not needed.

Signed-off-by: Andrea Righi <andrea.righi@canonical.com>
8 months agoannotations: properly update configs with included JSON files
Andrea Righi [Mon, 11 Dec 2023 09:25:34 +0000 (10:25 +0100)]
annotations: properly update configs with included JSON files

Fixes: 6d56aaf ("annotations: support JSON format")
Signed-off-by: Andrea Righi <andrea.righi@canonical.com>
8 months agoannotations: introduce --no-include
Andrea Righi [Mon, 11 Dec 2023 08:49:35 +0000 (09:49 +0100)]
annotations: introduce --no-include

Add an option to skip processing included annotations files. This option
can be useful to convert files from an old format to a newer one, by
dumping the contant of the local leaf-node annotations file, instead of
including the content of external files.

Signed-off-by: Andrea Righi <andrea.righi@canonical.com>
8 months agoannotations: support JSON format
Andrea Righi [Mon, 4 Dec 2023 11:53:42 +0000 (12:53 +0100)]
annotations: support JSON format

Allow to read and dump all annotations data in pure JSON format.

With this change applied the "annotations" script is able to read either
the old custom format (format version 4) or a new pure-JSON format
(format version 5).

It is possible to convert an old annotations file to the newer format
simply by running "annotations" (no argument): the script will parse the
old annotations (format version 4) and it will dump in output the new
content in the new pure-JSON format (format version 5).

Signed-off-by: Andrea Righi <andrea.righi@canonical.com>
8 months agotests: add an include test case
Andrea Righi [Tue, 5 Dec 2023 13:53:15 +0000 (14:53 +0100)]
tests: add an include test case

Signed-off-by: Andrea Righi <andrea.righi@canonical.com>
8 months agotests/test_todo_note: drop unnecessary debugging info
Andrea Righi [Tue, 5 Dec 2023 08:21:39 +0000 (09:21 +0100)]
tests/test_todo_note: drop unnecessary debugging info

Signed-off-by: Andrea Righi <andrea.righi@canonical.com>
8 months agoadd an 'annotations' helper script
Andrea Righi [Mon, 4 Dec 2023 11:05:17 +0000 (12:05 +0100)]
add an 'annotations' helper script

Add a simple 'annotations' script that allows to run the main
"annotations binary" from source without installing anything in the
system.

Signed-off-by: Andrea Righi <andrea.righi@canonical.com>
8 months agoannotations: dump all the structure as JSON if no argument is specified
Andrea Righi [Mon, 4 Dec 2023 11:02:43 +0000 (12:02 +0100)]
annotations: dump all the structure as JSON if no argument is specified

Signed-off-by: Andrea Righi <andrea.righi@canonical.com>
8 months agotests: add tox configuration to automate unit testing
Andrea Righi [Fri, 24 Nov 2023 10:07:06 +0000 (11:07 +0100)]
tests: add tox configuration to automate unit testing

Signed-off-by: Andrea Righi <andrea.righi@canonical.com>
8 months agotests: add some basic unit tests
Andrea Righi [Fri, 24 Nov 2023 10:06:48 +0000 (11:06 +0100)]
tests: add some basic unit tests

Signed-off-by: Andrea Righi <andrea.righi@canonical.com>
8 months agoannotations: update: properly update note for arch-flavour configs
Andrea Righi [Mon, 30 Oct 2023 13:08:49 +0000 (14:08 +0100)]
annotations: update: properly update note for arch-flavour configs

Values in the form "arch-flavour" are incorrectly processed in the logic
to determine if the note needs to be updated, causing a bunch of notes
to be incorrectly replaced with 'TODO: update not'.

Fix this by searching the values with the proper arch and flavour.

Signed-off-by: Andrea Righi <andrea.righi@canonical.com>
8 months agoannotations: update: update note when config is changing
Andrea Righi [Fri, 20 Oct 2023 07:42:57 +0000 (09:42 +0200)]
annotations: update: update note when config is changing

When a new .config is imported some values may change, but the
corresponding note is not always updated to reflect the new value.

This is wrong and it can lead to errors and incorrect information in the
annotations file.

To prevent this from happening automatically add a TODO note when any
config with a note is changing to force the reviewer to update the note.

Signed-off-by: Andrea Righi <andrea.righi@canonical.com>
8 months agoavoid generating python bytecode
Andrea Righi [Fri, 7 Jul 2023 08:44:25 +0000 (10:44 +0200)]
avoid generating python bytecode

We may want to include these scripts into kernel git repositories, so
better to avoid generating python bytecode to avoid including
unnecessary artifacts.

Signed-off-by: Andrea Righi <andrea.righi@canonical.com>
8 months agoannotations: make the output of config-check more user-friendly
Andrea Righi [Fri, 7 Jul 2023 08:29:59 +0000 (10:29 +0200)]
annotations: make the output of config-check more user-friendly

In case of a config change we shouldn't print an error, but a nicer
message instead explaining that the option simply changed.

Hopefully this will help to avoid all the misunderstanding that usually
happens by priting a normal change as an error.

Signed-off-by: Andrea Righi <andrea.righi@canonical.com>
8 months agoannotations: make argcomplete optional
Andrea Righi [Fri, 7 Jul 2023 08:28:29 +0000 (10:28 +0200)]
annotations: make argcomplete optional

Allow to run the main script also when argcomplete is not available.

Signed-off-by: Andrea Righi <andrea.righi@canonical.com>
8 months agoci: remove trailing space in pylint.yml
Andrea Righi [Thu, 6 Jul 2023 07:21:20 +0000 (09:21 +0200)]
ci: remove trailing space in pylint.yml

Signed-off-by: Andrea Righi <andrea.righi@canonical.com>
14 months agoMerge pull request #2 from corytodd/lint-check-prs v0.1
Andrea Righi [Fri, 16 Jun 2023 19:01:26 +0000 (21:01 +0200)]
Merge pull request #2 from corytodd/lint-check-prs

ci: run pylint on pull requests

14 months agoMerge pull request #1 from corytodd/fix-readme--space-delimited
Andrea Righi [Fri, 16 Jun 2023 18:59:47 +0000 (20:59 +0200)]
Merge pull request #1 from corytodd/fix-readme--space-delimited

readme: fix header list delimiter

14 months agoci: run pylint on pull requests 2/head
Cory Todd [Fri, 16 Jun 2023 17:17:00 +0000 (10:17 -0700)]
ci: run pylint on pull requests

Add pull_request as a trigger so linting issues are caught before
landing on main.

Signed-off-by: Cory Todd <cory.todd@canonical.com>
14 months agoreadme: fix header list delimiter 1/head
Cory Todd [Fri, 16 Jun 2023 17:10:19 +0000 (10:10 -0700)]
readme: fix header list delimiter

The ARCH and FLAVOUR lists are now space delimited.

Signed-off-by: Cory Todd <cory.todd@canonical.com>
14 months agodoc: update documentation and add README.md
Andrea Righi [Fri, 16 Jun 2023 09:42:54 +0000 (11:42 +0200)]
doc: update documentation and add README.md

Update documentation with the same information published in the
discourse post [1].

Moreover, convert README.rst into README.md.

[1] https://discourse.ubuntu.com/t/kernel-configuration-in-ubuntu/35857

Signed-off-by: Andrea Righi <andrea.righi@canonical.com>
14 months agodoc: add LICENSE file
Andrea Righi [Fri, 16 Jun 2023 08:48:34 +0000 (10:48 +0200)]
doc: add LICENSE file

Signed-off-by: Andrea Righi <andrea.righi@canonical.com>
14 months agoannotations: include sanitize-annotations into kconfig
Andrea Righi [Fri, 16 Jun 2023 09:13:51 +0000 (11:13 +0200)]
annotations: include sanitize-annotations into kconfig

Signed-off-by: Andrea Righi <andrea.righi@canonical.com>
14 months agosnap: add snapcraft.yaml
Andrea Righi [Fri, 16 Jun 2023 07:32:32 +0000 (09:32 +0200)]
snap: add snapcraft.yaml

Signed-off-by: Andrea Righi <andrea.righi@canonical.com>
14 months agodeb: update package description
Andrea Righi [Fri, 16 Jun 2023 06:50:56 +0000 (08:50 +0200)]
deb: update package description

Signed-off-by: Andrea Righi <andrea.righi@canonical.com>
14 months agocreate pylint.yml for github
Andrea Righi [Fri, 16 Jun 2023 10:14:00 +0000 (12:14 +0200)]
create pylint.yml for github

Signed-off-by: Andrea Righi <andrea.righi@canonical.com>
14 months agointegrate coding style checks in setup.py
Andrea Righi [Fri, 16 Jun 2023 06:09:54 +0000 (08:09 +0200)]
integrate coding style checks in setup.py

Signed-off-by: Andrea Righi <andrea.righi@canonical.com>
14 months agosetup.py: run coding style checks as part of the build
Andrea Righi [Thu, 15 Jun 2023 16:00:53 +0000 (18:00 +0200)]
setup.py: run coding style checks as part of the build

Signed-off-by: Andrea Righi <andrea.righi@canonical.com>
14 months agofix pylint warnings
Andrea Righi [Thu, 15 Jun 2023 15:54:55 +0000 (17:54 +0200)]
fix pylint warnings

Signed-off-by: Andrea Righi <andrea.righi@canonical.com>
14 months agoupdate .gitignore
Andrea Righi [Thu, 15 Jun 2023 15:40:32 +0000 (17:40 +0200)]
update .gitignore

Signed-off-by: Andrea Righi <andrea.righi@canonical.com>
14 months agoannotations: add command line autocompletion
Andrea Righi [Thu, 15 Jun 2023 15:36:35 +0000 (17:36 +0200)]
annotations: add command line autocompletion

Signed-off-by: Andrea Righi <andrea.righi@canonical.com>
14 months agopackaging: provide debian packaging info
Andrea Righi [Thu, 15 Jun 2023 15:25:08 +0000 (17:25 +0200)]
packaging: provide debian packaging info

Signed-off-by: Andrea Righi <andrea.righi@canonical.com>
14 months agopackaging: provide a proper packaging (pip) for the tool
Andrea Righi [Thu, 15 Jun 2023 15:14:32 +0000 (17:14 +0200)]
packaging: provide a proper packaging (pip) for the tool

Signed-off-by: Andrea Righi <andrea.righi@canonical.com>
14 months agodoc: add some refrences to README.rst
Andrea Righi [Thu, 15 Jun 2023 15:00:34 +0000 (17:00 +0200)]
doc: add some refrences to README.rst

Signed-off-by: Andrea Righi <andrea.righi@canonical.com>
14 months agodoc: rename README.md to README.rst
Andrea Righi [Thu, 15 Jun 2023 14:57:48 +0000 (16:57 +0200)]
doc: rename README.md to README.rst

The README is really an rst file, so rename it properly.

Signed-off-by: Andrea Righi <andrea.righi@canonical.com>
14 months agosanitize-annotations: move the script to the top folder
Andrea Righi [Thu, 15 Jun 2023 14:57:25 +0000 (16:57 +0200)]
sanitize-annotations: move the script to the top folder

Signed-off-by: Andrea Righi <andrea.righi@canonical.com>
15 months agokconfig: fix incompatibility with python < 3.9
Andrea Righi [Fri, 2 Jun 2023 13:27:30 +0000 (15:27 +0200)]
kconfig: fix incompatibility with python < 3.9

Signed-off-by: Andrea Righi <andrea.righi@canonical.com>
15 months agomove sanitize-annotations into tools/
Andrea Righi [Wed, 31 May 2023 13:38:08 +0000 (15:38 +0200)]
move sanitize-annotations into tools/

Signed-off-by: Andrea Righi <andrea.righi@canonical.com>
15 months agofix a bunch of pylint warnings
Andrea Righi [Wed, 31 May 2023 13:32:51 +0000 (15:32 +0200)]
fix a bunch of pylint warnings

Signed-off-by: Andrea Righi <andrea.righi@canonical.com>
15 months agoannotations: never drop configs that have notes different than the parent
Andrea Righi [Thu, 25 May 2023 16:59:10 +0000 (18:59 +0200)]
annotations: never drop configs that have notes different than the parent

Signed-off-by: Andrea Righi <andrea.righi@canonical.com>
15 months agointroduce sanitize-annotations.py
Andrea Righi [Wed, 24 May 2023 15:02:16 +0000 (17:02 +0200)]
introduce sanitize-annotations.py

Add a script to (try to) automatically sanitize old annotations files by
dropping all the deprecated flags, arbitrary enforcements rules, etc.

Signed-off-by: Andrea Righi <andrea.righi@canonical.com>
15 months agokconfig/annotations.py: support older way of merging dicts
Andrea Righi [Tue, 23 May 2023 06:28:41 +0000 (08:28 +0200)]
kconfig/annotations.py: support older way of merging dicts

The '|=' update operator for merging dicts is available starting in
python 3.9 however in focal we have python 3.8, which causes the
annotation parsing script to crash.

Support also the old way of merging dicts available since python 3.5
that uses dict unpacking, e.g. dict1 = {**dict1, **dict2}

Signed-off-by: Luke Nowakowski-Krijger <luke.nowakowskikrijger@canonical.com>
Signed-off-by: Andrea Righi <andrea.righi@canonical.com>
16 months agoannotations: use python3 in the shebang
Andrea Righi [Fri, 5 May 2023 06:40:17 +0000 (08:40 +0200)]
annotations: use python3 in the shebang

Make sure to not depend on python-is-python3 and explicitly use python3
for the main script.

Signed-off-by: Andrea Righi <andrea.righi@canonical.com>
17 months agoannotations: prevent duplicate include lines
Andrea Righi [Tue, 28 Mar 2023 10:48:03 +0000 (12:48 +0200)]
annotations: prevent duplicate include lines

Includes are always parsed recursively, but when we save them (e.g.,
when the annotations file is updated) we should always save only the
top-level includes, without repeating the recursive ones.

Signed-off-by: Andrea Righi <andrea.righi@canonical.com>
18 months agodoc: resync README.md with the one in the main kernel
Andrea Righi [Thu, 9 Mar 2023 21:18:50 +0000 (22:18 +0100)]
doc: resync README.md with the one in the main kernel

Signed-off-by: Andrea Righi <andrea.righi@canonical.com>
18 months agokconfig: Fix pylint violations
Juerg Haefliger [Fri, 10 Feb 2023 14:19:50 +0000 (15:19 +0100)]
kconfig: Fix pylint violations

Fix the following:
R0205: Class 'Config' inherits from object, can be safely removed from bases in python3 (useless-object-inheritance)
E1101: Instance of 'Config' has no '_parse' member (no-member)
W0613: Unused argument 'arch' (unused-argument)
W0613: Unused argument 'flavour' (unused-argument)
W1514: Using open without explicitly specifying an encoding (unspecified-encoding)
R0201: Method could be a function (no-self-use)
E1101: Instance of 'Config' has no 'config' member (no-member)
W0707: Consider explicitly re-raising using the 'from' keyword (raise-missing-from)
W0105: String statement has no effect (pointless-string-statement)
W0123: Use of eval (eval-used)
W0102: Dangerous default value [] as argument (dangerous-default-value)
R1723: Unnecessary "elif" after "break" (no-else-break)
R1705: Unnecessary "elif" after "return" (no-else-return)
R1704: Redefining argument with the local name 'arch' (redefined-argument-from-local)

Signed-off-by: Juerg Haefliger <juergh@proton.me>
18 months agoannotations: Fix pylint violations
Juerg Haefliger [Fri, 10 Feb 2023 09:31:51 +0000 (10:31 +0100)]
annotations: Fix pylint violations

Fix the following:
R1722: Consider using sys.exit() (consider-using-sys-exit)
C0209: Formatting a regular string which could be a f-string (consider-using-f-string)
W0703: Catching too general exception Exception (broad-except)
W1514: Using open without explicitly specifying an encoding (unspecified-encoding)
C0411: standard import "from signal import signal, SIGPIPE, SIG_DFL" should be placed before "from kconfig.annotations import Annotation, KConfig" (wrong-import-order)

Signed-off-by: Juerg Haefliger <juergh@proton.me>
18 months agosetup.cfg: Disable some overly conservative pylint checks
Juerg Haefliger [Sat, 11 Feb 2023 08:11:50 +0000 (09:11 +0100)]
setup.cfg: Disable some overly conservative pylint checks

Disable some 'too-many-<foo>' and 'too-few-<bar>' checks which we don't
really care about too much :-).

Signed-off-by: Juerg Haefliger <juergh@proton.me>
18 months agoAdd 'pylint' target and config section
Juerg Haefliger [Fri, 10 Feb 2023 09:19:58 +0000 (10:19 +0100)]
Add 'pylint' target and config section

Signed-off-by: Juerg Haefliger <juergh@proton.me>
18 months agoFix flake8 violations
Juerg Haefliger [Fri, 10 Feb 2023 07:34:13 +0000 (08:34 +0100)]
Fix flake8 violations

Signed-off-by: Juerg Haefliger <juergh@proton.me>
18 months agoAdd Makefile with initial 'lint' target
Juerg Haefliger [Fri, 10 Feb 2023 07:09:51 +0000 (08:09 +0100)]
Add Makefile with initial 'lint' target

Signed-off-by: Juerg Haefliger <juergh@proton.me>
18 months agoannotations: Check validity of FLAVOUR_DEP
Andrea Righi [Wed, 8 Feb 2023 07:53:48 +0000 (08:53 +0100)]
annotations: Check validity of FLAVOUR_DEP

FLAVOUR_DEP is used to map flavors from the main annotations file to
flavors from includes. Currently, there is no check that any of the
listed flavors exists or is valid so the resulting behavior is
(probably) undefined/unexpected. Add a sanity check to verify the
FLAVOUR_DEP flavors.

Signed-off-by: Juerg Haefliger <juerg.haefliger@canonical.com>
Signed-off-by: Andrea Righi <andrea.righi@canonical.com>
18 months agoannotations: cleanups + always save configs with note at the top
Andrea Righi [Wed, 8 Feb 2023 07:53:06 +0000 (08:53 +0100)]
annotations: cleanups + always save configs with note at the top

Signed-off-by: Juerg Haefliger <juerg.haefliger@canonical.com>
Signed-off-by: Andrea Righi <andrea.righi@canonical.com>
18 months agoannotations: support single-line rules
Andrea Righi [Wed, 8 Feb 2023 06:40:15 +0000 (07:40 +0100)]
annotations: support single-line rules

The old annotations scheme allowed single-line rules like:
CONFIG_FOO  policy<{..}> note<..>

With the switch to the new annotations script, we lost that capability.
This change brings it back.

Signed-off-by: Juerg Haefliger <juerg.haefliger@canonical.com>
Signed-off-by: Andrea Righi <andrea.righi@canonical.com>
19 months agoannotations: fix _remove_entry() logic
Andrea Righi [Fri, 3 Feb 2023 10:55:55 +0000 (11:55 +0100)]
annotations: fix _remove_entry() logic

Drop unnecessary delete statements and fix the code to properly remove
the entry in _remove_entry().

Reported-by: Juerg Haefliger <juerg.haefliger@canonical.com>
Signed-off-by: Andrea Righi <andrea.righi@canonical.com>
19 months agoannotations: do not drop undefined configs in derivatives
Andrea Righi [Tue, 31 Jan 2023 13:47:15 +0000 (14:47 +0100)]
annotations: do not drop undefined configs in derivatives

Prevent dropping configs that are undefined across all the supported
architectures in annotations that have includes, because we may want to
use them to override configs imported from other annotations.

Signed-off-by: Andrea Righi <andrea.righi@canonical.com>
19 months agoannotations: make sure to always drop undefined configs
Andrea Righi [Mon, 30 Jan 2023 08:11:54 +0000 (09:11 +0100)]
annotations: make sure to always drop undefined configs

Signed-off-by: Andrea Righi <andrea.righi@canonical.com>
19 months agoannotations: add CONFIG_GCC_VERSION to the list of skipped configs
Andrea Righi [Wed, 18 Jan 2023 15:49:02 +0000 (16:49 +0100)]
annotations: add CONFIG_GCC_VERSION to the list of skipped configs

Signed-off-by: Andrea Righi <andrea.righi@canonical.com>
19 months agoannotations: remove configs that are undefined across all arches/flavours
Andrea Righi [Tue, 3 Jan 2023 09:10:57 +0000 (10:10 +0100)]
annotations: remove configs that are undefined across all arches/flavours

Sometimes certain config options are removed in new kernels, so when
annotations is updated these options result to be undefined across all
architectures and flavours, in this case it's much more clean to simply
drop them from annotations (considering that the kernel doesn't support
them anymore).

Signed-off-by: Andrea Righi <andrea.righi@canonical.com>
19 months agoannotations: compact same value across all flavour within the same arch
Andrea Righi [Thu, 15 Dec 2022 08:46:20 +0000 (09:46 +0100)]
annotations: compact same value across all flavour within the same arch

Signed-off-by: Andrea Righi <andrea.righi@canonical.com>
19 months agoannotations: do not add constraints on toolchain
Andrea Righi [Tue, 13 Dec 2022 15:45:51 +0000 (16:45 +0100)]
annotations: do not add constraints on toolchain

Signed-off-by: Andrea Righi <andrea.righi@canonical.com>
19 months agoannotations: do not enforce toolchain versions
Andrea Righi [Mon, 12 Dec 2022 16:06:02 +0000 (17:06 +0100)]
annotations: do not enforce toolchain versions

Allow to use different versions of gcc, as and ld in the build ppa,
respect to the version used to produce the kernel packages.

Signed-off-by: Andrea Righi <andrea.righi@canonical.com>
19 months agoannotations: add missing CONFIG_ prefix in main()
Masahiro Yamada [Tue, 6 Dec 2022 00:43:50 +0000 (09:43 +0900)]
annotations: add missing CONFIG_ prefix in main()

This is common for do_query(), do_note(), do_write() (and whatever
command might be added in the future).

Move it to main().

Signed-off-by: Masahiro Yamada <masahiro.yamada@canonical.com>
Signed-off-by: Andrea Righi <andrea.righi@canonical.com>
19 months agoannotations: introduce --source
Andrea Righi [Mon, 5 Dec 2022 17:06:38 +0000 (18:06 +0100)]
annotations: introduce --source

Add an option to jump to the definition of a specific config option in
the kernel source code (this requires a prior `make tags` to work).

Signed-off-by: Andrea Righi <andrea.righi@canonical.com>
19 months agoannotations: add an option to enable config autocompletion in bash
Andrea Righi [Mon, 5 Dec 2022 16:48:39 +0000 (17:48 +0100)]
annotations: add an option to enable config autocompletion in bash

Type `source <(annotations --autocomplete)` to enable auto-completion of
config options (without the CONFIG_ prefix) in bash when running
annotations script commands.

Signed-off-by: Andrea Righi <andrea.righi@canonical.com>
19 months agoannotations: allow to specify --write and --note at the same time
Andrea Righi [Mon, 5 Dec 2022 15:38:13 +0000 (16:38 +0100)]
annotations: allow to specify --write and --note at the same time

Signed-off-by: Andrea Righi <andrea.righi@canonical.com>
19 months agoannotations: prevent python broken pipe errors
Andrea Righi [Mon, 5 Dec 2022 15:07:38 +0000 (16:07 +0100)]
annotations: prevent python broken pipe errors

Prevent broken pipe errors when showing output in pipe to other tools
(less for example).

Signed-off-by: Andrea Righi <andrea.righi@canonical.com>
19 months agoannotations: prevent generating .pyc files on import
Andrea Righi [Mon, 5 Dec 2022 11:45:53 +0000 (12:45 +0100)]
annotations: prevent generating .pyc files on import

We may end up adding these files to our git repos by mistake, so simply
prevent generating them in advance.

There's a tiny performance penalty with this change, because python
needs to re-generate the bytecode on-the-fly every time the annotations
script is called, but this overhead is absolutely negligible compared
the rest of the kernel build time.

Signed-off-by: Andrea Righi <andrea.righi@canonical.com>
19 months agoannotations: catch syntax errors in annotations
Andrea Righi [Mon, 5 Dec 2022 08:06:53 +0000 (09:06 +0100)]
annotations: catch syntax errors in annotations

Trigger a syntax error when a policy or note rule is not properly
closed.

Signed-off-by: Andrea Righi <andrea.righi@canonical.com>
19 months agoannotations: properly support multiple levels of inclusion
Andrea Righi [Mon, 5 Dec 2022 07:35:16 +0000 (08:35 +0100)]
annotations: properly support multiple levels of inclusion

Moreover, do some refactoring to optimize parsing.

Signed-off-by: Andrea Righi <andrea.righi@canonical.com>
19 months agoannotations: clarify error message with --import
Andrea Righi [Mon, 5 Dec 2022 06:53:20 +0000 (07:53 +0100)]
annotations: clarify error message with --import

Signed-off-by: Andrea Righi <andrea.righi@canonical.com>
19 months agoannotations: accept config options with or without CONFIG_ prefix
Andrea Righi [Mon, 5 Dec 2022 06:44:25 +0000 (07:44 +0100)]
annotations: accept config options with or without CONFIG_ prefix

Allow to specify config options with or without CONFIG_ prefix in the
commands --write and --note, to be consistent with --query that already
accepts both formats.

Reported-by: Masahiro Yamada <masahiro.yamada@canonical.com>
Signed-off-by: Andrea Righi <andrea.righi@canonical.com>
21 months agoannotations: properly merge configs with includes
Andrea Righi [Mon, 5 Dec 2022 06:28:49 +0000 (07:28 +0100)]
annotations: properly merge configs with includes

Signed-off-by: Andrea Righi <andrea.righi@canonical.com>
21 months agoannotations: support flavour dependencies (flavour inheritance)
Andrea Righi [Sat, 3 Dec 2022 12:06:03 +0000 (13:06 +0100)]
annotations: support flavour dependencies (flavour inheritance)

Allow to define flavour inheritance relationship in the annotations
file, such as:

  # FLAVOUR_DEP: {'amd64-lowlatency': 'amd64-generic', 'arm64-lowlatency': 'arm64-generic', 'arm64-lowlatency-64k': 'arm64-lowlatency-64k'}

In this case, for example, -lowlatency flavours inherits the config
values from -generic (both for amd64 and arm64) and -lowlatency-64
inherits the value from -generic-64k (only on arm64).

This allows to strongly reduce the size of annotations and helps to
read and review changes in annotations.

Signed-off-by: Andrea Righi <andrea.righi@canonical.com>
21 months agoannotations: allow to query CONFIG_<option> or just <option>
Andrea Righi [Thu, 1 Dec 2022 10:05:52 +0000 (11:05 +0100)]
annotations: allow to query CONFIG_<option> or just <option>

Signed-off-by: Andrea Righi <andrea.righi@canonical.com>
21 months agoannotations: allow to set notes directly and assume --query is the default command
Andrea Righi [Thu, 1 Dec 2022 09:51:11 +0000 (10:51 +0100)]
annotations: allow to set notes directly and assume --query is the default command

Allow to set a note directly to a config option without changing any
value and also assume --query is the default command, so we don't have
to specify --query explicitly to query config options.

Signed-off-by: Andrea Righi <andrea.righi@canonical.com>
21 months agoannotations: set and delete configs from command line
Andrea Righi [Tue, 29 Nov 2022 08:13:44 +0000 (09:13 +0100)]
annotations: set and delete configs from command line

Allow to set and delete config options from command line using the
'annotations' script (instead of manually editing the annotations file).

This also provides an interface to manage the annotations file from
other scripts.

Signed-off-by: Andrea Righi <andrea.righi@canonical.com>
21 months agoannotations: report config failures in alphabetical order
Andrea Righi [Mon, 28 Nov 2022 10:37:38 +0000 (11:37 +0100)]
annotations: report config failures in alphabetical order

This allows to review config check failures across multiple
architectures.

Signed-off-by: Andrea Righi <andrea.righi@canonical.com>
21 months agoannotations: provide --update command
Andrea Righi [Fri, 18 Nov 2022 10:22:29 +0000 (11:22 +0100)]
annotations: provide --update command

Add a command to import a partial .config (instead of resycning a full
.config as --import does).

Signed-off-by: Andrea Righi <andrea.righi@canonical.com>
21 months agoannotations: compact more redundant arch and flavours settings
Andrea Righi [Wed, 16 Nov 2022 08:57:04 +0000 (09:57 +0100)]
annotations: compact more redundant arch and flavours settings

Signed-off-by: Andrea Righi <andrea.righi@canonical.com>
21 months agodoc: simplify commands in examples
Andrea Righi [Tue, 15 Nov 2022 16:02:35 +0000 (17:02 +0100)]
doc: simplify commands in examples

Signed-off-by: Andrea Righi <andrea.righi@canonical.com>
21 months agoannotations: avoid generating a KeyError exception
Andrea Righi [Tue, 15 Nov 2022 11:02:56 +0000 (12:02 +0100)]
annotations: avoid generating a KeyError exception

Always try to return None when a config is not defined in annotations
rather then throwing an exception.

Signed-off-by: Andrea Righi <andrea.righi@canonical.com>
21 months agoannotations: allow to import/resync single config option
Andrea Righi [Tue, 15 Nov 2022 09:47:08 +0000 (10:47 +0100)]
annotations: allow to import/resync single config option

Signed-off-by: Andrea Righi <andrea.righi@canonical.com>
21 months agodoc: update TODO list
Andrea Righi [Tue, 15 Nov 2022 07:58:43 +0000 (08:58 +0100)]
doc: update TODO list

Signed-off-by: Andrea Righi <andrea.righi@canonical.com>
21 months agoannotations: properly handle dropped configs during import
Andrea Righi [Tue, 15 Nov 2022 07:58:30 +0000 (08:58 +0100)]
annotations: properly handle dropped configs during import

Signed-off-by: Andrea Righi <andrea.righi@canonical.com>
21 months agoannotations: check: catch options that are removed from the .config
Andrea Righi [Mon, 14 Nov 2022 22:09:07 +0000 (23:09 +0100)]
annotations: check: catch options that are removed from the .config

Signed-off-by: Andrea Righi <andrea.righi@canonical.com>
21 months agoannotations: make action argument mandatory
Andrea Righi [Mon, 14 Nov 2022 20:51:52 +0000 (21:51 +0100)]
annotations: make action argument mandatory

Signed-off-by: Andrea Righi <andrea.righi@canonical.com>
21 months agoannotations: avoid converting null results to kconfig format
Andrea Righi [Mon, 14 Nov 2022 20:49:36 +0000 (21:49 +0100)]
annotations: avoid converting null results to kconfig format

Signed-off-by: Andrea Righi <andrea.righi@canonical.com>
21 months agoannotations: try to compact annotations before saving it
Andrea Righi [Mon, 14 Nov 2022 19:01:43 +0000 (20:01 +0100)]
annotations: try to compact annotations before saving it

Signed-off-by: Andrea Righi <andrea.righi@canonical.com>
21 months agoannotations: automatically detect annotations file location
Andrea Righi [Mon, 14 Nov 2022 18:00:54 +0000 (19:00 +0100)]
annotations: automatically detect annotations file location

Signed-off-by: Andrea Righi <andrea.righi@canonical.com>
21 months agodoc: add a basic README.md
Andrea Righi [Mon, 14 Nov 2022 10:25:27 +0000 (11:25 +0100)]
doc: add a basic README.md

Signed-off-by: Andrea Righi <andrea.righi@canonical.com>