-
Notifications
You must be signed in to change notification settings - Fork 743
Break out utils of setup.sh #7777
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
Merged
Merged
Changes from all commits
Commits
Show all changes
2 commits
Select commit
Hold shift + click to select a range
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,57 @@ | ||
| #!/usr/bin/env bash | ||
| # Copyright 2025 Arm Limited and/or its affiliates. | ||
| # | ||
| # This source code is licensed under the BSD-style license found in the | ||
| # LICENSE file in the root directory of this source tree. | ||
|
|
||
| function verify_md5() { | ||
| # Compare the md5 of a file with a provided expected value. | ||
|
|
||
| # Arg 1: Expected checksum for file | ||
| # Arg 2: Path to file | ||
| # Exits with return code 1 if the number of arguments is incorrect. | ||
| # Exits with return code 2 if the calculated mf5 does not match the given. | ||
|
|
||
| [[ $# -ne 2 ]] \ | ||
| && { echo "[${FUNCNAME[0]}] Invalid number of args, expecting 2, but got $#"; exit 1; } | ||
| local ref_checksum="${1}" | ||
| local file="${2}" | ||
|
|
||
| if [[ "${OS}" == "Darwin" ]]; then | ||
| local file_checksum="$(md5 -q $file)" | ||
| else | ||
| local file_checksum="$(md5sum $file | awk '{print $1}')" | ||
| fi | ||
| if [[ ${ref_checksum} != ${file_checksum} ]]; then | ||
| echo "Mismatched MD5 checksum for file: ${file}. Expecting ${ref_checksum} but got ${file_checksum}. Exiting." | ||
| exit 2 | ||
| fi | ||
| } | ||
|
|
||
| function patch_repo() { | ||
| # Patch git repo found in $repo_dir, starting from patch $base_rev and applying patches found in $patch_dir/$name. | ||
|
|
||
| # Arg 1: Directory of repo to patch | ||
| # Arg 2: Rev to start patching at | ||
| # Arg 3: Directory 'setup-dir' containing patches in 'setup-dir/$name' | ||
Erik-Lundell marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| # Exits with return code 1 if the number of arguments is incorrect. | ||
| # Does not do any error handling if the base_rev or patch_dir is not found etc. | ||
|
|
||
| [[ $# -ne 3 ]] \ | ||
| && { echo "[${FUNCNAME[0]}] Invalid number of args, expecting 3, but got $#"; exit 1; } | ||
|
|
||
| local repo_dir="${1}" | ||
| local base_rev="${2}" | ||
| local name="$(basename $repo_dir)" | ||
| local patch_dir="${3}/$name" | ||
|
|
||
| echo -e "[${FUNCNAME[0]}] Patching ${name}..." | ||
| cd $repo_dir | ||
| git fetch | ||
| git reset --hard ${base_rev} | ||
|
|
||
| [[ -e ${patch_dir} && $(ls -A ${patch_dir}) ]] && \ | ||
| git am -3 ${patch_dir}/*.patch | ||
|
|
||
| echo -e "[${FUNCNAME[0]}] Patched ${name} @ $(git describe --all --long 2> /dev/null) in ${repo_dir} dir.\n" | ||
| } | ||
File renamed without changes.
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
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.
Uh oh!
There was an error while loading. Please reload this page.