From 66ec476d85442baf729cfb8e9696fe0698f2b21a Mon Sep 17 00:00:00 2001 From: 0x5c Date: Mon, 27 Mar 2023 04:41:45 -0400 Subject: [PATCH 1/9] chpst: remove dependency on prot.h prot.c provides two functions: prot_gid and prot_uid. prot_gid is fully unused, and depends on {chk,try}shsgr, both of which must be run at build-time and require that the user has additional groups. They are not needed by anything else and their removal gets rid of cross-compilation jank. prot_uid is used (once) by chpst, but since it is a no-op wrapper around setuid(), its use can be replaced by a normal call to setuid(). Solves the big questions from #11 --- src/Makefile | 22 +++------------------- src/TARGETS | 4 ---- src/chkshsgr.c | 13 ------------- src/chpst.c | 3 +-- src/hasshsgr.h1 | 3 --- src/hasshsgr.h2 | 4 ---- src/prot.c | 25 ------------------------- src/prot.h | 11 ----------- src/tryshsgr.c | 16 ---------------- src/warn-shsgr | 3 --- 10 files changed, 4 insertions(+), 100 deletions(-) delete mode 100644 src/chkshsgr.c delete mode 100644 src/hasshsgr.h1 delete mode 100644 src/hasshsgr.h2 delete mode 100644 src/prot.c delete mode 100644 src/prot.h delete mode 100644 src/tryshsgr.c delete mode 100644 src/warn-shsgr diff --git a/src/Makefile b/src/Makefile index d9624de..9834b3e 100644 --- a/src/Makefile +++ b/src/Makefile @@ -170,12 +170,6 @@ byte_diff.o: byte.h byte_diff.c compile byte_rchr.o: byte.h byte_rchr.c compile ./compile byte_rchr.c -chkshsgr: chkshsgr.o load - ./load chkshsgr - -chkshsgr.o: chkshsgr.c compile - ./compile chkshsgr.c - choose: choose.sh warn-auto.sh rm -f choose cat warn-auto.sh choose.sh \ @@ -232,11 +226,6 @@ hassgact.h: choose compile hassgact.h1 hassgact.h2 load trysgact.c hassgprm.h: choose compile hassgprm.h1 hassgprm.h2 load trysgprm.c ./choose cl trysgprm hassgprm.h1 hassgprm.h2 > hassgprm.h -hasshsgr.h: chkshsgr choose compile hasshsgr.h1 hasshsgr.h2 load \ -tryshsgr.c warn-shsgr - ./chkshsgr || ( cat warn-shsgr; exit 1 ) - ./choose clr tryshsgr hasshsgr.h1 hasshsgr.h2 > hasshsgr.h - haswaitp.h: choose compile haswaitp.h1 haswaitp.h2 load trywaitp.c ./choose cl trywaitp haswaitp.h1 haswaitp.h2 > haswaitp.h @@ -292,9 +281,6 @@ pathexec_run.o: compile env.h error.h gen_alloc.h pathexec.h \ pathexec_run.c str.h stralloc.h ./compile pathexec_run.c -prot.o: compile hasshsgr.h prot.c prot.h - ./compile prot.c - readclose.o: compile error.h gen_alloc.h readclose.c readclose.h \ stralloc.h ./compile readclose.c @@ -372,7 +358,7 @@ subgetopt.o: compile subgetopt.c subgetopt.h ./compile subgetopt.c sysdeps: compile direntry.h hasflock.h hasmkffo.h hassgact.h \ -hassgprm.h hasshsgr.h haswaitp.h iopause.h load select.h systype \ +hassgprm.h haswaitp.h iopause.h load select.h systype \ uint64.h reboot_system.h uw_tmp.h socket.lib rm -f sysdeps cat systype compile load socket.lib >>sysdeps @@ -385,7 +371,6 @@ uint64.h reboot_system.h uw_tmp.h socket.lib grep sysdep iopause.h >>sysdeps grep sysdep hasmkffo.h >>sysdeps grep sysdep hasflock.h >>sysdeps - grep sysdep hasshsgr.h >>sysdeps grep sysdep reboot_system.h >>sysdeps grep sysdep uw_tmp.h >>sysdeps cat sysdeps @@ -444,7 +429,7 @@ buffer_get.o buffer_put.o buffer_read.o buffer_write.o coe.o env.o \ error.o error_str.o fd_copy.o fd_move.o fifo.o lock_ex.o lock_exnb.o \ makelib ndelay_off.o ndelay_on.o open_append.o open_read.o \ open_trunc.o open_write.o openreadclose.o pathexec_env.o \ -pathexec_run.o prot.o readclose.o seek_set.o sgetopt.o sig.o \ +pathexec_run.o readclose.o seek_set.o sgetopt.o sig.o \ sig_block.o sig_catch.o sig_pause.o stralloc_cat.o stralloc_catb.o \ stralloc_cats.o stralloc_eady.o stralloc_opyb.o stralloc_opys.o \ stralloc_pend.o strerr_die.o strerr_sys.o subgetopt.o wait_nohang.o \ @@ -454,7 +439,7 @@ wait_pid.o coe.o env.o error.o error_str.o fd_copy.o fd_move.o fifo.o lock_ex.o \ lock_exnb.o ndelay_off.o ndelay_on.o open_append.o open_read.o \ open_trunc.o open_write.o openreadclose.o pathexec_env.o \ - pathexec_run.o prot.o readclose.o seek_set.o sgetopt.o sig.o \ + pathexec_run.o readclose.o seek_set.o sgetopt.o sig.o \ sig_block.o sig_catch.o sig_pause.o stralloc_cat.o stralloc_catb.o \ stralloc_cats.o stralloc_eady.o stralloc_opyb.o stralloc_opys.o \ stralloc_pend.o strerr_die.o strerr_sys.o subgetopt.o wait_nohang.o \ @@ -465,4 +450,3 @@ wait_nohang.o: compile haswaitp.h wait_nohang.c wait_pid.o: compile error.h haswaitp.h wait_pid.c ./compile wait_pid.c - diff --git a/src/TARGETS b/src/TARGETS index 46981ce..2a50be3 100644 --- a/src/TARGETS +++ b/src/TARGETS @@ -49,8 +49,6 @@ byte_copy.o byte_cr.o byte_diff.o byte_rchr.o -chkshsgr -chkshsgr.o choose coe.o compile @@ -68,7 +66,6 @@ hasflock.h hasmkffo.h hassgact.h hassgprm.h -hasshsgr.h haswaitp.h iopause.h iopause.o @@ -85,7 +82,6 @@ open_write.o openreadclose.o pathexec_env.o pathexec_run.o -prot.o readclose.o scan_ulong.o seek_set.o diff --git a/src/chkshsgr.c b/src/chkshsgr.c deleted file mode 100644 index 31eda67..0000000 --- a/src/chkshsgr.c +++ /dev/null @@ -1,13 +0,0 @@ -/* Public domain. */ - -#include -#include - -int main() -{ - gid_t x[4]; - - x[0] = x[1] = 0; - if (getgroups(1,x) == 0) if (setgroups(1,x) == -1) _exit(1); - _exit(0); -} diff --git a/src/chpst.c b/src/chpst.c index d597b68..20bf027 100644 --- a/src/chpst.c +++ b/src/chpst.c @@ -8,7 +8,6 @@ #include "strerr.h" #include "str.h" #include "uidgid.h" -#include "prot.h" #include "strerr.h" #include "scan.h" #include "fmt.h" @@ -80,7 +79,7 @@ void suidgid(char *user, unsigned int ext) { } if (setgroups(ugid.gids, ugid.gid) == -1) fatal("unable to setgroups"); if (setgid(*ugid.gid) == -1) fatal("unable to setgid"); - if (prot_uid(ugid.uid) == -1) fatal("unable to setuid"); + if (setuid(ugid.uid) == -1) fatal("unable to setuid"); } void euidgid(char *user, unsigned int ext) { diff --git a/src/hasshsgr.h1 b/src/hasshsgr.h1 deleted file mode 100644 index 3806277..0000000 --- a/src/hasshsgr.h1 +++ /dev/null @@ -1,3 +0,0 @@ -/* Public domain. */ - -/* sysdep: -shortsetgroups */ diff --git a/src/hasshsgr.h2 b/src/hasshsgr.h2 deleted file mode 100644 index 5624ed0..0000000 --- a/src/hasshsgr.h2 +++ /dev/null @@ -1,4 +0,0 @@ -/* Public domain. */ - -/* sysdep: +shortsetgroups */ -#define HASSHORTSETGROUPS 1 diff --git a/src/prot.c b/src/prot.c deleted file mode 100644 index 66cdc05..0000000 --- a/src/prot.c +++ /dev/null @@ -1,25 +0,0 @@ -/* Public domain. */ - -#include "hasshsgr.h" -#include "prot.h" - -#include -#include -#include - -int prot_gid(gid_t gid) -{ -#ifdef HASSHORTSETGROUPS - short x[2]; - x[0] = gid; x[1] = 73; /* catch errors */ - if (setgroups(1,x) == -1) return -1; -#else - if (setgroups(1,&gid) == -1) return -1; -#endif - return setgid(gid); /* _should_ be redundant, but on some systems it isn't */ -} - -int prot_uid(uid_t uid) -{ - return setuid(uid); -} diff --git a/src/prot.h b/src/prot.h deleted file mode 100644 index b9fa6c8..0000000 --- a/src/prot.h +++ /dev/null @@ -1,11 +0,0 @@ -/* Public domain. */ - -#ifndef PROT_H -#define PROT_H - -#include - -extern int prot_gid(gid_t); -extern int prot_uid(uid_t); - -#endif diff --git a/src/tryshsgr.c b/src/tryshsgr.c deleted file mode 100644 index c5ed6d6..0000000 --- a/src/tryshsgr.c +++ /dev/null @@ -1,16 +0,0 @@ -/* Public domain. */ - -int main() -{ - short x[4]; - - x[0] = x[1] = 1; - if (getgroups(1,x) == 0) if (setgroups(1,x) == -1) _exit(1); - - if (getgroups(1,x) == -1) _exit(1); - if (x[1] != 1) _exit(1); - x[1] = 2; - if (getgroups(1,x) == -1) _exit(1); - if (x[1] != 2) _exit(1); - _exit(0); -} diff --git a/src/warn-shsgr b/src/warn-shsgr deleted file mode 100644 index 37c351e..0000000 --- a/src/warn-shsgr +++ /dev/null @@ -1,3 +0,0 @@ -Oops. Your getgroups() returned 0, and setgroups() failed; this means -that I can't reliably do my shsgr test. Please either ``make'' as root -or ``make'' while you're in one or more supplementary groups. From 6c5bb6dfd5b52f11e0b1cd8cb0db5a232d1147d8 Mon Sep 17 00:00:00 2001 From: 0x5c Date: Mon, 27 Mar 2023 08:54:45 -0400 Subject: [PATCH 2/9] find-systype.sh: remove unused "systype" mechanism The "systype" machanism is merely a system info gatherer, and the info it collects is (mostly) not used anywhere. The only seemingly important info is the kernel and kernel version (or the lack thereof), and has been moved to where it is used (print-ar.sh) This gets rid of two cross-incompatible buildtime programs. One tried to find if the build was happening on NeXT, but that's not an operating system that print-ar.sh cares about. The other tried to do cpuid on x86, which is useless to the build. This seems to implement what #11 started. --- src/Makefile | 13 ++-- src/TARGETS | 1 - src/find-systype.sh | 143 -------------------------------------------- src/print-ar.sh | 3 +- src/print-cc.sh | 1 - src/print-ld.sh | 1 - src/trycpp.c | 9 --- src/x86cpuid.c | 40 ------------- 8 files changed, 7 insertions(+), 204 deletions(-) delete mode 100644 src/find-systype.sh delete mode 100644 src/trycpp.c delete mode 100644 src/x86cpuid.c diff --git a/src/Makefile b/src/Makefile index 9834b3e..23d246b 100644 --- a/src/Makefile +++ b/src/Makefile @@ -179,7 +179,7 @@ choose: choose.sh warn-auto.sh coe.o: coe.c coe.h compile ./compile coe.c -compile: conf-cc print-cc.sh systype warn-auto.sh +compile: conf-cc print-cc.sh warn-auto.sh rm -f compile sh print-cc.sh > compile chmod 555 compile @@ -235,7 +235,7 @@ iopause.h: choose compile iopause.h1 iopause.h2 load trypoll.c iopause.o: compile iopause.c iopause.h select.h tai.h taia.h uint64.h ./compile iopause.c -load: conf-ld print-ld.sh systype warn-auto.sh +load: conf-ld print-ld.sh warn-auto.sh rm -f load sh print-ld.sh > load chmod 555 load @@ -246,7 +246,7 @@ lock_ex.o: compile hasflock.h lock.h lock_ex.c lock_exnb.o: compile hasflock.h lock.h lock_exnb.c ./compile lock_exnb.c -makelib: print-ar.sh systype warn-auto.sh +makelib: print-ar.sh warn-auto.sh rm -f makelib sh print-ar.sh > makelib chmod 555 makelib @@ -358,10 +358,10 @@ subgetopt.o: compile subgetopt.c subgetopt.h ./compile subgetopt.c sysdeps: compile direntry.h hasflock.h hasmkffo.h hassgact.h \ -hassgprm.h haswaitp.h iopause.h load select.h systype \ +hassgprm.h haswaitp.h iopause.h load select.h \ uint64.h reboot_system.h uw_tmp.h socket.lib rm -f sysdeps - cat systype compile load socket.lib >>sysdeps + cat compile load socket.lib >>sysdeps grep sysdep direntry.h >>sysdeps grep sysdep haswaitp.h >>sysdeps grep sysdep hassgact.h >>sysdeps @@ -375,9 +375,6 @@ uint64.h reboot_system.h uw_tmp.h socket.lib grep sysdep uw_tmp.h >>sysdeps cat sysdeps -systype: find-systype.sh trycpp.c x86cpuid.c - sh find-systype.sh > systype - tai_now.o: compile tai.h tai_now.c uint64.h ./compile tai_now.c diff --git a/src/TARGETS b/src/TARGETS index 2a50be3..e78f783 100644 --- a/src/TARGETS +++ b/src/TARGETS @@ -106,7 +106,6 @@ strerr_die.o strerr_sys.o subgetopt.o sysdeps -systype tai_now.o tai_pack.o tai_sub.o diff --git a/src/find-systype.sh b/src/find-systype.sh deleted file mode 100644 index 9f6e565..0000000 --- a/src/find-systype.sh +++ /dev/null @@ -1,143 +0,0 @@ -# oper-:arch-:syst-:chip-:kern- -# oper = operating system type; e.g., sunos-4.1.4 -# arch = machine language; e.g., sparc -# syst = which binaries can run; e.g., sun4 -# chip = chip model; e.g., micro-2-80 -# kern = kernel version; e.g., sun4m -# dependence: arch --- chip -# \ \ -# oper --- syst --- kern -# so, for example, syst is interpreted in light of oper, but chip is not. -# anyway, no slashes, no extra colons, no uppercase letters. -# the point of the extra -'s is to ease parsing: can add hierarchies later. -# e.g., *:i386-*:*:pentium-*:* would handle pentium-100 as well as pentium, -# and i386-486 (486s do have more instructions, you know) as well as i386. -# the idea here is to include ALL useful available information. - -exec 2>/dev/null - -sys="`uname -s | tr '/:[A-Z]' '..[a-z]'`" -if [ x"$sys" != x ] -then - unamer="`uname -r | tr /: ..`" - unamem="`uname -m | tr /: ..`" - unamev="`uname -v | tr /: ..`" - - case "$sys" in - bsd.os|freebsd|netbsd|openbsd) - # in bsd 4.4, uname -v does not have useful info. - # in bsd 4.4, uname -m is arch, not chip. - oper="$sys-$unamer" - arch="$unamem" - syst="" - chip="`sysctl -n hw.model`" # hopefully - kern="" - ;; - linux) - # as in bsd 4.4, uname -v does not have useful info. - oper="$sys-$unamer" - syst="" - chip="$unamem" - kern="" - case "$chip" in - i386|i486|i586|i686) - arch="i386" - ;; - alpha) - arch="alpha" - ;; - esac - ;; - aix) - # naturally IBM has to get uname -r and uname -v backwards. dorks. - oper="$sys-$unamev-$unamer" - arch="`arch | tr /: ..`" - syst="" - chip="$unamem" - kern="" - ;; - sunos) - oper="$sys-$unamer-$unamev" - arch="`(uname -p || mach) | tr /: ..`" - syst="`arch | tr /: ..`" - chip="$unamem" # this is wrong; is there any way to get the real info? - kern="`arch -k | tr /: ..`" - ;; - unix_sv) - oper="$sys-$unamer-$unamev" - arch="`uname -m`" - syst="" - chip="$unamem" - kern="" - ;; - *) - oper="$sys-$unamer-$unamev" - arch="`arch | tr /: ..`" - syst="" - chip="$unamem" - kern="" - ;; - esac -else - gcc -c trycpp.c - gcc -o trycpp trycpp.o - case `./trycpp` in - nextstep) - oper="nextstep-`hostinfo | sed -n 's/^[ ]*NeXT Mach \([^:]*\):.*$/\1/p'`" - arch="`hostinfo | sed -n 's/^Processor type: \(.*\) (.*)$/\1/p' | tr /: ..`" - syst="" - chip="`hostinfo | sed -n 's/^Processor type: .* (\(.*\))$/\1/p' | tr ' /:' '...'`" - kern="" - ;; - *) - oper="unknown" - arch="" - syst="" - chip="" - kern="" - ;; - esac - rm -f trycpp.o trycpp -fi - -case "$chip" in -80486) - # let's try to be consistent here. (BSD/OS) - chip=i486 - ;; -i486DX) - # respect the hyphen hierarchy. (FreeBSD) - chip=i486-dx - ;; -i486.DX2) - # respect the hyphen hierarchy. (FreeBSD) - chip=i486-dx2 - ;; -Intel.586) - # no, you nitwits, there is no such chip. (NeXTStep) - chip=pentium - ;; -i586) - # no, you nitwits, there is no such chip. (Linux) - chip=pentium - ;; -i686) - # STOP SAYING THAT! (Linux) - chip=ppro -esac - -if gcc -c x86cpuid.c -then - if gcc -o x86cpuid x86cpuid.o - then - x86cpuid="`./x86cpuid | tr /: ..`" - case "$x86cpuid" in - ?*) - chip="$x86cpuid" - ;; - esac - fi -fi -rm -f x86cpuid x86cpuid.o - -echo "$oper-:$arch-:$syst-:$chip-:$kern-" | tr ' [A-Z]' '.[a-z]' diff --git a/src/print-ar.sh b/src/print-ar.sh index 99bc116..c31d937 100644 --- a/src/print-ar.sh +++ b/src/print-ar.sh @@ -2,7 +2,8 @@ cat warn-auto.sh echo 'main="$1"; shift' echo 'rm -f "$main"' echo 'ar cr "$main" ${1+"$@"}' -case "`cat systype`" in +kern="$(uname -s | tr '/:[A-Z]' '..[a-z])')-$(uname -r | tr /: ..)" || kern="unknown" +case $kern in sunos-5.*) ;; unix_sv*) ;; irix64-*) ;; diff --git a/src/print-cc.sh b/src/print-cc.sh index 31f4ed3..1bf3e3e 100644 --- a/src/print-cc.sh +++ b/src/print-cc.sh @@ -1,5 +1,4 @@ cc="`head -n1 conf-cc`" -systype="`cat systype`" cat warn-auto.sh echo exec "$cc" '-c ${1+"$@"}' diff --git a/src/print-ld.sh b/src/print-ld.sh index 59489a8..5f34bb8 100644 --- a/src/print-ld.sh +++ b/src/print-ld.sh @@ -1,5 +1,4 @@ ld="`head -n1 conf-ld`" -systype="`cat systype`" cat warn-auto.sh echo 'main="$1"; shift' diff --git a/src/trycpp.c b/src/trycpp.c deleted file mode 100644 index e4503d4..0000000 --- a/src/trycpp.c +++ /dev/null @@ -1,9 +0,0 @@ -/* Public domain. */ - -int main() -{ -#ifdef NeXT - printf("nextstep\n"); exit(0); -#endif - printf("unknown\n"); exit(0); -} diff --git a/src/x86cpuid.c b/src/x86cpuid.c deleted file mode 100644 index f81c593..0000000 --- a/src/x86cpuid.c +++ /dev/null @@ -1,40 +0,0 @@ -/* Public domain. */ - -#include - -void nope() -{ - exit(1); -} - -int main() -{ - unsigned long x[4]; - unsigned long y[4]; - int i; - int j; - char c; - - signal(SIGILL,nope); - - x[0] = 0; - x[1] = 0; - x[2] = 0; - x[3] = 0; - - asm volatile(".byte 15;.byte 162" : "=a"(x[0]),"=b"(x[1]),"=c"(x[3]),"=d"(x[2]) : "0"(0) ); - if (!x[0]) return 0; - asm volatile(".byte 15;.byte 162" : "=a"(y[0]),"=b"(y[1]),"=c"(y[2]),"=d"(y[3]) : "0"(1) ); - - for (i = 1;i < 4;++i) - for (j = 0;j < 4;++j) { - c = x[i] >> (8 * j); - if (c < 32) c = 32; - if (c > 126) c = 126; - putchar(c); - } - - printf("-%08x-%08x\n",y[0],y[3]); - - return 0; -} From ddd49d73d4c185543d9775e50046baf06e62509c Mon Sep 17 00:00:00 2001 From: 0x5c Date: Mon, 27 Mar 2023 11:13:52 -0400 Subject: [PATCH 3/9] tailib: switch to uint64_t This gets rid of tryulong64.c, a buildtime configure binary which interferes with cross-compilation, at the cost of bumping the minimum C version to C99. --- src/Makefile | 32 ++++++++++++++------------------ src/TARGETS | 1 - src/runsvdir.c | 2 +- src/tai.h | 6 +++--- src/tai_pack.c | 2 +- src/tai_unpack.c | 2 +- src/tryulong64.c | 13 ------------- src/uint64.h1 | 10 ---------- src/uint64.h2 | 10 ---------- 9 files changed, 20 insertions(+), 58 deletions(-) delete mode 100644 src/tryulong64.c delete mode 100644 src/uint64.h1 delete mode 100644 src/uint64.h2 diff --git a/src/Makefile b/src/Makefile index 23d246b..e2cca49 100644 --- a/src/Makefile +++ b/src/Makefile @@ -232,7 +232,7 @@ haswaitp.h: choose compile haswaitp.h1 haswaitp.h2 load trywaitp.c iopause.h: choose compile iopause.h1 iopause.h2 load trypoll.c ./choose clr trypoll iopause.h1 iopause.h2 > iopause.h -iopause.o: compile iopause.c iopause.h select.h tai.h taia.h uint64.h +iopause.o: compile iopause.c iopause.h select.h tai.h taia.h ./compile iopause.c load: conf-ld print-ld.sh warn-auto.sh @@ -359,7 +359,7 @@ subgetopt.o: compile subgetopt.c subgetopt.h sysdeps: compile direntry.h hasflock.h hasmkffo.h hassgact.h \ hassgprm.h haswaitp.h iopause.h load select.h \ -uint64.h reboot_system.h uw_tmp.h socket.lib +reboot_system.h uw_tmp.h socket.lib rm -f sysdeps cat compile load socket.lib >>sysdeps grep sysdep direntry.h >>sysdeps @@ -367,7 +367,6 @@ uint64.h reboot_system.h uw_tmp.h socket.lib grep sysdep hassgact.h >>sysdeps grep sysdep hassgprm.h >>sysdeps grep sysdep select.h >>sysdeps - grep sysdep uint64.h >>sysdeps grep sysdep iopause.h >>sysdeps grep sysdep hasmkffo.h >>sysdeps grep sysdep hasflock.h >>sysdeps @@ -375,40 +374,40 @@ uint64.h reboot_system.h uw_tmp.h socket.lib grep sysdep uw_tmp.h >>sysdeps cat sysdeps -tai_now.o: compile tai.h tai_now.c uint64.h +tai_now.o: compile tai.h tai_now.c ./compile tai_now.c -tai_pack.o: compile tai.h tai_pack.c uint64.h +tai_pack.o: compile tai.h tai_pack.c ./compile tai_pack.c -tai_sub.o: compile tai.h tai_sub.c uint64.h +tai_sub.o: compile tai.h tai_sub.c ./compile tai_sub.c -tai_unpack.o: compile tai.h tai_unpack.c uint64.h +tai_unpack.o: compile tai.h tai_unpack.c ./compile tai_unpack.c -taia_add.o: compile tai.h taia.h taia_add.c uint64.h +taia_add.o: compile tai.h taia.h taia_add.c ./compile taia_add.c -taia_approx.o: compile tai.h taia.h taia_approx.c uint64.h +taia_approx.o: compile tai.h taia.h taia_approx.c ./compile taia_approx.c -taia_frac.o: compile tai.h taia.h taia_frac.c uint64.h +taia_frac.o: compile tai.h taia.h taia_frac.c ./compile taia_frac.c -taia_less.o: compile tai.h taia.h taia_less.c uint64.h +taia_less.o: compile tai.h taia.h taia_less.c ./compile taia_less.c -taia_now.o: compile tai.h taia.h taia_now.c uint64.h +taia_now.o: compile tai.h taia.h taia_now.c ./compile taia_now.c -taia_pack.o: compile tai.h taia.h taia_pack.c uint64.h +taia_pack.o: compile tai.h taia.h taia_pack.c ./compile taia_pack.c -taia_sub.o: compile tai.h taia.h taia_sub.c uint64.h +taia_sub.o: compile tai.h taia.h taia_sub.c ./compile taia_sub.c -taia_uint.o: compile tai.h taia.h taia_uint.c uint64.h +taia_uint.o: compile tai.h taia.h taia_uint.c ./compile taia_uint.c time.a: iopause.o makelib tai_now.o tai_pack.o tai_sub.o tai_unpack.o \ @@ -418,9 +417,6 @@ taia_pack.o taia_sub.o taia_uint.o tai_unpack.o taia_add.o taia_approx.o taia_frac.o taia_less.o \ taia_now.o taia_pack.o taia_sub.o taia_uint.o -uint64.h: choose compile load tryulong64.c uint64.h1 uint64.h2 - ./choose clr tryulong64 uint64.h1 uint64.h2 > uint64.h - unix.a: alloc.o alloc_re.o buffer.o buffer_0.o buffer_1.o buffer_2.o \ buffer_get.o buffer_put.o buffer_read.o buffer_write.o coe.o env.o \ error.o error_str.o fd_copy.o fd_move.o fifo.o lock_ex.o lock_exnb.o \ diff --git a/src/TARGETS b/src/TARGETS index e78f783..4fe08aa 100644 --- a/src/TARGETS +++ b/src/TARGETS @@ -119,7 +119,6 @@ taia_pack.o taia_sub.o taia_uint.o time.a -uint64.h unix.a wait_nohang.o wait_pid.o diff --git a/src/runsvdir.c b/src/runsvdir.c index ecebd0a..4cc7857 100644 --- a/src/runsvdir.c +++ b/src/runsvdir.c @@ -233,7 +233,7 @@ int main(int argc, char **argv) { dev =s.st_dev; ino =s.st_ino; check =0; - if (now.sec.x <= (4611686018427387914ULL +(uint64)mtime)) + if (now.sec.x <= (4611686018427387914ULL +(uint64_t)mtime)) sleep(1); runsvdir(); while (fchdir(curdir) == -1) { diff --git a/src/tai.h b/src/tai.h index 1839f76..67ef0fe 100644 --- a/src/tai.h +++ b/src/tai.h @@ -3,13 +3,13 @@ #ifndef TAI_H #define TAI_H -#include "uint64.h" +#include struct tai { - uint64 x; + uint64_t x; } ; -#define tai_unix(t,u) ((void) ((t)->x = 4611686018427387914ULL + (uint64) (u))) +#define tai_unix(t,u) ((void) ((t)->x = 4611686018427387914ULL + (uint64_t) (u))) extern void tai_now(struct tai *); diff --git a/src/tai_pack.c b/src/tai_pack.c index 641fa5b..e73eaca 100644 --- a/src/tai_pack.c +++ b/src/tai_pack.c @@ -4,7 +4,7 @@ void tai_pack(char *s,const struct tai *t) { - uint64 x; + uint64_t x; x = t->x; s[7] = x & 255; x >>= 8; diff --git a/src/tai_unpack.c b/src/tai_unpack.c index 4541ff5..10c6d20 100644 --- a/src/tai_unpack.c +++ b/src/tai_unpack.c @@ -4,7 +4,7 @@ void tai_unpack(const char *s,struct tai *t) { - uint64 x; + uint64_t x; x = (unsigned char) s[0]; x <<= 8; x += (unsigned char) s[1]; diff --git a/src/tryulong64.c b/src/tryulong64.c deleted file mode 100644 index 003548a..0000000 --- a/src/tryulong64.c +++ /dev/null @@ -1,13 +0,0 @@ -/* Public domain. */ - -int main() -{ - unsigned long u; - u = 1; - u += u; u += u; u += u; u += u; u += u; u += u; u += u; u += u; - u += u; u += u; u += u; u += u; u += u; u += u; u += u; u += u; - u += u; u += u; u += u; u += u; u += u; u += u; u += u; u += u; - u += u; u += u; u += u; u += u; u += u; u += u; u += u; u += u; - if (!u) _exit(1); - _exit(0); -} diff --git a/src/uint64.h1 b/src/uint64.h1 deleted file mode 100644 index 486a380..0000000 --- a/src/uint64.h1 +++ /dev/null @@ -1,10 +0,0 @@ -/* Public domain. */ - -#ifndef UINT64_H -#define UINT64_H - -/* sysdep: -ulong64 */ - -typedef unsigned long long uint64; - -#endif diff --git a/src/uint64.h2 b/src/uint64.h2 deleted file mode 100644 index 8869e43..0000000 --- a/src/uint64.h2 +++ /dev/null @@ -1,10 +0,0 @@ -/* Public domain. */ - -#ifndef UINT64_H -#define UINT64_H - -/* sysdep: +ulong64 */ - -typedef unsigned long uint64; - -#endif From d1a1f35f4fdbb461eaad6d4d23df1a151b758527 Mon Sep 17 00:00:00 2001 From: 0x5c Date: Sun, 30 Apr 2023 20:23:47 -0400 Subject: [PATCH 4/9] iopause: assume poll() is available Since poll() is available on all platforms we care about, we don't need to check if it is. This gets rid of trypoll.c, the last configure-time check that required to be run on the host (messing with cross). We also get rid of trysysel.c, since select() was only used as a fallback when poll() isn't avaialble. --- src/Makefile | 12 ++------- src/TARGETS | 2 -- src/iopause.c | 47 ----------------------------------- src/{iopause.h2 => iopause.h} | 3 --- src/iopause.h1 | 21 ---------------- src/runit.c | 11 -------- src/select.h1 | 12 --------- src/select.h2 | 13 ---------- src/trypoll.c | 20 --------------- src/trysysel.c | 11 -------- 10 files changed, 2 insertions(+), 150 deletions(-) rename src/{iopause.h2 => iopause.h} (87%) delete mode 100644 src/iopause.h1 delete mode 100644 src/select.h1 delete mode 100644 src/select.h2 delete mode 100644 src/trypoll.c delete mode 100644 src/trysysel.c diff --git a/src/Makefile b/src/Makefile index e2cca49..c1d9c14 100644 --- a/src/Makefile +++ b/src/Makefile @@ -229,10 +229,7 @@ hassgprm.h: choose compile hassgprm.h1 hassgprm.h2 load trysgprm.c haswaitp.h: choose compile haswaitp.h1 haswaitp.h2 load trywaitp.c ./choose cl trywaitp haswaitp.h1 haswaitp.h2 > haswaitp.h -iopause.h: choose compile iopause.h1 iopause.h2 load trypoll.c - ./choose clr trypoll iopause.h1 iopause.h2 > iopause.h - -iopause.o: compile iopause.c iopause.h select.h tai.h taia.h +iopause.o: compile iopause.c tai.h taia.h ./compile iopause.c load: conf-ld print-ld.sh warn-auto.sh @@ -291,9 +288,6 @@ scan_ulong.o: compile scan.h scan_ulong.c seek_set.o: compile seek.h seek_set.c ./compile seek_set.c -select.h: choose compile select.h1 select.h2 trysysel.c - ./choose c trysysel select.h1 select.h2 > select.h - sgetopt.o: buffer.h compile sgetopt.c sgetopt.h subgetopt.h ./compile sgetopt.c @@ -358,7 +352,7 @@ subgetopt.o: compile subgetopt.c subgetopt.h ./compile subgetopt.c sysdeps: compile direntry.h hasflock.h hasmkffo.h hassgact.h \ -hassgprm.h haswaitp.h iopause.h load select.h \ +hassgprm.h haswaitp.h load \ reboot_system.h uw_tmp.h socket.lib rm -f sysdeps cat compile load socket.lib >>sysdeps @@ -366,8 +360,6 @@ reboot_system.h uw_tmp.h socket.lib grep sysdep haswaitp.h >>sysdeps grep sysdep hassgact.h >>sysdeps grep sysdep hassgprm.h >>sysdeps - grep sysdep select.h >>sysdeps - grep sysdep iopause.h >>sysdeps grep sysdep hasmkffo.h >>sysdeps grep sysdep hasflock.h >>sysdeps grep sysdep reboot_system.h >>sysdeps diff --git a/src/TARGETS b/src/TARGETS index 4fe08aa..1a2b719 100644 --- a/src/TARGETS +++ b/src/TARGETS @@ -67,7 +67,6 @@ hasmkffo.h hassgact.h hassgprm.h haswaitp.h -iopause.h iopause.o load lock_ex.o @@ -85,7 +84,6 @@ pathexec_run.o readclose.o scan_ulong.o seek_set.o -select.h sgetopt.o sig.o sig_block.o diff --git a/src/iopause.c b/src/iopause.c index ea5a426..9eb6eb8 100644 --- a/src/iopause.c +++ b/src/iopause.c @@ -1,7 +1,6 @@ /* Public domain. */ #include "taia.h" -#include "select.h" #include "iopause.h" void iopause(iopause_fd *x,unsigned int len,struct taia *deadline,struct taia *stamp) @@ -24,55 +23,9 @@ void iopause(iopause_fd *x,unsigned int len,struct taia *deadline,struct taia *s for (i = 0;i < len;++i) x[i].revents = 0; -#ifdef IOPAUSE_POLL - poll(x,len,millisecs); /* XXX: some kernels apparently need x[0] even if len is 0 */ /* XXX: how to handle EAGAIN? are kernels really this dumb? */ /* XXX: how to handle EINVAL? when exactly can this happen? */ -#else -{ - - struct timeval tv; - fd_set rfds; - fd_set wfds; - int nfds; - int fd; - - FD_ZERO(&rfds); - FD_ZERO(&wfds); - - nfds = 1; - for (i = 0;i < len;++i) { - fd = x[i].fd; - if (fd < 0) continue; - if (fd >= 8 * sizeof(fd_set)) continue; /*XXX*/ - - if (fd >= nfds) nfds = fd + 1; - if (x[i].events & IOPAUSE_READ) FD_SET(fd,&rfds); - if (x[i].events & IOPAUSE_WRITE) FD_SET(fd,&wfds); - } - - tv.tv_sec = millisecs / 1000; - tv.tv_usec = 1000 * (millisecs % 1000); - - if (select(nfds,&rfds,&wfds,(fd_set *) 0,&tv) <= 0) - return; - /* XXX: for EBADF, could seek out and destroy the bad descriptor */ - - for (i = 0;i < len;++i) { - fd = x[i].fd; - if (fd < 0) continue; - if (fd >= 8 * sizeof(fd_set)) continue; /*XXX*/ - - if (x[i].events & IOPAUSE_READ) - if (FD_ISSET(fd,&rfds)) x[i].revents |= IOPAUSE_READ; - if (x[i].events & IOPAUSE_WRITE) - if (FD_ISSET(fd,&wfds)) x[i].revents |= IOPAUSE_WRITE; - } - -} -#endif - } diff --git a/src/iopause.h2 b/src/iopause.h similarity index 87% rename from src/iopause.h2 rename to src/iopause.h index 8e58452..b425282 100644 --- a/src/iopause.h2 +++ b/src/iopause.h @@ -3,9 +3,6 @@ #ifndef IOPAUSE_H #define IOPAUSE_H -/* sysdep: +poll */ -#define IOPAUSE_POLL - #include #include diff --git a/src/iopause.h1 b/src/iopause.h1 deleted file mode 100644 index 5c53de7..0000000 --- a/src/iopause.h1 +++ /dev/null @@ -1,21 +0,0 @@ -/* Public domain. */ - -#ifndef IOPAUSE_H -#define IOPAUSE_H - -/* sysdep: -poll */ - -typedef struct { - int fd; - short events; - short revents; -} iopause_fd; - -#define IOPAUSE_READ 1 -#define IOPAUSE_WRITE 4 - -#include "taia.h" - -extern void iopause(iopause_fd *,unsigned int,struct taia *,struct taia *); - -#endif diff --git a/src/runit.c b/src/runit.c index 25da3b8..d9168af 100644 --- a/src/runit.c +++ b/src/runit.c @@ -47,10 +47,6 @@ int main (int argc, const char * const *argv, char * const *envp) { int wstat; int st; iopause_fd x; -#ifndef IOPAUSE_POLL - fd_set rfds; - struct timeval t; -#endif char ch; int ttyfd; struct stat s; @@ -145,14 +141,7 @@ int main (int argc, const char * const *argv, char * const *envp) { sig_unblock(sig_child); sig_unblock(sig_cont); sig_unblock(sig_int); -#ifdef IOPAUSE_POLL poll(&x, 1, 14000); -#else - t.tv_sec =14; t.tv_usec =0; - FD_ZERO(&rfds); - FD_SET(x.fd, &rfds); - select(x.fd +1, &rfds, (fd_set*)0, (fd_set*)0, &t); -#endif sig_block(sig_cont); sig_block(sig_child); sig_block(sig_int); diff --git a/src/select.h1 b/src/select.h1 deleted file mode 100644 index 68e971f..0000000 --- a/src/select.h1 +++ /dev/null @@ -1,12 +0,0 @@ -/* Public domain. */ - -#ifndef SELECT_H -#define SELECT_H - -/* sysdep: -sysselect */ - -#include -#include -extern int select(); - -#endif diff --git a/src/select.h2 b/src/select.h2 deleted file mode 100644 index 4bd4fcf..0000000 --- a/src/select.h2 +++ /dev/null @@ -1,13 +0,0 @@ -/* Public domain. */ - -#ifndef SELECT_H -#define SELECT_H - -/* sysdep: +sysselect */ - -#include -#include -#include -extern int select(); - -#endif diff --git a/src/trypoll.c b/src/trypoll.c deleted file mode 100644 index 6506617..0000000 --- a/src/trypoll.c +++ /dev/null @@ -1,20 +0,0 @@ -/* Public domain. */ - -#include -#include -#include - -int main() -{ - struct pollfd x; - - x.fd = open("trypoll.c",O_RDONLY); - if (x.fd == -1) _exit(111); - x.events = POLLIN; - if (poll(&x,1,10) == -1) _exit(1); - if (x.revents != POLLIN) _exit(1); - - /* XXX: try to detect and avoid poll() imitation libraries */ - - _exit(0); -} diff --git a/src/trysysel.c b/src/trysysel.c deleted file mode 100644 index 5be862d..0000000 --- a/src/trysysel.c +++ /dev/null @@ -1,11 +0,0 @@ -/* Public domain. */ - -#include -#include -#include -#include /* SVR4 silliness */ - -void foo() -{ - ; -} From d1041f8a5fb1949299536ac4882f77cd18e3e0ed Mon Sep 17 00:00:00 2001 From: 0x5c Date: Mon, 27 Mar 2023 10:42:00 -0400 Subject: [PATCH 5/9] build system: switch to configure script and improved Makefile This has dramatic effects on the build system complexity, and in the process exposing lots of dead weight. Split header files (.h1 .h2) are merged, and header files that only contained a single define have been fully replaced with -D. The makefile is no longer geneating scripts, and their files that hardcoded cc/ld/ar calls are gone. The build system is now fully compatible with standard variables like CC, PREFIX, DESTDIR, and such. The compiler is autodetected when unspecified, build flags are checked for compatibility, and installation directories can now be specified with configure flags. The configure script was heavily inspired by XBPS's. The "compile" script is gone along with the original top-level Makefile, both replaced with straightforward and more conventional makefiles. The "man" and "completions" subdirs are now integrated into the build system and use configure-time variables for the paths. No sed calls or patches should be required to set any paths or toolchain settings. Usage of .gitattributes and "$Id$" strings is now replaced with a VERSION define in the configure script, which optionally uses git to append the 8-digit commit hash to the version string. This also makes '-V' more meaningful. --- .gitattributes | 13 - .gitignore | 27 + .manpages | 0 Makefile | 68 +-- README.md | 7 + completions/Makefile | 19 + completions/{sv.bash => sv.bash.in} | 2 +- completions/{sv.zsh => sv.zsh.in} | 2 +- configure | 484 ++++++++++++++++++ src/trydrent.c => configure_tests/trydirent.c | 2 +- {src => configure_tests}/tryflock.c | 0 src/trymkffo.c => configure_tests/trymkfifo.c | 0 {src => configure_tests}/tryreboot.c | 0 .../trysigaction.c | 0 .../trysigprocmask.c | 0 {src => configure_tests}/trysocketlib.c | 0 {src => configure_tests}/tryuwtmp.c | 0 {src => configure_tests}/tryuwtmpx.c | 0 .../trywaitpid.c | 0 man/Makefile | 20 + man/{runsv.8 => runsv.8.in} | 4 +- man/{runsvchdir.8 => runsvchdir.8.in} | 4 +- man/{sv.8 => sv.8.in} | 4 +- man/{utmpset.8 => utmpset.8.in} | 2 +- package/Makefile.historic | 51 ++ package/check | 9 - package/commands | 9 - package/compile | 27 - package/install | 6 - package/install-man | 26 - package/upgrade | 29 -- src/Makefile | 465 +++-------------- src/TARGETS | 135 ----- src/choose.sh | 18 - src/chpst.c | 4 +- src/conf-cc | 5 - src/conf-ld | 3 - src/{direntry.h1 => direntry.h} | 12 +- src/direntry.h2 | 12 - src/fifo.c | 1 - src/hasflock.h1 | 3 - src/hasflock.h2 | 4 - src/hasmkffo.h1 | 3 - src/hasmkffo.h2 | 4 - src/hassgact.h1 | 3 - src/hassgact.h2 | 4 - src/hassgprm.h1 | 3 - src/hassgprm.h2 | 4 - src/haswaitp.h1 | 3 - src/haswaitp.h2 | 4 - src/lock_ex.c | 1 - src/lock_exnb.c | 1 - src/print-ar.sh | 15 - src/print-cc.sh | 4 - src/print-ld.sh | 5 - src/reboot_system.h1 | 8 - src/reboot_system.h2 | 8 - src/runit-init.c | 2 +- src/runit.c | 17 +- src/runit.h | 10 +- src/runsv.c | 2 - src/runsvchdir.c | 5 +- src/runsvctrl.c | 2 - src/runsvdir.c | 1 - src/runsvstat.c | 5 +- src/sig_block.c | 1 - src/sig_catch.c | 1 - src/sig_pause.c | 1 - src/strquote.h | 10 + src/sv.c | 7 +- src/svlogd.c | 4 +- src/svwaitdown.c | 5 +- src/svwaitup.c | 3 +- src/utmpset.c | 3 +- src/{uw_tmp.h1 => uw_tmp.h} | 25 +- src/uw_tmp.h2 | 13 - src/wait_nohang.c | 1 - src/wait_pid.c | 1 - src/warn-auto.sh | 2 - 79 files changed, 788 insertions(+), 880 deletions(-) delete mode 100644 .gitattributes create mode 100644 .gitignore delete mode 100644 .manpages create mode 100644 completions/Makefile rename completions/{sv.bash => sv.bash.in} (93%) rename completions/{sv.zsh => sv.zsh.in} (95%) create mode 100755 configure rename src/trydrent.c => configure_tests/trydirent.c (89%) rename {src => configure_tests}/tryflock.c (100%) rename src/trymkffo.c => configure_tests/trymkfifo.c (100%) rename {src => configure_tests}/tryreboot.c (100%) rename src/trysgact.c => configure_tests/trysigaction.c (100%) rename src/trysgprm.c => configure_tests/trysigprocmask.c (100%) rename {src => configure_tests}/trysocketlib.c (100%) rename {src => configure_tests}/tryuwtmp.c (100%) rename {src => configure_tests}/tryuwtmpx.c (100%) rename src/trywaitp.c => configure_tests/trywaitpid.c (100%) create mode 100644 man/Makefile rename man/{runsv.8 => runsv.8.in} (97%) rename man/{runsvchdir.8 => runsvchdir.8.in} (95%) rename man/{sv.8 => sv.8.in} (99%) rename man/{utmpset.8 => utmpset.8.in} (96%) create mode 100644 package/Makefile.historic delete mode 100755 package/check delete mode 100644 package/commands delete mode 100755 package/compile delete mode 100755 package/install delete mode 100755 package/install-man delete mode 100755 package/upgrade delete mode 100644 src/TARGETS delete mode 100644 src/choose.sh delete mode 100644 src/conf-cc delete mode 100644 src/conf-ld rename src/{direntry.h1 => direntry.h} (63%) delete mode 100644 src/direntry.h2 delete mode 100644 src/hasflock.h1 delete mode 100644 src/hasflock.h2 delete mode 100644 src/hasmkffo.h1 delete mode 100644 src/hasmkffo.h2 delete mode 100644 src/hassgact.h1 delete mode 100644 src/hassgact.h2 delete mode 100644 src/hassgprm.h1 delete mode 100644 src/hassgprm.h2 delete mode 100644 src/haswaitp.h1 delete mode 100644 src/haswaitp.h2 delete mode 100644 src/print-ar.sh delete mode 100644 src/print-cc.sh delete mode 100644 src/print-ld.sh delete mode 100644 src/reboot_system.h1 delete mode 100644 src/reboot_system.h2 create mode 100644 src/strquote.h rename src/{uw_tmp.h1 => uw_tmp.h} (57%) delete mode 100644 src/uw_tmp.h2 delete mode 100644 src/warn-auto.sh diff --git a/.gitattributes b/.gitattributes deleted file mode 100644 index 270f8fc..0000000 --- a/.gitattributes +++ /dev/null @@ -1,13 +0,0 @@ -src/chpst.c ident -src/runit-init.c ident -src/runit.c ident -src/runsv.c ident -src/runsvchdir.c ident -src/runsvctrl.c ident -src/runsvdir.c ident -src/runsvstat.c ident -src/sv.c ident -src/svlogd.c ident -src/svwaitdown.c ident -src/svwaitup.c ident -src/utmpset.c ident diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..30b95d8 --- /dev/null +++ b/.gitignore @@ -0,0 +1,27 @@ +# Generated config +config.mk + +# Objects +*.o +*.a + +# Generated manual pages +runsv.8 +runsvchdir.8 +sv.8 +utmpset.8 + +# Binaries +src/chpst +src/runit +src/runit-init +src/runsv +src/runsvdir +src/runsvchdir +src/sv +src/svlogd +src/utmpset + +# Generated completions +sv.bash +sv.zsh diff --git a/.manpages b/.manpages deleted file mode 100644 index e69de29..0000000 diff --git a/Makefile b/Makefile index 17e79b7..77a9a7a 100644 --- a/Makefile +++ b/Makefile @@ -1,49 +1,33 @@ -DESTDIR= +-include config.mk -PACKAGE=runit-2.1.2 -DIRS=doc man etc package src -MANPAGES=runit.8 runit-init.8 runsvdir.8 runsv.8 sv.8 utmpset.8 \ - runsvchdir.8 svlogd.8 chpst.8 +SUBDIRS = src man completions -all: clean .manpages $(PACKAGE).tar.gz +.PHONY: all install uninstall check clean -.manpages: - for i in $(MANPAGES); do \ - rman -S -f html -r '' < man/$$i | \ - sed -e "s}name='sect\([0-9]*\)' href='#toc[0-9]*'>\(.*\)}name='sect\1'>\2}g ; \ - s}Table of Contents}G. Pape
runit
}g ; \ - s}}}g" \ - > doc/$$i.html ; \ - done ; \ - echo 'fix up html manually...' - echo 'patch -p0 $@ + +install: all + install -d $(DESTDIR)$(SHAREDIR)/bash-completion/completions + install -m644 sv.bash $(DESTDIR)$(SHAREDIR)/bash-completion/completions/sv + install -d $(DESTDIR)$(SHAREDIR)/zsh/site-functions + install -m644 sv.zsh $(DESTDIR)$(SHAREDIR)/zsh/site-functions/_sv + +clean: + rm -f $(COMPLETIONS) diff --git a/completions/sv.bash b/completions/sv.bash.in similarity index 93% rename from completions/sv.bash rename to completions/sv.bash.in index ec0fcae..c8ff723 100644 --- a/completions/sv.bash +++ b/completions/sv.bash.in @@ -16,7 +16,7 @@ _sv() return ;; *) - COMPREPLY=( /var/service/* ) + COMPREPLY=( @@SERVICEDIR@@/* ) COMPREPLY=( ${COMPREPLY[@]##*/} ) COMPREPLY=( $(compgen -W '${COMPREPLY[@]}' -- ${cur}) ) return diff --git a/completions/sv.zsh b/completions/sv.zsh.in similarity index 95% rename from completions/sv.zsh rename to completions/sv.zsh.in index 465fbfd..bc3ade7 100644 --- a/completions/sv.zsh +++ b/completions/sv.zsh.in @@ -35,7 +35,7 @@ cmds) check ret=0;; args) - services=( /var/service/*(-/N:t) ) + services=( @@SERVICEDIR@@/*(-/N:t) ) (( $#services )) && _values services $services && ret=0 [[ $words[CURRENT] = */* ]] && _directories && ret=0 ;; diff --git a/configure b/configure new file mode 100755 index 0000000..1ac5318 --- /dev/null +++ b/configure @@ -0,0 +1,484 @@ +#!/bin/sh + +VERSION=2.1.2 + +# Ensure that we do not inherit these from env +BUILD_STATIC= +SILENT=yes +DEBUG= + +usage() +{ + cat <<_EOF +\`configure' configures runit to adapt to many kinds of systems. + +By default, \`make install' will install all the files in +\`/usr/local/sbin', \`/usr/local/lib' etc. You can specify +an installation prefix other than \`/usr/local' using \`--prefix', +for instance \`--prefix=\$HOME'. + +--prefix=DIR Install architecture-independent files in PREFIX +--exec-prefix=DIR Install architecture-dependent files in EPREFIX +--bindir=DIR Executables [PREFIX/bin] +--sysconfdir=DIR Configuration files directory [PREFIX/etc] +--mandir=DIR Man documentation [EPREFIX/share/man] +--datadir=DIR Read-only architecture-independent data [EPREFIX/share] +--servicedir=DIR Directory to store services in [/var/service] + +--verbose Disable silent build to see compilation details +--enable-debug Enables debugging (assertions and -g, default enabled) +--disable-debug Disables debugging (assertions and -g) +--enable-static Build all runit utils statically (default disabled) +--disable-static Don't build all runit utils statically +_EOF + exit 1 +} + +for x; do + opt=${x%%=*} + var=${x#*=} + case "$opt" in + --prefix) PREFIX=$var ;; + --exec-prefix) EPREFIX=$var ;; + --bindir) BINDIR=$var ;; + --mandir) MANDIR=$var ;; + --datadir) SHAREDIR=$var ;; + --sysconfdir) SYSCONFDIR=$var ;; + --servicedir) SERVICEDIR=$var ;; + --infodir) ;; # ignore autotools + --verbose) unset SILENT ;; + --enable-debug) DEBUG=yes ;; + --disable-debug) DEBUG=no ;; + --enable-static) BUILD_STATIC=yes ;; + --disable-static) BUILD_STATIC=no ;; + --help) usage;; + *) echo "$0: WARNING: unknown option $opt" >&2 ;; + esac +done + +: "${SED:=sed}" + +: "${PREFIX:=/usr/local}" +: "${EPREFIX:=${PREFIX}}" +: "${BINDIR:=${PREFIX}/bin}" +: "${SYSCONFDIR:=/etc}" +: "${SHAREDIR:=${EPREFIX}/share}" +: "${MANDIR:=${EPREFIX}/share/man}" +: "${SERVICEDIR:=/var/service}" + +CONFIG_MK=config.mk + +echo "Configuring runit ..." +rm -f $CONFIG_MK +echo "# Common vars used by runit." >$CONFIG_MK + +if type git >/dev/null; then + GIT_REV="$(git rev-parse --short=8 HEAD 2>/dev/null)" + if [ -n "$GIT_REV" ]; then + VERSION="$VERSION-$GIT_REV" + fi +fi + +echo "VERSION = $VERSION" >>$CONFIG_MK +echo "CPPFLAGS += -DVERSION=$VERSION" >>$CONFIG_MK +echo "PREFIX ?= $PREFIX" >>$CONFIG_MK +echo "EPREFIX ?= $EPREFIX" >>$CONFIG_MK +echo "SBINDIR ?= $BINDIR" >>$CONFIG_MK +echo "CPPFLAGS += -DSBINDIR=$BINDIR" >>$CONFIG_MK +echo "MANDIR ?= $MANDIR" >>$CONFIG_MK +echo "SHAREDIR ?= $SHAREDIR" >>$CONFIG_MK +echo "SYSCONFDIR ?= $SYSCONFDIR" >>$CONFIG_MK +echo "CPPFLAGS += -DSYSCONFDIR=$SYSCONFDIR" >>$CONFIG_MK +echo "SERVICEDIR ?= $SERVICEDIR" >>$CONFIG_MK +echo "CPPFLAGS += -DSERVICEDIR=$SERVICEDIR" >>$CONFIG_MK +echo "SED ?= $SED" >>$CONFIG_MK + +if [ -z "$CC" ]; then + printf "Looking for compiler ... " + for cc in gcc icc clang tcc pcc cc; do + if type $cc >/dev/null 2>&1; then + CC=$cc + echo "$CC" + break + fi + done + if [ -z "$CC" ]; then + echo + echo "no suitable compiler found - aborting" >&2 + exit 1 + fi +else + echo "Using compiler $CC" +fi + +echo "CC = $CC" >>$CONFIG_MK +echo "CFLAGS = -O2" >>$CONFIG_MK +echo "CPPFLAGS += -D_DEFAULT_SOURCE" >>$CONFIG_MK + +[ -z "$DEBUG" ] && DEBUG=yes +if [ -n "$DEBUG" ] && [ "$DEBUG" != no ] && [ "$DEBUG" != false ]; then + echo "Building with debugging symbols." + echo "CPPFLAGS += -DDEBUG" >>$CONFIG_MK + echo "CFLAGS += -g" >>$CONFIG_MK +else + echo "CPPFLAGS+= -DNDEBUG" >>$CONFIG_MK +fi + +# Add CPPFLAGS/CFLAGS/LDFLAGS to CC for testing features +XCC="$CC $CFLAGS $CPPFLAGS $LDFLAGS" + +check_compiler_flag() +{ + flag="$1" + mode="$2" + var="$3" + rv=0 + + [ -z "$var" ] && var="CFLAGS" + + printf "Checking if %s supports -%s%s ... " "$CC" "$mode" "$flag" + cat <_ccflag.c +#include +int main(void) { return 0; } +EOF + if $XCC -${mode}${flag} _ccflag.c -o _ccflag 2>_ccflag.err; then + if ! test -s _ccflag.err; then + if [ "$mode" = "W" ] && [ -z "$var" ]; then + echo "CFLAGS += -${mode}${flag}" >>$CONFIG_MK + else + echo "$var += -${mode}${flag}" >>$CONFIG_MK + fi + echo "yes." + else + rv=1 + echo "no." + fi + else + rv=1 + echo "no." + fi + [ -z "$SILENT" ] && cat _ccflag.err + rm -f _ccflag.c _ccflag _ccflag.err + return $rv +} + +# If supported, make sure to disable --as-needed for CC tests. +if check_compiler_flag "l,--no-as-needed" W LDFLAGS; then + XCC="$XCC -Wl,--no-as-needed" +fi + +# Check for some compiler warning flags +# TODO: check more compiler warning flags +# for f in all extra shadow "format=2" missing-prototypes \ +# missing-declarations nested-externs vla overlength-strings \ +# unsafe-loop-optimizations undef sign-compare \ +# missing-include-dirs old-style-definition \ +# init-self redundant-decls float-equal missing-noreturn \ +# cast-align cast-qual pointer-arith comment \ +# declaration-after-statement write-strings stack-protector; do +for f in all; do + check_compiler_flag "$f" W +done + +# Check for some compiler flags. +check_compiler_flag PIC f CFLAGS +check_compiler_flag "inline-functions" f CFLAGS + +if ! check_compiler_flag stack-protector-strong f CFLAGS; then + if check_compiler_flag stack-protector f CFLAGS; then + if [ "$CC" = "gcc" ]; then + check_compiler_flag "param ssp-buffer-size=1" - CFLAGS + fi + fi +fi + +# Check for some linker flags. +check_compiler_flag "l,-z,relro,-z,now,-z,noexecstack" W LDFLAGS + +# Check if PIE is supported. +if check_compiler_flag PIE f CFLAGS; then + if check_compiler_flag pie "" LDFLAGS; then + BUILD_PIE_VALUE=yes + else + BUILD_PIE_VALUE=no + fi +fi + +# A C99 compiler is required to build runit. +if ! check_compiler_flag "std=c99" "" CFLAGS; then + echo "ERROR: A compatible C99 compiler is required, exiting..." + exit 1 +fi + +if [ -n "$CFLAGS" ]; then + echo "CFLAGS += $CFLAGS" >>$CONFIG_MK +fi +if [ -n "$LDFLAGS" ]; then + echo "LDFLAGS += $LDFLAGS" >>$CONFIG_MK +fi +if [ -n "$CPPFLAGS" ]; then + echo "CPPFLAGS += $CPPFLAGS" >>$CONFIG_MK +fi + +if [ "$CC" = "tcc" ]; then + echo "CFLAGS += -Wno-error" >>$CONFIG_MK +fi + +# XXX: this whole mechanism reeks of trying to one-up the system's toolchain, +# but it's the one that was there and I'm not sure what are the implications +kern="$(uname -s | tr '/:[A-Z]' '..[a-z])')-$(uname -r | tr /: ..)" || kern="unknown" +AR="ar cr" +case $kern in + sunos-5.*) ;; + unix_sv*) ;; + irix64-*) ;; + irix-*) ;; + dgux-*) ;; + hp-ux-*) ;; + sco*) ;; + *) AR="ar crs" ;; +esac +echo "AR = $AR" >> $CONFIG_MK + +# +# Check for flock(). +# +func=flock +printf "Checking for $func() ... " +if test -n "$HASFLOCK"; then + echo "yes (cached)." +else + if $XCC configure_tests/try$func.c -o try$func 2>/dev/null; then + echo yes. + HASFLOCK=1 + else + echo no. + fi + rm -f try$func +fi +if test -n "$HASFLOCK"; then + echo "CPPFLAGS += -DHASFLOCK" >> $CONFIG_MK +fi + +# +# Check for sigprocmask(). +# +func=sigprocmask +printf "Checking for $func() ... " +if test -n "$HASSIGPROCMASK"; then + echo "yes (cached)." +else + if $XCC configure_tests/try$func.c -o try$func 2>/dev/null; then + echo yes. + HASSIGPROCMASK=1 + else + echo no. + fi + rm -f try$func +fi +if test -n "$HASSIGPROCMASK"; then + echo "CPPFLAGS += -DHASSIGPROCMASK" >> $CONFIG_MK +fi + +# +# Check for mkfifo(). +# +func="mkfifo" +printf "Checking for $func() ... " +if test -n "$HASMKFIFO"; then + echo "yes (cached)." +else + if $XCC configure_tests/try$func.c -o try$func 2>/dev/null; then + echo yes. + HASMKFIFO=1 + else + echo no. + fi + rm -f try$func +fi +if test -n "$HASMKFIFO"; then + echo "CPPFLAGS += -DHASMKFIFO" >> $CONFIG_MK +fi + +# +# Check for sigaction(). +# +func=sigaction +printf "Checking for $func() ... " +if test -n "$HASSIGACTION"; then + echo "yes (cached)." +else + if $XCC configure_tests/try$func.c -o try$func 2>/dev/null; then + echo yes. + HASSIGACTION=1 + else + echo no. + fi + rm -f try$func +fi +if test -n "$HASSIGACTION"; then + echo "CPPFLAGS += -DHASSIGACTION" >> $CONFIG_MK +fi + +# +# Check for waitpid(). +# +func=waitpid +printf "Checking for $func() ... " +if test -n "$HASWAITPID"; then + echo "yes (cached)." +else + if $XCC configure_tests/try$func.c -o try$func 2>/dev/null; then + echo yes. + HASWAITPID=1 + else + echo no. + fi + rm -f try$func +fi +if test -n "$HASWAITPID"; then + echo "CPPFLAGS += -DHASWAITPID" >> $CONFIG_MK +fi + +# +# Check for socket() link args. +# XXX: Is this correct? +# +printf "Checking for socket library ... " +if test -n "$SOCKETLIB"; then + # XXX: this seems very wrong, the value we want is empty in most cases, yet empty means "check again"? + echo "$SOCKETLIB (cached)." +else + _CC="$XCC configure_tests/trysocketlib.c -o trysocketlib" + if $_CC 2>/dev/null; then + SOCKETLIB= + echo yes. + elif $_CC -lxnet 2>/dev/null; then + SOCKETLIB="-lxnet" + echo "-lxnet" + elif $_CC -lsocket -lnsl 2>/dev/null; then + SOCKETLIB="-lsocket -lnsl" + echo "-lsocket -lnsl" + else + echo no. + echo "Can't find socket library!" + exit 1 + fi + rm -f trysocketlib +fi +echo "SOCKETLIB_LDFLAGS = $SOCKETLIB" >> $CONFIG_MK + +# +# Check for utmpx/utmp. +# +printf "Checking for utmpx ... " +if test -n "$HASUTMPX"; then + echo "$HASUTMPX (cached)." +else + if $XCC configure_tests/tryuwtmpx.c -o tryuwtmpx 2>/dev/null; then + HASUTMPX=1 + echo yes. + else + echo no. + fi + rm -f tryuwtmpx +fi + +printf "Checking for utmp ... " +if test -n "$HASUTMP"; then + echo "$HASUTMP (cached)." +else + if $XCC configure_tests/tryuwtmp.c -o tryuwtmp 2>/dev/null; then + HASUTMP=1 + echo yes. + else + echo no. + fi + rm -f tryuwtmp +fi + +if test -n "$HASUTMPX"; then + echo "Using utmpx" + echo "CPPFLAGS += -DHASUTMPX" >> $CONFIG_MK +elif test -n "$HASUTMP"; then + echo "Using utmp" +else + echo "Cannot find utmpx or utmp!" + exit 1 +fi + +# +# Check for dirent.h. +# +func=dirent +printf "Checking for $func.h ... " +if test -n "$HASDIRENT"; then + echo "yes (cached)." +else + if $XCC configure_tests/try$func.c -o try$func 2>/dev/null; then + echo yes. + HASDIRENT=1 + else + echo no. + fi + rm -f try$func +fi +if test -n "$HASDIRENT"; then + echo "CPPFLAGS += -DHASDIRENT" >> $CONFIG_MK +fi + +# +# Check for one argument reboot(). +# +printf "Checking for one argument reboot() ... " +if test -n "$HASONEARGREBOOT"; then + echo "yes (cached)." +else + if $XCC configure_tests/tryreboot.c -o tryreboot 2>/dev/null; then + echo yes. + HASONEARGREBOOT=1 + else + echo no. + fi + rm -f tryreboot +fi +if test -n "$HASONEARGREBOOT"; then + echo "CPPFLAGS += -DHASONEARGREBOOT" >> $CONFIG_MK +fi + +# If --enable-static enabled, build static binaries. +if [ "$BUILD_STATIC" = "yes" ]; then + echo "BUILD_STATIC = -static" >>$CONFIG_MK + BUILD_STATIC_VALUE=yes +else + echo "BUILD_STATIC = " >>$CONFIG_MK + BUILD_STATIC_VALUE=no +fi + +if [ -n "$SILENT" ]; then + echo "SILENT = @" >>$CONFIG_MK +else + echo "SILENT =" >>$CONFIG_MK +fi + +echo +echo " runit has been configured with the following options:" +echo +echo " PREFIX = $PREFIX" +echo " EPREFIX = $EPREFIX" +echo " BINDIR = $BINDIR" +echo " SYSCONFDIR = $SYSCONFDIR" +echo " SHAREDIR = $SHAREDIR" +echo " MANDIR = $MANDIR" +echo " SERVICEDIR = $SERVICEDIR" +echo " CFLAGS = $CFLAGS" +echo " LDFLAGS = $LDFLAGS" +echo +echo " Build programs as PIE = $BUILD_PIE_VALUE" +echo " Build static programs = $BUILD_STATIC_VALUE" +echo " Build with debugging = $DEBUG" +echo +echo " You can now run make && make install clean." +echo + +exit 0 diff --git a/src/trydrent.c b/configure_tests/trydirent.c similarity index 89% rename from src/trydrent.c rename to configure_tests/trydirent.c index 3333ac0..b8befd0 100644 --- a/src/trydrent.c +++ b/configure_tests/trydirent.c @@ -3,7 +3,7 @@ #include #include -void foo() +void main() { DIR *dir; struct dirent *d; diff --git a/src/tryflock.c b/configure_tests/tryflock.c similarity index 100% rename from src/tryflock.c rename to configure_tests/tryflock.c diff --git a/src/trymkffo.c b/configure_tests/trymkfifo.c similarity index 100% rename from src/trymkffo.c rename to configure_tests/trymkfifo.c diff --git a/src/tryreboot.c b/configure_tests/tryreboot.c similarity index 100% rename from src/tryreboot.c rename to configure_tests/tryreboot.c diff --git a/src/trysgact.c b/configure_tests/trysigaction.c similarity index 100% rename from src/trysgact.c rename to configure_tests/trysigaction.c diff --git a/src/trysgprm.c b/configure_tests/trysigprocmask.c similarity index 100% rename from src/trysgprm.c rename to configure_tests/trysigprocmask.c diff --git a/src/trysocketlib.c b/configure_tests/trysocketlib.c similarity index 100% rename from src/trysocketlib.c rename to configure_tests/trysocketlib.c diff --git a/src/tryuwtmp.c b/configure_tests/tryuwtmp.c similarity index 100% rename from src/tryuwtmp.c rename to configure_tests/tryuwtmp.c diff --git a/src/tryuwtmpx.c b/configure_tests/tryuwtmpx.c similarity index 100% rename from src/tryuwtmpx.c rename to configure_tests/tryuwtmpx.c diff --git a/src/trywaitp.c b/configure_tests/trywaitpid.c similarity index 100% rename from src/trywaitp.c rename to configure_tests/trywaitpid.c diff --git a/man/Makefile b/man/Makefile new file mode 100644 index 0000000..07e2d4b --- /dev/null +++ b/man/Makefile @@ -0,0 +1,20 @@ +-include ../config.mk + +MANPAGES = chpst.8 runit-init.8 runit.8 svlogd.8 runsvdir.8 +MANPAGES_IN = runsvchdir.8 sv.8 runsv.8 utmpset.8 + +.PHONY: all install clean + +all: $(MANPAGES) $(MANPAGES_IN) + +$(MANPAGES_IN): + $(SED) -e "s|@@SERVICEDIR@@|${SERVICEDIR}|g" $@.in > $@ + +install: all + install -d $(DESTDIR)$(MANDIR)/man8 + for page in $(MANPAGES) $(MANPAGES_IN); do \ + install -m644 $$page $(DESTDIR)$(MANDIR)/man8; \ + done + +clean: + rm -f $(MANPAGES_IN) diff --git a/man/runsv.8 b/man/runsv.8.in similarity index 97% rename from man/runsv.8 rename to man/runsv.8.in index 53f1b1b..7c75759 100644 --- a/man/runsv.8 +++ b/man/runsv.8.in @@ -157,9 +157,9 @@ This command is ignored if it is given to .IR service /log/supervise/control. .P Example: to send a TERM signal to the socklog-unix service, either do - # sv term /var/service/socklog-unix + # sv term @@SERVICEDIR@@/socklog-unix or - # printf t >/var/service/socklog-unix/supervise/control + # printf t >@@SERVICEDIR@@/socklog-unix/supervise/control .P .BR printf (1) usually blocks if no diff --git a/man/runsvchdir.8 b/man/runsvchdir.8.in similarity index 95% rename from man/runsvchdir.8 rename to man/runsvchdir.8.in index 793d653..325b60c 100644 --- a/man/runsvchdir.8 +++ b/man/runsvchdir.8.in @@ -27,13 +27,13 @@ with a symlink pointing to .IR dir . .P Normally -.I /var/service +.I @@SERVICEDIR@@ is a symlink to .IR current , and .BR runsvdir (8) is running -.IR /var/service/ . +.IR @@SERVICEDIR@@/ . .SH EXIT CODES .B runsvchdir prints an error message and exits 111 on error. diff --git a/man/sv.8 b/man/sv.8.in similarity index 99% rename from man/sv.8 rename to man/sv.8.in index 58f1c07..3743ec9 100644 --- a/man/sv.8 +++ b/man/sv.8.in @@ -30,7 +30,7 @@ If .I service doesn't start with a dot or slash and doesn't end with a slash, it is searched in the default services directory -.IR /var/service/ , +.IR @@SERVICEDIR@@/ , otherwise relative to the current directory. .P .I command @@ -232,7 +232,7 @@ This option implies .TP .B SVDIR The environment variable $SVDIR overrides the default services directory -.IR /var/service/ . +.IR @@SERVICEDIR@@/ . .TP .B SVWAIT The environment variable $SVWAIT overrides the default 7 seconds to wait diff --git a/man/utmpset.8 b/man/utmpset.8.in similarity index 96% rename from man/utmpset.8 rename to man/utmpset.8.in index 4f9b4ef..6bfb829 100644 --- a/man/utmpset.8 +++ b/man/utmpset.8.in @@ -34,7 +34,7 @@ to the .I finish scripts, e.g.: .P - $ cat /service/getty-5/finish + $ cat @@SERVICEDIR@@/getty-5/finish #!/bin/sh exec utmpset \-w tty5 $ diff --git a/package/Makefile.historic b/package/Makefile.historic new file mode 100644 index 0000000..d9ba92b --- /dev/null +++ b/package/Makefile.historic @@ -0,0 +1,51 @@ +# This is the former top-level Makefile + +DESTDIR= + +PACKAGE=runit-2.1.2 +DIRS=doc man etc package src +MANPAGES=runit.8 runit-init.8 runsvdir.8 runsv.8 sv.8 utmpset.8 \ + runsvchdir.8 svlogd.8 chpst.8 + +all: clean .manpages $(PACKAGE).tar.gz + +.manpages: + for i in $(MANPAGES); do \ + rman -S -f html -r '' < man/$$i | \ + sed -e "s}name='sect\([0-9]*\)' href='#toc[0-9]*'>\(.*\)}name='sect\1'>\2}g ; \ + s}Table of Contents}G. Pape
runit
}g ; \ + s}}}g" \ + > doc/$$i.html ; \ + done ; \ + echo 'fix up html manually...' + echo 'patch -p0 compile/home -test -h compile/src || ln -s $here/src compile/src - -echo 'Linking ./src/* into ./compile...' -for i in `ls src`; do - test -h compile/$i || ln -s src/$i compile/$i -done - -echo 'Compiling everything in ./compile...' -sh -cxe 'cd compile; exec make' - -echo 'Copying commands into ./command...' -for i in `cat package/commands`; do - rm -f command/$i'{new}' - cp -p compile/$i command/$i'{new}' - mv -f command/$i'{new}' command/$i -done diff --git a/package/install b/package/install deleted file mode 100755 index 4e3c468..0000000 --- a/package/install +++ /dev/null @@ -1,6 +0,0 @@ -#!/bin/sh -set -e - -package/compile -package/check -package/upgrade diff --git a/package/install-man b/package/install-man deleted file mode 100755 index cd49048..0000000 --- a/package/install-man +++ /dev/null @@ -1,26 +0,0 @@ -#!/bin/sh -set -e - -umask 022 -test -d package || sh -cx '! : Wrong working directory.' -test -d man || sh -cx '! : Wrong working directory.' - -here=`env - PATH=$PATH pwd` -parent=`dirname $here` - -echo 'Compressing manpages...' -for i in man/*.[1-8]; do - gzip -c $i >${i}.gz -done - -echo 'Making manpage links in /usr/local/man...' -cd man -for i in 8; do - mkdir -p /usr/local/man/man$i - for j in *.$i; do - rm -f /usr/local/man/man$i/$j.gz'{new}' - ln -s $parent/runit/man/$j.gz /usr/local/man/man$i/$j.gz'{new}' - mv -f /usr/local/man/man$i/$j.gz'{new}' /usr/local/man/man$i/$j.gz - done -done -cd .. diff --git a/package/upgrade b/package/upgrade deleted file mode 100755 index fac8902..0000000 --- a/package/upgrade +++ /dev/null @@ -1,29 +0,0 @@ -#!/bin/sh -set -e - -umask 022 -test -d package || sh -cx '! : Wrong working directory.' -test -d src || sh -cx '! : Wrong working directory.' - -here=`env - PATH=$PATH pwd` -parent=`dirname $here` - -echo 'Creating symlink runit -> runit-2.1.2...' -rm -f runit -ln -s runit-2.1.2 runit -mv -f runit .. - -echo 'Making command links in /command...' -mkdir -p /command -for i in `cat package/commands`; do - rm -f /command/$i'{new}' - ln -s $parent/runit/command/$i /command/$i'{new}' - mv -f /command/$i'{new}' /command/$i -done -echo 'Making compatibility links in /usr/local/bin...' -mkdir -p /usr/local/bin -for i in `cat package/commands`; do - rm -f /usr/local/bin/$i'{new}' - ln -s /command/$i /usr/local/bin/$i'{new}' - mv -f /usr/local/bin/$i'{new}' /usr/local/bin/$i -done diff --git a/src/Makefile b/src/Makefile index c1d9c14..5b660a8 100644 --- a/src/Makefile +++ b/src/Makefile @@ -1,437 +1,100 @@ -IT=chpst runit runit-init runsv runsvchdir runsvdir sv svlogd utmpset +-include ../config.mk -default: sysdeps $(IT) +PROGS=chpst runit runit-init runsv runsvchdir runsvdir sv svlogd utmpset -check: $(IT) - ./check-local $(IT) +.PHONY: all check install clean -runit: load runit.o unix.a byte.a - ./load runit unix.a byte.a -static +all: $(PROGS) -runit-init: load runit-init.o unix.a byte.a - ./load runit-init unix.a byte.a -static +check: $(PROGS) + ./check-local $(PROGS) -runsv: load runsv.o unix.a byte.a time.a - ./load runsv unix.a byte.a time.a +install: all + install -d $(DESTDIR)$(SBINDIR) + @for prog in $(PROGS); do \ + install -m 755 $$prog $(DESTDIR)$(SBINDIR); \ + done -runsvdir: load runsvdir.o unix.a byte.a time.a - ./load runsvdir unix.a byte.a time.a - -runsvstat: load runsvstat.o unix.a byte.a time.a - ./load runsvstat unix.a byte.a time.a - -runsvctrl: load runsvctrl.o unix.a byte.a - ./load runsvctrl unix.a byte.a - -sv: load sv.o unix.a byte.a time.a - ./load sv unix.a byte.a time.a - -svwaitup: load svwaitup.o unix.a byte.a time.a - ./load svwaitup unix.a byte.a time.a - -svwaitdown: load svwaitdown.o unix.a byte.a time.a - ./load svwaitdown unix.a byte.a time.a - -utmpset: load utmpset.o unix.a byte.a - ./load utmpset unix.a byte.a - -runsvchdir: load runsvchdir.o unix.a byte.a - ./load runsvchdir unix.a byte.a - -svlogd: load svlogd.o pmatch.o fmt_ptime.o unix.a byte.a time.a socket.lib - ./load svlogd pmatch.o fmt_ptime.o unix.a byte.a time.a \ - `cat socket.lib` - -chpst: load chpst.o uidgid.o unix.a byte.a - ./load chpst uidgid.o unix.a byte.a - -runit.o: compile sysdeps runit.c - ./compile runit.c - -runit-init.o: compile runit-init.c - ./compile runit-init.c - -runsv.o: compile sysdeps runsv.c - ./compile runsv.c - -runsvdir.o: compile sysdeps runsvdir.c - ./compile runsvdir.c - -runsvstat.o: compile sysdeps runsvstat.c - ./compile runsvstat.c - -runsvctrl.o: compile runsvctrl.c - ./compile runsvctrl.c - -sv.o: compile sysdeps sv.c - ./compile sv.c - -svwaitup.o: compile sysdeps svwaitup.c - ./compile svwaitup.c - -svwaitdown.o: compile sysdeps svwaitdown.c - ./compile svwaitdown.c - -utmpset.o: compile sysdeps utmpset.c - ./compile utmpset.c - -runsvchdir.o: compile runsvchdir.c - ./compile runsvchdir.c - -svlogd.o: compile sysdeps svlogd.c - ./compile svlogd.c - -chpst.o: compile sysdeps chpst.c - ./compile chpst.c - - -uidgid.o: compile uidgid.c uidgid.h - ./compile uidgid.c - -pmatch.o: compile pmatch.c - ./compile pmatch.c - -fmt_ptime.o: compile sysdeps fmt_ptime.c - ./compile fmt_ptime.c - -reboot_system.h: choose compile reboot_system.h1 reboot_system.h2 - ./choose c tryreboot reboot_system.h1 reboot_system.h2 > \ - reboot_system.h +clean: + rm -f *.o *.a $(PROGS) -uw_tmp.h: compile uw_tmp.h1 uw_tmp.h2 - ( ./compile tryuwtmpx.c 2>/dev/null && cat uw_tmp.h2 >uw_tmp.h ) || \ - ( ./compile tryuwtmp.c 2>/dev/null && cat uw_tmp.h1 >uw_tmp.h ) - rm -f tryuwtmp.o tryuwtmpx.o +runit: runit.o unix.a byte.a + @printf " [CCLD]\t\t$@\n" + ${SILENT}$(CC) $^ $(LDFLAGS) -static -o $@ -socket.lib: compile load trysocketlib.c - ./compile trysocketlib.c - ( ./load trysocketlib >/dev/null 2>&1 || \ - ( ./load trysocketlib -lxnet >/dev/null 2>&1 && echo '-lxnet' ) || \ - ( ./load trysocketlib -lsocket -lnsl >/dev/null 2>&1 && \ - echo '-lsocket -lnsl' ) \ - ) >socket.lib - rm -f trysocketlib.o trysocketlib +runit-init: runit-init.o unix.a byte.a + @printf " [CCLD]\t\t$@\n" + ${SILENT}$(CC) $^ $(LDFLAGS) -static -o $@ -clean: - find . -name \*~ -exec rm -f {} \; - find . -name .??*~ -exec rm -f {} \; - find . -name \#?* -exec rm -f {} \; - rm -f `cat TARGETS` +runsv: runsv.o unix.a byte.a time.a + @printf " [CCLD]\t\t$@\n" + ${SILENT}$(CC) $^ $(LDFLAGS) $(BUILD_STATIC) -o $@ -alloc.o: alloc.c alloc.h compile error.h - ./compile alloc.c +runsvdir: runsvdir.o unix.a byte.a time.a + @printf " [CCLD]\t\t$@\n" + ${SILENT}$(CC) $^ $(LDFLAGS) $(BUILD_STATIC) -o $@ -alloc_re.o: alloc.h alloc_re.c byte.h compile - ./compile alloc_re.c +runsvstat: runsvstat.o unix.a byte.a time.a + @printf " [CCLD]\t\t$@\n" + ${SILENT}$(CC) $^ $(LDFLAGS) $(BUILD_STATIC) -o $@ -buffer.o: buffer.c buffer.h compile - ./compile buffer.c +runsvctrl: runsvctrl.o unix.a byte.a + @printf " [CCLD]\t\t$@\n" + ${SILENT}$(CC) $^ $(LDFLAGS) $(BUILD_STATIC) -o $@ -buffer_0.o: buffer.h buffer_0.c compile - ./compile buffer_0.c +sv: sv.o unix.a byte.a time.a + @printf " [CCLD]\t\t$@\n" + ${SILENT}$(CC) $^ $(LDFLAGS) $(BUILD_STATIC) -o $@ -buffer_1.o: buffer.h buffer_1.c compile - ./compile buffer_1.c +svwaitup: svwaitup.o unix.a byte.a time.a + @printf " [CCLD]\t\t$@\n" + ${SILENT}$(CC) $^ $(LDFLAGS) $(BUILD_STATIC) -o $@ -buffer_2.o: buffer.h buffer_2.c compile - ./compile buffer_2.c +svwaitdown: svwaitdown.o unix.a byte.a time.a + @printf " [CCLD]\t\t$@\n" + ${SILENT}$(CC) $^ $(LDFLAGS) $(BUILD_STATIC) -o $@ -buffer_get.o: buffer.h buffer_get.c byte.h compile error.h - ./compile buffer_get.c +utmpset: utmpset.o unix.a byte.a + @printf " [CCLD]\t\t$@\n" + ${SILENT}$(CC) $^ $(LDFLAGS) $(BUILD_STATIC) -o $@ -buffer_put.o: buffer.h buffer_put.c byte.h compile error.h str.h - ./compile buffer_put.c +runsvchdir: runsvchdir.o unix.a byte.a + @printf " [CCLD]\t\t$@\n" + ${SILENT}$(CC) $^ $(LDFLAGS) $(BUILD_STATIC) -o $@ -buffer_read.o: buffer.h buffer_read.c compile - ./compile buffer_read.c +svlogd: svlogd.o pmatch.o fmt_ptime.o unix.a byte.a time.a + @printf " [CCLD]\t\t$@\n" + ${SILENT}$(CC) $^ $(LDFLAGS) $(BUILD_STATIC) $(SOCKETLIB_LDFLAGS) -o $@ -buffer_write.o: buffer.h buffer_write.c compile - ./compile buffer_write.c +chpst: chpst.o uidgid.o unix.a byte.a + @printf " [CCLD]\t\t$@\n" + ${SILENT}$(CC) $^ $(LDFLAGS) $(BUILD_STATIC) -o $@ byte.a: byte_chr.o byte_copy.o byte_cr.o byte_diff.o byte_rchr.o \ -fmt_uint.o fmt_uint0.o fmt_ulong.o makelib scan_ulong.o str_chr.o \ +fmt_uint.o fmt_uint0.o fmt_ulong.o scan_ulong.o str_chr.o \ str_diff.o str_len.o str_start.o - ./makelib byte.a byte_chr.o byte_copy.o byte_cr.o byte_diff.o \ - byte_rchr.o fmt_uint.o fmt_uint0.o fmt_ulong.o scan_ulong.o str_chr.o \ - str_diff.o str_len.o str_start.o - -byte_chr.o: byte.h byte_chr.c compile - ./compile byte_chr.c - -byte_copy.o: byte.h byte_copy.c compile - ./compile byte_copy.c - -byte_cr.o: byte.h byte_cr.c compile - ./compile byte_cr.c - -byte_diff.o: byte.h byte_diff.c compile - ./compile byte_diff.c - -byte_rchr.o: byte.h byte_rchr.c compile - ./compile byte_rchr.c - -choose: choose.sh warn-auto.sh - rm -f choose - cat warn-auto.sh choose.sh \ - > choose - chmod 555 choose - -coe.o: coe.c coe.h compile - ./compile coe.c - -compile: conf-cc print-cc.sh warn-auto.sh - rm -f compile - sh print-cc.sh > compile - chmod 555 compile - -direntry.h: choose compile direntry.h1 direntry.h2 trydrent.c - ./choose c trydrent direntry.h1 direntry.h2 > direntry.h - -env.o: compile env.c env.h str.h - ./compile env.c - -error.o: compile error.c error.h - ./compile error.c - -error_str.o: compile error.h error_str.c - ./compile error_str.c - -fd_copy.o: compile fd.h fd_copy.c - ./compile fd_copy.c - -fd_move.o: compile fd.h fd_move.c - ./compile fd_move.c - -fifo.o: compile fifo.c fifo.h hasmkffo.h - ./compile fifo.c - -fmt_uint.o: compile fmt.h fmt_uint.c - ./compile fmt_uint.c - -fmt_uint0.o: compile fmt.h fmt_uint0.c - ./compile fmt_uint0.c - -fmt_ulong.o: compile fmt.h fmt_ulong.c - ./compile fmt_ulong.c - -hasflock.h: choose compile hasflock.h1 hasflock.h2 load tryflock.c - ./choose cl tryflock hasflock.h1 hasflock.h2 > hasflock.h - -hasmkffo.h: choose compile hasmkffo.h1 hasmkffo.h2 load trymkffo.c - ./choose cl trymkffo hasmkffo.h1 hasmkffo.h2 > hasmkffo.h - -hassgact.h: choose compile hassgact.h1 hassgact.h2 load trysgact.c - ./choose cl trysgact hassgact.h1 hassgact.h2 > hassgact.h - -hassgprm.h: choose compile hassgprm.h1 hassgprm.h2 load trysgprm.c - ./choose cl trysgprm hassgprm.h1 hassgprm.h2 > hassgprm.h + @printf " [AR]\t\t$@\n" + ${SILENT}$(AR) $@ $^ -haswaitp.h: choose compile haswaitp.h1 haswaitp.h2 load trywaitp.c - ./choose cl trywaitp haswaitp.h1 haswaitp.h2 > haswaitp.h - -iopause.o: compile iopause.c tai.h taia.h - ./compile iopause.c - -load: conf-ld print-ld.sh warn-auto.sh - rm -f load - sh print-ld.sh > load - chmod 555 load - -lock_ex.o: compile hasflock.h lock.h lock_ex.c - ./compile lock_ex.c - -lock_exnb.o: compile hasflock.h lock.h lock_exnb.c - ./compile lock_exnb.c - -makelib: print-ar.sh warn-auto.sh - rm -f makelib - sh print-ar.sh > makelib - chmod 555 makelib - -ndelay_off.o: compile ndelay.h ndelay_off.c - ./compile ndelay_off.c - -ndelay_on.o: compile ndelay.h ndelay_on.c - ./compile ndelay_on.c - -open_append.o: compile open.h open_append.c - ./compile open_append.c - -open_read.o: compile open.h open_read.c - ./compile open_read.c - -open_trunc.o: compile open.h open_trunc.c - ./compile open_trunc.c - -open_write.o: compile open.h open_write.c - ./compile open_write.c - -openreadclose.o: compile error.h gen_alloc.h open.h openreadclose.c \ -openreadclose.h readclose.h stralloc.h - ./compile openreadclose.c - -pathexec_env.o: alloc.h byte.h compile env.h gen_alloc.h pathexec.h \ -pathexec_env.c str.h stralloc.h - ./compile pathexec_env.c - -pathexec_run.o: compile env.h error.h gen_alloc.h pathexec.h \ -pathexec_run.c str.h stralloc.h - ./compile pathexec_run.c - -readclose.o: compile error.h gen_alloc.h readclose.c readclose.h \ -stralloc.h - ./compile readclose.c - -scan_ulong.o: compile scan.h scan_ulong.c - ./compile scan_ulong.c - -seek_set.o: compile seek.h seek_set.c - ./compile seek_set.c - -sgetopt.o: buffer.h compile sgetopt.c sgetopt.h subgetopt.h - ./compile sgetopt.c - -sig.o: compile sig.c sig.h - ./compile sig.c - -sig_block.o: compile hassgprm.h sig.h sig_block.c - ./compile sig_block.c - -sig_catch.o: compile hassgact.h sig.h sig_catch.c - ./compile sig_catch.c - -sig_pause.o: compile hassgprm.h sig.h sig_pause.c - ./compile sig_pause.c - -str_chr.o: compile str.h str_chr.c - ./compile str_chr.c - -str_diff.o: compile str.h str_diff.c - ./compile str_diff.c - -str_len.o: compile str.h str_len.c - ./compile str_len.c - -str_start.o: compile str.h str_start.c - ./compile str_start.c - -stralloc_cat.o: byte.h compile gen_alloc.h stralloc.h stralloc_cat.c - ./compile stralloc_cat.c - -stralloc_catb.o: byte.h compile gen_alloc.h stralloc.h \ -stralloc_catb.c - ./compile stralloc_catb.c - -stralloc_cats.o: byte.h compile gen_alloc.h str.h stralloc.h \ -stralloc_cats.c - ./compile stralloc_cats.c - -stralloc_eady.o: alloc.h compile gen_alloc.h gen_allocdefs.h \ -stralloc.h stralloc_eady.c - ./compile stralloc_eady.c - -stralloc_opyb.o: byte.h compile gen_alloc.h stralloc.h \ -stralloc_opyb.c - ./compile stralloc_opyb.c - -stralloc_opys.o: byte.h compile gen_alloc.h str.h stralloc.h \ -stralloc_opys.c - ./compile stralloc_opys.c - -stralloc_pend.o: alloc.h compile gen_alloc.h gen_allocdefs.h \ -stralloc.h stralloc_pend.c - ./compile stralloc_pend.c - -strerr_die.o: buffer.h compile strerr.h strerr_die.c - ./compile strerr_die.c - -strerr_sys.o: compile error.h strerr.h strerr_sys.c - ./compile strerr_sys.c - -subgetopt.o: compile subgetopt.c subgetopt.h - ./compile subgetopt.c - -sysdeps: compile direntry.h hasflock.h hasmkffo.h hassgact.h \ -hassgprm.h haswaitp.h load \ -reboot_system.h uw_tmp.h socket.lib - rm -f sysdeps - cat compile load socket.lib >>sysdeps - grep sysdep direntry.h >>sysdeps - grep sysdep haswaitp.h >>sysdeps - grep sysdep hassgact.h >>sysdeps - grep sysdep hassgprm.h >>sysdeps - grep sysdep hasmkffo.h >>sysdeps - grep sysdep hasflock.h >>sysdeps - grep sysdep reboot_system.h >>sysdeps - grep sysdep uw_tmp.h >>sysdeps - cat sysdeps - -tai_now.o: compile tai.h tai_now.c - ./compile tai_now.c - -tai_pack.o: compile tai.h tai_pack.c - ./compile tai_pack.c - -tai_sub.o: compile tai.h tai_sub.c - ./compile tai_sub.c - -tai_unpack.o: compile tai.h tai_unpack.c - ./compile tai_unpack.c - -taia_add.o: compile tai.h taia.h taia_add.c - ./compile taia_add.c - -taia_approx.o: compile tai.h taia.h taia_approx.c - ./compile taia_approx.c - -taia_frac.o: compile tai.h taia.h taia_frac.c - ./compile taia_frac.c - -taia_less.o: compile tai.h taia.h taia_less.c - ./compile taia_less.c - -taia_now.o: compile tai.h taia.h taia_now.c - ./compile taia_now.c - -taia_pack.o: compile tai.h taia.h taia_pack.c - ./compile taia_pack.c - -taia_sub.o: compile tai.h taia.h taia_sub.c - ./compile taia_sub.c - -taia_uint.o: compile tai.h taia.h taia_uint.c - ./compile taia_uint.c - -time.a: iopause.o makelib tai_now.o tai_pack.o tai_sub.o tai_unpack.o \ +time.a: iopause.o tai_now.o tai_pack.o tai_sub.o tai_unpack.o \ taia_add.o taia_approx.o taia_frac.o taia_less.o taia_now.o \ taia_pack.o taia_sub.o taia_uint.o - ./makelib time.a iopause.o tai_now.o tai_pack.o tai_sub.o \ - tai_unpack.o taia_add.o taia_approx.o taia_frac.o taia_less.o \ - taia_now.o taia_pack.o taia_sub.o taia_uint.o + @printf " [AR]\t\t$@\n" + ${SILENT}$(AR) $@ $^ unix.a: alloc.o alloc_re.o buffer.o buffer_0.o buffer_1.o buffer_2.o \ buffer_get.o buffer_put.o buffer_read.o buffer_write.o coe.o env.o \ error.o error_str.o fd_copy.o fd_move.o fifo.o lock_ex.o lock_exnb.o \ -makelib ndelay_off.o ndelay_on.o open_append.o open_read.o \ +ndelay_off.o ndelay_on.o open_append.o open_read.o \ open_trunc.o open_write.o openreadclose.o pathexec_env.o \ pathexec_run.o readclose.o seek_set.o sgetopt.o sig.o \ sig_block.o sig_catch.o sig_pause.o stralloc_cat.o stralloc_catb.o \ stralloc_cats.o stralloc_eady.o stralloc_opyb.o stralloc_opys.o \ stralloc_pend.o strerr_die.o strerr_sys.o subgetopt.o wait_nohang.o \ wait_pid.o - ./makelib unix.a alloc.o alloc_re.o buffer.o buffer_0.o buffer_1.o \ - buffer_2.o buffer_get.o buffer_put.o buffer_read.o buffer_write.o \ - coe.o env.o error.o error_str.o fd_copy.o fd_move.o fifo.o lock_ex.o \ - lock_exnb.o ndelay_off.o ndelay_on.o open_append.o open_read.o \ - open_trunc.o open_write.o openreadclose.o pathexec_env.o \ - pathexec_run.o readclose.o seek_set.o sgetopt.o sig.o \ - sig_block.o sig_catch.o sig_pause.o stralloc_cat.o stralloc_catb.o \ - stralloc_cats.o stralloc_eady.o stralloc_opyb.o stralloc_opys.o \ - stralloc_pend.o strerr_die.o strerr_sys.o subgetopt.o wait_nohang.o \ - wait_pid.o - -wait_nohang.o: compile haswaitp.h wait_nohang.c - ./compile wait_nohang.c + @printf " [AR]\t\t$@\n" + ${SILENT}$(AR) $@ $^ -wait_pid.o: compile error.h haswaitp.h wait_pid.c - ./compile wait_pid.c +%.o: %.c + @printf " [CC]\t\t$@\n" + ${SILENT}$(CC) $(CFLAGS) $(CPPFLAGS) -c $< diff --git a/src/TARGETS b/src/TARGETS deleted file mode 100644 index 1a2b719..0000000 --- a/src/TARGETS +++ /dev/null @@ -1,135 +0,0 @@ -runit -runit.o -runit-init -runit-init.o -runsv -runsv.o -runsvdir -runsvdir.o -runsvstat -runsvstat.o -runsvctrl -runsvctrl.o -sv -sv.o -svwaitdown -svwaitdown.o -svwaitup -svwaitup.o -utmpset -utmpset.o -runsvchdir -runsvchdir.o -svlogd -svlogd.o -chpst -chpst.o -pmatch.o -fmt_ptime.o -uidgid.o -reboot_system.h -uw_tmp.h -socket.lib -trysocketlib -trysocketlib.o -check -alloc.o -alloc_re.o -buffer.o -buffer_0.o -buffer_1.o -buffer_2.o -buffer_get.o -buffer_put.o -buffer_read.o -buffer_write.o -byte.a -byte_chr.o -byte_copy.o -byte_cr.o -byte_diff.o -byte_rchr.o -choose -coe.o -compile -direntry.h -env.o -error.o -error_str.o -fd_copy.o -fd_move.o -fifo.o -fmt_uint.o -fmt_uint0.o -fmt_ulong.o -hasflock.h -hasmkffo.h -hassgact.h -hassgprm.h -haswaitp.h -iopause.o -load -lock_ex.o -lock_exnb.o -makelib -ndelay_off.o -ndelay_on.o -open_append.o -open_read.o -open_trunc.o -open_write.o -openreadclose.o -pathexec_env.o -pathexec_run.o -readclose.o -scan_ulong.o -seek_set.o -sgetopt.o -sig.o -sig_block.o -sig_catch.o -sig_pause.o -str_chr.o -str_diff.o -str_len.o -str_start.o -stralloc_cat.o -stralloc_catb.o -stralloc_cats.o -stralloc_eady.o -stralloc_opyb.o -stralloc_opys.o -stralloc_pend.o -strerr_die.o -strerr_sys.o -subgetopt.o -sysdeps -tai_now.o -tai_pack.o -tai_sub.o -tai_unpack.o -taia_add.o -taia_approx.o -taia_frac.o -taia_less.o -taia_now.o -taia_pack.o -taia_sub.o -taia_uint.o -time.a -unix.a -wait_nohang.o -wait_pid.o -chpst.local -runit-init.local -runit.local -runsv.local -runsvchdir.local -runsvctrl.local -runsvdir.local -runsvstat.local -sv.local -svlogd.local -svwaitdown.local -svwaitup.local -utmpset.local diff --git a/src/choose.sh b/src/choose.sh deleted file mode 100644 index feff2da..0000000 --- a/src/choose.sh +++ /dev/null @@ -1,18 +0,0 @@ - -result="$4" - -case "$1" in - *c*) ./compile $2.c >/dev/null 2>&1 || result="$3" ;; -esac - -case "$1" in - *l*) ./load $2 >/dev/null 2>&1 || result="$3" ;; -esac - -case "$1" in - *r*) ./$2 >/dev/null 2>&1 || result="$3" ;; -esac - -rm -f $2.o $2 - -exec cat "$result" diff --git a/src/chpst.c b/src/chpst.c index 20bf027..86bc607 100644 --- a/src/chpst.c +++ b/src/chpst.c @@ -3,10 +3,12 @@ #include #include #include +#include #include "sgetopt.h" #include "error.h" #include "strerr.h" #include "str.h" +#include "strquote.h" #include "uidgid.h" #include "strerr.h" #include "scan.h" @@ -326,7 +328,7 @@ int main(int argc, const char **argv) { case '0': nostdin =1; break; case '1': nostdout =1; break; case '2': nostderr =1; break; - case 'V': strerr_warn1("$Id$", 0); + case 'V': strerr_warn1(STR(VERSION), 0); case '?': usage(); } argv +=optind; diff --git a/src/conf-cc b/src/conf-cc deleted file mode 100644 index 984024f..0000000 --- a/src/conf-cc +++ /dev/null @@ -1,5 +0,0 @@ -gcc -O2 -Wall - -gcc -O2 -Wimplicit -Wunused -Wcomment -Wchar-subscripts -Wuninitialized -Wshadow -Wcast-qual -Wcast-align -Wwrite-strings - -This will be used to compile .c files. diff --git a/src/conf-ld b/src/conf-ld deleted file mode 100644 index 59a0de7..0000000 --- a/src/conf-ld +++ /dev/null @@ -1,3 +0,0 @@ -gcc -s - -This will be used to link .o files into an executable. diff --git a/src/direntry.h1 b/src/direntry.h similarity index 63% rename from src/direntry.h1 rename to src/direntry.h index 6cb088d..cc61610 100644 --- a/src/direntry.h1 +++ b/src/direntry.h @@ -3,10 +3,18 @@ #ifndef DIRENTRY_H #define DIRENTRY_H -/* sysdep: -dirent */ - #include + +#ifdef HASDIRENT + +#include +#define direntry struct dirent + +#else + #include #define direntry struct direct #endif + +#endif diff --git a/src/direntry.h2 b/src/direntry.h2 deleted file mode 100644 index bfd4d19..0000000 --- a/src/direntry.h2 +++ /dev/null @@ -1,12 +0,0 @@ -/* Public domain. */ - -#ifndef DIRENTRY_H -#define DIRENTRY_H - -/* sysdep: +dirent */ - -#include -#include -#define direntry struct dirent - -#endif diff --git a/src/fifo.c b/src/fifo.c index c14f683..f3817a5 100644 --- a/src/fifo.c +++ b/src/fifo.c @@ -2,7 +2,6 @@ #include #include -#include "hasmkffo.h" #include "fifo.h" #ifdef HASMKFIFO diff --git a/src/hasflock.h1 b/src/hasflock.h1 deleted file mode 100644 index ac7dfc3..0000000 --- a/src/hasflock.h1 +++ /dev/null @@ -1,3 +0,0 @@ -/* Public domain. */ - -/* sysdep: -flock */ diff --git a/src/hasflock.h2 b/src/hasflock.h2 deleted file mode 100644 index 1878f64..0000000 --- a/src/hasflock.h2 +++ /dev/null @@ -1,4 +0,0 @@ -/* Public domain. */ - -/* sysdep: +flock */ -#define HASFLOCK 1 diff --git a/src/hasmkffo.h1 b/src/hasmkffo.h1 deleted file mode 100644 index a562451..0000000 --- a/src/hasmkffo.h1 +++ /dev/null @@ -1,3 +0,0 @@ -/* Public domain. */ - -/* sysdep: -mkfifo */ diff --git a/src/hasmkffo.h2 b/src/hasmkffo.h2 deleted file mode 100644 index 8ac8943..0000000 --- a/src/hasmkffo.h2 +++ /dev/null @@ -1,4 +0,0 @@ -/* Public domain. */ - -/* sysdep: +mkfifo */ -#define HASMKFIFO 1 diff --git a/src/hassgact.h1 b/src/hassgact.h1 deleted file mode 100644 index 7639d24..0000000 --- a/src/hassgact.h1 +++ /dev/null @@ -1,3 +0,0 @@ -/* Public domain. */ - -/* sysdep: -sigaction */ diff --git a/src/hassgact.h2 b/src/hassgact.h2 deleted file mode 100644 index 60ff776..0000000 --- a/src/hassgact.h2 +++ /dev/null @@ -1,4 +0,0 @@ -/* Public domain. */ - -/* sysdep: +sigaction */ -#define HASSIGACTION 1 diff --git a/src/hassgprm.h1 b/src/hassgprm.h1 deleted file mode 100644 index ef3eee9..0000000 --- a/src/hassgprm.h1 +++ /dev/null @@ -1,3 +0,0 @@ -/* Public domain. */ - -/* sysdep: -sigprocmask */ diff --git a/src/hassgprm.h2 b/src/hassgprm.h2 deleted file mode 100644 index be9d0d7..0000000 --- a/src/hassgprm.h2 +++ /dev/null @@ -1,4 +0,0 @@ -/* Public domain. */ - -/* sysdep: +sigprocmask */ -#define HASSIGPROCMASK 1 diff --git a/src/haswaitp.h1 b/src/haswaitp.h1 deleted file mode 100644 index 0d6f82c..0000000 --- a/src/haswaitp.h1 +++ /dev/null @@ -1,3 +0,0 @@ -/* Public domain. */ - -/* sysdep: -waitpid */ diff --git a/src/haswaitp.h2 b/src/haswaitp.h2 deleted file mode 100644 index 015413f..0000000 --- a/src/haswaitp.h2 +++ /dev/null @@ -1,4 +0,0 @@ -/* Public domain. */ - -/* sysdep: +waitpid */ -#define HASWAITPID 1 diff --git a/src/lock_ex.c b/src/lock_ex.c index b75a764..93487a8 100644 --- a/src/lock_ex.c +++ b/src/lock_ex.c @@ -3,7 +3,6 @@ #include #include #include -#include "hasflock.h" #include "lock.h" #ifdef HASFLOCK diff --git a/src/lock_exnb.c b/src/lock_exnb.c index 9ec2b9c..4691fd1 100644 --- a/src/lock_exnb.c +++ b/src/lock_exnb.c @@ -3,7 +3,6 @@ #include #include #include -#include "hasflock.h" #include "lock.h" #ifdef HASFLOCK diff --git a/src/print-ar.sh b/src/print-ar.sh deleted file mode 100644 index c31d937..0000000 --- a/src/print-ar.sh +++ /dev/null @@ -1,15 +0,0 @@ -cat warn-auto.sh -echo 'main="$1"; shift' -echo 'rm -f "$main"' -echo 'ar cr "$main" ${1+"$@"}' -kern="$(uname -s | tr '/:[A-Z]' '..[a-z])')-$(uname -r | tr /: ..)" || kern="unknown" -case $kern in - sunos-5.*) ;; - unix_sv*) ;; - irix64-*) ;; - irix-*) ;; - dgux-*) ;; - hp-ux-*) ;; - sco*) ;; - *) echo 'ranlib "$main"' ;; -esac diff --git a/src/print-cc.sh b/src/print-cc.sh deleted file mode 100644 index 1bf3e3e..0000000 --- a/src/print-cc.sh +++ /dev/null @@ -1,4 +0,0 @@ -cc="`head -n1 conf-cc`" - -cat warn-auto.sh -echo exec "$cc" '-c ${1+"$@"}' diff --git a/src/print-ld.sh b/src/print-ld.sh deleted file mode 100644 index 5f34bb8..0000000 --- a/src/print-ld.sh +++ /dev/null @@ -1,5 +0,0 @@ -ld="`head -n1 conf-ld`" - -cat warn-auto.sh -echo 'main="$1"; shift' -echo exec "$ld" '-o "$main" "$main".o ${1+"$@"}' diff --git a/src/reboot_system.h1 b/src/reboot_system.h1 deleted file mode 100644 index d4950c9..0000000 --- a/src/reboot_system.h1 +++ /dev/null @@ -1,8 +0,0 @@ -#include -#include - -/* sysdep: -std reboot */ - -int reboot_system(int what) { - return(reboot(what, (char *)0)); -} diff --git a/src/reboot_system.h2 b/src/reboot_system.h2 deleted file mode 100644 index b30d1e9..0000000 --- a/src/reboot_system.h2 +++ /dev/null @@ -1,8 +0,0 @@ -#include -#include - -/* sysdep: +std reboot */ - -int reboot_system(int what) { - return(reboot(what)); -} diff --git a/src/runit-init.c b/src/runit-init.c index f075d98..bf199ea 100644 --- a/src/runit-init.c +++ b/src/runit-init.c @@ -67,7 +67,7 @@ int main (int argc, const char * const *argv, char * const *envp) { break; case '-': if ((*argv)[1] == 'V') - strerr_warn1("$Id$\n", 0); + strerr_warn1(STR(VERSION), 0); default: usage(); } diff --git a/src/runit.c b/src/runit.c index d9168af..342dce8 100644 --- a/src/runit.c +++ b/src/runit.c @@ -14,7 +14,6 @@ #include "ndelay.h" #include "wait.h" #include "open.h" -#include "reboot_system.h" /* #define DEBUG */ @@ -22,10 +21,18 @@ #define WARNING "- runit: warning: " #define FATAL "- runit: fatal: " +static int reboot_system(int what) { + #ifdef HASONEARGREBOOT + return(reboot(what)); + #else + return(reboot(what, (char *)0)); + #endif +} + const char * const stage[3] ={ - "/etc/runit/1", - "/etc/runit/2", - "/etc/runit/3" }; + STR(SYSCONFDIR) "/runit/1", + STR(SYSCONFDIR) "/runit/2", + STR(SYSCONFDIR) "/runit/3" }; int selfpipe[2]; int sigc =0; @@ -86,7 +93,7 @@ int main (int argc, const char * const *argv, char * const *envp) { if (RB_DISABLE_CAD == 0) reboot_system(0); #endif - strerr_warn3(INFO, "$Id$", + strerr_warn3(INFO, STR(VERSION), ": booting.", 0); /* runit */ diff --git a/src/runit.h b/src/runit.h index ba98386..6e61a0c 100644 --- a/src/runit.h +++ b/src/runit.h @@ -1,4 +1,6 @@ -#define RUNIT "/sbin/runit" -#define STOPIT "/etc/runit/stopit" -#define REBOOT "/etc/runit/reboot" -#define CTRLALTDEL "/etc/runit/ctrlaltdel" +#include "strquote.h" + +#define RUNIT STR(SBINDIR) "/runit" +#define STOPIT STR(SYSCONFDIR) "/runit/stopit" +#define REBOOT STR(SYSCONFDIR) "/runit/reboot" +#define CTRLALTDEL STR(SYSCONFDIR) "/runit/ctrlaltdel" diff --git a/src/runsv.c b/src/runsv.c index ecf4677..c9a13df 100644 --- a/src/runsv.c +++ b/src/runsv.c @@ -22,8 +22,6 @@ #define USAGE " dir" -#define VERSION "$Id$" - char *progname; int selfpipe[2]; diff --git a/src/runsvchdir.c b/src/runsvchdir.c index 9bf17f7..51397eb 100644 --- a/src/runsvchdir.c +++ b/src/runsvchdir.c @@ -3,13 +3,12 @@ #include #include #include "strerr.h" +#include "strquote.h" #include "error.h" #include "buffer.h" #define USAGE " dir" -#define SVDIR "/etc/runit/runsvdir" - -#define VERSION "$Id$" +#define SVDIR STR(SYSCONFDIR) "/runit/runsvdir" char *progname; char *new; diff --git a/src/runsvctrl.c b/src/runsvctrl.c index ccf8fc8..4954ca5 100644 --- a/src/runsvctrl.c +++ b/src/runsvctrl.c @@ -5,8 +5,6 @@ #define USAGE " u|d|o|p|c|h|a|i|q|1|2|t|k|x|e service ..." -#define VERSION "$Id$" - #define FATAL "runsvctrl: fatal: " #define WARNING "runsvctrl: warning: " diff --git a/src/runsvdir.c b/src/runsvdir.c index 4cc7857..561093c 100644 --- a/src/runsvdir.c +++ b/src/runsvdir.c @@ -17,7 +17,6 @@ #include "ndelay.h" #define USAGE " [-P] dir" -#define VERSION "$Id$" #define MAXSERVICES 1000 diff --git a/src/runsvstat.c b/src/runsvstat.c index c17bbd3..baa387b 100644 --- a/src/runsvstat.c +++ b/src/runsvstat.c @@ -2,6 +2,7 @@ #include #include #include "strerr.h" +#include "strquote.h" #include "error.h" #include "sgetopt.h" #include "open.h" @@ -11,8 +12,6 @@ #define USAGE " [ -l ] service ..." -#define VERSION "$Id$" - #define FATAL "runsvstat: fatal: " #define WARNING "runsvstat: warning: " @@ -118,7 +117,7 @@ int main(int argc, char **argv) { showlog =1; break; case 'V': - strerr_warn1(VERSION, 0); + strerr_warn1(STR(VERSION), 0); case '?': usage(); } diff --git a/src/sig_block.c b/src/sig_block.c index a46c860..3db3a04 100644 --- a/src/sig_block.c +++ b/src/sig_block.c @@ -2,7 +2,6 @@ #include #include "sig.h" -#include "hassgprm.h" void sig_block(int sig) { diff --git a/src/sig_catch.c b/src/sig_catch.c index 7b5bd89..7297be0 100644 --- a/src/sig_catch.c +++ b/src/sig_catch.c @@ -2,7 +2,6 @@ #include #include "sig.h" -#include "hassgact.h" void sig_catch(int sig,void (*f)()) { diff --git a/src/sig_pause.c b/src/sig_pause.c index 3d1a793..551d670 100644 --- a/src/sig_pause.c +++ b/src/sig_pause.c @@ -2,7 +2,6 @@ #include #include "sig.h" -#include "hassgprm.h" void sig_pause(void) { diff --git a/src/strquote.h b/src/strquote.h new file mode 100644 index 0000000..d7be336 --- /dev/null +++ b/src/strquote.h @@ -0,0 +1,10 @@ +/* public domain */ + +#ifndef STRQUOTE_H +#define STRQUOTE_H + +// convenience macros for stringifying defined values +#define __QUOTE(v) #v +#define STR(v) __QUOTE(v) + +#endif diff --git a/src/sv.c b/src/sv.c index e076bd6..0f5b1e8 100644 --- a/src/sv.c +++ b/src/sv.c @@ -3,6 +3,7 @@ #include #include "str.h" #include "strerr.h" +#include "strquote.h" #include "error.h" #include "sgetopt.h" #include "open.h" @@ -17,8 +18,6 @@ #define USAGE " [-v] [-w sec] command service ..." #define USAGELSB " [-w sec] command" -#define VERSION "$Id$" - #define FATAL "fatal: " #define FAIL "fail: " #define WARN "warning: " @@ -32,7 +31,7 @@ char *progname; char *action; char *acts; -char *varservice ="/var/service/"; +char *varservice = STR(SERVICEDIR); char **service; char **servicex; unsigned int services; @@ -285,7 +284,7 @@ int main(int argc, char **argv) { switch(i) { case 'w': scan_ulong(optarg, &wait); case 'v': verbose =1; break; - case 'V': strerr_warn1(VERSION, 0); + case 'V': strerr_warn1(STR(VERSION), 0); case '?': usage(); } } diff --git a/src/svlogd.c b/src/svlogd.c index 8c68c73..aa0d978 100644 --- a/src/svlogd.c +++ b/src/svlogd.c @@ -14,6 +14,7 @@ #include "alloc.h" #include "stralloc.h" #include "strerr.h" +#include "strquote.h" #include "buffer.h" #include "sig.h" #include "env.h" @@ -35,7 +36,6 @@ #include "iopause.h" #define USAGE " [-ttv] [-r c] [-R abc] [-l len] [-b buflen] dir ..." -#define VERSION "$Id$" #define FATAL "svlogd: fatal: " #define WARNING "svlogd: warning: " @@ -693,7 +693,7 @@ int main(int argc, const char **argv) { case 'v': ++verbose; break; - case 'V': strerr_warn1(VERSION, 0); + case 'V': strerr_warn1(STR(VERSION), 0); case '?': usage(); } } diff --git a/src/svwaitdown.c b/src/svwaitdown.c index 6cd3efc..e3e744e 100644 --- a/src/svwaitdown.c +++ b/src/svwaitdown.c @@ -1,5 +1,6 @@ #include #include "strerr.h" +#include "strquote.h" #include "error.h" #include "sgetopt.h" #include "scan.h" @@ -12,8 +13,6 @@ #define INFO "svwaitdown: " #define USAGE " [-v] [-t 1..6000] service ..." -#define VERSION "$Id$" - const char *progname; const char * const *dir; unsigned int rc =0; @@ -57,7 +56,7 @@ int main(int argc, const char * const *argv) { verbose =1; break; case 'V': - strerr_warn1(VERSION, 0); + strerr_warn1(STR(VERSION), 0); case '?': usage(); } diff --git a/src/svwaitup.c b/src/svwaitup.c index e2d6c57..0d7eb0a 100644 --- a/src/svwaitup.c +++ b/src/svwaitup.c @@ -1,5 +1,6 @@ #include #include "strerr.h" +#include "strquote.h" #include "error.h" #include "sgetopt.h" #include "scan.h" @@ -50,7 +51,7 @@ int main(int argc, const char * const *argv) { verbose =1; break; case 'V': - strerr_warn1("$Id$", 0); + strerr_warn1(STR(VERSION), 0); case '?': usage(); } diff --git a/src/utmpset.c b/src/utmpset.c index 2011f1d..ddb8884 100644 --- a/src/utmpset.c +++ b/src/utmpset.c @@ -6,6 +6,7 @@ #include #include "uw_tmp.h" #include "strerr.h" +#include "strquote.h" #include "sgetopt.h" #include "seek.h" #include "str.h" @@ -97,7 +98,7 @@ int main (int argc, const char * const *argv, const char * const *envp) { wtmp =1; break; case 'V': - strerr_warn1("$Id$", 0); + strerr_warn1(STR(VERSION), 0); case '?': usage(); } diff --git a/src/uw_tmp.h1 b/src/uw_tmp.h similarity index 57% rename from src/uw_tmp.h1 rename to src/uw_tmp.h index 2d5e994..c668fc8 100644 --- a/src/uw_tmp.h1 +++ b/src/uw_tmp.h @@ -1,7 +1,24 @@ +#ifndef UW_TMP_H +#define UW_TMP_H + #include -#include -/* sysdep: -utmpx */ +#ifdef HASUTMPX + +#include + +#define UW_TMP_UFILE _UTMPX_FILE +#define UW_TMP_WFILE _WTMPX_FILE + +#ifndef ut_time +#define ut_time ut_tv.tv_sec +#endif + +typedef struct futmpx uw_tmp; + +#else + +#include #ifdef _PATH_UTMP #define UW_TMP_UFILE _PATH_UTMP @@ -17,3 +34,7 @@ #endif typedef struct utmp uw_tmp; + +#endif + +#endif diff --git a/src/uw_tmp.h2 b/src/uw_tmp.h2 deleted file mode 100644 index ae9542e..0000000 --- a/src/uw_tmp.h2 +++ /dev/null @@ -1,13 +0,0 @@ -#include -#include - -/* sysdep: +utmpx */ - -#define UW_TMP_UFILE _UTMPX_FILE -#define UW_TMP_WFILE _WTMPX_FILE - -#ifndef ut_time -#define ut_time ut_tv.tv_sec -#endif - -typedef struct futmpx uw_tmp; diff --git a/src/wait_nohang.c b/src/wait_nohang.c index 5c9c53d..bddd9a9 100644 --- a/src/wait_nohang.c +++ b/src/wait_nohang.c @@ -2,7 +2,6 @@ #include #include -#include "haswaitp.h" int wait_nohang(wstat) int *wstat; { diff --git a/src/wait_pid.c b/src/wait_pid.c index c2869b8..eb47630 100644 --- a/src/wait_pid.c +++ b/src/wait_pid.c @@ -3,7 +3,6 @@ #include #include #include "error.h" -#include "haswaitp.h" #ifdef HASWAITPID diff --git a/src/warn-auto.sh b/src/warn-auto.sh deleted file mode 100644 index 36d2313..0000000 --- a/src/warn-auto.sh +++ /dev/null @@ -1,2 +0,0 @@ -#!/bin/sh -# WARNING: This file was auto-generated. Do not edit! From 369880d1eaad3da4a094e2ec35d2a87dab661605 Mon Sep 17 00:00:00 2001 From: 0x5c Date: Sun, 2 Apr 2023 04:29:14 -0400 Subject: [PATCH 6/9] src/: remove long deprecated obsolete programs They were all deprecated in runit 1.3.2 (Dec 2005), replaced with sv and removed from the default targets of the makefile by 1.4.0 (Mar 2006), and fully undocumented by 1.5.1 (May 2006). This makes for a ~17 years deprecation notice, pretty good. --- src/Makefile | 16 ---- src/runsvctrl.c | 80 -------------------- src/runsvctrl.check | 23 ------ src/runsvctrl.dist | 8 -- src/runsvstat.c | 166 ---------------------------------------- src/runsvstat.check | 26 ------- src/runsvstat.dist | 12 --- src/svwaitdown.c | 176 ------------------------------------------- src/svwaitdown.check | 24 ------ src/svwaitdown.dist | 12 --- src/svwaitup.c | 127 ------------------------------- src/svwaitup.check | 28 ------- src/svwaitup.dist | 14 ---- 13 files changed, 712 deletions(-) delete mode 100644 src/runsvctrl.c delete mode 100755 src/runsvctrl.check delete mode 100644 src/runsvctrl.dist delete mode 100644 src/runsvstat.c delete mode 100755 src/runsvstat.check delete mode 100644 src/runsvstat.dist delete mode 100644 src/svwaitdown.c delete mode 100755 src/svwaitdown.check delete mode 100644 src/svwaitdown.dist delete mode 100644 src/svwaitup.c delete mode 100755 src/svwaitup.check delete mode 100644 src/svwaitup.dist diff --git a/src/Makefile b/src/Makefile index 5b660a8..e7ee715 100644 --- a/src/Makefile +++ b/src/Makefile @@ -34,26 +34,10 @@ runsvdir: runsvdir.o unix.a byte.a time.a @printf " [CCLD]\t\t$@\n" ${SILENT}$(CC) $^ $(LDFLAGS) $(BUILD_STATIC) -o $@ -runsvstat: runsvstat.o unix.a byte.a time.a - @printf " [CCLD]\t\t$@\n" - ${SILENT}$(CC) $^ $(LDFLAGS) $(BUILD_STATIC) -o $@ - -runsvctrl: runsvctrl.o unix.a byte.a - @printf " [CCLD]\t\t$@\n" - ${SILENT}$(CC) $^ $(LDFLAGS) $(BUILD_STATIC) -o $@ - sv: sv.o unix.a byte.a time.a @printf " [CCLD]\t\t$@\n" ${SILENT}$(CC) $^ $(LDFLAGS) $(BUILD_STATIC) -o $@ -svwaitup: svwaitup.o unix.a byte.a time.a - @printf " [CCLD]\t\t$@\n" - ${SILENT}$(CC) $^ $(LDFLAGS) $(BUILD_STATIC) -o $@ - -svwaitdown: svwaitdown.o unix.a byte.a time.a - @printf " [CCLD]\t\t$@\n" - ${SILENT}$(CC) $^ $(LDFLAGS) $(BUILD_STATIC) -o $@ - utmpset: utmpset.o unix.a byte.a @printf " [CCLD]\t\t$@\n" ${SILENT}$(CC) $^ $(LDFLAGS) $(BUILD_STATIC) -o $@ diff --git a/src/runsvctrl.c b/src/runsvctrl.c deleted file mode 100644 index 4954ca5..0000000 --- a/src/runsvctrl.c +++ /dev/null @@ -1,80 +0,0 @@ -#include -#include "strerr.h" -#include "error.h" -#include "open.h" - -#define USAGE " u|d|o|p|c|h|a|i|q|1|2|t|k|x|e service ..." - -#define FATAL "runsvctrl: fatal: " -#define WARNING "runsvctrl: warning: " - -char *progname; -unsigned int rc =0; - -void usage() { strerr_die4x(1, "usage: ", progname, USAGE, "\n"); } - -void fatal(char *m1) { strerr_die3sys(111, FATAL, m1, ": "); } -void warn(char *m1, char *m2) { - rc++; - strerr_warn5(WARNING, m1, ": ", m2, ": ", &strerr_sys); -} -void warnx(char *m1, char *m2) { - rc++; - strerr_warn4(WARNING, m1, ": ", m2, 0); -} - -int ctrl(char *name, char c) { - int fd; - - if ((fd =open_write("supervise/control")) == -1) { - if (errno == error_nodevice) - warnx(name, "runsv not running."); - else - warn(name, "unable to open supervise/control"); - return(-1); - } - if (write(fd, &c, 1) != 1) { - warn(name, "unable to write to supervise/control"); - return(-1); - } - return(1); -} - -int main(int argc, char **argv) { - char **dir; - int curdir; - char c; - - progname =*argv++; - - if (! argv || ! *argv) usage(); - - switch ((c =**argv)) { - case 'e': c ='x'; - case 'u': case 'd': case 'o': case 'x': case 'p': case 'c': case 'h': - case 'a': case 'i': case 't': case 'k': case 'q': case '1': case '2': - break; - default: - usage(); - } - dir =++argv; - if (! dir || ! *dir) usage(); - - if ((curdir =open_read(".")) == -1) { - rc =100; - fatal("unable to open current directory"); - } - for (; dir && *dir; dir++) { - if (chdir(*dir) == -1) { - warn(*dir, "unable to change directory"); - continue; - } - ctrl(*dir, c); - if (fchdir(curdir) == -1) { - rc =100; - fatal("unable to change directory"); - } - } - if (rc > 100) rc =100; - _exit(rc); -} diff --git a/src/runsvctrl.check b/src/runsvctrl.check deleted file mode 100755 index 7911074..0000000 --- a/src/runsvctrl.check +++ /dev/null @@ -1,23 +0,0 @@ -#!/bin/sh -rm -rf "${ctmp}" - -runsvctrl -echo $? - -mkdir "${ctmp}" -echo '#!/bin/sh' >"${ctmp}"/run -echo 'echo starting' >>"${ctmp}"/run -echo 'exec sleep 14' >>"${ctmp}"/run -chmod 700 "${ctmp}"/run -runsv "${ctmp}" & -sleep 1 -test -r "${ctmp}"/supervise/stat || sleep 2 -runsvctrl down "${ctmp}" -echo $? -sleep 1 -cat "${ctmp}"/supervise/stat -runsvctrl exit "${ctmp}" -echo $? -wait -echo $? -rm -rf "${ctmp}" diff --git a/src/runsvctrl.dist b/src/runsvctrl.dist deleted file mode 100644 index b07cf8a..0000000 --- a/src/runsvctrl.dist +++ /dev/null @@ -1,8 +0,0 @@ -usage: runsvctrl u|d|o|p|c|h|a|i|q|1|2|t|k|x|e service ... - -1 -starting -0 -down -0 -0 diff --git a/src/runsvstat.c b/src/runsvstat.c deleted file mode 100644 index baa387b..0000000 --- a/src/runsvstat.c +++ /dev/null @@ -1,166 +0,0 @@ -#include -#include -#include -#include "strerr.h" -#include "strquote.h" -#include "error.h" -#include "sgetopt.h" -#include "open.h" -#include "buffer.h" -#include "tai.h" -#include "fmt.h" - -#define USAGE " [ -l ] service ..." - -#define FATAL "runsvstat: fatal: " -#define WARNING "runsvstat: warning: " - -const char *progname; -unsigned int rc =0; -struct stat s; -int showlog =0; - -void usage() { strerr_die4x(1, "usage: ", progname, USAGE, "\n"); } - -void fatal(char *m1) { strerr_die3sys(111, FATAL, m1, ": "); } -void warn(char *m1, char *m2) { - rc++; - strerr_warn5(WARNING, m1, ": ", m2, ": ", &strerr_sys); -} -void warnx(char *m1, char *m2) { - rc++; - strerr_warn4(WARNING, m1, ": ", m2, 0); -} - -int show_status(char *name) { - char status[20]; - int pid; - int fd; - int normallyup =0; - char sulong[FMT_ULONG]; - struct tai when; - struct tai now; - - if (stat("down", &s) == -1) { - if (errno != error_noent) { - warn(name, "unable to stat down"); - return(-1); - } - normallyup = 1; - } - if ((fd =open_write("supervise/ok")) == -1) { - if (errno == error_nodevice) - warnx(name, "runsv not running."); - else - warn(name, "unable to open supervise/ok"); - return(-1); - } - close(fd); - if ((fd =open_read("supervise/status")) == -1) { - warn(name, "unable to open supervise/status"); - return(-1); - } - switch(read(fd, status, 20)) { - case 20: break; - case -1: - warn(name, "unable to read supervise/status"); - return(-1); - default: - warnx(name, "unable to read supervise/status: bad format."); - return(-1); - } - pid =(unsigned char) status[15]; - pid <<=8; pid +=(unsigned char)status[14]; - pid <<=8; pid +=(unsigned char)status[13]; - pid <<=8; pid +=(unsigned char)status[12]; - - tai_unpack(status,&when); - tai_now(&now); - if (tai_less(&now,&when)) when =now; - tai_sub(&when,&now,&when); - - buffer_puts(buffer_1, name); - buffer_puts(buffer_1, ": "); - if (pid) { - switch (status[19]) { - case 1: buffer_puts(buffer_1, "run "); break; - case 2: buffer_puts(buffer_1, "finish "); break; - } - buffer_puts(buffer_1, "(pid "); - buffer_put(buffer_1, sulong, fmt_ulong(sulong, pid)); - buffer_puts(buffer_1, ") "); - } - else - buffer_puts(buffer_1, "down "); - buffer_put(buffer_1, sulong, fmt_ulong(sulong, tai_approx(&when))); - buffer_puts(buffer_1, " seconds"); - if (pid && !normallyup) buffer_puts(buffer_1,", normally down"); - if (!pid && normallyup) buffer_puts(buffer_1,", normally up"); - if (pid && status[16]) buffer_puts(buffer_1,", paused"); - if (!pid && (status[17] == 'u')) buffer_puts(buffer_1,", want up"); - if (pid && (status[17] == 'd')) buffer_puts(buffer_1,", want down"); - if (pid && status[18]) buffer_puts(buffer_1, ", got TERM"); - /* buffer_putsflush(buffer_1, "\n"); */ - return(1); -} - -int main(int argc, char **argv) { - int opt; - int curdir; - char **dir; - - progname =*argv; - - while ((opt =getopt(argc, (const char * const *)argv, "lV")) != opteof) { - switch(opt) { - case 'l': - showlog =1; - break; - case 'V': - strerr_warn1(STR(VERSION), 0); - case '?': - usage(); - } - } - argv +=optind; - - dir =argv; - if (! dir || ! *dir) usage(); - - if ((curdir =open_read(".")) == -1) { - rc =100; - fatal("unable to open current directory"); - } - for (; dir && *dir; dir++) { - if (chdir(*dir) == -1) { - warn(*dir, "unable to change directory"); - continue; - } - if (show_status(*dir) == 1) { - if (showlog) { - if (stat("log", &s) == -1) { - if (errno != error_noent) - warn("unable to stat()", "./log"); - } - else { - if (! S_ISDIR(s.st_mode)) - warnx("./log", "not a directory."); - else { - if (chdir("log") == -1) { - warn(*dir, "unable to change directory"); - continue; - } - show_status("\n log"); - } - } - } - buffer_puts(buffer_1, "\n"); buffer_flush(buffer_1); - } - if (fchdir(curdir) == -1) { - rc =100; - fatal("unable to change directory"); - } - } - if (rc > 100) rc =100; - _exit(rc); -} diff --git a/src/runsvstat.check b/src/runsvstat.check deleted file mode 100755 index 6ccde11..0000000 --- a/src/runsvstat.check +++ /dev/null @@ -1,26 +0,0 @@ -#!/bin/sh -rm -rf "${ctmp}" - -runsvstat -echo $? -runsvstat -V -echo $? - -mkdir "${ctmp}" -echo '#!/bin/sh' >"${ctmp}"/run -echo 'echo starting' >>"${ctmp}"/run -echo 'exec sleep 14' >>"${ctmp}"/run -chmod 700 "${ctmp}"/run -chpst -2 runsvstat "${ctmp}" -echo $? -runsv "${ctmp}" & -sleep 1 -test -r "${ctmp}"/supervise/stat || sleep 2 -chpst -1 runsvstat "${ctmp}" -echo $? -runsvctrl exit "${ctmp}" -wait -echo $? -chpst -2 runsvstat "${ctmp}" -echo $? -rm -rf "${ctmp}" diff --git a/src/runsvstat.dist b/src/runsvstat.dist deleted file mode 100644 index 24b9ed4..0000000 --- a/src/runsvstat.dist +++ /dev/null @@ -1,12 +0,0 @@ -usage: runsvstat [ -l ] service ... - -1 -$Id$ -usage: runsvstat [ -l ] service ... - -1 -1 -starting -0 -0 -1 diff --git a/src/svwaitdown.c b/src/svwaitdown.c deleted file mode 100644 index e3e744e..0000000 --- a/src/svwaitdown.c +++ /dev/null @@ -1,176 +0,0 @@ -#include -#include "strerr.h" -#include "strquote.h" -#include "error.h" -#include "sgetopt.h" -#include "scan.h" -#include "open.h" -#include "tai.h" -#include "buffer.h" - -#define FATAL "svwaitdown: fatal: " -#define WARN "svwaitdown: warning: " -#define INFO "svwaitdown: " -#define USAGE " [-v] [-t 1..6000] service ..." - -const char *progname; -const char * const *dir; -unsigned int rc =0; - -void fatal(const char *m) { strerr_die3sys(111, FATAL, m, ": "); } -void warn(const char *s1, const char *s2, struct strerr *e) { - dir++; rc++; - strerr_warn3(WARN, s1, s2, e); -} -void usage() { strerr_die4x(1, "usage: ", progname, USAGE, "\n"); } - -int main(int argc, const char * const *argv) { - int opt; - unsigned long sec =600; - int verbose =0; - int doexit =0; - int dokill =0; - int wdir; - int fd; - char status[20]; - int r; - unsigned long pid; - struct tai start; - struct tai now; - - progname =*argv; - - while ((opt =getopt(argc, argv, "t:xkvV")) != opteof) { - switch(opt) { - case 't': - scan_ulong(optarg, &sec); - if ((sec < 1) || (sec > 6000)) usage(); - break; - case 'x': - doexit =1; - break; - case 'k': - dokill =1; - break; - case 'v': - verbose =1; - break; - case 'V': - strerr_warn1(STR(VERSION), 0); - case '?': - usage(); - } - } - argv +=optind; - if (! argv || ! *argv) usage(); - - if ((wdir =open_read(".")) == -1) - fatal("unable to open current working directory"); - - for (dir =argv; *dir; ++dir) { - if (dir != argv) - if (fchdir(wdir) == -1) fatal("unable to switch to starting directory"); - if (chdir(*dir) == -1) continue; /* bummer */ - if ((fd =open_write("supervise/control")) == -1) continue; /* bummer */ - if (write(fd, "dx", 1 +doexit) != (1 +doexit)) { - close(fd); continue; /* bummer */ - } - close(fd); - } - dir =argv; - - tai_now(&start); - while (*dir) { - if (fchdir(wdir) == -1) fatal("unable to switch to starting directory"); - if (chdir(*dir) == -1) { - warn(*dir, ": unable to change directory: ", &strerr_sys); - continue; - } - if ((fd =open_write("supervise/ok")) == -1) { - if (errno == error_nodevice) { - if (verbose) strerr_warn3(INFO, *dir, ": runsv not running.", 0); - dir++; - } - else - warn(*dir, ": unable to open supervise/ok: ", &strerr_sys); - continue; - } - close(fd); - - if ((fd =open_read("supervise/status")) == -1) { - warn(*dir, "unable to open supervise/status: ", &strerr_sys); - continue; - } - r =buffer_unixread(fd, status, 20); - close(fd); - if ((r < 18) || (r == 19)) { /* supervise compatibility */ - if (r == -1) - warn(*dir, "unable to read supervise/status: ", &strerr_sys); - else - warn(*dir, ": unable to read supervise/status: bad format.", 0); - continue; - } - pid =(unsigned char)status[15]; - pid <<=8; pid +=(unsigned char)status[14]; - pid <<=8; pid +=(unsigned char)status[13]; - pid <<=8; pid +=(unsigned char)status[12]; - - if (! doexit && ! pid) { - /* ok, service is down */ - if (verbose) strerr_warn3(INFO, *dir, ": down.", 0); - dir++; - continue; - } - - if (status[17] != 'd') { /* catch previous failures */ - if ((fd =open_write("supervise/control")) == -1) { - warn(*dir, ": unable to open supervise/control: ", &strerr_sys); - continue; - } - if (write(fd, "dx", 1 +doexit) != (1 +doexit)) { - warn(*dir, ": unable to write to supervise/control: ", &strerr_sys); - close(fd); - continue; - } - close(fd); - } - - tai_now(&now); - tai_sub(&now, &now, &start); - if (tai_approx(&now) >= sec) { - /* timeout */ - if (verbose) strerr_warn2(INFO, "timeout.", 0); - if (dokill) { - if (chdir(*dir) == -1) { - warn(*dir, ": unable to change directory: ", &strerr_sys); - continue; - } - if ((fd =open_write("supervise/control")) == -1) { - if (errno == error_nodevice) { - if (verbose) - strerr_warn3(INFO, *dir, ": runsv not running.", 0); - dir++; - } - else - warn(*argv, ": unable to open supervise/control: ", &strerr_sys); - continue; - } - if (write(fd, "k", 1) != 1) - warn(*argv, ": unable to write to supervise/control: ", &strerr_sys); - else - strerr_warn3(INFO, *dir, ": killed.", 0); - close(fd); - dir++; - if (! *dir) _exit(111); - continue; - } - _exit(111); - } - sleep(1); - } - if (fchdir(wdir) == -1) - strerr_warn2(WARN, "unable to switch to starting directory: ", &strerr_sys); - close(wdir); - if (rc > 100) rc =100; - _exit(rc); -} diff --git a/src/svwaitdown.check b/src/svwaitdown.check deleted file mode 100755 index 5cf6c21..0000000 --- a/src/svwaitdown.check +++ /dev/null @@ -1,24 +0,0 @@ -#!/bin/sh -rm -rf "${ctmp}" - -svwaitdown -echo $? -svwaitdown -V -echo $? - -mkdir "${ctmp}" -echo '#!/bin/sh' >"${ctmp}"/run -echo 'echo starting' >>"${ctmp}"/run -echo 'exec sleep 14' >>"${ctmp}"/run -chmod 700 "${ctmp}"/run -runsv "${ctmp}" & -sleep 1 -test -r "${ctmp}"/supervise/stat || sleep 2 -svwaitdown "${ctmp}" -echo $? -svwaitdown -x "${ctmp}" -echo $? -cat "${ctmp}"/supervise/stat -wait -echo $? -rm -rf "${ctmp}" diff --git a/src/svwaitdown.dist b/src/svwaitdown.dist deleted file mode 100644 index 2d83839..0000000 --- a/src/svwaitdown.dist +++ /dev/null @@ -1,12 +0,0 @@ -usage: svwaitdown [-v] [-t 1..6000] service ... - -1 -$Id$ -usage: svwaitdown [-v] [-t 1..6000] service ... - -1 -starting -0 -0 -down -0 diff --git a/src/svwaitup.c b/src/svwaitup.c deleted file mode 100644 index 0d7eb0a..0000000 --- a/src/svwaitup.c +++ /dev/null @@ -1,127 +0,0 @@ -#include -#include "strerr.h" -#include "strquote.h" -#include "error.h" -#include "sgetopt.h" -#include "scan.h" -#include "open.h" -#include "tai.h" -#include "buffer.h" -#include "fmt.h" - -#define FATAL "svwaitup: fatal: " -#define WARN "svwaitup: warning: " -#define INFO "svwaitup: " -#define USAGE " [-v] [-s 1..600] service ..." - -const char *progname; -unsigned long sec =2; -unsigned int rc =0; -const char * const *dir; - -void fatal(const char *m) { strerr_die3sys(111, FATAL, m, ": "); } -void warn(const char *s1, const char *s2, struct strerr *e) { - dir++; rc++; - strerr_warn3(WARN, s1, s2, e); -} -void usage() { strerr_die4x(1, "usage: ", progname, USAGE, "\n"); } - -int main(int argc, const char * const *argv) { - int opt; - int verbose =0; - char status[18]; - int fd; - int is; - int r; - int wdir; - unsigned long pid; - struct tai when; - struct tai now; - char sulong[FMT_ULONG]; - - progname =*argv; - - while ((opt =getopt(argc, argv, "s:vV")) != opteof) { - switch(opt) { - case 's': - scan_ulong(optarg, &sec); - if ((sec < 1) || (sec > 600)) usage(); - break; - case 'v': - verbose =1; - break; - case 'V': - strerr_warn1(STR(VERSION), 0); - case '?': - usage(); - } - } - argv +=optind; - if (! argv || ! *argv) usage(); - - if ((wdir =open_read(".")) == -1) - fatal("unable to open current working directory"); - - dir =argv; - while (*dir) { - if (dir != argv) - if (fchdir(wdir) == -1) fatal("unable to switch to starting directory"); - if (chdir(*dir) == -1) { - warn(*dir, ": unable to change directory: ", &strerr_sys); - continue; - } - if ((fd =open_write("supervise/ok")) == -1) { - if (errno == error_nodevice) - warn(*dir, ": runsv not running.", 0); - else - warn(*dir, ": unable to open supervise/ok: ", &strerr_sys); - continue; - } - close(fd); - - if ((fd =open_read("supervise/status")) == -1) { - warn(*dir, "unable to open supervise/status: ", &strerr_sys); - continue; - } - r =buffer_unixread(fd, status, sizeof status); - close(fd); - if (r < sizeof status) { - if (r == -1) - warn(*dir, "unable to read supervise/status: ", &strerr_sys); - else - warn(*dir, ": unable to read supervise/status: bad format.", 0); - continue; - } - - pid =(unsigned char)status[15]; - pid <<=8; pid +=(unsigned char)status[14]; - pid <<=8; pid +=(unsigned char)status[13]; - pid <<=8; pid +=(unsigned char)status[12]; - if (! pid) { - warn(*dir, ": is down.", 0); - continue; - } - - tai_unpack(status, &when); - tai_now(&now); - if (tai_less(&now, &when)) when =now; - tai_sub(&when, &now, &when); - is =tai_approx(&when); - - if (is >= sec) { - /* ok */ - if (verbose) { - sulong[fmt_ulong(sulong, is)] =0; - strerr_warn5(INFO, *dir, ": is up (", sulong, " seconds)", 0); - } - dir++; - continue; - } - sleep(sec -is); - } - if (fchdir(wdir) == -1) - strerr_warn2(WARN, "unable to switch to starting directory: ", &strerr_sys); - close(wdir); - if (rc > 100) rc =100; - _exit(rc); -} diff --git a/src/svwaitup.check b/src/svwaitup.check deleted file mode 100755 index a1be802..0000000 --- a/src/svwaitup.check +++ /dev/null @@ -1,28 +0,0 @@ -#!/bin/sh -rm -rf "${ctmp}" - -svwaitup -echo $? -svwaitup -V -echo $? - -mkdir "${ctmp}" -echo '#!/bin/sh' >"${ctmp}"/run -echo 'echo starting' >>"${ctmp}"/run -echo 'exec sleep 14' >>"${ctmp}"/run -chmod 700 "${ctmp}"/run -runsv "${ctmp}" & -sleep 1 -test -r "${ctmp}"/supervise/stat || sleep 2 -svwaitup "${ctmp}" -echo $? -cat "${ctmp}"/supervise/stat -svwaitup -s2 "${ctmp}" -echo $? -cat "${ctmp}"/supervise/stat -runsvctrl exit "${ctmp}" -wait -echo $? -chpst -2 svwaitup -s2 "${ctmp}" -echo $? -rm -rf "${ctmp}" diff --git a/src/svwaitup.dist b/src/svwaitup.dist deleted file mode 100644 index 692990f..0000000 --- a/src/svwaitup.dist +++ /dev/null @@ -1,14 +0,0 @@ -usage: svwaitup [-v] [-s 1..600] service ... - -1 -$Id$ -usage: svwaitup [-v] [-s 1..600] service ... - -1 -starting -0 -run -0 -run -0 -1 From 487f6c9f01eb299b390eed71d4d10c9fe4d96174 Mon Sep 17 00:00:00 2001 From: 0x5c Date: Tue, 4 Apr 2023 03:53:57 -0400 Subject: [PATCH 7/9] tests: unbork Many of the tests were broken from expecting a specific ~~version~~ commit hash string in the command output (the $Id$ stuff). Another was broken by a new argument added by void. --- .gitignore | 3 +++ src/Makefile | 2 +- src/chpst.check | 2 -- src/chpst.dist | 6 +----- src/sv.check | 2 -- src/sv.dist | 4 ---- src/svlogd.check | 2 -- src/svlogd.dist | 4 ---- src/utmpset.check | 2 -- src/utmpset.dist | 4 ---- 10 files changed, 5 insertions(+), 26 deletions(-) diff --git a/.gitignore b/.gitignore index 30b95d8..2cf0ebf 100644 --- a/.gitignore +++ b/.gitignore @@ -25,3 +25,6 @@ src/utmpset # Generated completions sv.bash sv.zsh + +# Test output +src/*.local diff --git a/src/Makefile b/src/Makefile index e7ee715..2c46c55 100644 --- a/src/Makefile +++ b/src/Makefile @@ -16,7 +16,7 @@ install: all done clean: - rm -f *.o *.a $(PROGS) + rm -f *.o *.a $(PROGS) *.local runit: runit.o unix.a byte.a @printf " [CCLD]\t\t$@\n" diff --git a/src/chpst.check b/src/chpst.check index 384113e..4510693 100755 --- a/src/chpst.check +++ b/src/chpst.check @@ -3,8 +3,6 @@ rm -rf "${ctmp}" chpst echo $? -chpst -V -echo $? # -u # -U diff --git a/src/chpst.dist b/src/chpst.dist index 6779bfd..bfeaa11 100644 --- a/src/chpst.dist +++ b/src/chpst.dist @@ -1,8 +1,4 @@ -usage: chpst [-vP012] [-u user[:group]] [-U user[:group]] [-b argv0] [-e dir] [-/ root] [-n nice] [-l|-L lock] [-m n] [-d n] [-o n] [-p n] [-f n] [-c n] prog - -100 -$Id: f279d44141c981dd7535a12260efcf1ef7beed26 $ -usage: chpst [-vP012] [-u user[:group]] [-U user[:group]] [-b argv0] [-e dir] [-/ root] [-n nice] [-l|-L lock] [-m n] [-d n] [-o n] [-p n] [-f n] [-c n] prog +usage: chpst [-vP012] [-u user[:group]] [-U user[:group]] [-b argv0] [-e dir] [-/ root] [-C pwd] [-n nice] [-l|-L lock] [-m n] [-d n] [-o n] [-p n] [-f n] [-c n] prog 100 test=1 diff --git a/src/sv.check b/src/sv.check index d3c277c..a778719 100755 --- a/src/sv.check +++ b/src/sv.check @@ -4,8 +4,6 @@ trap 'rm -rf "${ctmp}"' EXIT sv echo $? -sv -V -echo $? mkdir "${ctmp}" cat >"${ctmp}"/run <<-\EOT diff --git a/src/sv.dist b/src/sv.dist index 5b6c3ee..d0d86ca 100644 --- a/src/sv.dist +++ b/src/sv.dist @@ -1,9 +1,5 @@ usage: sv [-v] [-w sec] command service ... -100 -$Id: 900314260c6d52c986c5357673bea2f3bd3f4698 $ -usage: sv [-v] [-w sec] command service ... - 100 starting 0 diff --git a/src/svlogd.check b/src/svlogd.check index 7d926ef..383f930 100755 --- a/src/svlogd.check +++ b/src/svlogd.check @@ -3,8 +3,6 @@ rm -rf "${ctmp}" svlogd echo $? -svlogd -V -echo $? mkdir "${ctmp}" echo foo |svlogd "${ctmp}" diff --git a/src/svlogd.dist b/src/svlogd.dist index b3329e6..d29b1e6 100644 --- a/src/svlogd.dist +++ b/src/svlogd.dist @@ -1,9 +1,5 @@ usage: svlogd [-ttv] [-r c] [-R abc] [-l len] [-b buflen] dir ... -111 -$Id: 5e55a90e0a1b35ec47fed3021453c50675ea1117 $ -usage: svlogd [-ttv] [-r c] [-R abc] [-l len] [-b buflen] dir ... - 111 0 foo diff --git a/src/utmpset.check b/src/utmpset.check index 51cf1a4..f68f01f 100755 --- a/src/utmpset.check +++ b/src/utmpset.check @@ -1,5 +1,3 @@ #!/bin/sh utmpset echo $? -utmpset -V -echo $? diff --git a/src/utmpset.dist b/src/utmpset.dist index d5c0370..2340829 100644 --- a/src/utmpset.dist +++ b/src/utmpset.dist @@ -1,7 +1,3 @@ usage: utmpset [-w] line 1 -$Id: cb399098f794012a7f5e6a3a7090b2d53b86c08c $ -usage: utmpset [-w] line - -1 From 4fc3e920c0e8e00124dd01673a10ea1d711ae135 Mon Sep 17 00:00:00 2001 From: 0x5c Date: Thu, 13 Apr 2023 22:03:11 -0400 Subject: [PATCH 8/9] configure: get rid of funky mechanism to find $AR The unixes where the special case mattered are so niche nowadays that it seems reasonable to change the value of $AR only if it is provided to configure. --- configure | 19 +++---------------- 1 file changed, 3 insertions(+), 16 deletions(-) diff --git a/configure b/configure index 1ac5318..bb37325 100755 --- a/configure +++ b/configure @@ -111,7 +111,10 @@ else echo "Using compiler $CC" fi +: "${AR:=ar crs}" + echo "CC = $CC" >>$CONFIG_MK +echo "AR = $AR" >> $CONFIG_MK echo "CFLAGS = -O2" >>$CONFIG_MK echo "CPPFLAGS += -D_DEFAULT_SOURCE" >>$CONFIG_MK @@ -224,22 +227,6 @@ if [ "$CC" = "tcc" ]; then echo "CFLAGS += -Wno-error" >>$CONFIG_MK fi -# XXX: this whole mechanism reeks of trying to one-up the system's toolchain, -# but it's the one that was there and I'm not sure what are the implications -kern="$(uname -s | tr '/:[A-Z]' '..[a-z])')-$(uname -r | tr /: ..)" || kern="unknown" -AR="ar cr" -case $kern in - sunos-5.*) ;; - unix_sv*) ;; - irix64-*) ;; - irix-*) ;; - dgux-*) ;; - hp-ux-*) ;; - sco*) ;; - *) AR="ar crs" ;; -esac -echo "AR = $AR" >> $CONFIG_MK - # # Check for flock(). # From f41fb8ad2aec77707efa924327acbd00cd5fdf96 Mon Sep 17 00:00:00 2001 From: 0x5c Date: Thu, 13 Apr 2023 22:11:18 -0400 Subject: [PATCH 9/9] configure: remove obsolete test for socket.h link args ~~~ runit 0.13.1 Mon, 19 Jan 2004 18:32:58 +0000 * trysocketlib.c: new; check for libraries needed for socket() on some systems (fixes link failure on solaris, thx Uffe Jakobsen). ~~~ 19 years later, we don't really need to care about solaris oddities anymore. --- configure | 28 ---------------------------- configure_tests/trysocketlib.c | 12 ------------ src/Makefile | 2 +- 3 files changed, 1 insertion(+), 41 deletions(-) delete mode 100644 configure_tests/trysocketlib.c diff --git a/configure b/configure index bb37325..afb2aac 100755 --- a/configure +++ b/configure @@ -327,34 +327,6 @@ if test -n "$HASWAITPID"; then echo "CPPFLAGS += -DHASWAITPID" >> $CONFIG_MK fi -# -# Check for socket() link args. -# XXX: Is this correct? -# -printf "Checking for socket library ... " -if test -n "$SOCKETLIB"; then - # XXX: this seems very wrong, the value we want is empty in most cases, yet empty means "check again"? - echo "$SOCKETLIB (cached)." -else - _CC="$XCC configure_tests/trysocketlib.c -o trysocketlib" - if $_CC 2>/dev/null; then - SOCKETLIB= - echo yes. - elif $_CC -lxnet 2>/dev/null; then - SOCKETLIB="-lxnet" - echo "-lxnet" - elif $_CC -lsocket -lnsl 2>/dev/null; then - SOCKETLIB="-lsocket -lnsl" - echo "-lsocket -lnsl" - else - echo no. - echo "Can't find socket library!" - exit 1 - fi - rm -f trysocketlib -fi -echo "SOCKETLIB_LDFLAGS = $SOCKETLIB" >> $CONFIG_MK - # # Check for utmpx/utmp. # diff --git a/configure_tests/trysocketlib.c b/configure_tests/trysocketlib.c deleted file mode 100644 index 0fe5d06..0000000 --- a/configure_tests/trysocketlib.c +++ /dev/null @@ -1,12 +0,0 @@ -#include -#include -#include -#include -#include - -int main(void) { - int s; - - s =socket(AF_INET, SOCK_STREAM, 0); - return(close(s)); -} diff --git a/src/Makefile b/src/Makefile index 2c46c55..2aa59fc 100644 --- a/src/Makefile +++ b/src/Makefile @@ -48,7 +48,7 @@ runsvchdir: runsvchdir.o unix.a byte.a svlogd: svlogd.o pmatch.o fmt_ptime.o unix.a byte.a time.a @printf " [CCLD]\t\t$@\n" - ${SILENT}$(CC) $^ $(LDFLAGS) $(BUILD_STATIC) $(SOCKETLIB_LDFLAGS) -o $@ + ${SILENT}$(CC) $^ $(LDFLAGS) $(BUILD_STATIC) -o $@ chpst: chpst.o uidgid.o unix.a byte.a @printf " [CCLD]\t\t$@\n"