diff --git a/Makefile b/Makefile new file mode 100644 index 0000000..3a0cb16 --- /dev/null +++ b/Makefile @@ -0,0 +1,14 @@ +all : + $(MAKE) -C src it + $(MAKE) -C doc it + +clean : + $(MAKE) -C src clean + $(MAKE) -C doc clean + +install : + package/install + +dist : + sh src/tarsource.sh + diff --git a/debian/changelog b/debian/changelog new file mode 100644 index 0000000..b2eb49b --- /dev/null +++ b/debian/changelog @@ -0,0 +1,18 @@ +trigger (0:0.68) trusty; urgency=low + + * release 0.68 from alangrow.com. man page fixes. + + -- Alan Grow Sun, 26 Apr 2015 16:24:41 -0600 + +trigger (0:0.67) trusty; urgency=low + + * release 0.67 from alangrow.com + + -- Alan Grow Sat, 18 Apr 2015 17:57:30 -0600 + +trigger (0:0.66) unstable; urgency=low + + * release 0.66 from superscript.com + + -- Super Script Mon, 04 Jun 2012 11:20:19 -0400 + diff --git a/debian/compat b/debian/compat new file mode 100644 index 0000000..7f8f011 --- /dev/null +++ b/debian/compat @@ -0,0 +1 @@ +7 diff --git a/debian/control b/debian/control new file mode 100644 index 0000000..870a1ee --- /dev/null +++ b/debian/control @@ -0,0 +1,13 @@ +Source: trigger +Section: devel +Priority: optional +Maintainer: Super Script +Build-Depends: debhelper (>= 7.0.50~), asciidoc (>= 8.6.9~), + xsltproc (>= 1.1.28~), docbook (>= 4.5~), docbook-xml (>= 4.5~), docbook-xsl (>= 1.78~) +Standards-Version: 0.1.0 + +Package: trigger +Architecture: any +Depends: ${shlibs:Depends} +Description: Unix utilities for event-based program execution. + Unix utilities for event-based program execution. diff --git a/debian/copyright b/debian/copyright new file mode 100644 index 0000000..2bdc4c9 --- /dev/null +++ b/debian/copyright @@ -0,0 +1,9 @@ +This package was debianized by Alan Grow on +Mon, 04 Jun 2012 11:20:19 -0400 + +Upstream Author: Super Script (sst@superscript.com) + +Copyright: + +This code, like Prof.~ Bernstein's original code, is released into the public +domain. diff --git a/debian/rules b/debian/rules new file mode 100755 index 0000000..17a1d14 --- /dev/null +++ b/debian/rules @@ -0,0 +1,14 @@ +#!/usr/bin/make -f +# -*- makefile -*- + +DIR = ./debian/trigger + +%: + dh $@ + +override_dh_install: + install -d -m 0755 $(DIR)/usr/bin + install -m 0755 command/* $(DIR)/usr/bin + install -d -m 0755 $(DIR)/usr/share/man/man1 + install -m 0644 doc/*.1 $(DIR)/usr/share/man/man1 + diff --git a/doc/Makefile b/doc/Makefile index e8588db..e44387a 100644 --- a/doc/Makefile +++ b/doc/Makefile @@ -40,6 +40,9 @@ install.html \ trigger-listen.html \ trigger-pull.html \ trigger-wait.html \ +trigger-listen.1 \ +trigger-pull.1 \ +trigger-wait.1 \ develop.html \ asciidoc.css sh makefile.build default.build it it @@ -74,6 +77,15 @@ webpage.conf \ attribute.conf sh makefile.build default.html.build trigger-wait.html trigger-wait +trigger-listen.1: trigger-listen.txt + sh makefile.build default.1.build trigger-listen.1 trigger-listen + +trigger-pull.1: trigger-pull.txt + sh makefile.build default.1.build trigger-pull.1 trigger-pull + +trigger-wait.1: trigger-wait.txt + sh makefile.build default.1.build trigger-wait.1 trigger-wait + clean: rm -f \ attribute.conf \ @@ -84,4 +96,7 @@ clean: mkfile \ trigger-listen.html \ trigger-pull.html \ - trigger-wait.html + trigger-wait.html \ + trigger-listen.1 \ + trigger-pull.1 \ + trigger-wait.1 diff --git a/doc/default.1.build b/doc/default.1.build new file mode 100644 index 0000000..a9ceb37 --- /dev/null +++ b/doc/default.1.build @@ -0,0 +1,5 @@ +build_ifchanged "$2.txt" +safe a2x --format manpage --no-xmllint --xsltproc-opts "--nonet" "$2.txt" +safe cat "$1" # a2x can't write to stdout? :/ +exit $? + diff --git a/doc/it=d b/doc/it=d index b634ed5..5dfd292 100644 --- a/doc/it=d +++ b/doc/it=d @@ -5,3 +5,6 @@ trigger-pull.html trigger-wait.html develop.html asciidoc.css +trigger-listen.1 +trigger-pull.1 +trigger-wait.1 diff --git a/doc/makefile.build b/doc/makefile.build index c797743..be1e990 100644 --- a/doc/makefile.build +++ b/doc/makefile.build @@ -27,7 +27,7 @@ build_dependcc() { } build_do() { - ( . "$build_it_cmds" "$1" "$2" "$3" > "$3" ) + ( . "./$build_it_cmds" "$1" "$2" "$3" > "$3" ) } build_it() { diff --git a/doc/trigger-listen.txt b/doc/trigger-listen.txt index 86b75cd..1e3a7f4 100644 --- a/doc/trigger-listen.txt +++ b/doc/trigger-listen.txt @@ -2,19 +2,20 @@ :doctype: manpage == NAME -trigger-listen - listen to a fifo and run a command +trigger-listen - listen to a fifo(7) and execute a command + == SYNOPSIS -!!!! -trigger-listen [ -UdDqQv1 -c _limit_ -t _timeout_ -i _interval_ -g _gid_ -u _uid_ ] _path_ _prog_ -!!!! +*+trigger-listen+ [ +-UdDqQv1+ +-c+ +_limit_+ +-t+ +_timeout_+ +-i+ +_interval_+ +-g+ +_gid_+ +-u+ +_uid_+ ] +_path_+ +_prog_+* + == DESCRIPTION -The +trigger-listen+ program listens for input on the fifo +_path_+. When -it receives input +trigger-listen+ invokes +_prog_+ and continues to -listen for input on +_path_+. An external program pulls the trigger by -writing a byte of data to +_path_+. The +trigger-listen+ does not examine input -data. +The +trigger-listen+ program listens for input on the +fifo(7)+ +_path_+ using ++read(2)+. When it receives input +trigger-listen+ invokes +_prog_+ and +continues to listen for input on +_path_+. An external program pulls the +trigger by writing a byte of data to +_path_+. The +trigger-listen+ program +does not examine input data. + == OPTIONS @@ -22,13 +23,12 @@ data. +-q+:: Quiet. Do not print error messages. -+-Q+:: ++-Q+:: Print error messages. (Default) +-v+:: Verbose. Print both status and error messages. - === LISTENING OPTIONS +-1+:: Execute +_prog_+ immediately upon startup. @@ -40,32 +40,33 @@ trigger pull occurs while +_limit_+ copies are running, copies exits. +-t _timeout_+:: -Wait at most +_timeout_+ seconds for a trigger pull. If -+_timeout_+ +Wait at most +_timeout_+ seconds for a trigger pull. If +_timeout_+ seconds elapse without a trigger pull, then +trigger-listen+ pulls -its own trigger. The default value of +_timeout_+ -is +(unsigned int)~0+. +its own trigger. (Default: +(unsigned int)~0+) +-i _interval_+:: Wait at least +_interval_+ seconds between executions of -+_prog_+. If -it receives a trigger pull within +_interval_+ seconds of the last -execution, +trigger-listen+ executes +_prog_+ when -+_interval_+ -seconds have elapsed. The default value of +_interval_+ is 0. ++_prog_+. If +trigger-listen+ receives a trigger pull within +_interval_+ +seconds of the last execution, +trigger-listen+ executes +_prog_+ when ++_interval_+ seconds have elapsed. (Default: 0). +-g _gid_+:: -Switch group ID to +_gid_+ after preparing to receive trigger pulls. +Set the effective group ID to +_gid_+ using +setgid(2)+ after preparing to +receive trigger pulls. +-u _uid_+:: -Switch user ID to +_uid_+ after preparing to receive connections. +Set the effective user ID to +_uid_+ using +setuid(2)+ after preparing to +receive trigger pulls. +-U+:: -Same as +-g $GID -u $UID+. Typically, +$GID+ and +$UID+ are -set by http://cr.yp.to/daemontools/envuidgid.html[+envuidgid+]. +Set the effective user ID to the +environ(7)+ variable +_UID_+ and the +effective group ID to the +environ(7)+ variable +_GID_+ after preparing to +receive trigger pulls. Same as +-g+ +_$GID_+ +-u+ +_$UID_+, where +_$UID_+ +and +_$GID_+ are typically set by +http://cr.yp.to/daemontools/envuidgid.html[+envuidgid(8)+]. -+-d+:: -Delete. Remove and recreate the fifo +_path_+ upon startup. (Default) ++-d+:: +Delete. Remove and recreate the +fifo(7)+ +_path_+ upon startup. (Default) +-D+:: No delete. Do not remove and recreate +_path_+ upon startup. @@ -73,12 +74,15 @@ No delete. Do not remove and recreate +_path_+ upon startup. == EXIT STATUS The +trigger-listen+ program exits 111 for temporary errors and 100 for -permanent errors. It exits 0 on success or when terminated by signal. +permanent errors. +trigger-listen+ exits 0 on success or when terminated by +signal. == EXAMPLES -!!!! -trigger-listen ./trigger echo \'Hello world!' -!!!! +*+trigger-listen+ ./trigger echo \'Hello world!'* +== SEE ALSO ++mkfifo(1)+, link:trigger-pull.html[+trigger-pull(1)+], +link:trigger-wait.html[+trigger-wait(1)+], +setuid(2)+, +setgid(2)+, ++fifo(7)+, +envuidgid(8)+ diff --git a/doc/trigger-pull.txt b/doc/trigger-pull.txt index 3e6cd30..8ae951c 100644 --- a/doc/trigger-pull.txt +++ b/doc/trigger-pull.txt @@ -2,27 +2,23 @@ :doctype: manpage == NAME -trigger-pull - write a non-blocking byte to a fifo to pull a trigger +trigger-pull - write a non-blocking byte to a fifo(7) to pull a trigger == SYNOPSIS -!!!! -trigger-pull _path_ -!!!! +*+trigger-pull+ +_path_+* == DESCRIPTION -The +trigger-pull+ performs a non-blocking write of one byte of data to -+_path_+. +The +trigger-pull+ program performs a non-blocking +write(2)+ of one byte of +data to +_path_+. == EXIT STATUS The +trigger-pull+ program exits 100 for incorrect usage and 111 for temporary -errors. It does not retry if the write would have blocked and it ignores the -lack of reader on the fifo +_path_+, treating these as successes. - +errors. It does not retry if the +write(2)+ would have blocked and it ignores the +lack of reader on the +fifo(7)+ +_path_+, treating these as successes. == EXAMPLES -!!!! -trigger-pull ./trigger -!!!! - +*trigger-pull ./trigger* +== SEE ALSO ++mkfifo(1)+, link:trigger-listen.html[+trigger-listen(1)+], +trigger-wait(1)+, +fifo(7)+ diff --git a/doc/trigger-wait.txt b/doc/trigger-wait.txt index 51d31c8..231a013 100644 --- a/doc/trigger-wait.txt +++ b/doc/trigger-wait.txt @@ -2,50 +2,50 @@ :doctype: manpage == NAME -trigger-wait - listen to a trigger and optionally run a command +trigger-wait - listen to a fifo(7) and optionally execute a command == SYNOPSIS -!!!! -trigger-wait [ -wWdD -t _timeout_ ] _path_ [ _prog_ ] -!!!! +*+trigger-wait+ [ +-wWdD+ +-t+ _timeout_ ] _path_ [ _prog_ ]* == DESCRIPTION -The +trigger-wait+ listens for input on the fifo +_path_+. If +_prog_+ is -present, +trigger-wait+ runs it and optionally waits for it to complete. It -then exits 0 if it received a trigger pull and 99 otherwise. +The +trigger-wait+ program listens for input on the +fifo(7)+ +_path_+ using ++read(2)+. If +_prog_+ is present, +trigger-wait+ executes +_prog_+ and +optionally waits for it to complete. === OPTIONS +-t _timeout_+:: Wait at most +_timeout_+ seconds for a trigger pull. If +_timeout_+ -seconds elapse without a trigger pull, then +trigger-listen+ pulls -its own trigger. The default value of +_timeout_+ -is +(unsigned int)~0+. +seconds elapse without a trigger pull, then +trigger-wait+ pulls +its own trigger. (Default: +(unsigned int)~0+) +-w+:: -Wait for +_prog_+ to complete. (Default) +Wait for +_prog_+ to complete before exit. (Default) +-W+:: -Do not wait for +_prog_+ to complete. +Do not wait for +_prog_+ to complete before exit. +-d+:: -Delete. Remove and recreate the fifo +_path_+ upon startup. (Default) +Delete. Remove and recreate the +fifo(7)+ +_path_+ upon startup. (Default) +-D+:: No delete. Do not remove and recreate +_path_+ upon startup. == EXIT STATUS -The +trigger-wait+ program exits 100 for permanent -errors and 111 for temporary errors. It exits 0 if it received a trigger pull, -and 99 otherwise. +The +trigger-wait+ program exits 100 for permanent errors and 111 for +temporary errors. It exits 0 if it received a trigger pull, and 99 otherwise. == EXAMPLES -Assume that the processor for +/service/foo/log+ pulls the trigger as its dying -act: -!!!! -cd /service/foo && trigger-wait -t 5 ./trigger-rotate svc -a log -!!!! +Assume that the processor for +_/service/foo/log_+ pulls the trigger as its +dying act: +*cd /service/foo && trigger-wait -t 5 ./trigger-rotate svc -a log* + + +== SEE ALSO ++mkfifo(1)+, link:trigger-pull.html[+trigger-pull(1)+], +link:trigger-listen.html[+trigger-listen(1)+], +fifo(7)+, +multilog(8)+, ++svc(8)+ diff --git a/package/build b/package/build index ef9f3f7..4d332cd 100755 --- a/package/build +++ b/package/build @@ -122,7 +122,7 @@ then safe awk ' BEGIN { for (i = 1;i < ARGC;++i) - file[ARGV[i]] = 1 + file[ARGV[i]] = 1 ARGC = 1 } { if (file[$1]) print $1 } @@ -138,4 +138,3 @@ else fi exit 0 - diff --git a/package/versions b/package/versions index 16beebb..17e7e97 100644 --- a/package/versions +++ b/package/versions @@ -2,3 +2,5 @@ 0.60 0.65 0.66 +0.67 +0.68 diff --git a/src/makefile.build b/src/makefile.build index c797743..a3628e2 100644 --- a/src/makefile.build +++ b/src/makefile.build @@ -27,7 +27,7 @@ build_dependcc() { } build_do() { - ( . "$build_it_cmds" "$1" "$2" "$3" > "$3" ) + ( . "./$build_it_cmds" "$1" "$2" "$3" > "$3" ) } build_it() { @@ -35,14 +35,13 @@ build_it() { build_it_target="$2" build_it_base="$3" build_it_tmp="$build_it_target.tmp" - build_do "$build_it_target" "$build_it_base" "$build_it_tmp" \ - && { - [ -f "$build_it_tmp" ] && mv "$build_it_tmp" "$build_it_target" - } \ - || { + if build_do "$build_it_target" "$build_it_base" "$build_it_tmp" + then + [ -f "$build_it_tmp" ] && safe mv "$build_it_tmp" "$build_it_target" + else rm -f "$build_it_tmp" return 111 - } + fi return 0 } @@ -52,5 +51,5 @@ build_it() { # build_it cmds target base [ 1 -le $# ] || usage -build_it "$@" +safe build_it "$@" exit 0 diff --git a/src/tarsource.sh b/src/tarsource.sh new file mode 100644 index 0000000..2547715 --- /dev/null +++ b/src/tarsource.sh @@ -0,0 +1,27 @@ +#!/bin/sh + +set -e + +PKG_NAME=`basename "$PWD"` +PKG_VERSION="`tail -1 package/versions`" +PKG_BUILD_DIR="$PKG_NAME-$PKG_VERSION" +PKG_SOURCE="$PKG_NAME-$PKG_VERSION".tar.gz + +main() +{ + git ls-files | tar_rewrite "@^@$PKG_BUILD_DIR/@" czf ./"$PKG_SOURCE" -T - + echo "created tarball at ./$PKG_SOURCE" +} + +tar_rewrite() +{ + pattern="$1" ; shift + if [ -n "`tar --version | head -1 | grep GNU`" ]; then + tar "$@" --transform "flags=r;s${pattern}" + else + tar "$@" -s "$pattern" + fi +} + +main "$@" +