summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLaurent Bercot <ska-skaware@skarnet.org>2021-12-03 05:32:58 +0000
committerLaurent Bercot <ska@appnovation.com>2021-12-03 05:32:58 +0000
commit611773a0946f9b1d1b834953236a96cbdfea2211 (patch)
tree59d7ee729dc4f160dffae116ebfd052362af494e
parentfc7aa7da7f0e8638707b66b7ea897afb8e1fa355 (diff)
downloads6-rc-611773a0946f9b1d1b834953236a96cbdfea2211.tar.xz
Prepare for 0.5.3.0, add contents.d and dependencies.d support
Signed-off-by: Laurent Bercot <ska@appnovation.com>
-rw-r--r--NEWS9
-rw-r--r--doc/index.html2
-rw-r--r--doc/s6-rc-compile.html31
-rw-r--r--doc/upgrade.html10
-rw-r--r--package/info2
-rw-r--r--src/s6-rc/s6-rc-compile.c42
6 files changed, 79 insertions, 17 deletions
diff --git a/NEWS b/NEWS
index c766458..4753284 100644
--- a/NEWS
+++ b/NEWS
@@ -1,5 +1,14 @@
Changelog for s6-rc.
+In 0.6.0.0
+----------
+
+ - s6-rc-compile now reads service dependencies and bundle contents
+from directories, not from files. This makes it easier for package
+managers to drop services in a source database without modifying
+existing files.
+
+
In 0.5.2.3
----------
diff --git a/doc/index.html b/doc/index.html
index 06fb919..0bb9aeb 100644
--- a/doc/index.html
+++ b/doc/index.html
@@ -67,7 +67,7 @@ requirement if you link against the shared version of the skalibs library. </li>
<ul>
<li> The current released version of s6-rc is
-<a href="s6-rc-0.5.2.3.tar.gz">0.5.2.3</a>. </li>
+<a href="s6-rc-0.5.3.0.tar.gz">0.5.3.0</a>. </li>
<li> Alternatively, you can checkout a copy of the
<a href="//git.skarnet.org/cgi-bin/cgit.cgi/s6-rc/">s6-rc
git repository</a>:
diff --git a/doc/s6-rc-compile.html b/doc/s6-rc-compile.html
index c00ced8..acaf3c6 100644
--- a/doc/s6-rc-compile.html
+++ b/doc/s6-rc-compile.html
@@ -115,15 +115,23 @@ contents, i.e. all the services it represents will be marked as essential. </li>
<h3> For bundles </h3>
<ul>
- <li> A regular file named <tt>contents</tt>. This file must be a list
+ <li> A directory named <tt>contents.d</tt>. This directory must contain
+files, no matter their type, no matter their contents, named after services.
+(Typically, empty regular files are used.)
+All the services named in this directory will be represented by the bundle
+named <em>service</em>. </li>
+ <li> If <tt>contents.d</tt> does not exist, the bundle contents can be read
+from a regular file named <tt>contents</tt>. This file must be a list
of service names, one per line. Whitespace at the beginning of a line
is ignored, but trailing whitespace is not. Lines starting with a <tt>#</tt>
character are ignored. The file defines the services that will be
-represented by the bundle named <em>service</em>. </li>
+represented by the bundle named <em>service</em>. Note that this format is
+deprecated. </li>
</ul>
<p>
- It is possible to use bundle names in a <tt>contents</tt> file.
+ It is possible to use bundle names in a <tt>contents.d</tt> directory or a
+<tt>contents</tt> file.
However, if s6-rc-compile detects a cycle in bundle definitions, it will
complain and exit 1.
</p>
@@ -143,22 +151,27 @@ must contain an integer, which is the maximum number of milliseconds
stop; if stopping the service takes longer than this value, s6-rc will declare
the transition a failure. If the file does not exist, or contains 0, no timeout
is defined and s6-rc will wait indefinitely for the service to stop. </li>
- <li> An optional regular file named <tt>dependencies</tt>. This file must be a list
+ <li> An optional directory named <tt>dependencies.d</tt>. This directory must contain
+files, no matter their type, no matter their contents, named after services.
+(Typically, empty regular files are used.) All the services named in this directory
+will be <em>direct dependencies</em> of <em>service</em>, i.e. the services that must
+be up in order for <em>service</em> to work properly. </li>
+ <li> If <tt>dependencies.d</tt> does not exist: an optional regular file named
+<tt>dependencies</tt>. This file must be a list
of service names, one per line. Whitespace at the beginning of a line
is ignored, but trailing whitespace is not. Lines starting with a <tt>#</tt>
character are ignored. The file defines the <em>direct dependencies</em> of
-<em>service</em>, i.e. the services that must be up in order for
-<em>service</em> to work properly. </li>
+<em>service</em>. Note that this format is deprecated. </li>
</ul>
<p>
It is unnecessary to manually define complete sets of dependencies in the
-<tt>dependencies</tt> file, because
+<tt>dependencies.d</tt> directory or the <tt>dependencies</tt> file, because
<a href="s6-rc.html">s6-rc</a> will properly handle dependency chains.
If <em>A</em> depends on <em>B</em>, no matter the underlying
implementation of <em>B</em>, and the current implementation of <em>B</em>
depends on <em>C</em>, then you should just put <em>B</em> in
-<tt><em>A</em>/dependencies</tt>; when starting the set,
+<tt><em>A</em>/dependencies.d</tt>; when starting the set,
<a href="s6-rc.html">s6-rc</a> will start <em>C</em> first, then
<em>B</em>, then <em>A</em>. If the underlying implementation of <em>B</em>
changes and does not depend on <em>C</em>, then you will just have to
@@ -168,7 +181,7 @@ will still be correct.
<p>
Of course, if <em>A</em> depends on <em>C</em> anyway, you should add
-both <em>B</em> and <em>C</em> to <tt><em>A</em>/dependencies</tt>.
+both <em>B</em> and <em>C</em> to <tt><em>A</em>/dependencies.d</tt>.
</p>
<p>
diff --git a/doc/upgrade.html b/doc/upgrade.html
index 5c75358..1697860 100644
--- a/doc/upgrade.html
+++ b/doc/upgrade.html
@@ -30,6 +30,16 @@ minor and bugfix version changes.
<h1> What has changed in s6-rc </h1>
+<h2> in 0.5.3.0 </h2>
+
+<ul>
+ <li> <a href="s6-rc-compile.html">s6-rc-compile</a> now reads
+service dependency information from the <tt>dependencies.d</tt>
+directory and bundle information from the <tt>contents.d</tt>
+directory, instead of the <tt>dependencies</tt> and <tt>contents</tt>
+flat files. The old format is still supported, but deprecated. </li>
+</ul>
+
<h2> in 0.5.2.3 </h2>
<ul>
diff --git a/package/info b/package/info
index fcc1686..2e81ce1 100644
--- a/package/info
+++ b/package/info
@@ -1,4 +1,4 @@
package=s6-rc
-version=0.5.2.3
+version=0.5.3.0
category=admin
package_macro_name=S6RC
diff --git a/src/s6-rc/s6-rc-compile.c b/src/s6-rc/s6-rc-compile.c
index b0ec688..853bacb 100644
--- a/src/s6-rc/s6-rc-compile.c
+++ b/src/s6-rc/s6-rc-compile.c
@@ -266,7 +266,11 @@ static int add_namelist (before_t *be, int dfd, char const *srcdir, char const *
int cont = 1 ;
char buf[2048] ;
int fd = open_readatb(dfd, list) ;
- if (fd < 0) return 0 ;
+ if (fd < 0)
+ {
+ if (errno == ENOENT) return 0 ;
+ strerr_diefu6sys(111, "open ", srcdir, "/", name, "/", list) ;
+ }
buffer_init(&b, &buffer_read, fd, buf, 2048) ;
*listindex = genalloc_len(unsigned int, &be->indices) ;
while (cont)
@@ -304,6 +308,32 @@ static int add_namelist (before_t *be, int dfd, char const *srcdir, char const *
return 1 ;
}
+static int add_namelistd (before_t *be, int dfd, char const *srcdir, char const *name, char const *list, unsigned int *listindex, unsigned int *n)
+{
+ DIR *dir = opendir_at(dfd, list) ;
+ if (!dir)
+ {
+ if (errno == ENOENT) return 0 ;
+ strerr_diefu6sys(111, "opendir ", srcdir, "/", name, "/", list) ;
+ }
+ *listindex = genalloc_len(unsigned int, &be->indices) ;
+ for (;;)
+ {
+ direntry *d ;
+ unsigned int pos, kpos ;
+ errno = 0 ;
+ d = readdir(dir) ;
+ if (!d) break ;
+ if (d->d_name[0] == '.') continue ;
+ add_name(be, name, d->d_name, SVTYPE_UNDEFINED, &pos, &kpos) ;
+ if (!genalloc_append(unsigned int, &be->indices, &pos)) dienomem() ;
+ }
+ dir_close(dir) ;
+ if (errno) strerr_diefu4sys(111, "readdir ", srcdir, "/", list) ;
+ *n = genalloc_len(unsigned int, &be->indices) - *listindex ;
+ return 1 ;
+}
+
static void read_script (before_t *be, int dfd, char const *srcdir, char const *name, char const *script, unsigned int *argvindex, unsigned int *argc, int mandatory)
{
int r = 0 ;
@@ -377,10 +407,9 @@ static void add_common (before_t *be, int dfd, char const *srcdir, char const *n
{
unsigned int dummy ;
add_name(be, srcdir, name, svtype, &dummy, &common->kname) ;
- if (!add_namelist(be, dfd, srcdir, name, "dependencies", &common->depindex, &common->ndeps))
+ if (!add_namelistd(be, dfd, srcdir, name, "dependencies.d", &common->depindex, &common->ndeps)
+ && !add_namelist(be, dfd, srcdir, name, "dependencies", &common->depindex, &common->ndeps))
{
- if (errno != ENOENT)
- strerr_diefu5sys(111, "open ", srcdir, "/", name, "/dependencies") ;
common->depindex = genalloc_len(unsigned int, &be->indices) ;
common->ndeps = 0 ;
}
@@ -489,8 +518,9 @@ static inline void add_bundle (before_t *be, int dfd, char const *srcdir, char c
unsigned int dummy ;
if (verbosity >= 3) strerr_warni3x(name, " has type ", "bundle") ;
add_name(be, srcdir, name, SVTYPE_BUNDLE, &bundle.name, &dummy) ;
- if (!add_namelist(be, dfd, srcdir, name, "contents", &bundle.listindex, &bundle.n))
- strerr_diefu5sys(111, "open ", srcdir, "/", name, "/contents") ;
+ if (!add_namelistd(be, dfd, srcdir, name, "contents.d", &bundle.listindex, &bundle.n)
+ && !add_namelist(be, dfd, srcdir, name, "contents", &bundle.listindex, &bundle.n))
+ strerr_diefu5sys(111, "open ", srcdir, "/", name, "/contents") ;
bundle.annotation_flags = read_flags(dfd, srcdir, name) ;
if (!genalloc_append(bundle_t, &be->bundles, &bundle)) dienomem() ;
}