[Unstable/Lunar][RFC][PATCH] UBUNTU: [Packaging] kernelconfig: Automatically split the annotations file
Juerg Haefliger
juerg.haefliger at canonical.com
Fri Feb 3 10:38:59 UTC 2023
We currently need an annotation rule for every single kernel config
because the parser does not understand dependencies. A lot of configs are
therefore due to other config setting or dependencies and are not directly
controllable but they still end up in the annotations file and pollute it.
Ideally, all configs that are set deliberately should have a note, the
rest are just mechanically introduced necessary options. With this patch,
the annotations file is split up and all rules *without* notes are moved
to a separate file 'annotations.dep'. The idea being that by looking at
the 'main' annotations file, one can tell what this kernel's config is all
about. This is especially helpful for derivatives that include and
override the master annotations.
Obviously the whole concept depends on the maintainer being diligent and
adding notes to configs that are manually modified...
Signed-off-by: Juerg Haefliger <juerg.haefliger at canonical.com>
---
debian/scripts/misc/kernelconfig | 33 ++++++++++++++++++++++++++++++++
1 file changed, 33 insertions(+)
diff --git a/debian/scripts/misc/kernelconfig b/debian/scripts/misc/kernelconfig
index a3559f323b57..578972083259 100755
--- a/debian/scripts/misc/kernelconfig
+++ b/debian/scripts/misc/kernelconfig
@@ -173,6 +173,39 @@ else
python3 debian/scripts/misc/annotations -f "${annotations_file}" \
--arch "${arch}" --flavour "${flavour}" --import "${tmp_conf_file}"
done
+
+ if grep -q '^include "annotations.dep"' "${annotations_file}" ; then
+ echo
+ echo "Splitting annotations ..."
+ echo
+
+ # Collect the configs with notes
+ declare -A config_w_notes
+ while IFS=" " read -r config rest ; do
+ config_w_notes[${config}]=1
+ done < <(grep '^CONFIG_.* note<' "${annotations_file}")
+
+ # Move all configs without notes to the dependers file
+ true > "${annotations_file}".new
+ while IFS= read -r line ; do
+ outfile="${annotations_file}".new
+ if [ "${line#CONFIG_}" != "${line}" ] ; then
+ config=${line%% *}
+ if [ ${config_w_notes[${config}]:-0} -eq 0 ] ; then
+ outfile="${annotations_file}".dep
+ fi
+ fi
+ echo "${line}" >> "${outfile}"
+ done < "${annotations_file}"
+
+ # Squeeze multiple empty lines and remove any trailing
+ # empty line from the annotations file
+ cat -s "${annotations_file}".new | sed '${/^$/d}' > "${annotations_file}"
+ rm "${annotations_file}".new
+
+ # Sort the dependers file
+ sort -uo "${annotations_file}".dep "${annotations_file}".dep
+ fi
fi
exit "${rc}"
--
2.34.1
More information about the kernel-team
mailing list