refresh runit

This commit is contained in:
joborun linux 2024-10-01 02:48:05 +03:00
parent 5e87b9936b
commit e2426f0bd8
13 changed files with 420 additions and 0 deletions

11
runit/30-binfmt.hook Normal file
View file

@ -0,0 +1,11 @@
[Trigger]
Type = Path
Operation = Install
Operation = Upgrade
Target = usr/lib/binfmt.d/*.conf
[Action]
Description = Registering binary formats...
When = PostTransaction
Exec = /usr/share/libalpm/scripts/runit-hook binfmt
NeedsTargets

12
runit/30-sysctl.hook Normal file
View file

@ -0,0 +1,12 @@
[Trigger]
Type = Path
Operation = Install
Operation = Upgrade
Target = etc/sysctl.d/*.conf
Target = usr/lib/sysctl.d/*.conf
[Action]
Description = Applying kernel sysctl settings...
When = PostTransaction
Exec = /usr/share/libalpm/scripts/runit-hook sysctl
NeedsTargets

126
runit/PKGBUILD Normal file
View file

@ -0,0 +1,126 @@
#!/usr/bin/bash
# JOBoRun : Jwm OpenBox Obarun RUNit
# Maintainer : Joe Bo Run <joborun@disroot.org>
# PkgSource : url="https://gittea.disroot.org/joborun-pkg/jobcore/$pkgname"
# Website : https://pozol.eu
#-----------------------------------------| DESCRIPTION |---------------------------------------
#src-url="https://git.disroot/org/joborun/runit-joborun"
_url="https://git.disroot.org/joborun-pkg/repos/raw/branch/main"
_pkgname="runit-joborun"
_pkgver="20230911"
# set default service path to /run/runit/service
_servicedir=/run/runit/service
# This is a major refresh of runit in order to build in gcc 14+
# All thanks to Clan Z. Liu @ https://github.com/clan/runit
# runit can be compiled and built on gcc >=14.x.x
# All those patches have been incorporated to the new official release marked 2.2.0
pkgname=runit
pkgver=2.2.0
pkgrel=01
pkgdesc='a cross-platform Unix init scheme with service supervision'
url='http://smarden.org/runit/'
makedepends=('sh')
backup=('etc/rc.local' 'etc/rc.shutdown')
install=runit.install
source=("http://smarden.org/${pkgname}/${pkgname}-${pkgver}.tar.gz"
"runit-joborun.tar.xz::$_url/$_pkgname-$_pkgver.tar.xz"
"halt.c"
"shutdown"
"runit-hook"
"runit-install.hook"
"runit-remove.hook"
"30-binfmt.hook"
"30-sysctl.hook"
"README.md")
prepare() {
# set default service path to /run/runit/service
cd "${srcdir}/admin/${pkgname}-${pkgver}"
sed -i "s|/service/|${_servicedir}/|" src/sv.c
# apply patches
}
build() {
cd "${srcdir}"
cc ${CFLAGS} halt.c -o halt ${LDFLAGS}
# cc halt.c -o halt # alternative to static
make SERVICEDIR="${_servicedir}"
cd "${srcdir}/admin/${pkgname}-${pkgver}"
CFLAGS="${CFLAGS} -static" # alternative to static
LDFLAGS="${LDFLAGS} -static" # alternative to static
package/compile
}
check() {
cd "${srcdir}/admin/${pkgname}-${pkgver}"
package/check
}
package() {
depends=('runit-rc' 'joborun66'
# "gcc-libs=14.2.1+r134+gab884fffe3fc" # to build dynamically add these to prevent breaking upgrade
# "glibc=2.40+r16+gaa533d58ff" # to build dynamically add these to prevent breaking upgrade
)
optdepends=('runit-bash-completions: Runit completions for Bash')
# commands
install -dm755 "${pkgdir}/usr/bin/run"
install -Dm755 ${srcdir}/admin/${pkgname}-${pkgver}/command/* "${pkgdir}/usr/bin"
install -Dm755 ${srcdir}/halt ${pkgdir}/usr/bin/run/halt
ln -s halt ${pkgdir}/usr/bin/run/poweroff
ln -s halt ${pkgdir}/usr/bin/run/reboot
install -Dm755 ${srcdir}/shutdown ${pkgdir}/usr/bin/run/shutdown
cd ${srcdir}/
make DESTDIR="${pkgdir}" PREFIX="/usr" SERVICEDIR="${_servicedir}" install-runit
# man pages
install -dm755 "${pkgdir}/usr/share/man/man8"
install -Dm644 ${srcdir}/admin/${pkgname}-${pkgver}/man/* "${pkgdir}/usr/share/man/man8"
# alpm hooks
install -Dm755 "${srcdir}/runit-hook" "${pkgdir}/usr/share/libalpm/scripts/runit-hook"
install -Dm644 -t "${pkgdir}/usr/share/libalpm/hooks" "${srcdir}"/*.hook
# license
install -dm755 ${pkgdir}/usr/share/licenses/${pkgname}
install -Dm644 "${srcdir}/admin/${pkgname}-${pkgver}/package/COPYING" ${pkgdir}/usr/share/licenses/${pkgname}/COPYING
sed -n '/To the extent/,/0/p' README.md > "${pkgdir}"/usr/share/licenses/${pkgname}/LICENSE
# doc
install -dm755 ${pkgdir}/usr/share/doc/${pkgname}
install -Dm644 "${srcdir}/README.md" ${pkgdir}//usr/share/doc/${pkgname}/README.md
install -Dm644 "${srcdir}/admin/${pkgname}-${pkgver}/package/CHANGES" ${pkgdir}//usr/share/doc/${pkgname}/CHANGES
}
#---- arch license gpg-key & sha256sums ----
arch=(x86_64)
license=('BSD')
sha256sums=(95ef4d2868b978c7179fe47901e5c578e11cf273d292bd6208bd3a7ccb029290 # runit-2.2.0.tar.gz
f524e90ae33fccf3fa89fb574064944ab1bc580df277ab9b93696c166b6a0b6d # runit-joborun.tar.xz
26f2c30c3f65a1370f8a377600f8492fbcd93aeaec239ab460d6a01eb8eb7801 # halt.c
7f11c5cab16f10178612b6a81d37184c25c4426b9c2d5d3f8ef7ed7ab2b52c56 # shutdown
00483e08767b01c3eed76b4d626adf28eac83e7095c5ff1c38e5b98b445496ab # runit-hook
a3e95c60b616ae0a85690d0251924b084f85166cfbd7c037377cfe67b3baaf1b # runit-install.hook
b85ae57b50a323fd5b11c3584b1b34f723b38d769ea238ab3c27429f2f4fb7b9 # runit-remove.hook
3248e86fe739aaff412f5b4f77b689f690fac1c0e9e634a0305cc3f517d41338 # 30-binfmt.hook
af91ca198fc402f39faf9e62b8da56e47f5cda9ce3d61c43fcf5b24f59fbbf5a # 30-sysctl.hook
c475a61fc186219c003ac6969ac771c6790341a62e2264db101abb0a98ebb289) # README.md
## 72927d317bf499546b6f311ca25f36ee7198a0fea18b546eb2e829eda252a5d1 runit-2.2.0-01-x86_64.pkg.tar.lz

25
runit/README.md Normal file
View file

@ -0,0 +1,25 @@
## G.Pape finally caved in and incorporated all patches gathered and created by Clan Z. Liu to create version 2.2.0
## runit patched and rebuilt with Clan Z. Liu patches for gcc 14+
### This is important to those running on runit
As mentioned before since arch moved to gcc 14 runit failed to build. All previous building warnings
turned to errors. https://github.com/clan/runit a gentoo maintainer of runit, trying to keep it alive
when gentoo was about to drop it (source based distro, no binaries, everything has to build at all
times - what joborun was expected to be as well) developed a series of patches for every error AND
every warning that gcc 14 and 15 were causing. Some patches from the past that came from debian, void,
and artix were either redundant, conflicting, or causing errors themselves, except for one for svlogd
which we kept as it seems good.
Together with a recent clean-up of runit-rc this makes runit more solid but please pay attention to
your booting for any “fail” tags and /var/log/dmesg.log and report.
On our few different systems it is all flags green (except for udevd seems to be taking a little
longer than expected in some old machines but no problems).
#joborun
ref: https://diaspora-fr.org/posts/e2656b705980013d9f9c0025900e4586

1
runit/clean Normal file
View file

@ -0,0 +1 @@
rm -rf {src,pkg,runit*.gz,runit*.xz}

2
runit/deps Normal file
View file

@ -0,0 +1,2 @@

82
runit/halt.c Normal file
View file

@ -0,0 +1,82 @@
/*
* halt.c: A halt/poweroff/reboot wrapper for Joborun runit implementation
* Based on halt.c from void-runit and artix runit
*/
#include <errno.h>
#include <unistd.h>
#include <err.h>
#include <string.h>
#include <sys/reboot.h>
extern char *__progname;
typedef enum {NOOP, HALT, REBOOT, POWEROFF} action_type;
int main(int argc, char *argv[]) {
int do_sync = 1;
int do_force = 0;
int opt;
action_type action = NOOP;
if (strcmp(__progname, "halt") == 0)
action = HALT;
else if (strcmp(__progname, "reboot") == 0)
action = REBOOT;
else if (strcmp(__progname, "poweroff") == 0)
action = POWEROFF;
else
warnx("no default behavior, needs to be called as halt/reboot/poweroff.");
while ((opt = getopt(argc, argv, "dfhinw")) != -1)
switch (opt) {
case 'n':
do_sync = 0;
break;
case 'w':
action = NOOP;
do_sync = 0;
break;
case 'd':
case 'h':
case 'i':
/* silently ignored. */
break;
case 'f':
do_force = 1;
break;
default:
errx(1, "Usage: %s [-n] [-f]", __progname);
}
if (do_sync)
sync();
switch (action) {
case HALT:
if (do_force)
reboot(RB_HALT_SYSTEM);
else
execl("/bin/runit-init", "init", "0", (char*)0);
err(1, "halt failed");
break;
case POWEROFF:
if (do_force)
reboot(RB_POWER_OFF);
else
execl("/bin/runit-init", "init", "0", (char*)0);
err(1, "poweroff failed");
break;
case REBOOT:
if (do_force)
reboot(RB_AUTOBOOT);
else
execl("/bin/runit-init", "init", "6", (char*)0);
err(1, "reboot failed");
break;
case NOOP:
break;
}
return 0;
}

