# Copyright 1999-2008 Gentoo Foundation # Distributed under the terms of the GNU General Public License v2 # $Header: $ inherit eutils webapp MY_P="BackupPC-${PV}" DESCRIPTION="backup system for desktops to a servers disk" HOMEPAGE="http://backuppc.sourceforge.net" SRC_URI="mirror://sourceforge/${PN}/${MY_P}.tar.gz" LICENSE="GPL-2" KEYWORDS="~amd64 x86" IUSE="doc rsync samba" DEPEND="dev-lang/perl" RDEPEND="${DEPEND} dev-perl/Compress-Zlib dev-perl/Archive-Zip >=app-arch/tar-1.13.20 app-arch/par2cmdline app-arch/gzip app-arch/bzip2 virtual/mta www-servers/apache rsync? ( >=dev-perl/File-RsyncP-0.68 ) rss? ( dev-perl/XML-RSS ) samba? ( net-fs/samba )" S=${WORKDIR}/${MY_P} pkg_setup() { local backuppcuserid backuppcuserid="101" if ! egrep "^backuppc" -q /etc/passwd ; then while [ "$exitloop" != "1" ] ; do found=""; for i in `cut -d':' -f3 /etc/passwd` ; do if [ "$i" == "$backuppcuserid" ] ; then found=1 ; backuppcuserid=$(($backuppcuserid+1)); fi ; done ; if [ "$found" == "" ] ; then exitloop=1; fi ; done ; else backuppcuserid="`egrep '^backuppc' /etc/passwd | cut -d':' -f3 `" fi einfo "Using ${backuppcuserid} as the UID for the backuppc user" backuppcuseridG="${backuppcuserid}" enewgroup backuppc enewuser backuppc ${backuppcuseridG} -1 /dev/null backuppc webapp_pkg_setup } src_unpack() { unpack ${A} cd "${S}" sed -i -e "1s_/bin/perl_/usr/bin/perl_" configure.pl } src_compile() { find ./ -name 'CVS' -type d | xargs rm -rf echo "#include " > backuppc.c echo "#include " >> backuppc.c echo "#include " >> backuppc.c echo "int main(){" >> backuppc.c echo "setuid(${backuppcuseridG});" >> backuppc.c echo "system(\"./BackupPC_Admin\");" >> backuppc.c echo "return 0;" >> backuppc.c echo "}" >> backuppc.c einfo "gcc backuppc.c -o index.cgi" gcc backuppc.c -o index.cgi } src_test() { einfo "Can not test" } src_install() { local myconf myconf="" if use samba ; then myconf="--bin-path smbclient=$(type -p smbclient)" myconf="${myconf} --bin-path nmblookup=$(type -p nmblookup)" fi webapp_src_preinst einfo ${MY_HTDOCSDIR} dodir ${MY_HTDOCSDIR}/${PN} ./configure.pl \ --batch \ --bin-path perl=$(type -p perl) \ --bin-path tar=$(type -p tar) \ --bin-path rsync=$(type -p rsync) \ --bin-path ping=$(type -p ping) \ --bin-path df=$(type -p df) \ --bin-path ssh=$(type -p ssh) \ --bin-path sendmail=$(type -p sendmail) \ --bin-path hostname=$(type -p hostname) \ --bin-path gzip=$(type -p gzip) \ --bin-path bzip2=$(type -p bzip2) \ --install-dir /usr/BackupPC \ --data-dir /var/lib/BackupPC \ --hostname $(hostname) \ --uid-ignore \ --dest-dir "${D}" \ --html-dir ${MY_HTDOCSDIR}/image \ --html-dir-url /${PN}/image \ --cgi-dir ${MY_HTDOCSDIR} \ --fhs \ ${myconf} || die "failed the configure.pl script" pod2man \ --section=8 \ --center="BackupPC manual" \ "${S}"/doc/BackupPC.pod backuppc.8 || die "failed to generate man page" doman backuppc.8 diropts -m 750 keepdir /var/log/BackupPC keepdir /var/lib/BackupPC diropts -m 755 keepdir /etc/BackupPC newinitd "${S}"/init.d/gentoo-backuppc backuppc newconfd "${S}"/init.d/gentoo-backuppc.conf backuppc insopts -m 0755 -o root -g backuppc insinto ${MY_HTDOCSDIR} doins index.cgi doins "${FILESDIR}"/.htaccess insopts -m 640 insinto /etc/BackupPC doins "${FILESDIR}"/authUser webapp_postinst_txt \ en "${FILESDIR}"/postinstall-en.txt || die "webapp_postinst_txt" webapp_hook_script "${FILESDIR}"/fixperms webapp_src_install || die "webapp_src_install" } pkg_postinst() { webapp_pkg_postinst ebegin "Adjusting ownership of various things..." chown -Rf backuppc:backuppc /etc/BackupPC chown -f root:apache /etc/BackupPC/authUser chown -Rf backuppc:backuppc /var/log/BackupPC chown -Rf backuppc:backuppc /var/lib/BackupPC eend $? elog "Please read the documentation" elog "It is important to know that the webserver and the backuppc user" elog "*must* be one and the same" }