2019-11-25 18:20:23 +00:00
|
|
|
#!/bin/bash
|
2020-02-06 22:31:30 +00:00
|
|
|
#
|
|
|
|
# Creates commits that moves all configuration options for a subsystem from the
|
|
|
|
# pending configuration directory to the common configuration directory. Each
|
|
|
|
# commit is contained on a branch named "configs/<date>/<subsystem path>.
|
|
|
|
#
|
|
|
|
# The commit message is formed from redhat/commit_template and includes Cc
|
|
|
|
# information for the relevant maintainers using get_maintainers.pl. This
|
|
|
|
# requires that you have $RHMAINTAINERS pointing to a valid maintainer file.
|
2019-11-25 18:20:23 +00:00
|
|
|
|
2020-02-06 22:31:30 +00:00
|
|
|
if ! git show -s --oneline HEAD | grep -q "AUTOMATIC: New configs"; then
|
2019-11-25 18:20:23 +00:00
|
|
|
echo "The git HEAD doesn't look like the correct commit"
|
|
|
|
exit 1
|
|
|
|
fi
|
|
|
|
|
2020-02-06 22:31:30 +00:00
|
|
|
config_bundles_dir=$(mktemp -d)
|
|
|
|
tmpdir=$(mktemp -d)
|
|
|
|
|
|
|
|
function cleanup {
|
|
|
|
rm -rf "$config_bundles_dir"
|
|
|
|
rm -rf "$tmpdir"
|
|
|
|
}
|
|
|
|
trap cleanup EXIT
|
|
|
|
|
2019-11-25 18:20:23 +00:00
|
|
|
# Easy way to get each of the files to process
|
2021-04-28 21:56:34 +00:00
|
|
|
# Not interested in Fedora configs
|
|
|
|
git diff --name-only HEAD HEAD^ | grep -v "pending-fedora" > "$tmpdir"/new_config_files
|
2019-11-25 18:20:23 +00:00
|
|
|
|
Fix fedora-only config updates
After every scheduled upstream merge, a script is run to find new
configs, generate pending-* files for them and for ark, create
branches to push MRs.
However, there is a case where new Fedora configs are found but not
new ARK configs. This case had issues.
When the merge is done, make dist-configs-commit is called for Fedora
and RHEL. This results in a possible new commit if configs are found.
The command is run twice and creates the following matrix:
1. Both Fedora and RHEL have new configs.
2. Neither Fedora nor RHEL have new configs.
3. Fedora does not have new configs, but RHEL does.
4. Fedora has new configs, bug RHEL does not.
1 and 2 are common and 1-3 are handled correctly.
Scenario 4 is not.
When the configs are committed, the next script gen_config_patches.sh
looks for a special commit 'AUTOMATIC'. It doesn't care if that commit
comes from Fedora or RHEL.
The gen_config_patches.sh can not handle pending-fedora changes, so
those changes are filtered in the script.
In scenario 4 that leaves an empty file to process, which the script
aborts on. Further no print out was displayed which slowed down
debugging.
The are multiple ways to address this. This patch does multiple things.
* Adds a print statement on the failure for future debugging.
* Exits on success if there are no changes to process after filtering.
* Reduces the risk of calling gen_config_patches.sh by only calling
the script when RHEL adds new configs.
Tested scenario 4 with last week's os-build HEAD.
Signed-off-by: Don Zickus <dzickus@redhat.com>
2021-07-19 17:23:19 +00:00
|
|
|
if [ ! -s "$tmpdir"/new_config_files ]; then
|
|
|
|
echo "No config changes after filtering"
|
|
|
|
exit 0
|
|
|
|
fi
|
|
|
|
|
2019-11-25 18:20:23 +00:00
|
|
|
while read -r line; do
|
|
|
|
# Read all the files and split up by file path of each config item.
|
|
|
|
# ethernet and net get handled separately others can be added as needed
|
2020-02-06 22:31:29 +00:00
|
|
|
#
|
|
|
|
# A sample of the input file we're parsing is:
|
|
|
|
# # CONFIG_ARCH_RANDOM:
|
|
|
|
# #
|
|
|
|
# # Random number generation (part of the ARMv8.5 Extensions)
|
|
|
|
# # provides a high bandwidth, cryptographically secure
|
|
|
|
# # hardware random number generator.
|
|
|
|
# #
|
|
|
|
# # Symbol: ARCH_RANDOM [=y]
|
|
|
|
# # Type : bool
|
|
|
|
# # Prompt: Enable support for random number generation
|
|
|
|
# # Location:
|
|
|
|
# # -> Kernel Features
|
|
|
|
# # -> ARMv8.5 architectural features
|
|
|
|
# # Defined at arch/arm64/Kconfig:1533
|
|
|
|
# #
|
|
|
|
# CONFIG_ARCH_RANDOM=y
|
2020-02-06 22:31:30 +00:00
|
|
|
awk -v BASE="$config_bundles_dir" '
|
2020-02-06 22:31:29 +00:00
|
|
|
function strip_kconfig_path(path_with_text)
|
|
|
|
{
|
|
|
|
sub("#.*Defined at ", "", path_with_text)
|
|
|
|
sub(":[0-9]+", "", path_with_text)
|
|
|
|
return path_with_text
|
|
|
|
}
|
2019-11-25 18:20:23 +00:00
|
|
|
/Defined at drivers\/net\/ethernet/ {
|
2020-02-06 22:31:29 +00:00
|
|
|
# For configs in here, bundle configs by vendor
|
|
|
|
kconfig_path=strip_kconfig_path($0);
|
|
|
|
split(kconfig_path, path_parts, "/")
|
|
|
|
# Only use the first component after drivers/net/ethernet
|
|
|
|
subsystem_path=BASE"/drivers:net:ethernet:"path_parts[4]
|
|
|
|
print config >> subsystem_path;
|
2019-11-25 18:20:23 +00:00
|
|
|
next;
|
|
|
|
}
|
|
|
|
/Defined at drivers\/net/ {
|
2020-02-06 22:31:29 +00:00
|
|
|
# For configs in here, bundle configs by driver type
|
|
|
|
kconfig_path=strip_kconfig_path($0);
|
|
|
|
split(kconfig_path, path_parts, "/")
|
|
|
|
subsystem_path=BASE"/drivers:net:"path_parts[3];
|
|
|
|
print config >> subsystem_path;
|
2019-11-25 18:20:23 +00:00
|
|
|
next;
|
|
|
|
}
|
|
|
|
/Defined at / {
|
2020-02-06 22:31:29 +00:00
|
|
|
# Bundle all other configuration by the first two components of the path
|
|
|
|
kconfig_path=strip_kconfig_path($0);
|
|
|
|
split(kconfig_path, path_parts, "/")
|
|
|
|
subsystem_path=BASE"/"path_parts[1]":"path_parts[2]
|
|
|
|
print config >> subsystem_path;
|
2019-11-25 18:20:23 +00:00
|
|
|
next;
|
|
|
|
}
|
2021-07-26 09:15:33 +00:00
|
|
|
/^# Symbol: .*/ {
|
|
|
|
split($0, a, " ");
|
|
|
|
config="CONFIG_"a[3];
|
2019-11-25 18:20:23 +00:00
|
|
|
#print config;
|
|
|
|
}
|
2020-02-06 22:31:30 +00:00
|
|
|
' "$line"
|
|
|
|
done < "$tmpdir"/new_config_files
|
2019-11-25 18:20:23 +00:00
|
|
|
|
2020-02-06 22:31:30 +00:00
|
|
|
# $config_bundles_dir now contains files containing a list of configs per file path
|
|
|
|
for f in "$config_bundles_dir"/*; do
|
Fix fedora-only config updates
After every scheduled upstream merge, a script is run to find new
configs, generate pending-* files for them and for ark, create
branches to push MRs.
However, there is a case where new Fedora configs are found but not
new ARK configs. This case had issues.
When the merge is done, make dist-configs-commit is called for Fedora
and RHEL. This results in a possible new commit if configs are found.
The command is run twice and creates the following matrix:
1. Both Fedora and RHEL have new configs.
2. Neither Fedora nor RHEL have new configs.
3. Fedora does not have new configs, but RHEL does.
4. Fedora has new configs, bug RHEL does not.
1 and 2 are common and 1-3 are handled correctly.
Scenario 4 is not.
When the configs are committed, the next script gen_config_patches.sh
looks for a special commit 'AUTOMATIC'. It doesn't care if that commit
comes from Fedora or RHEL.
The gen_config_patches.sh can not handle pending-fedora changes, so
those changes are filtered in the script.
In scenario 4 that leaves an empty file to process, which the script
aborts on. Further no print out was displayed which slowed down
debugging.
The are multiple ways to address this. This patch does multiple things.
* Adds a print statement on the failure for future debugging.
* Exits on success if there are no changes to process after filtering.
* Reduces the risk of calling gen_config_patches.sh by only calling
the script when RHEL adds new configs.
Tested scenario 4 with last week's os-build HEAD.
Signed-off-by: Don Zickus <dzickus@redhat.com>
2021-07-19 17:23:19 +00:00
|
|
|
if [ ! -e "$f" ]; then
|
|
|
|
echo "Missing generated config file: $f"
|
|
|
|
exit 1 # No files in config_bundles_dir, abort
|
|
|
|
fi
|
2020-02-06 22:31:29 +00:00
|
|
|
# we had to change to : for the file name so switch it back
|
|
|
|
_f=$(basename "$f" | sed -e 's/:/\//g')
|
2019-11-25 18:20:23 +00:00
|
|
|
# Commit subject
|
2020-02-06 22:31:30 +00:00
|
|
|
echo "[redhat] New configs in $_f" > "$tmpdir"/commit
|
|
|
|
echo "" >> "$tmpdir"/commit
|
2019-11-25 18:20:23 +00:00
|
|
|
# And the boiler plate
|
2020-02-06 22:31:30 +00:00
|
|
|
cat redhat/commit_template >> "$tmpdir"/commit
|
2019-11-25 18:20:23 +00:00
|
|
|
# This loop actually grabs the help text to put in the commit
|
|
|
|
while read -r line; do
|
|
|
|
# last line is the actual config we need to put in the dir
|
2023-04-20 12:58:24 +00:00
|
|
|
tail -n 1 redhat/configs/pending-rhel/generic/"$line" > redhat/configs/rhel/generic/"$line"
|
2019-11-25 18:20:23 +00:00
|
|
|
# get everything except the last line for the commit text
|
2023-04-20 12:58:24 +00:00
|
|
|
head -n -1 redhat/configs/pending-rhel/generic/"$line" | sed -e 's/^#//g' >> "$tmpdir"/commit
|
2019-11-25 18:20:23 +00:00
|
|
|
# add a nice separator that renders in gitlab
|
2020-02-06 22:31:30 +00:00
|
|
|
echo -ne "\n---\n\n" >> "$tmpdir"/commit
|
2019-11-25 18:20:23 +00:00
|
|
|
# remove the pending option
|
2023-04-20 12:58:24 +00:00
|
|
|
rm redhat/configs/pending-rhel/generic/"$line"
|
2020-02-06 22:31:30 +00:00
|
|
|
done < "$f"
|
|
|
|
if [ -n "$RHMAINTAINERS" ] && [ -f ./scripts/get_maintainer.pl ] && [ -f "$RHMAINTAINERS" ]; then
|
|
|
|
echo "" >> "$tmpdir"/commit
|
|
|
|
./scripts/get_maintainer.pl --no-rolestats --mpath "$RHMAINTAINERS" --no-git --no-git-fallback -f "$_f" | sed "s/^/Cc: /" >> "$tmpdir"/commit
|
2019-11-25 18:20:23 +00:00
|
|
|
fi
|
|
|
|
# We do a separate branch per config commit
|
2020-02-06 22:31:30 +00:00
|
|
|
if ! git checkout -b "configs/$(date +%F)/$_f"; then
|
|
|
|
printf "Unable to check out configs/%s/%s branch!\n" "$(date +%F)" "$_f"
|
|
|
|
exit 1
|
|
|
|
fi
|
2019-11-25 18:20:23 +00:00
|
|
|
# One file path is done, time to commit!
|
|
|
|
git add redhat/configs
|
2020-05-06 15:18:07 +00:00
|
|
|
git commit -s -F "$tmpdir"/commit
|
2020-04-30 13:46:37 +00:00
|
|
|
git checkout os-build
|
2019-11-25 18:20:23 +00:00
|
|
|
done
|