Re: [announce] buildroot-s6 0.2.0

2015-11-12 Thread Alex Suykov
Thu, Nov 12, 2015 at 09:29:37PM +0100, Eric Le Bihan wrote:

> Comments welcomed!

depends on BR2_TOOLCHAIN_USES_GLIBC || BR2_TOOLCHAIN_USES_MUSL looks really
strange, uClibc is typically the least problematic libc.

I can definitely build it with a uclibc toolchain, all it needs is -lrt
in skalibs configure when testing for posix_spawn* and later whenever -lskalibs
is used.

It does not work though. What I have so far is this:

execve("/usr/sbin/s6-echo", ["s6-echo", "--", "Starting system."], ...)
execve("s6-echo", ["s6-echo", "--", "Starting system."], ...)
execve("s6-echo", ["s6-echo", "--", "Starting system."], ...)
execve("s6-echo", ["s6-echo", "--", "Starting system."], ...)
execve("s6-echo", ["s6-echo", "--", "Starting system."], ...)
...

and it keeps repeating that execve in an infinite loop.

That's execline running /sbin/init.
The first if and the first occurence of a { } block in that script.
Strange, but I did not look further into this yet.

> buildroot-s6 is a sandbox to play with the s6 stack and see how it could be
> integrated into the official Buildroot. It is still a work-in-progress.

The worst part will be dealing with per-package service files.
I did try doing similar thing. Ended up with all my stuff in BR2_EXTERNAL,
this way it's much easier to keep Buildroot proper up to date.


[announce] buildroot-s6 0.2.0

2015-11-12 Thread Eric Le Bihan
Hi!

The version 0.2.0 of buildroot-s6, a set of Makefiles to generate embedded
Linux systems using s6 as init system, is available [1].

What's new?

- update of the s6 stack.
- possibility to select "s6 init" as init system in Buildroot configuration
  menu.
- addition of s6-linux-init-skeleton.
- fix for system shutdown (courtesy of /etc/rc.tini).

Formerly, all the files needed to use s6 as an init system were stored in the
"custom" subdirectory. In order to allow the user to select "s6 init" as init
system, I added a new package named "s6-linux-init-skeleton", which now
provides all the files for a basic setup (inspired by the examples from
s6-rc). The "custom" directory now only contains the files for the user custom
services (e.g. running `rngd` on the Raspberry Pi). See
buildroot/package/s6-linux-init-skeleton/files for details.

s6-linux-init-skeleton still needs improvements to be properly integrated into
Buildroot (e.g. better network/disk management).

buildroot-s6 is a sandbox to play with the s6 stack and see how it could be
integrated into the official Buildroot. It is still a work-in-progress.

About the branching model: the "stable" version will always be available on
the "master" branch, the latest developments will take place on "develop"
(thank you, Captain Obvious).

About the version scheme: stable version string will always contains even
numbers (e.g. 0.2.0), development/intermediate/unstable version string will
always contains odd numbers (e.g. 0.3.1).

I will shortly release 0.2.2, with an update of the s6 stack.

Comments welcomed!

[1] https://github.com/elebihan/buildroot-s6/

--
ELB


Re: Safely replacing /etc/s6-rc/compiled

2015-11-12 Thread Laurent Bercot

On 12/11/2015 18:59, Jan Bramkamp wrote:

Is there a way to update /etc/s6-rc/compiled without risking a broken
system if the power fails midway through the update? The best I can
come up with is to use a symlink to a uniquely named compiled
directory and a recompile wrapper


 That is exactly the way it's intended to be used.
 /etc/s6-rc/compiled should at all times be a symlink to the real
compiled database, and the link should be updated atomically.

 I did not provide binaries or scripts to do that around s6-rc-update,
because the exact details of the operations are policy; I expected
admins to be able to use the mechanism responsibly - and I was right,
because you are doing the right thing! :)

--
 Laurent


Re: s6 hangs at shutdown

2015-11-12 Thread Eric Le Bihan
Hi everybody!

