generated from qualcomm/qualcomm-repository-template
-
Notifications
You must be signed in to change notification settings - Fork 3
Add check script for new entry to qcom-fitimage.its #26
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
amrianan
wants to merge
1
commit into
qualcomm-linux:main
Choose a base branch
from
amrianan:main
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,129 @@ | ||
| #!/usr/bin/env bash | ||
| set -euo pipefail | ||
|
|
||
| ITS_FILE="qcom-fitimage.its" | ||
| META_FILE="qcom-metadata.dts" | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Can we take the file path from user? If not provided, then fallback to these? |
||
|
|
||
| if [[ ! -f "$ITS_FILE" ]]; then | ||
| echo "fail FILE_NOT_FOUND qcom-fitimage.its" >&2 | ||
| exit 1 | ||
| fi | ||
|
|
||
| if [[ ! -f "$META_FILE" ]]; then | ||
| echo "fail FILE_NOT_FOUND qcom-metadata.dts" >&2 | ||
| exit 1 | ||
| fi | ||
|
|
||
| tmpdir="$(mktemp -d)" | ||
| trap 'rm -rf "$tmpdir"' EXIT | ||
|
|
||
| missing_any=0 | ||
|
|
||
| ############################################################################### | ||
| # 1. Collect all configuration subnodes and their compatible strings | ||
| ############################################################################### | ||
| awk -v out="$tmpdir/config_compat.txt" ' | ||
| BEGIN { | ||
| in_configs = 0 | ||
| in_node = 0 | ||
| node_name = "" | ||
| } | ||
|
|
||
| /configurations[[:space:]]*\{/ { | ||
| in_configs = 1 | ||
| next | ||
| } | ||
|
|
||
| in_configs && /^\}/ { | ||
| in_configs = 0 | ||
| next | ||
| } | ||
|
|
||
| # Match a configuration subnode: "<cfg_name> {" | ||
| in_configs && /^[[:space:]]*[^[:space:]]+[[:space:]]*\{/ { | ||
| node_name = $1 | ||
| sub(/:$/, "", node_name) | ||
| in_node = 1 | ||
| next | ||
| } | ||
|
|
||
| in_node && /^[[:space:]]*};/ { | ||
| in_node = 0 | ||
| node_name = "" | ||
| next | ||
| } | ||
|
|
||
| # Extract compatible = "<string>"; | ||
| in_node && /compatible[[:space:]]*=/ { | ||
| line = $0 | ||
| if (match(line, /"[^"]*"/)) { | ||
| compat = substr(line, RSTART+1, RLENGTH-2) | ||
| print node_name, compat >> out | ||
| } | ||
| } | ||
| ' "$ITS_FILE" | ||
|
|
||
| if [[ ! -s "$tmpdir/config_compat.txt" ]]; then | ||
| echo "fail NO_CONFIG_COMPAT qcom-fitimage.its" | ||
| exit 1 | ||
| fi | ||
|
|
||
| ############################################################################### | ||
| # 2. Collect only node (subnode) names from qcom-metadata.dts | ||
| # - Ignore labels | ||
| # - Take the last identifier before "{" | ||
| ############################################################################### | ||
|
|
||
| meta_nodes="$tmpdir/meta_nodes.txt" | ||
|
|
||
| awk ' | ||
| # Any node definition line ending with "{" | ||
| /^[[:space:]]*[^&].*\{/ { | ||
| line = $0 | ||
|
|
||
| # Remove everything from "{" onward | ||
| sub(/\{.*/, "", line) | ||
|
|
||
| # Trim leading/trailing whitespace | ||
| sub(/^[[:space:]]+/, "", line) | ||
| sub(/[[:space:]]+$/, "", line) | ||
|
|
||
| # Split on whitespace; last field is the node name (after optional label:) | ||
| n = split(line, a, /[[:space:]]+/) | ||
| if (n < 1) | ||
| next | ||
|
|
||
| node = a[n] | ||
|
|
||
| # Strip trailing ":" if any (defensive, though labels should be before node) | ||
| sub(/:$/, "", node) | ||
|
|
||
| if (node != "") { | ||
| print node | ||
| } | ||
| } | ||
| ' "$META_FILE" | sort -u > "$meta_nodes" | ||
|
|
||
| ############################################################################### | ||
| # 3. For each configuration, check substrings against node names only | ||
| ############################################################################### | ||
|
|
||
| while read -r cfg compat; do | ||
| compat_no_prefix="${compat#qcom,}" | ||
| IFS='-' read -r -a parts <<< "$compat_no_prefix" | ||
|
|
||
| for part in "${parts[@]}"; do | ||
| [[ -z "$part" ]] && continue | ||
|
|
||
| if ! grep -qx "$part" "$meta_nodes"; then | ||
| echo "fail ${part} ${cfg}" | ||
| missing_any=1 | ||
| fi | ||
| done | ||
| done < "$tmpdir/config_compat.txt" | ||
|
|
||
| if [[ "$missing_any" -ne 0 ]]; then | ||
| exit 2 | ||
| fi | ||
|
|
||
| echo "success" | ||
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can we add usage of the script in comments?