aboutsummaryrefslogtreecommitdiff
path: root/upload_amo.sh
diff options
context:
space:
mode:
Diffstat (limited to 'upload_amo.sh')
-rwxr-xr-xupload_amo.sh25
1 files changed, 14 insertions, 11 deletions
diff --git a/upload_amo.sh b/upload_amo.sh
index 115f39a..71e12ca 100755
--- a/upload_amo.sh
+++ b/upload_amo.sh
@@ -24,11 +24,11 @@ SECRET="$3"
XPI_PATH="$4"
base64url() {
- ech "$1" | base64 -w 0 | tr '/+' '_-' | tr -d '='
+ printf %s "$1" | base64 -w 0 | tr '/+' '_-' | tr -d '='
}
sha256hmac() {
- base64url "$(ech "$2" | openssl dgst -sha256 -hmac "$1" -binary -)"
+ base64url "$(printf %s "$2" | openssl dgst -sha256 -hmac "$1" -binary -)"
}
get_manifest_key() {
@@ -52,8 +52,8 @@ EOF
local JWT_MESSAGE=$(base64url "$JWT_HEAD").$(base64url "$JWT_PAYLOAD")
local JWT_SIGNATURE=$(sha256hmac "$SECRET" "$JWT_MESSAGE")
local JWT=$JWT_MESSAGE.$JWT_SIGNATURE
- errcho "Using JWT: $JWT"
- ech $JWT
+ printf "Using JWT: $JWT\n" >&2
+ printf $JWT
}
get_extension_url() {
@@ -61,19 +61,22 @@ get_extension_url() {
EXTENSION_VER="$(get_manifest_key version "$XPI_PATH")"
if [ -z "$EXTENSION_ID" -o -z "$EXTENSION_VER" ]; then
- errcho "Couldn't extract extension id and version. Please check if $XPI_PATH contains proper manifest.json file."
+ printf "Couldn't extract extension id and version. Please check if %s contains proper manifest.json file.\n" \
+ "$XPI_PATH" >&2
exit 1
fi
- ech "https://addons.mozilla.org/api/v4/addons/$EXTENSION_ID/versions/$EXTENSION_VER/"
+ printf 'https://addons.mozilla.org/api/v4/addons/%s/versions/%s/' \
+ "$EXTENSION_ID" "$EXTENSION_VER"
}
-usage() {
- errcho "Usage: $_PROG_NAME upload|check|test API_KEY SECRET XPI_PATH"
+print_usage() {
+ printf 'Usage: %s upload|check|test API_KEY SECRET XPI_PATH\n' \
+ "$_PROG_NAME" >&2
}
if [ $# != 4 ]; then
- usage
+ print_usage
exit 1
fi
@@ -83,7 +86,7 @@ case "$OPERATION" in
test)
curl "https://addons.mozilla.org/api/v4/accounts/profile/" \
-g -H "Authorization: JWT $(generate_jwt)"
- echo
+ printf '\n'
;;
check)
RETURNED_DATA="$(curl $(get_extension_url) \
@@ -95,7 +98,7 @@ case "$OPERATION" in
-H "Authorization: JWT $(generate_jwt)")"
;;
*)
- usage
+ print_usage
exit 1
;;
esac