On Thu, Nov 12, 2015 at 06:37:00PM +0100, Laurent Bercot wrote:
> On 12/11/2015 16:45, Alex Suykov wrote:
> > s6-svc: fatal: unable to control /run/service/s6-svscan-log: supervisor 
> > not listening
> >(...)
> >By this point ps shows pid 1 as
> >
> > foreground s6-rc -ad change foreground s6-echo Performing reboot. 
> > s6-reboot
>
>  Indeed: it's a mistake to run "s6-rc -ad change" in /etc/rc.shutdown,
> because by that point s6-svscan is not running anymore. s6-rc needs an
> operational supervision tree.
>
>  "s6-rc -ad change" should be run before switching to stage 3.
> Éric, can you please change this? The latest version of s6-linux-init
> produces a set of scripts that work, with an additional /etc/rc.tini
> to perform that kind of "stage 2 shutdown".

The "develop" branch of the repository contains an updated version of the s6
stack, as well as improvements and fixes for this problem (namely the use of
/etc/rc.tini). I will merge it shortly into "master".

--
ELB


Re: Safely replacing /etc/s6-rc/compiled

2015-11-12 Thread Steve Litt
On Thu, 12 Nov 2015 18:59:30 +0100
Jan Bramkamp  wrote:

> Is there a way to update /etc/s6-rc/compiled without risking a broken 
> system if the power fails midway through the update?

Couldn't you just back up the file(s), and if something goes wrong,
boot back in with System Rescue CD and copy the backups back to
original?
 
SteveT

Steve Litt 
November 2015 featured book: Troubleshooting Techniques
 of the Successful Technologist
http://www.troubleshooters.com/techniques


Safely replacing /etc/s6-rc/compiled

2015-11-12 Thread Jan Bramkamp
Is there a way to update /etc/s6-rc/compiled without risking a broken 
system if the power fails midway through the update?
The best I can come up with is to use a symlink to a uniquely named 
compiled directory and a recompile wrapper along those lines:


cd /etc/s6-rc
s6-rc-compile .compiled-$SUFFIX source
s6-rc-update $PWD/.compiled-$SUFFIX $* # TODO: avoid $*
ln -s .compiled-$SUFFIX .compiled-${SUFFIX}.link
mv .compiled-${SUFFIX}.link compiled
# TODO: cleanup old .compiled-* dirs
fsync compiled .


Re: s6 hangs at shutdown

2015-11-12 Thread Laurent Bercot

On 12/11/2015 16:45, Alex Suykov wrote:

 s6-svc: fatal: unable to control /run/service/s6-svscan-log: supervisor 
not listening
(...)
By this point ps shows pid 1 as

 foreground s6-rc -ad change foreground s6-echo Performing reboot. s6-reboot


 Indeed: it's a mistake to run "s6-rc -ad change" in /etc/rc.shutdown,
because by that point s6-svscan is not running anymore. s6-rc needs an
operational supervision tree.

 "s6-rc -ad change" should be run before switching to stage 3.
Éric, can you please change this? The latest version of s6-linux-init
produces a set of scripts that work, with an additional /etc/rc.tini
to perform that kind of "stage 2 shutdown".

 In the meantime, Alex, to reboot your machine:
 - edit the "foreground { s6-rc -ad change }" line out of /etc/rc.shutdown
 - run "s6-rc -da change && s6-svscanctl -i /run/service"

 It will work in most cases. It may not work if you are running
unsupervised processes keeping resources open on mounted
filesystems; in that case, kill those processes and try again.
(Solving this issue automatically is a hard problem, and needs
some ugly tweaks (asymmetry of up and down scripts for mounting
filesystems) that Éric and I can work out.

--
 Laurent



s6 hangs at shutdown

2015-11-12 Thread Alex Suykov
Hi,

I'm trying to reboot s6-based qemu system [1] and it seems to hang
at around s6-rc -ad change stage. Could anyone please point out why
it can't proceed to reboot, maybe I'm doing something wrong?

The system runs with s6-svscan as pid 1.
I log in and initiate reboot with

s6-svscanctl -i /run/service

This results in

s6-svc: fatal: unable to control /run/service/s6-svscan-log: supervisor not 
listening
Shutting down system.
Syncing disks.

but I still have my sh, and I can see with ps that all s6-supervise have been
killed except for s6-supervise getty. By this point ps shows pid 1 as

foreground s6-rc -ad change foreground s6-echo Performing reboot. s6-reboot

and it does not seem to proceed any further.
Killing sh, getty or its supervisor does not help.
Same with halt and poweroff.

The init script in that system is
  custom/board/common/overlay/s6-init/sbin/init
and reboot script is
  custom/board/common/overlay/s6-init/etc/rc.shutdown


[1] https://github.com/elebihan/buildroot-s6