summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--INSTALL6
-rw-r--r--NEWS9
-rw-r--r--doc/index.html8
-rw-r--r--doc/upgrade.html19
-rw-r--r--package/info2
-rw-r--r--src/s6-rc/s6-rc-compile.c55
6 files changed, 75 insertions, 24 deletions
diff --git a/INSTALL b/INSTALL
index 9baba55..7087420 100644
--- a/INSTALL
+++ b/INSTALL
@@ -6,9 +6,9 @@ Build Instructions
- A POSIX-compliant C development environment
- GNU make version 3.81 or later
- - skalibs version 2.6.0.1 or later: http://skarnet.org/software/skalibs/
- - execline version 2.3.0.3 or later: http://skarnet.org/software/execline/
- - s6 version 2.6.1.1 or later: http://skarnet.org/software/s6/
+ - skalibs version 2.6.2.0 or later: http://skarnet.org/software/skalibs/
+ - execline version 2.3.0.4 or later: http://skarnet.org/software/execline/
+ - s6 version 2.6.2.0 or later: http://skarnet.org/software/s6/
This software will run on any operating system that implements
POSIX.1-2008, available at:
diff --git a/NEWS b/NEWS
index dc1e8af..88e0c6c 100644
--- a/NEWS
+++ b/NEWS
@@ -1,5 +1,14 @@
Changelog for s6-rc.
+In 0.3.0.1
+----------
+
+ - s6-rc-compile now guarantees the numbering of the services.
+This is useful when the database format changes. You should
+recompile your databases in preparation for the switch to
+s6-rc-0.4.0.0.
+
+
In 0.3.0.0
----------
diff --git a/doc/index.html b/doc/index.html
index 544fa85..d4f6746 100644
--- a/doc/index.html
+++ b/doc/index.html
@@ -48,11 +48,11 @@ scripts are also run in a controlled environment.
<li> A POSIX-compliant system with a standard C development environment </li>
<li> GNU make, version 3.81 or later </li>
<li> <a href="//skarnet.org/software/skalibs/">skalibs</a> version
-2.6.0.1 or later </li>
+2.6.2.0 or later </li>
<li> <a href="//skarnet.org/software/execline/">execline</a> version
-2.3.0.3 or later </li>
+2.3.0.4 or later </li>
<li> <a href="//skarnet.org/software/s6/">s6</a> version
-2.6.1.1 or later </li>
+2.6.2.0 or later </li>
</ul>
<h3> Licensing </h3>
@@ -66,7 +66,7 @@ scripts are also run in a controlled environment.
<ul>
<li> The current released version of s6-rc is
-<a href="s6-rc-0.3.0.0.tar.gz">0.3.0.0</a>. </li>
+<a href="s6-rc-0.3.0.1.tar.gz">0.3.0.1</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/upgrade.html b/doc/upgrade.html
index fa441d1..8b48740 100644
--- a/doc/upgrade.html
+++ b/doc/upgrade.html
@@ -30,6 +30,25 @@ minor and bugfix version changes.
<h1> What has changed in s6-rc </h1>
+<h2> in 0.3.0.1 </h2>
+
+<ul>
+ <li> <a href="//skarnet.org/software/skalibs/">skalibs</a>
+dependency bumped to 2.6.2.0. </li>
+ <li> <a href="//skarnet.org/software/execline/">execline</a>
+dependency bumped to 2.3.0.4. </li>
+ <li> <a href="//skarnet.org/software/s6/">s6</a>
+dependency bumped to 2.6.2.0. </li>
+ <li> New <tt>-p</tt> option to <a href="s6-rc-init.html">s6-rc-init</a>
+to allow using several live directories with the same scandir. </li>
+ <li> New command: <a href="s6-rc.html"><tt>s6-rc diff</tt></a>. </li>
+ <li> <a href="s6-rc-compile.html">s6-rc-compile</a> now guarantees that
+service numbers do not change if the source database does not change.
+This is useful for updates to the database format. You should recompile
+your service databases in preparation for the switch to s6-rc-0.4.0.0. </li>
+</ul>
+
+
<h2> in 0.3.0.0 </h2>
<ul>
diff --git a/package/info b/package/info
index 436da19..34ec8eb 100644
--- a/package/info
+++ b/package/info
@@ -1,4 +1,4 @@
package=s6-rc
-version=0.3.0.0
+version=0.3.0.1
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 dbf1f67..4206fb7 100644
--- a/src/s6-rc/s6-rc-compile.c
+++ b/src/s6-rc/s6-rc-compile.c
@@ -6,6 +6,7 @@
#include <fcntl.h>
#include <unistd.h>
#include <errno.h>
+#include <stdlib.h> /* qsort */
#include <skalibs/types.h>
#include <skalibs/bitarray.h>
#include <skalibs/strerr2.h>
@@ -471,18 +472,21 @@ static inline void add_source (before_t *be, int dirfd, char const *srcdir, char
else strerr_dief6x(1, "invalid ", srcdir, "/", name, "/type", ": must be oneshot, longrun, or bundle") ;
}
-static inline void add_sources (before_t *be, char const *srcdir)
+static int qsort_cannot_use_strcmp_directly (void const *a, void const *b)
{
- size_t start = satmp.len ;
- size_t cur ;
+ return strcmp(*(char const *const *)a, *(char const *const *)b) ;
+}
+
+static inline void add_sources (before_t *be, char const *srcdir, stralloc *sa)
+{
+ unsigned int n = 0 ;
+ int fdsrc ;
DIR *dir = opendir(srcdir) ;
if (!dir) strerr_diefu2sys(111, "opendir ", srcdir) ;
- if (!stralloc_cats(&satmp, srcdir) || !stralloc_catb(&satmp, "/", 1)) dienomem() ;
- cur = satmp.len ;
+ fdsrc = dirfd(dir) ;
for (;;)
{
struct stat st ;
- int fd ;
direntry *d ;
errno = 0 ;
d = readdir(dir) ;
@@ -491,19 +495,34 @@ static inline void add_sources (before_t *be, char const *srcdir)
if (strchr(d->d_name, '\n'))
strerr_dief3x(1, "subdirectory of ", srcdir, " contains a newline character") ;
check_identifier(srcdir, d->d_name) ;
- satmp.len = cur ;
- if (!stralloc_catb(&satmp, d->d_name, strlen(d->d_name) + 1)) dienomem() ;
- if (stat(satmp.s + start, &st) < 0)
- strerr_diefu2sys(111, "stat ", satmp.s + start) ;
+ if (stat_at(fdsrc, d->d_name, &st) < 0)
+ strerr_diefu4sys(111, "stat ", srcdir, "/", d->d_name) ;
if (!S_ISDIR(st.st_mode)) continue ;
- fd = open_readb(satmp.s + start) ;
- if (fd < 0) strerr_diefu2sys(111, "open ", satmp.s + start) ;
- add_source(be, fd, srcdir, d->d_name) ;
- close(fd) ;
+ n++ ;
+ if (!stralloc_catb(sa, d->d_name, strlen(d->d_name)+1)) dienomem() ;
}
if (errno) strerr_diefu2sys(111, "readdir ", srcdir) ;
+ if (n)
+ {
+ size_t pos = 0 ;
+ char const *names[n] ;
+ for (unsigned int i = 0 ; i < n ; i++)
+ {
+ names[i] = sa->s + pos ;
+ pos += strlen(sa->s + pos) + 1 ;
+ }
+ qsort(names, n, sizeof(char const *), &qsort_cannot_use_strcmp_directly) ;
+ for (unsigned int i = 0 ; i < n ; i++)
+ {
+ int fd = open_readatb(fdsrc, names[i]) ;
+ if (fd < 0) strerr_diefu4sys(111, "open ", srcdir, "/", names[i]) ;
+ add_source(be, fd, srcdir, names[i]) ;
+ close(fd) ;
+ }
+ sa->len = 0 ;
+ }
+ else if (verbosity) strerr_warnw3x("source ", srcdir, " is empty") ;
dir_close(dir) ;
- satmp.len = start ;
}
static inline void add_pipeline_bundles (before_t *be)
@@ -1415,7 +1434,11 @@ int main (int argc, char const *const *argv)
compiled = *argv++ ;
before.specialdeps[0] = add_internal_longrun(&before, S6RC_ONESHOT_RUNNER) ;
before.specialdeps[1] = add_internal_longrun(&before, S6RC_FDHOLDER) ;
- for (; *argv ; argv++) add_sources(&before, *argv) ;
+ {
+ stralloc sa = STRALLOC_ZERO ;
+ for (; *argv ; argv++) add_sources(&before, *argv, &sa) ;
+ stralloc_free(&sa) ;
+ }
add_pipeline_bundles(&before) ;
{