OpenRC/Prefix

This work is a reponse to.

The following guideline applies to a Gentoo Prefix on RHEL-5.6 amd64 and on Debian 6.0 amd64, for other setups it should be similar. Feel free to documents corner cases here.

Using heroxbd's overlay
This is a developer's overlay by heroxbd. The changes will be reviewed and included in the official tree gradually. As of Aug 11, 2012, the overlay includes sys-apps/portage-9999 (for keeping /etc/{init,conf}.d and fixing shebangs inside), sys-apps/openrc-9999 (for adding back Prefix support and exporting EPREFIX).

Let's add heroxbd's overlay with Layman from app-portage/layman,

Make sure overlays from layman are effective,

replace /gentoo with your own $EPREFIX.

Details for playing with layman can be found at Layman.

install portage from the overlay
ebuilds with files into /etc/{init,conf}.d
 * Default portage in prefix removes /etc/{init,conf}.d directories with prompts like

emerge portage from heroxbd's overlay to disable this behavior.

install masked version of baselayout-prefix from the main tree

 * baselayout-prefix comes from baselayout-1, which has file-collision with openrc. emerge sys-apps/baselayout-prefix-1.12.14-r1 to remove the offending files.

(optional) using an external service supervisor
Usually, OpenRC starts process in background via start-stop-daemon. This custom comes from the BSD world, and have intrinsic drawbacks as discussed by GreyCat. To track the status of service reliably and restart critical services (e.g. remote shell daemon on a headless server) when accidentally killed, a process supervisor may be used.

There is an experimental support of OpenRC to work together with runit.

To try this out, enable the runit USE flag for OpenRC,

first trial
openrc is not out of box now, first attempt

Let's eliminate the blocks.

glibc and sysvinit
In Gentoo Prefix, glibc and sysvinit are supposed to be provided outside Prefix by host OS. Let's tell portage that we have any version of glibc and sysvinit she wants:

now it we can go on,

Example: tinc
tinc is a decentralized VPN. A tinc started from Gentoo Prefix can serve as a relay node in the VPN, if tun/tap is not available for normal user.

emerge tinc, or re-emerge to get its {init,conf}.d files back with our new portage

prefixify init script
fix shebang in the init script,

fire up tincd from OpenRC
Make necessary changes in ${EPREFIX}/etc/conf.d/tinc.networks and ${EPREFIX}/etc/tinc according to your specific setup.

Add tincd into default runlevel

Finally we are done with

Example: nginx
nginx is a small, robust and high-performance web server.

Emerge nginx, or re-emerge to get its initd and confd files back with our new portage:

prefixify init script
fix shebang in the init script,

normal privilege

 * remove "user nginx nginx;" from the first line of ${EPREFIX}/etc/nginx/nginx.conf
 * You cannot listen on port 80 without root privilege. Change it to 8008,

External resources
Benda's OpenRC page