112 lines
3.0 KiB
Bash
112 lines
3.0 KiB
Bash
|
# Copyright 2019 Gentoo Authors
|
||
|
# Distributed under the terms of the GNU General Public License v2
|
||
|
|
||
|
EAPI=6
|
||
|
|
||
|
inherit golang-vcs-snapshot golang-build user
|
||
|
|
||
|
EGO_SRC=github.com/gogs/gogs
|
||
|
EGO_PN=${EGO_SRC}/...
|
||
|
DESCRIPTION="Gogs is a painless self-hosted Git service."
|
||
|
HOMEPAGE="https://gogs.io"
|
||
|
EGIT_COMMIT="06b6eaba060f8b874a4c2a8c84515b2ea45321d6"
|
||
|
SRC_URI="https://${EGO_SRC}/archive/${EGIT_COMMIT}.tar.gz -> ${P}.tar.gz"
|
||
|
|
||
|
|
||
|
LICENSE="MIT License"
|
||
|
SLOT="0/${PVR}"
|
||
|
KEYWORDS="~amd64 ~x86"
|
||
|
IUSE="mysql postgres +sqlite +pam +ssl"
|
||
|
|
||
|
DEPEND="sqlite? ( dev-db/sqlite:3 )"
|
||
|
RDEPEND="${DEPEND}
|
||
|
mysql? ( virtual/mysql )
|
||
|
postgres? ( dev-db/postgresql[pam?,ssl?] )
|
||
|
"
|
||
|
|
||
|
USER_NAME="gogs"
|
||
|
USER_DIR="/var/lib/${USER_NAME}"
|
||
|
APP_DIR="/usr/share/${PN}"
|
||
|
|
||
|
pkg_setup() {
|
||
|
enewgroup ${USER_NAME}
|
||
|
enewuser ${USER_NAME} -1 /bin/bash "${USER_DIR}" ${USER_NAME}
|
||
|
GOLANG_PKG_LDFLAGS+=" -X github.com/gogits/gogs/modules/setting.BuildTime=$(date -u '+%Y-%m-%d')"
|
||
|
}
|
||
|
|
||
|
src_prepare() {
|
||
|
default
|
||
|
|
||
|
cd ${S}/src/${EGO_SRC}
|
||
|
cp conf/app.ini "${T}"/app.user.ini || die
|
||
|
|
||
|
sed -i "1,4d" "${T}"/app.user.ini || die
|
||
|
sed -i \
|
||
|
-e "s:^PATH = data/gogs.db:PATH = database/${PN}.db:" \
|
||
|
-e "s:^STATIC_ROOT_PATH =.*:STATIC_ROOT_PATH = ${EPREFIX}/usr/share/themes/${PN}:" \
|
||
|
-e "s:^MODE =.*:MODE = console:" \
|
||
|
-e "s:^OFFLINE_MODE =.*:OFFLINE_MODE = true:" \
|
||
|
-e "s:^DISABLE_ROUTER_LOG =.*:DISABLE_ROUTER_LOG = true:" \
|
||
|
-e "s:^DISABLE_GRAVATAR =.*:DISABLE_GRAVATAR = true:" \
|
||
|
-e "s:^PROVIDER =.*:PROVIDER = memory:" \
|
||
|
-e "s:^RUN_MODE =.*:RUN_MODE = prod:" \
|
||
|
-e "s:^# NEVER EVER.*::" \
|
||
|
-e "s:^# PLEASE MAKE.*::" \
|
||
|
conf/app.ini "${T}"/app.user.ini || die
|
||
|
|
||
|
# Fallback for sqlite as main backend
|
||
|
if use sqlite; then
|
||
|
sed -i \
|
||
|
-e "s:^DB_TYPE = mysql.*:DB_TYPE = sqlite3:" \
|
||
|
conf/app.ini "${T}"/app.user.ini || die
|
||
|
fi
|
||
|
|
||
|
# These are settings specific only to the main app.ini.
|
||
|
sed -i \
|
||
|
-e "s:^ROOT_PATH =.*:ROOT_PATH = ${EPREFIX}/var/log/${PN}:" \
|
||
|
-e "s:^ROOT =.*:ROOT = ${EPREFIX}${USER_DIR}/repositories:" \
|
||
|
-e "s:^RUN_USER =.*:RUN_USER = ${USER_NAME}:" \
|
||
|
conf/app.ini || die
|
||
|
|
||
|
# These are settings specific only to the app.ini used by users.
|
||
|
sed -i \
|
||
|
-e "s:^ROOT_PATH =.*:ROOT_PATH = <home>/${PN}/log:" \
|
||
|
-e "s:^ROOT =.*:ROOT = <home>/${PN}/repositories:" \
|
||
|
-e "s:^RUN_USER =.*:RUN_USER = <user>:" \
|
||
|
"${T}"/app.user.ini || die
|
||
|
}
|
||
|
|
||
|
src_install() {
|
||
|
golang-build_src_install
|
||
|
cd src/github.com/gogs/gogs
|
||
|
|
||
|
dobin ${S}/bin/${PN}
|
||
|
|
||
|
# Install init files
|
||
|
newconfd "${FILESDIR}/confd" ${PN}
|
||
|
newinitd "${FILESDIR}/initd" ${PN}
|
||
|
|
||
|
# Install configuration files
|
||
|
insinto /etc/${PN}/conf
|
||
|
insopts -m640
|
||
|
doins "${T}"/app.user.ini
|
||
|
doins conf/app.ini
|
||
|
|
||
|
# Fix permissions of config files
|
||
|
keepdir /etc/${PN}/
|
||
|
fperms 775 /etc/${PN}/conf
|
||
|
fowners -R :${USER_NAME} /etc/${PN}
|
||
|
|
||
|
# Install theme files
|
||
|
insinto /usr/share/themes/${PN}/
|
||
|
insopts -m440
|
||
|
doins -r public/
|
||
|
doins -r templates/
|
||
|
fowners -R ${USER_NAME}:${USER_NAME} /usr/share/themes/${PN}/
|
||
|
|
||
|
# Create log directory
|
||
|
keepdir /var/log/${PN}
|
||
|
# fperms 775 /var/log/${PN}
|
||
|
fowners -R ${USER_NAME}:${USER_NAME} /var/log/${PN}
|
||
|
}
|