Git init
[external/insserv.git] / debian / patches / 81_lessverbose.patch
1 Purpose: Reduce verbosity level (drop Loading... messages)
2 Fixes:   -
3 Status:  Not yet submitted upstream.
4 ---
5
6 Index: insserv/listing.h
7 ===================================================================
8 --- insserv.orig/listing.h      2009-09-26 22:35:25.000000000 +0200
9 +++ insserv/listing.h   2009-09-26 22:35:39.000000000 +0200
10 @@ -283,7 +283,7 @@
11  extern const char *const delimeter;
12  extern void error(const char *restrict fmt, ...) attribute((noreturn,format(printf,1,2)));
13  extern void warn (const char *restrict fmt, ...) attribute((format(printf,1,2)));
14 -extern void info (const char *restrict fmt, ...) attribute((format(printf,1,2)));
15 +extern void info (int level, const char *restrict fmt, ...) attribute((format(printf,2,3)));
16  extern inline int map_has_runlevels(void) attribute((always_inline));
17  extern inline char map_runlevel_to_key(const int runlevel);
18  extern inline ushort map_key_to_lvl(const char key);
19 @@ -312,23 +312,23 @@
20         (unlinkat(d,x,0) != 0 && (errno != EISDIR || unlinkat(d,x,AT_REMOVEDIR) != 0)))) \
21         warn ("can not remove(%s%s): %s\n", rcd, x, strerror(errno)); \
22         else \
23 -       info("remove service %s/%s%s\n", path, rcd, x); }))
24 +       info(1, "remove service %s/%s%s\n", path, rcd, x); }))
25  #else
26  # define xremove(d,x) (__extension__ ({ if ((dryrun ? 0 : (remove(x) != 0))) \
27         warn ("can not remove(%s%s): %s\n", rcd, x, strerror(errno)); \
28         else \
29 -       info("remove service %s/%s%s\n", path, rcd, x); }))
30 +       info(1, "remove service %s/%s%s\n", path, rcd, x); }))
31  #endif
32  #if defined(HAS_symlinkat) && defined(_ATFILE_SOURCE)
33  # define xsymlink(d,x,y) (__extension__ ({ if ((dryrun ? 0 : (symlinkat(x, d, y) != 0))) \
34         warn ("can not symlink(%s, %s%s): %s\n", x, rcd, y, strerror(errno)); \
35         else \
36 -       info("enable service %s -> %s/%s%s\n", x, path, rcd, y); }))
37 +       info(1, "enable service %s -> %s/%s%s\n", x, path, rcd, y); }))
38  #else
39  # define xsymlink(d,x,y) (__extension__ ({ if ((dryrun ? 0 : (symlink(x, y) != 0))) \
40         warn ("can not symlink(%s, %s%s): %s\n", x, rcd, y, strerror(errno)); \
41         else \
42 -       info("enable service %s -> %s/%s%s\n", x, path, rcd, y); }))
43 +       info(1, "enable service %s -> %s/%s%s\n", x, path, rcd, y); }))
44  #endif
45  #if defined(HAS_fstatat) && defined(_ATFILE_SOURCE)
46  # define xstat(d,x,s)  (__extension__ ({ fstatat(d,x,s, 0); }))
47 Index: insserv/insserv.c
48 ===================================================================
49 --- insserv.orig/insserv.c      2009-09-26 22:35:39.000000000 +0200
50 +++ insserv/insserv.c   2009-09-26 22:35:41.000000000 +0200
51 @@ -114,8 +114,8 @@
52  /* The main line buffer if unique */
53  static char buf[LINE_MAX];
54  
55 -/* When to be verbose */
56 -static boolean verbose = false;
57 +/* When to be verbose, and what level of verbosity */
58 +static int verbose = 0;
59  
60  /* When to be verbose */
61  static boolean dryrun = false;
62 @@ -690,9 +690,9 @@
63  
64      if (dryrun) {
65  #ifdef USE_KILL_IN_BOOT
66 -       info("dryrun, not creating .depend.boot, .depend.start, .depend.halt, and .depend.stop\n");
67 +       info(1, "dryrun, not creating .depend.boot, .depend.start, .depend.halt, and .depend.stop\n");
68  #else  /* not USE_KILL_IN_BOOT */
69 -       info("dryrun, not creating .depend.boot, .depend.start, and .depend.stop\n");
70 +       info(1, "dryrun, not creating .depend.boot, .depend.start, and .depend.stop\n");
71  #endif /* not USE_KILL_IN_BOOT */
72         return;
73      }
74 @@ -707,8 +707,8 @@
75         return;
76      }
77  
78 -    info("creating .depend.boot\n");
79 -    info("creating .depend.start\n");
80 +    info(1, "creating .depend.boot\n");
81 +    info(1, "creating .depend.start\n");
82  
83      lsort('S');                                        /* Sort into start order, set new sorder */
84  
85 @@ -874,9 +874,9 @@
86         return;
87      }
88  
89 -    info("creating .depend.halt\n");
90 +    info(1, "creating .depend.halt\n");
91  #endif /* USE_KILL_IN_BOOT */
92 -    info("creating .depend.stop\n");
93 +    info(1, "creating .depend.stop\n");
94  
95      lsort('K');                                        /* Sort into stop order, set new korder */
96  
97 @@ -1014,9 +1014,9 @@
98  /*
99   * Print message when verbose is enabled
100   */
101 -void info(const char *fmt, ...) {
102 +void info(int level, const char *fmt, ...) {
103      va_list ap;
104 -    if (!verbose)
105 +    if (level > verbose)
106         goto out;
107      va_start(ap, fmt);
108      _logger(fmt, ap);
109 @@ -1062,7 +1062,7 @@
110  
111      if (stat(rcpath, &st) < 0) {
112         if (errno == ENOENT) {
113 -           info("creating directory '%s'\n", rcpath);
114 +           info(1, "creating directory '%s'\n", rcpath);
115             if (!dryrun)
116                 mkdir(rcpath, (S_IRWXU|S_IRGRP|S_IXGRP|S_IROTH|S_IXOTH));
117         } else
118 @@ -1190,7 +1190,7 @@
119      char *basenamestr = basename(path); /* GNU basename */
120      char *retval = is_upstart_job_recursive(path, basenamestr);
121      if (retval)
122 -        info("script '%s' is upstart job\n", basenamestr);
123 +        info(2, "script '%s' is upstart job\n", basenamestr);
124      return retval;
125  }
126  
127 @@ -1225,7 +1225,7 @@
128  #define description    script_inf.description
129  #define interactive    script_inf.interactive
130  
131 -    info("Loading %s\n", path);
132 +    info(2, "Loading %s\n", path);
133  
134      if (NULL != (upstart_job = is_upstart_job(path))) {
135          char cmd[2048];
136 @@ -1882,7 +1882,7 @@
137      regmatch_t subloc[SUBCONFNUM], *val = (regmatch_t*)0;
138      FILE *conf;
139  
140 -    info("Loading %s\n", file);
141 +    info(2, "Loading %s\n", file);
142  
143      do {
144         const char * fptr = file;
145 @@ -2347,10 +2347,10 @@
146                 ignore = true;
147                 break;
148             case 'v':
149 -               verbose = true;
150 +               verbose ++;
151                 break;
152             case 'n':
153 -               verbose = true;
154 +               verbose ++;
155                 dryrun = true;
156                 break;
157             case 'p':