# Copyright 1999-2018 Gentoo Authors # Distributed under the terms of the GNU General Public License v2 EAPI=7 inherit user systemd DESCRIPTION="Folding@Home is a distributed computing project for protein folding" HOMEPAGE="https://foldingathome.org/" MY_P="fahclient_${PV}-64bit-release" SRC_URI="https://download.foldingathome.org/releases/public/release/fahclient/debian-stable-64bit/v$(ver_cut 1-2)/${MY_P}.tar.bz2 -> ${MY_P}-debian.tar.bz2" RESTRICT="mirror bindist strip" LICENSE="FAH-EULA-2014 FAH-special-permission" SLOT="0" KEYWORDS="~amd64" IUSE="" # Expressly listing all deps, as this is a binpkg and it is doubtful whether # e.g. uclibc or clang can provide what is necessary at runtime RDEPEND=" sys-devel/gcc sys-libs/glibc sys-libs/zlib" S="${WORKDIR}/${MY_P}" QA_PREBUILT="opt/foldingathome/*" pkg_setup() { elog "" elog "Special permission is hereby granted to the Gentoo project to provide an" elog "automated installer package which downloads and installs the Folding@home client" elog "software. Permission is also granted for future Gentoo installer packages on the" elog "condition that they continue to adhere to all of the terms of the accompanying" elog "Folding@home license agreements and display this notice." elog "-- Vijay S. Pande, Stanford University, 07 May 2013" elog "" elog "(ref: http://foldingforum.org/viewtopic.php?f=16&t=22524&p=241992#p241992 )" elog "" enewuser foldingathome -1 -1 "${EPREFIX}"/opt/foldingathome } src_install() { exeinto /opt/foldingathome doexe FAHClient FAHCoreWrapper insinto /opt/foldingathome doins sample-config.xml fowners -R foldingathome:foldingathome /opt/foldingathome dodoc CHANGELOG.md README.md newconfd - foldingathome <<- EOF # Config file for ${EPREFIX}/etc/init.d/foldingathome # # The f@h client configuration can be found in /opt/foldingathome/config.xml # Run emerge --config ${CATEGORY}/${PN} to configure your client. # The options that may be passed to the client can be obtained # by running ${EPREFIX}/opt/foldingathome/FAHClient --help FOLD_OPTS="" EOF newinitd - foldingathome <<- EOF #!/sbin/openrc-run # Copyright 1999-2018 Gentoo Authors # Distributed under the terms of the GNU General Public License v2 command="${EPREFIX}/opt/foldingathome/FAHClient" command_args="\${FOLD_OPTS}" command_user=foldingathome command_background=1 directory="${EPREFIX}/opt/foldingathome" pidfile="/run/\${RC_SVCNAME}.pid" EOF systemd_newunit - foldingathome.service <<- EOF [Unit] Description=Folding@Home V7 Client Documentation=https://foldingathome.org [Service] Type=simple User=foldingathome WorkingDirectory=${EPREFIX}/opt/foldingathome PIDFile=/run/fahclient.pid ExecStart=${EPREFIX}/opt/foldingathome/FAHClient -v start ExecReload=${EPREFIX}/opt/foldingathome/FAHClient -v restart ExecStop=${EPREFIX}/opt/foldingathome/FAHClient -v stop KillMode=process [Install] WantedBy=multi-user.target EOF } pkg_postinst() { elog "To run Folding@home in the background at boot:" elog "(openrc)\trc-update add foldingathome default" elog "(systemd)\tsystemctl enable foldingathome" elog "" if [ ! -e "${EPREFIX}"/opt/foldingathome/config.xml ]; then elog "No config.xml file found -- please run" elog "emerge --config ${CATEGORY}/${PN} to configure your client," elog "or specify all necessary runtime options in FOLD_OPTS within" elog "${EPREFIX}/etc/conf.d/foldingathome" elog "" fi if ver_test $(set -- ${REPLACING_VERSIONS} 999; echo $1) -lt 7.5.1; then elog "NOTE, the 'initfolding' helper script has been dropped, please" elog "use emerge --config ${P} or run FAHClient --configure directly" elog "and adjust file permissions and ownership yourself" elog "" fi elog "Please see ${EPREFIX}/opt/foldingathome/FAHClient --help for more details." einfo "" einfo "The original package maintainer encourages you to acquire a username and join team 36480." einfo "http://folding.stanford.edu/English/Download#ntoc2" einfo "" } pkg_postrm() { if [[ -z ${REPLACED_BY_VERSION} ]]; then elog "Folding@home data files were not removed." elog "Remove them manually from ${EPREFIX}/opt/foldingathome" fi } pkg_config() { cd "${EPREFIX}"/opt/foldingathome || die su foldingathome -s /bin/sh -c "./FAHClient --configure" }