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
# 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
if [[ "${BASH_VERSINFO:-0}" -lt 4 ]]; then
@ -120,10 +120,10 @@ root_command() {
fi
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"
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"
do_call "sudo apt-get update"
@ -164,13 +164,6 @@ install.sh_usage() {
if [[ -n $long_usage ]]; then
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 " Do not call outside APIs (only functionally needed)\n"
echo
@ -179,6 +172,13 @@ install.sh_usage() {
printf " Dry run (do not install anything)\n"
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" "SOURCE"
@ -226,8 +226,8 @@ normalize_input() {
}
inspect_args() {
readarray -t sorted_keys < <(printf '%s\n' "${!args[@]}" | sort)
if ((${#args[@]})); then
readarray -t sorted_keys < <(printf '%s\n' "${!args[@]}" | sort)
echo args:
for k in "${sorted_keys[@]}"; do echo "- \${args[$k]} = ${args[$k]}"; done
else
@ -242,6 +242,14 @@ inspect_args() {
echo "- \${other_args[$i]} = ${other_args[$i]}"
done
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() {
@ -312,7 +320,7 @@ parse_requirements() {
[[ -n ${args['source']:-} ]] || args['source']="stable"
[[ -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
exit 1
fi
@ -329,16 +337,14 @@ initialize() {
run() {
declare -A args=()
declare -A deps=()
declare -a other_args=()
declare -a input=()
normalize_input "$@"
parse_requirements "${input[@]}"
case "$action" in
"root")
root_command
;;
"root") root_command ;;
esac
}

View File

@ -110,10 +110,10 @@ if [[ $NEEDS_LIBSSL1_1 == "true" ]]; then
fi
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"
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"
do_call "sudo apt-get update"