Gentoo Websites Logo
Go to: Gentoo Home Documentation Forums Lists Bugs Planet Store Wiki Get Gentoo!
Bug 510898 - net-proxy/polipo add systemd support
Summary: net-proxy/polipo add systemd support
Status: RESOLVED FIXED
Alias: None
Product: Gentoo Linux
Classification: Unclassified
Component: [OLD] Server (show other bugs)
Hardware: All Linux
: Normal normal (vote)
Assignee: Gentoo systemd Team
URL:
Whiteboard:
Keywords: NeedPatch
Depends on:
Blocks: install-systemd-unit
  Show dependency tree
 
Reported: 2014-05-21 04:52 UTC by Yichao Zhou
Modified: 2015-03-30 11:27 UTC (History)
3 users (show)

See Also:
Package list:
Runtime testing required: ---


Attachments
service file (polipo@.service,184 bytes, text/plain)
2015-02-10 07:03 UTC, Yichao Zhou
Details
full ebuild (polipo-1.1.1) (polipo-1.1.1.ebuild,1.69 KB, text/plain)
2015-02-10 07:09 UTC, Yichao Zhou
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Yichao Zhou 2014-05-21 04:52:09 UTC
1.  Portage should provide a service file.

https://projects.archlinux.org/svntogit/community.git/tree/trunk/polipo.service?h=packages/polipo

2.  Portage should add a systemd uses flag to this package so that 
/usr/portage/net-proxy/polipo/polipo.crond will not be installed.

/usr/portage/net-proxy/polipo/polipo.crond is a cron job that relies on OpenRC.  When using systemd, my cron always sends me mail that contains the error message

 * You are attempting to run an openrc service on a
 * system which openrc did not boot.
 * You may be inside a chroot or you may have used
 * another initialization system to boot this system.
 * In this situation, you will get unpredictable results!
 * If you really want to do this, issue the following command:
 * touch /run/openrc/softlevel

Reproducible: Always
Comment 1 Andrew Savchenko gentoo-dev 2015-01-09 00:38:28 UTC
If someone is willing to add systemd support, please provide all necessary files and patches (including ebuild patch) and test them.

I don't have an access to a systemd setup, so I can't provide and test required changes on my own.
Comment 2 Yichao Zhou 2015-01-10 05:33:04 UTC
Why this is resolved as "CANTFIX"? It should remain open until someone fixes it.
Comment 3 Andrew Savchenko gentoo-dev 2015-01-10 05:43:03 UTC
I can't fix this bug, that's why I marked it as CANTFIX. If someone is willing to fix it, instructions are above. You can change the bug status when solution will be available.
Comment 4 Richard Freeman gentoo-dev 2015-01-10 06:10:51 UTC
This can stay open until fixe . Maintainers are not obligated to add init.d scripts or units.
Comment 5 Yichao Zhou 2015-02-10 07:02:33 UTC
Here is my patch:

--- /usr/portage/net-proxy/polipo/polipo-1.1.1.ebuild   2015-01-12 19:01:15.000000000 +0800
+++ polipo-1.1.1.ebuild 2015-02-10 14:39:22.947687487 +0800
@@ -14,12 +14,13 @@
        KEYWORDS="amd64 x86"
 fi
 
-inherit ${_GIT} toolchain-funcs user
+inherit ${_GIT} toolchain-funcs user systemd
 
 DESCRIPTION="A caching web proxy"
 HOMEPAGE="http://www.pps.jussieu.fr/~jch/software/polipo/"
 LICENSE="MIT GPL-2"
 SLOT="0"
+IUSE="systemd"
 
 DEPEND="sys-apps/texinfo"
 RDEPEND=""
@@ -39,18 +40,23 @@
 
        newinitd "${FILESDIR}/${PN}.initd-2" ${PN}
        insinto /etc/${PN} ; doins "${FILESDIR}/config"
-       exeinto /etc/cron.weekly ; newexe "${FILESDIR}/${PN}.crond-2" ${PN}
+       systemd_dounit "${FILESDIR}"/${PN}@.service
+       if ! use systemd; then
+               exeinto /etc/cron.weekly ; newexe "${FILESDIR}/${PN}.crond-2" ${PN}
+       fi
 
        dodoc CHANGES README
        dohtml html/*
 }
 
 pkg_postinst() {
-       einfo "Do not forget to read the manual."
-       einfo "Change the config file in /etc/${PN} to suit your needs."
-       einfo ""
-       einfo "Polipo OpenRC init scripts can now be multiplexed:"
-       einfo "1. create /etc/${PN}/config.foo"
-       einfo "2. symlink /etc/init.d/{${PN}.foo -> ${PN}}"
-       einfo "3. make sure all instances use unique ip:port pair and cachedir, if any"
+       elog "Do not forget to read the manual."
+       elog "Change the config file in /etc/${PN} to suit your needs."
+       elog ""
+       elog "Polipo init scripts can now be multiplexed:"
+       elog "1. create /etc/${PN}/config.foo"
+       elog "2. symlink /etc/init.d/{${PN}.foo -> ${PN}}"
+       elog "  a. if you are using OpenRC, symlink /etc/init.d/{${PN}.foo -> ${PN}}"
+       elog "  b. if you are using systemd, execute \"systemctl enable polipo@config.foo\""
+       elog "3. make sure all instances use unique ip:port pair and cachedir, if any"
 }
Comment 6 Yichao Zhou 2015-02-10 07:03:41 UTC
Created attachment 396048 [details]
service file
Comment 7 Yichao Zhou 2015-02-10 07:08:14 UTC
service file should be placed in files/polipo@.service
Comment 8 Yichao Zhou 2015-02-10 07:09:00 UTC
Created attachment 396052 [details]
full ebuild (polipo-1.1.1)
Comment 9 Andrew Savchenko gentoo-dev 2015-03-29 21:15:22 UTC
(In reply to Yichao Zhou from comment #7)
> service file should be placed in files/polipo@.service

Why "@"? As I see from other packages, normal naming scheme is "${PN}.service".
Comment 10 Yichao Zhou 2015-03-30 06:45:10 UTC
The systemd service files with suffix "@" are called instance.  See http://0pointer.de/blog/projects/instances.html for details.

Using instance, we can use one service to start multiple instances of a service.  For example, "systemctl enable polipo@config.foo" will enable the polipo that uses "config.foo" as the configuration file.
Comment 11 Andrew Savchenko gentoo-dev 2015-03-30 09:28:49 UTC
Repoman doesn't allow "@" character in file names.
systemd_dounit doesn't allow to change unit file name.

Find another way to solve this (see how multiplexing is handled for other packages).
Comment 12 Andrew Savchenko gentoo-dev 2015-03-30 09:31:02 UTC
And please consider that in Gentoo systemd unit files are usually name ".service", not ".systemd".
Comment 13 Andrew Savchenko gentoo-dev 2015-03-30 09:31:39 UTC
Forget my last comment, my mistake.
Comment 14 Andrew Savchenko gentoo-dev 2015-03-30 11:27:03 UTC
File name issue with:
systemd_newunit "${FILESDIR}/${PN}_at.service" "${PN}@.service"

Changes are added to polipo-1.1.1-r1.