New port: sysutils/runit-faster

Runit is a daemontools replacement with the following features:

- Service supervision
- Clean process state
- Reliable logging facility
- Fast system bootup and shutdown
- Packaging friendly
- Small code size

This very experimental port comes with a complete suite of
configuration files and services to replace init(8) and rc(8) with
runit for initializing your system.  Heavily inspired by Void Linux'
init scripts.

For usage instructions visit:
https://people.freebsd.org/~tobik/runit-faster.html

Some fixes applied to sysutils/runit:

- Fix most compiler warnings
- Fix bug where runit will only halt the system instead of powering it
  off
- Pet rclint for runsvdir
- Pet portlint and regenerate patches
This commit is contained in:
Tobias Kortkamp 2018-03-08 05:16:46 +00:00
parent 2cf26f04eb
commit 90c819ddbe
Notes: svn2git 2021-03-31 03:12:20 +00:00
svn path=/head/; revision=463865
14 changed files with 360 additions and 0 deletions

View file

@ -1078,6 +1078,7 @@
SUBDIR += rubygem-yell
SUBDIR += rundeck
SUBDIR += runit
SUBDIR += runit-faster
SUBDIR += runwhen
SUBDIR += s6
SUBDIR += s6-rc

View file

@ -0,0 +1,97 @@
# Created by: Sergei Kolobov <sergei@kolobov.com>
# $FreeBSD$
PORTNAME= runit
DISTVERSION= 2.1.2-0.1.13
RUNITVERSION= ${DISTVERSION:C/(.*)-(.*)/\1/}
CONFVERSION= ${DISTVERSION:C/(.*)-(.*)/\2/}
CATEGORIES= sysutils
MASTER_SITES= http://smarden.org/runit/ \
http://www.bayofrum.net/dist/runit/ \
LOCAL/tobik:config \
https://pkg.tobik.me/distfiles/:config
PKGNAMESUFFIX= -faster
DISTFILES= runit-${RUNITVERSION}${EXTRACT_SUFX} \
freebsd-runit-${CONFVERSION}${EXTRACT_SUFX}:config
MAINTAINER= tobik@FreeBSD.org
COMMENT= Runit based init replacement for ${OPSYS}
LICENSE= BSD3CLAUSE
LICENSE_FILE= ${WRKSRC}/package/COPYING
RUN_DEPENDS= snooze:sysutils/snooze
CONFLICTS_INSTALL= runit
PLIST_SUB= RUNITDIR=${RUNITDIR}
USE_RC_SUBR= runsvdir
WRKSRC= ${WRKDIR}/admin/runit-${RUNITVERSION}
OPTIONS_DEFINE= DOCS ROOT
ROOT_DESC= Install bootstrap files into /etc/runit and /sbin
PORTDOCS= *
ROOT_VARS= RUNITDIR=/etc/runit SBINDIR=/sbin
ROOT_VARS_OFF= RUNITDIR=${PREFIX}/etc/runit SBINDIR=${PREFIX}/sbin
post-patch:
@${REINPLACE_CMD} -e 's,/service/,/var/service,' \
-e 's,/etc/runit,${RUNITDIR},' \
-e 's,/sbin/runit,${SBINDIR}/runit,' \
${WRKSRC}/man/* ${WRKSRC}/doc/*.html \
${WRKSRC}/src/sv.c \
${WRKSRC}/src/runsvchdir.c \
${WRKSRC}/src/runit.c \
${WRKSRC}/src/runit.h
do-configure:
@${ECHO_CMD} "${CC} ${CFLAGS}" > ${WRKSRC}/src/conf-cc
@${ECHO_CMD} "${CC}" > ${WRKSRC}/src/conf-ld
do-build:
@cd ${WRKSRC} && package/compile
do-install:
@${MKDIR} ${STAGEDIR}${RUNITDIR} ${STAGEDIR}${SBINDIR}
${INSTALL_PROGRAM} ${WRKSRC}/command/* ${STAGEDIR}${SBINDIR}
${INSTALL_MAN} ${WRKSRC}/man/*.8 ${STAGEDIR}${PREFIX}/man/man8
@${DO_MAKE_BUILD} -C ${WRKDIR}/freebsd-runit-${CONFVERSION} \
DESTDIR=${STAGEDIR} \
LOCALBASE=${LOCALBASE} \
PREFIX=${PREFIX} \
RUNITDIR=${RUNITDIR} \
SVDIR=${PREFIX}/etc/sv \
install
# Point runit to the run directory (a necessity to let runit work on
# read-only root filesystems) and make sure rebooting and powering off
# can work correctly.
@${LN} -s /var/run/runit/reboot ${STAGEDIR}${RUNITDIR}/reboot
@${LN} -s /var/run/runit/stopit ${STAGEDIR}${RUNITDIR}/stopit
do-install-DOCS-on:
@${MKDIR} ${STAGEDIR}${DOCSDIR}
cd ${WRKSRC} && ${INSTALL_DATA} \
package/CHANGES package/README package/THANKS doc/*.html \
${STAGEDIR}${DOCSDIR}
post-install:
# Micromanaging pkg-plist is no fun here... Generate it on the fly
# instead.
@${FIND} -s ${STAGEDIR}${RUNITDIR} ${STAGEDIR}${PREFIX}/etc/sv ${STAGEDIR}${SBINDIR} \
-not -type d | ${SORT} | ${SED} \
-e 's,^${STAGEDIR},,' \
-e 's,^${PREFIX}/,,' \
>> ${TMPPLIST}
@${FIND} -s ${STAGEDIR}${RUNITDIR} ${STAGEDIR}${PREFIX}/etc/sv ${STAGEDIR}${SBINDIR} \
-type d | ${SORT} | ${SED} \
-e 's,^${STAGEDIR},,' \
-e 's,^${PREFIX}/,,' \
-e 's,^,@dir ,' >> ${TMPPLIST}
do-test:
@cd ${WRKSRC} && package/check
.include <bsd.port.mk>

View file

@ -0,0 +1,5 @@
TIMESTAMP = 1520485557
SHA256 (runit-2.1.2.tar.gz) = 6fd0160cb0cf1207de4e66754b6d39750cff14bb0aa66ab49490992c0c47ba18
SIZE (runit-2.1.2.tar.gz) = 110916
SHA256 (freebsd-runit-0.1.13.tar.gz) = d7c7dd66f5fdd06ebf80c5348cf05796a3e0abddacc456e6955da33b88ac1fab
SIZE (freebsd-runit-0.1.13.tar.gz) = 14164

View file

@ -0,0 +1,11 @@
--- src/chkshsgr.c.orig 2018-03-05 09:33:03 UTC
+++ src/chkshsgr.c
@@ -4,7 +4,7 @@
int main()
{
- short x[4];
+ gid_t x[4];
x[0] = x[1] = 0;
if (getgroups(1,x) == 0) if (setgroups(1,x) == -1) _exit(1);

View file

@ -0,0 +1,28 @@
--- src/pathexec_run.c.orig 2014-08-10 18:22:35 UTC
+++ src/pathexec_run.c
@@ -5,6 +5,7 @@
#include "str.h"
#include "env.h"
#include "pathexec.h"
+#include <unistd.h>
static stralloc tmp;
@@ -15,7 +16,7 @@ void pathexec_run(const char *file,const char * const
int savederrno;
if (file[str_chr(file,'/')]) {
- execve(file,argv,envp);
+ execve(file,(char *const *)argv,(char *const *)envp);
return;
}
@@ -32,7 +33,7 @@ void pathexec_run(const char *file,const char * const
if (!stralloc_cats(&tmp,file)) return;
if (!stralloc_0(&tmp)) return;
- execve(tmp.s,argv,envp);
+ execve(tmp.s,(char *const *)argv,(char * const *)envp);
if (errno != error_noent) {
savederrno = errno;
if ((errno != error_acces) && (errno != error_perm) && (errno != error_isdir)) return;

View file

@ -0,0 +1,20 @@
--- src/prot.c.orig 2018-03-05 09:31:55 UTC
+++ src/prot.c
@@ -3,7 +3,7 @@
#include "hasshsgr.h"
#include "prot.h"
-int prot_gid(int gid)
+int prot_gid(gid_t gid)
{
#ifdef HASSHORTSETGROUPS
short x[2];
@@ -15,7 +15,7 @@ int prot_gid(int gid)
return setgid(gid); /* _should_ be redundant, but on some systems it isn't */
}
-int prot_uid(int uid)
+int prot_uid(uid_t uid)
{
return setuid(uid);
}

