]> gitweb.michael.orlitzky.com - mjo-overlay.git/blob - app-backup/backuppc/backuppc-3.3.1.ebuild
app-backup/backuppc: fix comment.
[mjo-overlay.git] / app-backup / backuppc / backuppc-3.3.1.ebuild
1 # Copyright 1999-2015 Gentoo Foundation
2 # Distributed under the terms of the GNU General Public License v2
3 # $Id$
4
5 EAPI=5
6
7 inherit depend.apache eutils user
8
9 MY_P="BackupPC-${PV}"
10
11 DESCRIPTION="High-performance backups to a server's disk"
12 HOMEPAGE="http://backuppc.sourceforge.net/"
13 SRC_URI="mirror://sourceforge/${PN}/${MY_P}.tar.gz"
14
15 LICENSE="GPL-2"
16 KEYWORDS="~amd64 ~x86"
17
18 IUSE="rss samba"
19
20 APACHE_MODULES="apache2_modules_alias,"
21 APACHE_MODULES+="apache2_modules_unixd,"
22 APACHE_MODULES+="apache2_modules_authz_user"
23
24 DEPEND="dev-lang/perl
25 app-admin/apache-tools
26 app-admin/makepasswd"
27 RDEPEND="${DEPEND}
28 virtual/perl-IO-Compress
29 dev-perl/Archive-Zip
30 dev-perl/libwww-perl
31 >=app-arch/tar-1.13.20
32 app-arch/par2cmdline
33 app-arch/gzip
34 app-arch/bzip2
35 virtual/mta
36 www-apache/mod_perl
37 www-apache/mpm_itk
38 || ( >=www-servers/apache-2.4[${APACHE_MODULES},apache2_modules_cgi]
39 >=www-servers/apache-2.4[${APACHE_MODULES},apache2_modules_cgid]
40 >=www-servers/apache-2.4[${APACHE_MODULES},apache2_modules_fcgid] )
41 net-misc/rsync
42 >=dev-perl/File-RsyncP-0.68
43 rss? ( dev-perl/XML-RSS )
44 samba? ( net-fs/samba )"
45
46 need_apache2_4
47
48 SLOT="0"
49
50 S="${WORKDIR}/${MY_P}"
51
52 CGIDIR="/usr/lib/backuppc/htdocs"
53 CONFDIR="/etc/BackupPC"
54 DATADIR="/var/lib/backuppc"
55 DOCDIR="/usr/share/doc/${PF}"
56 LOGDIR="/var/log/BackupPC"
57
58 pkg_setup() {
59 enewgroup backuppc
60 enewuser backuppc -1 /bin/bash /var/lib/backuppc backuppc
61 }
62
63 src_prepare() {
64 epatch "${FILESDIR}/3.3.0/01-fix-configure.pl.patch"
65 epatch "${FILESDIR}/3.3.0/02-fix-config.pl-formatting.patch"
66 epatch "${FILESDIR}/3.3.0/03-reasonable-config.pl-defaults.patch"
67
68 epatch "${FILESDIR}/3.2.0/04-add-docdir-marker.patch"
69 epatch "${FILESDIR}/3.2.0/05-nicelevel.patch"
70
71 # Fix docs location using the marker that we've patched in.
72 sed -i "s+__DOCDIR__+${DOCDIR}+" "lib/BackupPC/CGI/View.pm" \
73 || die "failed to sed the documentation location"
74 }
75
76 src_install() {
77 local myconf
78 myconf=""
79 if use samba ; then
80 myconf="--bin-path smbclient=$(type -p smbclient)"
81 myconf="${myconf} --bin-path nmblookup=$(type -p nmblookup)"
82 fi
83
84 /usr/bin/env perl ./configure.pl \
85 --batch \
86 --bin-path perl=$(type -p perl) \
87 --bin-path tar=$(type -p tar) \
88 --bin-path rsync=$(type -p rsync) \
89 --bin-path ping=$(type -p ping) \
90 --bin-path df=$(type -p df) \
91 --bin-path ssh=$(type -p ssh) \
92 --bin-path sendmail=$(type -p sendmail) \
93 --bin-path hostname=$(type -p hostname) \
94 --bin-path gzip=$(type -p gzip) \
95 --bin-path bzip2=$(type -p bzip2) \
96 --config-dir "${CONFDIR}" \
97 --install-dir /usr \
98 --data-dir "${DATADIR}" \
99 --hostname 127.0.0.1 \
100 --uid-ignore \
101 --dest-dir "${D%/}" \
102 --html-dir "${CGIDIR}"/image \
103 --html-dir-url /image \
104 --cgi-dir "${CGIDIR}" \
105 --fhs \
106 ${myconf} || die "failed the configure.pl script"
107
108 ebegin "Installing documentation"
109
110 pod2man \
111 -errors=none \
112 --section=8 \
113 --center="BackupPC manual" \
114 "${S}"/doc/BackupPC.pod backuppc.8 \
115 || die "failed to generate man page"
116
117 doman backuppc.8
118
119 # Place the documentation in the correct location
120 dodoc "${D}/usr/doc/BackupPC.html"
121 dodoc "${D}/usr/doc/BackupPC.pod"
122 rm -rf "${D}/usr/doc" || die
123
124 eend 0
125
126 # Setup directories
127 dodir "${CONFDIR}/pc"
128
129 keepdir "${CONFDIR}"
130 keepdir "${CONFDIR}/pc"
131 keepdir "${DATADIR}"/{trash,pool,pc,cpool}
132 keepdir "${LOGDIR}"
133
134 ebegin "Setting up init.d/conf.d scripts"
135 newinitd "${S}"/init.d/gentoo-backuppc backuppc
136 newconfd "${S}"/init.d/gentoo-backuppc.conf backuppc
137
138 insinto "${APACHE_MODULES_CONFDIR}"
139 doins "${FILESDIR}"/99_backuppc.conf
140
141 # Make sure that the ownership is correct
142 chown -R backuppc:backuppc "${D}${CONFDIR}" || die
143 chown -R backuppc:backuppc "${D}${DATADIR}" || die
144 chown -R backuppc:backuppc "${D}${LOGDIR}" || die
145 }
146
147 pkg_postinst() {
148 elog "Installation finished, you may now start using BackupPC."
149 elog
150 elog "- Read the documentation in /usr/share/doc/${PF}/BackupPC.html"
151 elog " Please pay special attention to the security section."
152 elog
153 elog "- You can launch backuppc by running:"
154 elog
155 elog " # /etc/init.d/backuppc start"
156 elog
157 elog "- To enable the GUI, first edit ${ROOT}etc/conf.d/apache2 and add,"
158 elog
159 elog " \"-D BACKUPPC -D PERL -D MPM_ITK\""
160 elog
161 elog " to the APACHE2_OPTS line."
162 elog
163 elog " Then you must edit ${ROOT}etc/apache2/modules.d/00_mpm_itk.conf"
164 elog " and adjust the values of LimitUIDRange/LimitGIDRange to include"
165 elog " the UID and GID of the backuppc user."
166 elog
167 elog " Finally, start apache:"
168 elog
169 elog " # /etc/init.d/apache2 start"
170 elog
171 elog " The web interface should now be running on,"
172 elog
173 elog " http://127.0.0.1:8080/"
174 elog
175
176 # Generate a new password if there's no auth file
177 if [[ ! -f "${CONFDIR}/users.htpasswd" ]]; then
178 adminuser="backuppc"
179 adminpass=$( makepasswd --chars=12 )
180 htpasswd -bc "${CONFDIR}/users.htpasswd" $adminuser $adminpass
181
182 elog ""
183 elog "- Created admin user $adminuser with password $adminpass"
184 elog " To add new users, run: "
185 elog ""
186 elog " # htpasswd ${CONFDIR}/users.htpasswd newUser"
187 fi
188 }