]> gitweb.michael.orlitzky.com - mjo-overlay.git/blob - app-backup/backuppc/backuppc-3.3.1.ebuild
app-backup/backuppc: bump package version.
[mjo-overlay.git] / app-backup / backuppc / backuppc-3.3.1.ebuild
1 # Copyright 1999-2014 Gentoo Foundation
2 # Distributed under the terms of the GNU General Public License v2
3 # $Id$
4
5 EAPI="5"
6
7 inherit eutils systemd webapp user
8
9 MY_P="BackupPC-${PV}"
10
11 DESCRIPTION="A high-performance system for backing up computers 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 DEPEND="dev-lang/perl
21 app-admin/apache-tools
22 app-admin/makepasswd"
23 RDEPEND="${DEPEND}
24 virtual/perl-IO-Compress
25 dev-perl/Archive-Zip
26 dev-perl/libwww-perl
27 >=app-arch/tar-1.13.20
28 app-arch/par2cmdline
29 app-arch/gzip
30 app-arch/bzip2
31 virtual/mta
32 www-apache/mod_perl
33 www-servers/apache
34 net-misc/rsync
35 >=dev-perl/File-RsyncP-0.68
36 rss? ( dev-perl/XML-RSS )
37 samba? ( net-fs/samba )"
38
39 WEBAPP_MANUAL_SLOT="yes"
40 SLOT="0"
41
42 S=${WORKDIR}/${MY_P}
43
44 CONFDIR="/etc/BackupPC"
45 DATADIR="/var/lib/backuppc"
46 LOGDIR="/var/log/BackupPC"
47
48 pkg_setup() {
49 webapp_pkg_setup
50 enewgroup backuppc
51 enewuser backuppc -1 /bin/bash /var/lib/backuppc backuppc
52 }
53
54 src_prepare() {
55 epatch "${FILESDIR}/3.3.0/01-fix-configure.pl.patch"
56 epatch "${FILESDIR}/3.3.0/02-fix-config.pl-formatting.patch"
57 epatch "${FILESDIR}/3.3.0/03-reasonable-config.pl-defaults.patch"
58
59 # Fix the documentation location in the CGI interface
60 epatch "${FILESDIR}/3.2.0/04-add-docdir-marker.patch"
61 sed -i "s+__DOCDIR__+/usr/share/doc/${PF}+" "lib/BackupPC/CGI/View.pm"
62
63 epatch "${FILESDIR}/3.2.0/05-nicelevel.patch"
64 sed -i -e 's/--chuid ${USER}//' "${S}"/init.d/src/gentoo-backuppc || die "Failed to fix the init script"
65 }
66
67 src_test() {
68 true
69 }
70
71 src_install() {
72 webapp_src_preinst
73
74 local myconf
75 myconf=""
76 if use samba ; then
77 myconf="--bin-path smbclient=$(type -p smbclient)"
78 myconf="${myconf} --bin-path nmblookup=$(type -p nmblookup)"
79 fi
80
81 /usr/bin/env perl ./configure.pl \
82 --batch \
83 --bin-path perl=$(type -p perl) \
84 --bin-path tar=$(type -p tar) \
85 --bin-path rsync=$(type -p rsync) \
86 --bin-path ping=$(type -p ping) \
87 --bin-path df=$(type -p df) \
88 --bin-path ssh=$(type -p ssh) \
89 --bin-path sendmail=$(type -p sendmail) \
90 --bin-path hostname=$(type -p hostname) \
91 --bin-path gzip=$(type -p gzip) \
92 --bin-path bzip2=$(type -p bzip2) \
93 --config-dir ${CONFDIR} \
94 --install-dir /usr \
95 --data-dir ${DATADIR} \
96 --hostname $(hostname) \
97 --uid-ignore \
98 --dest-dir "${D%/}" \
99 --html-dir ${MY_HTDOCSDIR}/image \
100 --html-dir-url /image \
101 --cgi-dir ${MY_HTDOCSDIR} \
102 --fhs \
103 ${myconf} || die "failed the configure.pl script"
104
105 ebegin "Installing documentation"
106
107 pod2man \
108 -errors=none \
109 --section=8 \
110 --center="BackupPC manual" \
111 "${S}"/doc/BackupPC.pod backuppc.8 || die "failed to generate man page"
112
113 doman backuppc.8
114
115 # Place the documentation in the correct location
116 dodoc "${D}/usr/doc/BackupPC.html"
117 dodoc "${D}/usr/doc/BackupPC.pod"
118 rm -rf "${D}/usr/doc"
119
120 eend 0
121
122 # Setup directories
123 dodir ${CONFDIR}/pc
124
125 keepdir ${CONFDIR}
126 keepdir ${CONFDIR}/pc
127 keepdir ${DATADIR}/{trash,pool,pc,cpool}
128 keepdir ${LOGDIR}
129
130 ebegin "Setting up init.d/conf.d/systemd scripts"
131 newinitd "${S}"/init.d/gentoo-backuppc backuppc
132 newconfd "${S}"/init.d/gentoo-backuppc.conf backuppc
133 systemd_dounit "${FILESDIR}/${PN}.service"
134 eend 0
135
136 ebegin "Setting up an apache instance for backuppc"
137
138 cp "${FILESDIR}/apache2-backuppc."{conf,init} "${WORKDIR}/"
139 cp "${FILESDIR}/httpd.conf" "${WORKDIR}/httpd.conf"
140 sed -i -e "s+HTDOCSDIR+${MY_HTDOCSDIR}+g" "${WORKDIR}/httpd.conf"
141 sed -i -e "s+AUTHFILE+${CONFDIR}/users.htpasswd+g" "${WORKDIR}/httpd.conf"
142
143 moduledir="/usr/lib/apache2/modules"
144
145 # Check if the Apache ServerRoot is real.
146 # This is sometimes broken on older amd64 systems.
147 # In this case we just patch our config file appropriately.
148 if [[ ! -d "/usr/lib/apache2" ]]; then
149 if [[ -d "/usr/lib64/apache2" ]]; then
150 sed -i -e "s+/usr/lib/apache2+/usr/lib64/apache2+g" "${WORKDIR}/httpd.conf"
151 sed -i -e "s+/usr/lib/apache2+/usr/lib64/apache2+g" "${WORKDIR}/apache2-backuppc.conf"
152 moduledir="/usr/lib64/apache2/modules"
153 fi
154 fi
155
156 # Check if we're using mod_cgid instead of mod_cgi
157 # This happens if you install apache with USE="threads"
158 if [[ -f "${moduledir}/mod_cgid.so" ]]; then
159 sed -i -e "s+mod_cgi+mod_cgid+g" "${WORKDIR}/httpd.conf"
160 sed -i -e "s+cgi_module+cgid_module+g" "${WORKDIR}/httpd.conf"
161 fi
162
163 # Install conf.d/init.d files for apache2-backuppc
164 if [ -e /etc/init.d/apache2 ]; then
165 newconfd "${WORKDIR}/apache2-backuppc.conf" apache2-backuppc
166 newinitd /etc/init.d/apache2 apache2-backuppc
167 else
168 newconfd "${WORKDIR}/apache2-backuppc.conf" apache2-backuppc
169 newinitd "${WORKDIR}/apache2-backuppc.init" apache2-backuppc
170 fi
171
172 insopts -m 0644
173 insinto ${CONFDIR}
174 doins "${WORKDIR}/httpd.conf"
175
176 eend $?
177
178 webapp_src_install || die "webapp_src_install"
179
180 # Make sure that the ownership is correct
181 chown -R backuppc:backuppc "${D}${CONFDIR}"
182 chown -R backuppc:backuppc "${D}${DATADIR}"
183 chown -R backuppc:backuppc "${D}${LOGDIR}"
184 }
185
186 pkg_postinst() {
187 # This is disabled since BackupPC doesn't need it
188 # webapp_pkg_postinst
189
190 elog "Installation finished, now may now start using BackupPC."
191 elog ""
192 elog "- Read the documentation in /usr/share/doc/${PF}/BackupPC.html"
193 elog " Please pay special attention to the security section."
194 elog ""
195 elog "- You can launch backuppc and it's apache web interface by running:"
196 elog " # /etc/init.d/backuppc start"
197 elog " # /etc/init.d/apache2-backuppc start"
198
199 if [[ ! -e /etc/runlevels/default/backuppc ]]; then
200 elog ""
201 elog "- You also might want to add these scripts to your default runlevel:"
202 elog " # rc-update add backuppc default"
203 elog " # rc-update add apache2-backuppc default"
204 fi
205
206 # Generate a new password if there's no auth file
207 if [[ ! -f "${CONFDIR}/users.htpasswd" ]]; then
208 adminuser="backuppc"
209 adminpass=$( makepasswd --chars=12 )
210 htpasswd -bc "${CONFDIR}/users.htpasswd" $adminuser $adminpass
211
212 elog ""
213 elog "- Created admin user $adminuser with password $adminpass"
214 elog " To add new users, run: "
215 elog " # htpasswd ${CONFDIR}/users.htpasswd newUser"
216 fi
217
218 if [[ -d "/etc/backuppc" ]]; then
219 ewarn ""
220 ewarn "Detected old config directory in /etc/backuppc"
221 ewarn "Please migrate relevant config files to ${CONFDIR} before starting backuppc"
222 fi
223 }