View file

@ -0,0 +1,15 @@
--- src/prot.h.orig 2018-03-05 09:38:43 UTC
+++ src/prot.h
@@ -3,7 +3,10 @@
#ifndef PROT_H
#define PROT_H
-extern int prot_gid(int);
-extern int prot_uid(int);
+#include <sys/param.h>
+#include <unistd.h>
+
+extern int prot_gid(gid_t);
+extern int prot_uid(uid_t);
#endif

View file

@ -0,0 +1,15 @@
--- src/runit.c.orig 2018-03-06 14:39:19 UTC
+++ src/runit.c
@@ -309,10 +309,10 @@ int main (int argc, const char * const *argv, char * c
reboot_system(RB_AUTOBOOT);
}
else {
-#ifdef RB_POWER_OFF
+#ifdef RB_POWEROFF
strerr_warn2(INFO, "power off...", 0);
sync();
- reboot_system(RB_POWER_OFF);
+ reboot_system(RB_POWEROFF);
sleep(2);
#endif
#ifdef RB_HALT_SYSTEM

View file

@ -0,0 +1,10 @@
--- src/svlogd.c.orig 2014-08-10 18:22:34 UTC
+++ src/svlogd.c
@@ -430,6 +430,7 @@ unsigned int logdir_open(struct logdir *ld, const char
ld->name =(char*)fn;
ld->ppid =0;
ld->match ='+';
+ ld->udpaddr.sin_family =AF_INET;
ld->udpaddr.sin_port =0;
ld->udponly =0;
while (! stralloc_copys(&ld->prefix, "")) pause_nomem();

View file

@ -0,0 +1,90 @@
Since init lacks this code in FreeBSD (utx-logout is performed in pam_lastlog)
we will simply make utmpset.c a noop if utmpx is present.
http://lists.freebsd.org/pipermail/freebsd-ports/2011-May/067872.html
--- src/tryuwtmpx.c.orig 2014-08-10 18:22:35 UTC
+++ src/tryuwtmpx.c
@@ -1,9 +1,9 @@
#include <sys/types.h>
#include <utmpx.h>
-struct futmpx ut;
+struct utmpx ut;
int main(void) {
- char *s =ut.ut_name;
+ char *s =ut.ut_user;
return(0);
}
--- src/utmpset.c.orig 2014-08-10 18:22:35 UTC
+++ src/utmpset.c
@@ -22,6 +22,11 @@ const char *progname;
void usage(void) { strerr_die4x(1, "usage: ", progname, USAGE, "\n"); }
int utmp_logout(const char *line) {
+
+#ifdef _UW_TMP_UTMPX
+ int ok = 1; /* do_nada(); */
+#else /* _UW_TMP_UTMP */
+
int fd;
uw_tmp ut;
int ok =-1;
@@ -45,9 +50,13 @@ int utmp_logout(const char *line) {
break;
}
close(fd);
+#endif /* _UW_TMP_UTMPX */
return(ok);
}
int wtmp_logout(const char *line) {
+#ifdef _UW_TMP_UTMPX
+ return 1; /* do_nada(); */
+#else /* _UW_TMP_UTMP */
int fd;
int len;
struct stat st;
@@ -79,6 +88,7 @@ int wtmp_logout(const char *line) {
}
close(fd);
return(1);
+#endif /* _UW_TMP_UTMPX */
}
int main (int argc, const char * const *argv, const char * const *envp) {
--- src/uw_tmp.h1.orig 2014-08-10 18:22:35 UTC
+++ src/uw_tmp.h1
@@ -3,6 +3,8 @@
/* sysdep: -utmpx */
+#ifndef _UW_TMP_UTMP
+#define _UW_TMP_UTMP
#ifdef _PATH_UTMP
#define UW_TMP_UFILE _PATH_UTMP
#define UW_TMP_WFILE _PATH_WTMP
@@ -17,3 +19,4 @@
#endif
typedef struct utmp uw_tmp;
+#endif /* _UW_TMP_UTMP */
--- src/uw_tmp.h2.orig 2014-08-10 18:22:35 UTC
+++ src/uw_tmp.h2
@@ -3,11 +3,12 @@
/* sysdep: +utmpx */
-#define UW_TMP_UFILE _UTMPX_FILE
-#define UW_TMP_WFILE _WTMPX_FILE
-
+#ifndef _UW_TMP_UTMPX
+#define _UW_TMP_UTMPX
#ifndef ut_time
#define ut_time ut_tv.tv_sec
#endif
-typedef struct futmpx uw_tmp;
+typedef struct utmpx uw_tmp;
+
+#endif /* _UW_TMP_UTMPX */

View file

@ -0,0 +1,38 @@
#!/bin/sh
#
# $FreeBSD$
#
# PROVIDE: runsvdir
# BEFORE: SERVERS
# KEYWORD: shutdown
#
# Add the following lines to /etc/rc.conf to enable `runsvdir':
#
# runsvdir_enable="YES"
# runsvdir_path="/var/service"
. /etc/rc.subr
name=runsvdir
desc="starts and monitors a collection of runsv(8) processes"
rcvar=runsvdir_enable
load_rc_config runsvdir
: ${runsvdir_enable:=NO}
: ${runsvdir_path=/var/service}
command="%%PREFIX%%/sbin/runsvdir"
start_cmd=runsvdir_start
stop_postcmd="%%PREFIX%%/sbin/sv exit ${runsvdir_path}/*"
runsvdir_start()
{
/bin/test -d ${runsvdir_path} || /bin/mkdir -p ${runsvdir_path}
/usr/bin/env -i \
PATH=/command:%%PREFIX%%/sbin:%%PREFIX%%/bin:/sbin:/bin:/usr/sbin:/usr/bin \
/usr/sbin/daemon -c -f \
${command} ${runsvdir_path}
}
run_rc_command $1

View file

@ -0,0 +1,15 @@
Runit is a daemontools replacement with the following features:
- Service supervision
- Clean process state
- Reliable logging facility
- Fast system bootup and shutdown
- Packaging friendly
- Small code size
This very experimental port comes with a complete suite of
configuration files and services to replace init(8) and rc(8) with
runit for initializing your system. Heavily inspired by Void Linux'
init scripts.
WWW: http://smarden.org/runit/

View file

@ -0,0 +1,2 @@
Please see https://people.freebsd.org/~tobik/runit-faster.html for
usage intstructions.

View file

@ -0,0 +1,13 @@
man/man8/chpst.8.gz
man/man8/runit-init.8.gz
man/man8/runit.8.gz
man/man8/runsv.8.gz
man/man8/runsvchdir.8.gz
man/man8/runsvdir.8.gz
man/man8/sv.8.gz
man/man8/svlogd.8.gz
man/man8/utmpset.8.gz
@postexec [ ! -e %%RUNITDIR%%/runsvdir/current ] && cd %%RUNITDIR%%/runsvdir && ln -s default current
@postunexec rm -f %%RUNITDIR%%/runsvdir/current
@postexec ln -sf /var/run/runit/runsvdir/current /var/service
@postunexec rm -f /var/service