Use gpg for install script instead of apt-key (#5856)

* possible fix to #5838

* fixed syntax
This commit is contained in:
Matthias Mair 2023-11-04 03:11:57 +01:00 committed by GitHub
parent 7396b028d7
commit 19810d0965
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 26 additions and 20 deletions

View File

@ -1,5 +1,5 @@
#!/usr/bin/env bash #!/usr/bin/env bash
# This script was generated by bashly 0.9.4 (https://bashly.dannyb.co) # This script was generated by bashly 1.1.1 (https://bashly.dannyb.co)
# Modifying it manually is not recommended # Modifying it manually is not recommended
if [[ "${BASH_VERSINFO:-0}" -lt 4 ]]; then if [[ "${BASH_VERSINFO:-0}" -lt 4 ]]; then
@ -120,10 +120,10 @@ root_command() {
fi fi
echo "### Getting and adding key" echo "### Getting and adding key"
wget -qO- https://dl.packager.io/srv/$publisher/InvenTree/key | sudo apt-key add - curl -fsSL https://dl.packager.io/srv/$publisher/InvenTree/key | gpg --dearmor | tee /etc/apt/trusted.gpg.d/pkgr-inventree.gpg> /dev/null
echo "### Adding package source" echo "### Adding package source"
do_call "sudo wget -O /etc/apt/sources.list.d/inventree.list https://dl.packager.io/srv/$publisher/InvenTree/$source_url/installer/$DIST_OS/$DIST_VER.repo" SOURCE_URL="deb [signed-by=/etc/apt/trusted.gpg.d/pkgr-inventree.gpg] https://dl.packager.io/srv/deb/$publisher/InvenTree/$source_url/$DIST_OS $DIST_VER main"
echo "$SOURCE_URL" | tee /etc/apt/sources.list.d/inventree.list > /dev/null
echo "### Updating package lists" echo "### Updating package lists"
do_call "sudo apt-get update" do_call "sudo apt-get update"
@ -164,13 +164,6 @@ install.sh_usage() {
if [[ -n $long_usage ]]; then if [[ -n $long_usage ]]; then
printf "%s\n" "Options:" printf "%s\n" "Options:"
printf " %s\n" "--help, -h"
printf " Show this help\n"
echo
printf " %s\n" "--version, -v"
printf " Show version number\n"
echo
printf " %s\n" "--no-call, -n" printf " %s\n" "--no-call, -n"
printf " Do not call outside APIs (only functionally needed)\n" printf " Do not call outside APIs (only functionally needed)\n"
echo echo
@ -179,6 +172,13 @@ install.sh_usage() {
printf " Dry run (do not install anything)\n" printf " Dry run (do not install anything)\n"
echo echo
printf " %s\n" "--help, -h"
printf " Show this help\n"
echo
printf " %s\n" "--version, -v"
printf " Show version number\n"
echo
printf "%s\n" "Arguments:" printf "%s\n" "Arguments:"
printf " %s\n" "SOURCE" printf " %s\n" "SOURCE"
@ -226,8 +226,8 @@ normalize_input() {
} }
inspect_args() { inspect_args() {
readarray -t sorted_keys < <(printf '%s\n' "${!args[@]}" | sort)
if ((${#args[@]})); then if ((${#args[@]})); then
readarray -t sorted_keys < <(printf '%s\n' "${!args[@]}" | sort)
echo args: echo args:
for k in "${sorted_keys[@]}"; do echo "- \${args[$k]} = ${args[$k]}"; done for k in "${sorted_keys[@]}"; do echo "- \${args[$k]} = ${args[$k]}"; done
else else
@ -242,6 +242,14 @@ inspect_args() {
echo "- \${other_args[$i]} = ${other_args[$i]}" echo "- \${other_args[$i]} = ${other_args[$i]}"
done done
fi fi
if ((${#deps[@]})); then
readarray -t sorted_keys < <(printf '%s\n' "${!deps[@]}" | sort)
echo
echo deps:
for k in "${sorted_keys[@]}"; do echo "- \${deps[$k]} = ${deps[$k]}"; done
fi
} }
parse_requirements() { parse_requirements() {
@ -312,7 +320,7 @@ parse_requirements() {
[[ -n ${args['source']:-} ]] || args['source']="stable" [[ -n ${args['source']:-} ]] || args['source']="stable"
[[ -n ${args['publisher']:-} ]] || args['publisher']="inventree" [[ -n ${args['publisher']:-} ]] || args['publisher']="inventree"
if [[ ! ${args['source']} =~ ^(stable|master|main)$ ]]; then if [[ -n ${args['source']} ]] && [[ ! ${args['source']} =~ ^(stable|master|main)$ ]]; then
printf "%s\n" "source must be one of: stable, master, main" >&2 printf "%s\n" "source must be one of: stable, master, main" >&2
exit 1 exit 1
fi fi
@ -329,16 +337,14 @@ initialize() {
run() { run() {
declare -A args=() declare -A args=()
declare -A deps=()
declare -a other_args=() declare -a other_args=()
declare -a input=() declare -a input=()
normalize_input "$@" normalize_input "$@"
parse_requirements "${input[@]}" parse_requirements "${input[@]}"
case "$action" in case "$action" in
"root") "root") root_command ;;
root_command
;;
esac esac
} }

View File

@ -110,10 +110,10 @@ if [[ $NEEDS_LIBSSL1_1 == "true" ]]; then
fi fi
echo "### Getting and adding key" echo "### Getting and adding key"
wget -qO- https://dl.packager.io/srv/$publisher/InvenTree/key | sudo apt-key add - curl -fsSL https://dl.packager.io/srv/$publisher/InvenTree/key | gpg --dearmor | tee /etc/apt/trusted.gpg.d/pkgr-inventree.gpg> /dev/null
echo "### Adding package source" echo "### Adding package source"
do_call "sudo wget -O /etc/apt/sources.list.d/inventree.list https://dl.packager.io/srv/$publisher/InvenTree/$source_url/installer/$DIST_OS/$DIST_VER.repo" SOURCE_URL="deb [signed-by=/etc/apt/trusted.gpg.d/pkgr-inventree.gpg] https://dl.packager.io/srv/deb/$publisher/InvenTree/$source_url/$DIST_OS $DIST_VER main"
echo "$SOURCE_URL" | tee /etc/apt/sources.list.d/inventree.list > /dev/null
echo "### Updating package lists" echo "### Updating package lists"
do_call "sudo apt-get update" do_call "sudo apt-get update"