Skip to content

Commit

Permalink
Fix typo and error on getopts
Browse files Browse the repository at this point in the history
  • Loading branch information
QU3B1M committed Oct 29, 2024
1 parent 9924c22 commit 6f5dcb9
Showing 1 changed file with 74 additions and 79 deletions.
153 changes: 74 additions & 79 deletions build-scripts/baptizer.sh
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
#!/bin/bash

set -e

function usage() {
Expand All @@ -21,49 +20,47 @@ function usage() {
# Parse arguments
# ====
function parse_args() {

while getopts ":h:p:a:d:r:m:x:ph:rh" arg; do
while getopts ":h:p:a:d:r:m:x:ph:rh:" arg; do
case $arg in
h)
usage
exit 1
;;
p)
PLATFORM=$OPTARG
;;
a)
ARCHITECTURE=$OPTARG
;;
d)
DISTRIBUTION=$OPTARG
;;
r)
REVISION=$OPTARG
;;
m)
IS_MIN=true
;;
x)
IS_RELEASE=true
;;
ph)
PLUGINS_HASH=$OPTARF
;;
rh)
REPORTING_HASH=$OPTARF
;;
:)
echo "Error: -${OPTARG} requires an argument"
usage
exit 1
;;
?)
echo "Invalid option: -${arg}"
exit 1
;;
h)
usage
exit 1
;;
p)
PLATFORM=$OPTARG
;;
a)
ARCHITECTURE=$OPTARG
;;
d)
DISTRIBUTION=$OPTARG
;;
r)
REVISION=$OPTARG
;;
m)
IS_MIN=true
;;
x)
IS_RELEASE=true
;;
ph)
PLUGINS_HASH=$OPTARG
;;
rh)
REPORTING_HASH=$OPTARG
;;
:)
echo "Error: -${OPTARG} requires an argument"
usage
exit 1
;;
?)
echo "Invalid option: -${arg}"
exit 1
;;
esac
done

[ -z "$PLATFORM" ] && PLATFORM=$(uname -s | awk '{print tolower($0)}')
[ -z "$ARCHITECTURE" ] && ARCHITECTURE=$(uname -m)
[ -z "$DISTRIBUTION" ] && DISTRIBUTION="tar"
Expand All @@ -72,44 +69,43 @@ function parse_args() {
[ -z "$IS_RELEASE" ] && IS_RELEASE=false

case $PLATFORM-$DISTRIBUTION-$ARCHITECTURE in
linux-tar-x64 | darwin-tar-x64)
EXT="tar.gz"
SUFFIX="$PLATFORM-x64"
;;
linux-tar-arm64 | darwin-tar-arm64)
EXT="tar.gz"
SUFFIX="$PLATFORM-arm64"
;;
linux-deb-x64)
EXT="deb"
SUFFIX="amd64"
;;
linux-deb-arm64)
EXT="deb"
SUFFIX="arm64"
;;
linux-rpm-x64)
EXT="rpm"
SUFFIX="x86_64"
;;
linux-rpm-arm64)
EXT="rpm"
SUFFIX="aarch64"
;;
windows-zip-x64)
EXT="zip"
SUFFIX="$PLATFORM-x64"
;;
windows-zip-arm64)
EXT="zip"
SUFFIX="$PLATFORM-arm64"
;;
*)
echo "Unsupported platform-distribution-architecture combination: $PLATFORM-$DISTRIBUTION-$ARCHITECTURE"
exit 1
;;
linux-tar-x64 | darwin-tar-x64)
EXT="tar.gz"
SUFFIX="$PLATFORM-x64"
;;
linux-tar-arm64 | darwin-tar-arm64)
EXT="tar.gz"
SUFFIX="$PLATFORM-arm64"
;;
linux-deb-x64)
EXT="deb"
SUFFIX="amd64"
;;
linux-deb-arm64)
EXT="deb"
SUFFIX="arm64"
;;
linux-rpm-x64)
EXT="rpm"
SUFFIX="x86_64"
;;
linux-rpm-arm64)
EXT="rpm"
SUFFIX="aarch64"
;;
windows-zip-x64)
EXT="zip"
SUFFIX="$PLATFORM-x64"
;;
windows-zip-arm64)
EXT="zip"
SUFFIX="$PLATFORM-arm64"
;;
*)
echo "Unsupported platform-distribution-architecture combination: $PLATFORM-$DISTRIBUTION-$ARCHITECTURE"
exit 1
;;
esac

}

# ====
Expand Down Expand Up @@ -159,7 +155,6 @@ function get_package_name() {
# ====
function main() {
parse_args "${@}"

get_package_name
echo "$PACKAGE_NAME"
}
Expand Down

0 comments on commit 6f5dcb9

Please sign in to comment.