2022-07-23 13:16:10 +02:00
|
|
|
#!/usr/bin/env bash
|
2022-04-17 16:28:34 +02:00
|
|
|
|
2022-12-12 20:38:44 +01:00
|
|
|
# This installs Go tools on Linux.
|
2022-07-23 13:55:05 +02:00
|
|
|
# bash <(curl -s https://raw.githubusercontent.com/photoprism/photoprism/develop/scripts/dist/install-go-tools.sh)
|
|
|
|
|
2022-07-23 13:08:24 +02:00
|
|
|
PATH="/usr/local/sbin:/usr/sbin:/sbin:/usr/local/bin:/usr/bin:/bin:/scripts:/usr/local/go/bin:/go/bin:$PATH"
|
2022-04-17 16:28:34 +02:00
|
|
|
|
2022-12-12 20:38:44 +01:00
|
|
|
# Abort if not executed as root.
|
2022-04-17 16:28:34 +02:00
|
|
|
if [[ $(id -u) != "0" ]]; then
|
|
|
|
echo "Usage: run ${0##*/} as root" 1>&2
|
|
|
|
exit 1
|
|
|
|
fi
|
|
|
|
|
2022-07-23 15:02:28 +02:00
|
|
|
if ! command -v go &> /dev/null
|
|
|
|
then
|
2022-08-12 20:17:17 +02:00
|
|
|
echo "Go must be installed to run this."
|
2022-07-23 15:02:28 +02:00
|
|
|
exit 1
|
|
|
|
fi
|
|
|
|
|
2023-10-05 23:18:54 +02:00
|
|
|
# Determine the system architecture.
|
2022-07-23 13:55:05 +02:00
|
|
|
if [[ $PHOTOPRISM_ARCH ]]; then
|
|
|
|
SYSTEM_ARCH=$PHOTOPRISM_ARCH
|
|
|
|
else
|
|
|
|
SYSTEM_ARCH=$(uname -m)
|
|
|
|
fi
|
|
|
|
|
2023-10-05 23:18:54 +02:00
|
|
|
DESTARCH=${BUILD_ARCH:-$SYSTEM_ARCH}
|
2022-04-18 14:14:32 +02:00
|
|
|
|
2022-07-23 15:09:29 +02:00
|
|
|
if [ -d "/go" ]; then
|
|
|
|
GOPATH="/go"
|
|
|
|
elif [[ -z $GOPATH ]]; then
|
|
|
|
GOPATH=$(go env GOPATH)
|
|
|
|
fi
|
|
|
|
|
2022-04-17 16:28:34 +02:00
|
|
|
set -e
|
|
|
|
|
2022-07-23 15:02:28 +02:00
|
|
|
mkdir -p "$GOPATH/src"
|
2022-04-18 14:14:32 +02:00
|
|
|
|
2022-07-23 14:57:17 +02:00
|
|
|
# Install remaining tools in "/usr/local/bin".
|
2022-07-23 13:55:05 +02:00
|
|
|
case $DESTARCH in
|
|
|
|
arm | ARM | aarch | armv7l | armhf)
|
|
|
|
# no additional tools on ARMv7 to reduce build time
|
2023-07-20 08:36:01 +02:00
|
|
|
echo "Skipping installation of Go tools."
|
2022-07-23 13:55:05 +02:00
|
|
|
;;
|
|
|
|
|
|
|
|
*)
|
2023-11-03 13:05:12 +01:00
|
|
|
echo "Installing Go tools for ${DESTARCH^^} in /usr/local/bin..."
|
2022-07-23 14:57:17 +02:00
|
|
|
GOBIN="/usr/local/bin" go install golang.org/x/tools/cmd/goimports@latest
|
2024-01-10 10:11:51 +01:00
|
|
|
GOBIN="/usr/local/bin" go install golang.org/x/tools/cmd/godoc@latest
|
2022-07-23 14:57:17 +02:00
|
|
|
GOBIN="/usr/local/bin" go install github.com/psampaz/go-mod-outdated@latest
|
|
|
|
GOBIN="/usr/local/bin" go install github.com/mikefarah/yq/v4@latest
|
|
|
|
GOBIN="/usr/local/bin" go install github.com/kyoh86/richgo@latest
|
2023-04-06 08:23:11 +02:00
|
|
|
GOBIN="/usr/local/bin" go install github.com/muesli/duf@latest
|
2023-07-20 08:22:57 +02:00
|
|
|
GOBIN="/usr/local/bin" go install github.com/go-delve/delve/cmd/dlv@latest
|
2023-11-03 13:05:12 +01:00
|
|
|
GOBIN="/usr/local/bin" go install github.com/goreleaser/nfpm/v2/cmd/nfpm@latest
|
2022-07-23 13:55:05 +02:00
|
|
|
;;
|
|
|
|
esac
|
2022-04-18 14:14:32 +02:00
|
|
|
|
|
|
|
chmod -R a+rwX "$GOPATH"
|
|
|
|
|
|
|
|
echo "Done."
|