2016-08-15 15:38:50 +02:00
|
|
|
#
|
|
|
|
# Common variables
|
|
|
|
#
|
|
|
|
|
|
|
|
APPNAME="gogs"
|
|
|
|
|
|
|
|
# Gogs version
|
2017-04-04 09:14:20 +02:00
|
|
|
VERSION="0.11"
|
2016-08-15 15:38:50 +02:00
|
|
|
|
|
|
|
# Detect the system architecture to download the right tarball
|
2016-10-18 00:09:26 +02:00
|
|
|
# NOTE: `uname -m` is more accurate and universal than `arch`
|
|
|
|
# See https://en.wikipedia.org/wiki/Uname
|
|
|
|
if [ -n "$(uname -m | grep 64)" ]; then
|
2017-03-02 13:54:38 +01:00
|
|
|
ARCHITECTURE="linux_amd64"
|
2016-10-18 00:09:26 +02:00
|
|
|
elif [ -n "$(uname -m | grep 86)" ]; then
|
2017-03-02 13:54:38 +01:00
|
|
|
ARCHITECTURE="linux_386"
|
2016-10-18 00:09:26 +02:00
|
|
|
elif [ -n "$(uname -m | grep arm)" ]; then
|
2017-03-02 13:54:38 +01:00
|
|
|
ARCHITECTURE="raspi2_armv6"
|
2016-10-18 00:09:26 +02:00
|
|
|
else
|
2017-04-05 21:06:22 +02:00
|
|
|
ynh_die "Unable to detect your achitecture, please open a bug describing \
|
|
|
|
your hardware and the result of the command \"uname -m\"." 1
|
2016-10-18 00:09:26 +02:00
|
|
|
fi
|
2016-08-15 15:38:50 +02:00
|
|
|
|
|
|
|
# Remote URL to fetch Gogs tarball
|
2017-03-02 13:54:38 +01:00
|
|
|
GOGS_BINARY_URL="https://github.com/gogits/gogs/releases/download/v${VERSION}/${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"
|
2017-02-19 22:24:20 +01:00
|
|
|
rm -rf "$gogs_tarball" "${TMPDIR:-/tmp/fakefile}"
|
2016-08-15 15:38:50 +02:00
|
|
|
}
|