Converter from single-file init/rc input formats

2018-03-25 Thread Casper Ti. Vector
For your amusement, I just made a silly converter from a format remotely
like that of OpenRC.  Note that unlike slew.rc which is largely
independent of any particular rc(1) feature, this converter depends on
rc(1)'s ability to handle variables with unconventional names (eg.
`timeout-kill' and `data/test') and to easily use dynamically named
variables (eg. `$$_name').  And seriously, if you really find a
single-file format necessary (for marketing reasons :(), I think a
shell-based format would be better than alternatives like systemd units
or immortal `run.yml' files.

-- 
My current OpenPGP key:
RSA4096/0x227E8CAAB7AA186C (expires: 2020.10.19)
7077 7781 B859 5166 AE07 0286 227E 8CAA B7AA 186C

#!/bin/rc -e

_wrap=/etc/slew/lib/wrap.rc
_base=/etc/slew/conv
if (~ $#* 0) exit 1
. $1
if (! ~ $#self 1 || ~ $self */*) exit 1
mkdir $self
cp $1 conv

for (_name in \
type contents dependencies notification-fd nosetsid \
timeout-up timeout-down timeout-kill timeout-finish \
producer-for consumer-for pipeline-name \
) {
if (! ~ $#$_name 0) {
echo $$_name | tr -s ' ' '\n' > $self/$_name
}
}

for (_name in $extra) {
if (~ $_name */*) mkdir -p `{dirname $self/$_name}
printf '%s' $$_name > $self/$_name
}

for (_name in up down run finish) {
if (whatis $_name > /dev/null >[2=1])
printf '#!/bin/execlineb -P\n%s %s %s\n' \
$_wrap $_base/$self.rc $_name > $self/$_name
}

#!/bin/rc -e

. $1
$2

#!/bin/rc

self=hello
type=longrun
dependencies=(origin)
extra=(data/test)

data/test=''

fn run {
echo Hello world
exec cat >[2=1]
}



Parsing /etc/os-release

2018-03-25 Thread Jonathan de Boyne Pollard
For those who might be parsing /etc/os-release, and for those who have 
seen the way that the nosh toolset does it, in its build system and in 
the external configuration import subsystem:


* https://unix.stackexchange.com/a/433245/5132



Re: [Announce] s6.rc: a distribution-friendly init/rc framework

2018-03-25 Thread Casper Ti. Vector
On Sun, Mar 25, 2018 at 06:38:33AM +, Laurent Bercot wrote:
> A major selling point of the s6 and s6-rc formats is that they're easy
> to autogenerate, and a frontend would be proof of that. We claim we're
> technically better than everyone else, and that our paradigm is more
> flexible than others - well there's the opportunity to prove it.
Fine if you think so.  Religions can really be annoying and wasteful.

-- 
My current OpenPGP key:
RSA4096/0x227E8CAAB7AA186C (expires: 2020.10.19)
7077 7781 B859 5166 AE07 0286 227E 8CAA B7AA 186C