2016-08-15 15:38:50 +02:00
|
|
|
#
|
|
|
|
# Common variables
|
|
|
|
#
|
|
|
|
|
|
|
|
APPNAME="gogs"
|
|
|
|
|
|
|
|
# Gogs version
|
2016-10-17 19:33:38 +02:00
|
|
|
VERSION="0.9.71"
|
2016-08-15 15:38:50 +02:00
|
|
|
|
|
|
|
# Detect the system architecture to download the right tarball
|
|
|
|
case $(arch) in
|
|
|
|
x86_64) ARCHITECTURE="amd64"
|
|
|
|
;;
|
2016-08-15 19:30:32 +02:00
|
|
|
i386|i686) ARCHITECTURE="386"
|
2016-08-15 15:38:50 +02:00
|
|
|
;;
|
2016-08-30 22:09:01 +02:00
|
|
|
armhf|armel|armv7l) ARCHITECTURE="arm"
|
2016-08-15 15:38:50 +02:00
|
|
|
;;
|
2016-10-11 21:44:19 +02:00
|
|
|
*) echo 'Unable to detect your achitecture, please open a bug describing \
|
|
|
|
your hardware and the result of the command "arch".' && exit 1
|
2016-08-15 15:38:50 +02:00
|
|
|
;;
|
|
|
|
esac
|
|
|
|
|
|
|
|
# Remote URL to fetch Gogs tarball
|
2016-08-30 22:09:01 +02:00
|
|
|
GOGS_BINARY_URL="https://github.com/gogits/gogs/releases/download/v${VERSION}/linux_${ARCHITECTURE}.zip"
|
2016-08-15 15:38:50 +02:00
|
|
|
|
|
|
|
#
|
|
|
|
# Common helpers
|
|
|
|
#
|
|
|
|
|
|
|
|
# Download and extract Gogs binary to the given directory
|
|
|
|
# usage: extract_gogs DESTDIR
|
|
|
|
extract_gogs() {
|
|
|
|
local DESTDIR=$1
|
2016-08-30 22:09:01 +02:00
|
|
|
local TMPDIR=$(mktemp -d)
|
2016-08-15 15:38:50 +02:00
|
|
|
|
|
|
|
# retrieve and extract Gogs tarball
|
2016-08-30 22:09:01 +02:00
|
|
|
gogs_tarball="/tmp/gogs.zip"
|
2016-08-15 15:38:50 +02:00
|
|
|
rm -f "$gogs_tarball"
|
|
|
|
wget -q -O "$gogs_tarball" "$GOGS_BINARY_URL" \
|
|
|
|
|| ynh_die "Unable to download Gogs tarball"
|
2016-08-30 22:09:01 +02:00
|
|
|
unzip -q "$gogs_tarball" -d "$TMPDIR" \
|
2016-08-15 15:38:50 +02:00
|
|
|
|| ynh_die "Unable to extract Gogs tarball"
|
2016-10-11 23:01:52 +02:00
|
|
|
sudo rsync -a "$TMPDIR"/gogs/* "$DESTDIR"
|
2016-08-30 22:09:01 +02:00
|
|
|
rm -rf "$gogs_tarball" "$TMPDIR"
|
2016-08-15 15:38:50 +02:00
|
|
|
}
|