-
Notifications
You must be signed in to change notification settings - Fork 361
scripts: Add support to checkout specific commits for alsa repos #10869
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
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -12,14 +12,17 @@ declare -a REPOS=( | |
| # Add more repositories here... | ||
| ) | ||
|
|
||
| # Commit ID to check for (optional). If specified, the script will update | ||
| # the repository if this commit ID is not found. Leave empty to skip. | ||
| # This array order must align with REPO array above. | ||
| declare -a COMMIT_ID=( | ||
| "df8f1cc1ec9d9ee15be5e2c23ad25b9389fd8766" | ||
| "09550cd393b1a7d307ee6f26637b1ed7bd275e38" | ||
| # Add more IDs here... | ||
| ) | ||
| # Per-repo commit/tag overrides via --<repo-name>-commit=<ref>. | ||
| # Example: --alsa-lib-commit=v1.2.3 --alsa-utils-commit=abc1234 | ||
| # If not provided for a repo the original update logic (fetch + pull) applies. | ||
| declare -A REPO_COMMIT | ||
| for arg in "$@"; do | ||
| case "$arg" in | ||
| --*-commit=*) | ||
| key="${arg#--}" | ||
| REPO_COMMIT["${key%-commit=*}"]="${key#*-commit=}" ;; | ||
| esac | ||
| done | ||
|
|
||
| # Directory where repositories will be cloned/updated. | ||
| if [[ -z "$SOF_WORKSPACE" ]]; then | ||
|
|
@@ -50,28 +53,26 @@ declare -a TARGET_ARGS=( | |
| "--enable-alsatopology" | ||
| ) | ||
|
|
||
| # Function to check if a commit ID exists in a repository | ||
| check_commit() { | ||
| local repo_dir="$1" | ||
| local commit_id="$2" | ||
|
|
||
| if [ -z "$commit_id" ]; then | ||
| return 0 # Skip check if no commit ID is provided | ||
| fi | ||
|
|
||
| if ! git -C "$repo_dir" rev-parse --quiet --verify "$commit_id" >/dev/null 2>&1; then | ||
| return 1 # Commit ID not found | ||
| else | ||
| return 0 # Commit ID found | ||
| fi | ||
| } | ||
|
|
||
|
|
||
| # Function to update the repository | ||
| update_repo() { | ||
| local repo_dir="$1" | ||
|
Comment on lines
56
to
58
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. Implemented in |
||
| local default_branch | ||
| echo "Updating repository: $repo_dir" | ||
| git -C "$repo_dir" fetch --all | ||
|
|
||
| if ! git -C "$repo_dir" symbolic-ref -q HEAD >/dev/null; then | ||
| default_branch=$(git -C "$repo_dir" symbolic-ref --quiet --short refs/remotes/origin/HEAD 2>/dev/null || true) | ||
| default_branch="${default_branch#origin/}" | ||
|
|
||
| if [[ -z "$default_branch" ]]; then | ||
| echo "Error: unable to determine default branch in $repo_dir" >&2 | ||
| exit 1 | ||
| fi | ||
|
|
||
| git -C "$repo_dir" checkout "$default_branch" 2>/dev/null || \ | ||
| git -C "$repo_dir" checkout -b "$default_branch" --track "origin/$default_branch" | ||
| fi | ||
|
|
||
| git -C "$repo_dir" pull | ||
| } | ||
|
|
||
|
|
@@ -114,10 +115,15 @@ for ((i = 0; i < ${#REPOS[@]}; i++)); do | |
| if [ ! -d "$repo_dir" ]; then | ||
| echo "Cloning repository: $repo_url" | ||
| git clone "$repo_url" "$repo_dir" || { echo "git clone failed for $repo_url"; exit 1; } | ||
| elif ! check_commit "$repo_dir" "${COMMIT_ID[i]}"; then | ||
| update_repo "$repo_dir" | ||
| fi | ||
|
|
||
| ref="${REPO_COMMIT[$repo_name]}" | ||
| if [[ -n "$ref" ]]; then | ||
| git -C "$repo_dir" fetch --all | ||
| git -C "$repo_dir" checkout "$ref" || | ||
| { echo "git checkout $ref failed in $repo_dir"; exit 1; } | ||
| else | ||
| echo "Repository $repo_name is up to date." | ||
| update_repo "$repo_dir" | ||
| fi | ||
|
|
||
| build_and_install "$repo_dir" "${CONFIGURE_ARGS[i]}" | ||
|
Collaborator
Author
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. This is a pre-existing issue and I think it doesnt really matter. there is no TARGET_ARGS passed and that's fine. |
||
|
|
||
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.
@lgirdwood @singalsu Can you check? This is now against the idea Liam had with hard coded git commits. The idea would be that SOF would be always built with a specific version of alsa-lib/tools that is known to work. If e.g. topology PR needs a newer ALSA, the same PR could modify the ALSA reqs.
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.
I'm generally fine if they override, but maybe west is the best way forward here @dbaluta ?