summaryrefslogtreecommitdiff
blob: 24c1327bb2a750d807062b06ba058a9ba6480f27 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
# Copyright 1999-2020 Gentoo Authors
# Distributed under the terms of the GNU General Public License v2

EAPI=8

CMAKE_WARN_UNUSED_CLI=no
CMAKE_MAKEFILE_GENERATOR="emake"

MY_PV=${PV/_/-}
MY_PN="bareos"
MY_P="${MY_PN}-${MY_PV}"

if [[ ${PV} == 9999 ]]; then
	inherit cmake webapp git-r3
	S=${WORKDIR}/${PF}/webui
	SRC_URI=""
	EGIT_REPO_URI="https://github.com/${MY_PN}/${MY_PN}.git"
	KEYWORDS=""
else
	inherit cmake webapp
	S=${WORKDIR}/${MY_PN}-Release-${PV}/webui
	SRC_URI="https://github.com/${MY_PN}/${MY_PN}/archive/Release/${MY_PV}.tar.gz -> ${MY_P}.tar.gz"
	KEYWORDS="~amd64 ~x86"
fi

DESCRIPTION="Featureful client/server network backup suite"
HOMEPAGE="https://www.bareos.org/"
RESTRICT="mirror"

LICENSE="AGPL-3"

IUSE=""

DEPEND=""
RDEPEND="${DEPEND}
	dev-lang/php[bzip2,ctype,curl,fileinfo,filter,fpm,gd,iconv,intl,mhash,nls,pdo,postgres,session,simplexml,ssl,xml,xmlreader,xmlwriter,zip]
	virtual/httpd-php
"

need_httpd_fastcgi

pkg_setup() {
	webapp_pkg_setup
}

src_prepare() {
	# fix missing VERSION
	sed -i "s/@BAREOS_FULL_VERSION@/${PV}/g" version.php.in || die

	cmake_src_prepare
	default
}

src_configure() {
	if [[ ${PV} == 9999 ]]; then
		pushd "${WORKDIR}/${PF}"
	else
		pushd "${S}"/..
	fi
	CURRENT_VERSION=$(echo $(cmake -P get_version.cmake) | sed 's/[- ]//g')
	popd
	local mycmakeargs=(
		-DVERSION_STRING=${CURRENT_VERSION}
		-Wno-dev
	)
	cmake_src_configure
}

src_install() {
	webapp_src_preinst

	dodoc README.md doc/README-TRANSLATION.md

	dodir "/etc/bareos/bareos-dir.d"
	cp -r install/bareos/bareos-dir.d/* "${D}/etc/bareos/bareos-dir.d"

	sed -i -e "s,/var/www/bareos-webui/,${MY_HTDOCSDIR}," "install/nginx/bareos-webui.conf"
	sed -i -e "s,/usr/share/bareos-webui/,${MY_HTDOCSDIR}," "install/apache/bareos-webui.conf"

	webapp_server_configfile nginx "install/nginx/bareos-webui.conf" bareos-webui.include
	webapp_server_configfile apache "install/apache/bareos-webui.conf" bareos-webui.conf

	insinto /etc/${PN}
	doins install/{configuration,directors}.ini

	insinto "${MY_HTDOCSDIR#${EPREFIX}}"
	doins -r .

	webapp_configfile "${MY_HTDOCSDIR#${EPREFIX}}"/config/application.config.php
	webapp_configfile "${MY_HTDOCSDIR#${EPREFIX}}"/config/autoload/global.php

	keepdir "${MY_HTDOCSDIR#${EPREFIX}}"/data
	webapp_serverowned "${MY_HTDOCSDIR#${EPREFIX}}"/data

	# cleanup
	find  "${D}/${MY_HTDOCSDIR#${EPREFIX}}" -name "*.in" -delete
	rm -rf "${D}/${MY_HTDOCSDIR#${EPREFIX}}"/{CMakeLists.txt,install,cmake,phpunit.xml,scripts,doc,tests}

	webapp_postinst_txt en ${FILESDIR}/postinstall-en.txt

	webapp_src_install
}

pkg_postinst() {
	einfo ""
	einfo "The webui uses 'webapp-config' to be configured. To install it may be called like so:"
	einfo ""
	einfo "  webapp-config -h localhost -d bareos-webui -I bareos-webui ${PV}"
	einfo ""
	einfo "See 'man webapp-config' for more details."
	einfo ""
	einfo "For more details about how to configure the bareos webui, see:"
	einfo "  https://docs.bareos.org/IntroductionAndTutorial/InstallingBareosWebui.html"
	einfo ""
	ewarn ""
	ewarn "You need to configure your webserver!"
	ewarn "vhost configuration templates can be found under /usr/share/webapps/bareos-webui/${PV}/conf"
	ewarn ""
	ewarn "IMPORTANT: make sure the docroot of your webserver points to the public/ folder within webapp htdocs directory"
	ewarn ""
}