50
runit/runit-hook Normal file
View file

@ -0,0 +1,50 @@
#!/bin/sh -e
runit_live() {
if [ ! -L /run/runit/service ]; then
echo >&2 " Skipped: Current root is not booted."
exit 0
fi
}
svc_help(){
echo " ==> Start/stop/restart a service:"
echo " sv <start/stop/restart> <service>"
}
svc_add_help(){
echo " ==> Add a service:"
echo " ln -s /etc/runit/sv/<service> /etc/runit/runsvdir/default/"
echo " for essential console and udevd services"
echo " ln -s /usr/lib/runit/sv/<service> /etc/runit/runsvdir/default/"
echo " for all other services on stage 2 "
echo " We avoid using /run/runit/service as the target as it does not"
echo " exist in chroot, as most other distros and runit documentation say"
svc_help
}
svc_del_help(){
echo " ==> Remove a service:"
echo " rm /etc/runit/runsvdir/default/<service>"
svc_help
}
each_conf() {
while read -r f; do
"$@" "/$f"
done
}
op="$1"; shift
case $op in
sysctl) runit_live; each_conf /usr/bin/sysctl -q -p ;;
binfmt) runit_live; each_conf /usr/lib/rc/sv.d/binfmt once ;;
# For use by other packages
reload) runit_live; /usr/bin/sv "$@" reload ;;
add) svc_add_help ;;
del) svc_del_help ;;
*) echo >&2 " Invalid operation '$op'"; exit 1 ;;
esac
exit 0

