[Initscripts-ng-commits] r1016 - in /trunk/src/insserv/debian: changelog patches/62_upstart_job.patch patches/series
pere at users.alioth.debian.org
pere at users.alioth.debian.org
Sat Sep 26 10:22:55 UTC 2009
Author: pere
Date: Sat Sep 26 10:22:52 2009
New Revision: 1016
URL: http://svn.debian.org/wsvn/initscripts-ng/?sc=1&rev=1016
Log:
New patch 62_upstart_job.patch implementing support for upstart
jobs (Closes: #547235).
Added:
trunk/src/insserv/debian/patches/62_upstart_job.patch
Modified:
trunk/src/insserv/debian/changelog
trunk/src/insserv/debian/patches/series
Modified: trunk/src/insserv/debian/changelog
URL: http://svn.debian.org/wsvn/initscripts-ng/trunk/src/insserv/debian/changelog?rev=1016&op=diff
==============================================================================
--- trunk/src/insserv/debian/changelog (original)
+++ trunk/src/insserv/debian/changelog Sat Sep 26 10:22:52 2009
@@ -7,6 +7,8 @@
are detected.
* Make check-initd-order report missing provides header as errors
instead of printing perl warnings.
+ * New patch 62_upstart_job.patch implementing support for upstart
+ jobs (Closes: #547235).
-- Petter Reinholdtsen <pere at debian.org> Sun, 20 Sep 2009 22:05:40 +0200
Added: trunk/src/insserv/debian/patches/62_upstart_job.patch
URL: http://svn.debian.org/wsvn/initscripts-ng/trunk/src/insserv/debian/patches/62_upstart_job.patch?rev=1016&op=file
==============================================================================
--- trunk/src/insserv/debian/patches/62_upstart_job.patch (added)
+++ trunk/src/insserv/debian/patches/62_upstart_job.patch Sat Sep 26 10:22:52 2009
@@ -1,0 +1,121 @@
+Purpose: Add support for upstart jobs.
+Fixes: #547235
+Status: Work in progress, not submitted upstream yet.
+---
+
+Index: insserv/insserv.8.in
+===================================================================
+--- insserv.orig/insserv.8.in 2009-09-26 12:19:05.000000000 +0200
++++ insserv/insserv.8.in 2009-09-26 12:20:19.000000000 +0200
+@@ -339,6 +339,12 @@
+ name as the boot or init script in the directory
+ .IR /etc/insserv/overrides/ .
+ .\"
++.SH UPSTART JOB COMPATIBILITY
++To allow upstart jobs to work as init.d scripts, insserv will
++recognize a symlink from path/to/init.d/script to
++/lib/init/upstart-job as upstart jobs, and instead of reading the
++header from the file will run the script with the argument lsb-header
++to get the script header.
+ .SH EXIT CODES
+ The exit codes have the following conditions:
+ .RS 7
+Index: insserv/insserv.c
+===================================================================
+--- insserv.orig/insserv.c 2009-09-26 12:19:05.000000000 +0200
++++ insserv/insserv.c 2009-09-26 12:20:21.000000000 +0200
+@@ -1154,6 +1154,43 @@
+ xreset(script_inf.interactive);
+ }
+
++static char *is_upstart_job_recursive(const char *path,
++ const char *basenamestr)
++{
++ struct stat statbuf;
++ if (-1 == lstat(path, &statbuf)) {
++ error("stat(%s): %s\n", path, strerror(errno));
++ }
++ if (S_ISLNK(statbuf.st_mode)) {
++ char buf[2048];
++ int len = readlink(path, buf, sizeof(buf)-1);
++ if (0 < len) {
++ buf[len] = '\0';
++ if (0 == strcmp(buf, "/lib/init/upstart-job")) {
++ /* upstart job, return base name of original symlink */
++ return strdup(basenamestr);
++ } else
++ return is_upstart_job_recursive(buf, basenamestr);
++ }
++ }
++ return 0;
++}
++
++/*
++ * return name of upstart job if the script is a symlink to
++ * /lib/init/upstart-job, or NULL if path do not point to an
++ * upstart job.
++ */
++static char* is_upstart_job(const char *path)
++{
++
++ char *basenamestr = basename(path); /* GNU basename */
++ char *retval = is_upstart_job_recursive(path, basenamestr);
++ if (retval)
++ info("script '%s' is upstart job\n", basenamestr);
++ return retval;
++}
++
+ #define FOUND_LSB_HEADER 0x01
+ #define FOUND_LSB_DEFAULT 0x02
+ #define FOUND_LSB_OVERRIDE 0x04
+@@ -1170,7 +1207,8 @@
+ char *pbuf = buf;
+ FILE *script;
+ uchar ret = 0;
+- int fd;
++ int fd = -1;
++ char *upstart_job = NULL;
+
+ #define provides script_inf.provides
+ #define required_start script_inf.required_start
+@@ -1186,12 +1224,23 @@
+
+ info("Loading %s\n", path);
+
+- if ((fd = xopen(dfd, path, o_flags)) < 0 || (script = fdopen(fd, "r")) == (FILE*)0)
+- error("fopen(%s): %s\n", path, strerror(errno));
++ if (NULL != (upstart_job = is_upstart_job(path))) {
++ char cmd[2048];
++ int len;
++ len = snprintf(cmd, sizeof(cmd),
++ "/lib/init/upstart-job %s lsb-header", upstart_job);
++ if (len < 0 || sizeof(cmd) == len)
++ error("snprintf: insufficient buffer for %s\n", path);
++ if ((FILE*)0 == (script = popen(cmd, "r")))
++ error("popen(%s): %s\n", path, strerror(errno));
++ } else {
++ if ((fd = xopen(dfd, path, o_flags)) < 0 || (script = fdopen(fd, "r")) == (FILE*)0)
++ error("fopen(%s): %s\n", path, strerror(errno));
+
+ #if defined _XOPEN_SOURCE && (_XOPEN_SOURCE - 0) >= 600
+- (void)posix_fadvise(fd, 0, 0, POSIX_FADV_SEQUENTIAL);
++ (void)posix_fadvise(fd, 0, 0, POSIX_FADV_SEQUENTIAL);
+ #endif
++ }
+
+ #define COMMON_ARGS buf, SUBNUM, subloc, 0
+ #define COMMON_SHD_ARGS buf, SUBNUM_SHD, subloc, 0
+@@ -1303,7 +1352,12 @@
+ (void)posix_fadvise(fd, 0, 0, POSIX_FADV_NOREUSE);
+ #endif
+
+- fclose(script);
++ if (upstart_job) {
++ pclose(script);
++ free(upstart_job);
++ upstart_job = 0;
++ } else
++ fclose(script);
+
+ if (begin && end)
+ ret |= FOUND_LSB_HEADER;
Modified: trunk/src/insserv/debian/patches/series
URL: http://svn.debian.org/wsvn/initscripts-ng/trunk/src/insserv/debian/patches/series?rev=1016&op=diff
==============================================================================
--- trunk/src/insserv/debian/patches/series (original)
+++ trunk/src/insserv/debian/patches/series Sat Sep 26 10:22:52 2009
@@ -7,6 +7,7 @@
50_symlink_in_initddir.patch
#60_all_keyword_start_only.patch
61_interactive_keyword.patch
+62_upstart_job.patch
70_req_start_all_depends.patch
71_complete_makefile.patch
80_manual_warnings.patch
More information about the Initscripts-ng-commits
mailing list