backuppc-3.3.1-r4.ebuild 5.3 KB

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