-
Notifications
You must be signed in to change notification settings - Fork 44
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
CPU Arch: added helper script for simple string replacements (#66)
* CPU Arch: added helper script for simple string replacements * Archstring: remaining type from testing * Archstring: now with named parameters * README: updates * Archstring: cleanup * Archstring: extraneous a * Archstring: EOF newline * Goss: testing shorthand parameters * Archstring: detect and filter bad arguments * Goss: fixed missing EOL * Archstring: removed extraneous semicolon * Archstring: bracket consistency Co-authored-by: Bryan Latten <latten@adobe.com>
- Loading branch information
1 parent
b132b0e
commit a00ed1a
Showing
10 changed files
with
117 additions
and
25 deletions.
There are no files selected for viewing
This file contains 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
This file contains 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
This file contains 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
This file contains 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
This file contains 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
This file contains 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
This file contains 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
This file contains 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
This file contains 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
This file contains 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,62 @@ | ||
#!/bin/bash | ||
|
||
# Script to detect processor architecture and output one of the two input parameters | ||
# Example: when a download path requires an arch-specific package name | ||
# | ||
# --x64 {value}: output if an x86_64 architecture is detected | ||
# --arm64 {value}: output if an arm64 or aarch64 architecture is detected | ||
function usage() { | ||
echo "usage: $(basename $0) --x64 value --arm64 value" | ||
exit 1 | ||
} | ||
|
||
if [[ "$#" -eq 0 ]]; then | ||
usage | ||
fi | ||
|
||
while [[ "$#" -gt 0 ]] | ||
do | ||
case $1 in | ||
-i|--x64) | ||
declare x64="$2" | ||
;; | ||
-a|--arm64) | ||
declare arm64="$2" | ||
;; | ||
*) | ||
usage | ||
;; | ||
esac | ||
# shift 2, since we consumed the arch specifier and the value | ||
shift 2 | ||
# assert there are positional parameters remaining | ||
if [[ "$?" -ne 0 ]]; then | ||
usage | ||
fi; | ||
done | ||
|
||
if [[ -z "$x64" ]]; then | ||
echo "error: missing --x64 input" | ||
exit 1 | ||
fi | ||
|
||
if [[ -z "$arm64" ]]; then | ||
echo "error: missing --arm64 input" | ||
exit 1 | ||
fi | ||
|
||
DETECTED_ARCH="$(uname -m)" | ||
ARCH_X64='x86_64' | ||
ARCH_ARM64='aarch64' | ||
ARCH_ARM64_ALT='arm64' | ||
|
||
if [[ $DETECTED_ARCH == $ARCH_X64 ]]; then | ||
echo $x64 | ||
elif [[ $DETECTED_ARCH == $ARCH_ARM64 ]]; then | ||
echo $arm64 | ||
elif [[ $DETECTED_ARCH == $ARCH_ARM64_ALT ]]; then | ||
echo $arm64 | ||
else | ||
echo "failure: $DETECTED_ARCH not supported" | ||
exit 1 | ||
fi; |