11
runit/runit-install.hook Normal file
View file

@ -0,0 +1,11 @@
[Trigger]
Type = Path
Operation = Install
Operation = Upgrade
Target = etc/runit/sv/*
[Action]
Description = Displaying runit service help ...
When = PostTransaction
Exec = /usr/share/libalpm/scripts/runit-hook add
NeedsTargets

10
runit/runit-remove.hook Normal file
View file

@ -0,0 +1,10 @@
[Trigger]
Type = Path
Operation = Remove
Target = etc/runit/sv/*
[Action]
Description = Displaying runit service help ...
When = PostTransaction
Exec = /usr/share/libalpm/scripts/runit-hook del
NeedsTargets

10
runit/runit.install Normal file
View file

@ -0,0 +1,10 @@
post_upgrade()
{
if [ -x /etc/rc.local.pacsave ]; then
mv /etc/rc.local.pacsave /etc/rc.local
echo "==> If you have the '/etc/rc.local saved as /etc/rc.local.pacsave'"
echo " message, it should've been moved back to /etc/rc.local, in case"
echo " it doesn't get moved, you need to move it manually."
echo " Our apologies for the inconvenience."
fi
}

74
runit/shutdown Normal file
View file

@ -0,0 +1,74 @@
#!/bin/sh
# shutdown - shutdown(8) lookalike for runit
# taken from Void Linux
single() {
runsvchdir single
}
abort() {
printf '%s\n' "$1" >&2
exit 1
}
usage() {
abort "Usage: ${0##*/} [-fF] [-kchPr] time [warning message]"
}
action=single
while getopts akrhPHfFnct: opt; do
case "$opt" in
a|n|H) abort "'-$opt' is not implemented";;
t) ;;
f) touch /fastboot;;
F) touch /forcefsck;;
k) action=true;;
c) action=cancel;;
h|P) action=halt;;
r) action=reboot;;
[?]) usage;;
esac
done
shift $((OPTIND - 1))
[ $# -eq 0 ] && usage
time=$1; shift
message="${*:-system is going down}"
if [ "$action" = "cancel" ]; then
kill "$(cat /run/runit/shutdown.pid)"
if [ -e /etc/nologin ] && ! [ -s /etc/nologin ]; then
rm /etc/nologin
fi
echo "${*:-shutdown cancelled}" | wall
exit
fi
touch /run/runit/shutdown.pid 2>/dev/null || abort "Not enough permissions to execute ${0#*/}"
echo $$ >/run/runit/shutdown.pid
case "$time" in
now) time=0;;
+*) time=${time#+};;
*:*) abort "absolute time is not implemented";;
*) abort "invalid time";;
esac
for break in 5 0; do
[ "$time" -gt "$break" ] || continue
[ "$break" = 0 ] && touch /etc/nologin
printf '%s in %s minutes\n' "$message" "$time" | wall
printf 'shutdown: sleeping for %s minutes... ' "$(( time - break ))"
sleep $(( (time - break) * 60 ))
time="$break"
printf '\n'
[ "$break" = 0 ] && rm /etc/nologin
done
printf '%s NOW\n' "$message" | wall
$action

6
runit/time Normal file
View file

@ -0,0 +1,6 @@
real 0m20.370s
user 0m7.397s
sys 0m1.894s