Message ID | 20230203103859.528812-1-juerg.haefliger@canonical.com |
---|---|
State | New |
Headers | show |
Series | [Unstable/Lunar,RFC] UBUNTU: [Packaging] kernelconfig: Automatically split the annotations file | expand |
On Fri, Feb 03, 2023 at 11:38:59AM +0100, Juerg Haefliger wrote: > 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@canonical.com> So, I've played with this a little bit and I like the idea of having a way to immediately identify the subset of configs with a note (configs that we care about) vs configs without notes (dependencies or configs that we don't care). However, I don't know if introducing a new file and hard-code the name "annotations.dep" is the ideal solution. Also because in perspective we may have multiple annotations files (annotations.ubuntu, annotations.cloud, annotations.systemd, annotations.apparmor, etc.). So, I was wondering if the annotations script could just save the configs with a note at the end of the files after the other configs. In this way we would still keep a single file and at the same time maintain the separation between configs-with-note vs configs-without-note. This change would be implemented in the annotations script itself and we won't have to touch any other script. What do you think? Thanks, -Andrea > --- > 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 > > > -- > kernel-team mailing list > kernel-team@lists.ubuntu.com > https://lists.ubuntu.com/mailman/listinfo/kernel-team
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}"
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@canonical.com> --- debian/scripts/misc/kernelconfig | 33 ++++++++++++++++++++++++++++++++ 1 file changed, 33 insertions(+)