chiark / gitweb /
Fixed gawk script for git-tar target.
authorSven Eden <yamakuzure@gmx.net>
Thu, 23 Feb 2017 16:20:49 +0000 (17:20 +0100)
committerSven Eden <yamakuzure@gmx.net>
Tue, 14 Mar 2017 09:23:22 +0000 (10:23 +0100)
The previous variant was nice and sleek. But unfortunately, there are
constructs like:

  #if 0
  (... old code ...)
  #else
  (... alternative code for elogind ...)
  #endif // 0

These fragments couldn't be handled by the old code, but can by the
new one.

To make this work, the precompiler macros must be set like shown above.
Apart from that, all lines like:

/// Any doxygen one-line-comments with elogind in it are removed

are removed, too. Please note the three slashes.

And finally, all commented out #include directives are removed as well.

Makefile.am
src/basic/cgroup-util.c
src/cgroups-agent/cgroups-agent.c
src/core/cgroup.c
src/login/loginctl.c
src/login/logind-core.c

index f91734b..d3d5ac7 100644 (file)
@@ -943,15 +943,26 @@ git-tag:
 
 .PHONY: git-tar
 git-tar:
-       git archive --format=tar --prefix=elogind-$(VERSION)-raw/ HEAD | \
-               (cd /var/tmp/ && tar xf -) ; \
-       (cd /var/tmp && rm -rf elogind-$(VERSION) && $(MKDIR_P) elogind-$(VERSION) && \
+       $(AM_V_at)git archive --format=tar --prefix=elogind-$(VERSION)-raw/ HEAD | \
+               (cd /var/tmp/ && tar xf -)
+       $(AM_V_GEN)(cd /var/tmp && rm -rf elogind-$(VERSION) && $(MKDIR_P) elogind-$(VERSION) && \
         for f in `find elogind-$(VERSION)-raw/ -type f | cut -d '/' -f 2-` ; do \
-               $(MKDIR_P) elogind-$(VERSION)/`dirname $$f` ; \
-               $(AWK) '/^#if 0\s*$$/,/^#endif\s+\/\/\s+0\s*$$/{next}{print}' \
-                       elogind-$(VERSION)-raw/$$f \
-               | $(SED) -e '/^\/\/\/ .*elogind.*$$/d' \
-                        -e '/^\/\/ #include.*$$/d' > elogind-$(VERSION)/$$f ; \
+               $(MKDIR_P) elogind-$(VERSION)/`dirname $$f` ;            \
+               $(AWK) 'BEGIN                    { i=0;e=0      }        \
+                       /^#if\s+0\s*$$/          { i=1;next     }        \
+                       /^#else\s*$$/            {                       \
+                           { if ( i==1 ) e=1; else print }{next}        \
+                       }                                                \
+                       /^#endif\s*\/\/\s*0\s*$$/ {                      \
+                           { if ( i==1 ) { i=0;e=0 } else print }{next} \
+                       }                                                \
+                       /^\s*\/\/\/.*elogind.*$$/{ next         }        \
+                       /^\s*\/\/\s*#include.+$$/{ next         }        \
+                       { if ( (i==0) || (e==1) ) print         }'       \
+                         elogind-$(VERSION)-raw/$$f                     \
+                       > elogind-$(VERSION)/$$f ;                       \
+                       chmod `stat -c '%a' elogind-$(VERSION)-raw/$$f`  \
+                                           elogind-$(VERSION)/$$f ;     \
         done ; \
         for l in `find elogind-$(VERSION)-raw/ -type l | cut -d '/' -f 2-` ; do \
                $(MKDIR_P) elogind-$(VERSION)/`dirname $$l` ; \
@@ -959,7 +970,7 @@ git-tar:
         done ; \
         tar czf elogind-$(VERSION).tar.gz elogind-$(VERSION) ; \
         rm -rf elogind-$(VERSION) elogind-$(VERSION)-raw) ; \
-       mv /var/tmp/elogind-$(VERSION).tar.gz ./
+       $(AM_V_at)mv /var/tmp/elogind-$(VERSION).tar.gz ./
 
 .PHONY: install-tree
 install-tree: all
index bd17b5e..5dc631e 100644 (file)
@@ -2178,7 +2178,7 @@ int cg_unified(void) {
         else if (F_TYPE_EQUAL(fs.f_type, TMPFS_MAGIC))
 #else
         if (F_TYPE_EQUAL(fs.f_type, TMPFS_MAGIC))
-#endif // elogind
+#endif // 0
                 unified_cache = false;
         else
                 return -ENOEXEC;
index 975ccaa..e72c5c1 100644 (file)
@@ -63,7 +63,7 @@ int main(int argc, char *argv[]) {
                 /* If dbus isn't running or responding, there is nothing
                  * we can do about it. */
                 log_debug_errno(r, "Failed to open system bus: %m");
-#endif
+#endif // 0
                 return EXIT_FAILURE;
         }
 
@@ -77,7 +77,7 @@ int main(int argc, char *argv[]) {
                 log_debug_errno(r, "Failed to send signal message on private connection: %m");
 #else
                 log_debug_errno(r, "Failed to send signal message: %m");
-#endif
+#endif // 0
                 return EXIT_FAILURE;
         }
 
index 1733521..c0bfecb 100644 (file)
@@ -1297,7 +1297,7 @@ int manager_setup_cgroup(Manager *m) {
 
 #else
                         return log_error_errno(EOPNOTSUPP, "Unified cgroup hierarchy not supported: %m");
-#endif // elogind
+#endif // 0
                 } else if (m->running_as == MANAGER_SYSTEM) {
                         /* On the legacy hierarchy we only get
                          * notifications via cgroup agents. (Which
index 7b259ce..080d64a 100644 (file)
@@ -1538,7 +1538,7 @@ static int parse_argv(int argc, char *argv[]) {
 #if 0
                 { "lines",           required_argument, NULL, 'n'                 },
                 { "output",          required_argument, NULL, 'o'                 },
-#endif //
+#endif // 0
                 { "ignore-inhibitors", no_argument,     NULL, 'i'                 },
                 {}
         };
index f8b2d43..2b4d6ff 100644 (file)
@@ -279,7 +279,7 @@ int manager_get_session_by_pid(Manager *m, pid_t pid, Session **session) {
         _cleanup_free_ char *unit = NULL;
 #else
         _cleanup_free_ char *session_name = NULL;
-#endif
+#endif // 0
         Session *s;
         int r;
 
@@ -304,7 +304,7 @@ int manager_get_session_by_pid(Manager *m, pid_t pid, Session **session) {
         s = hashmap_get(m->sessions, session_name);
         log_debug_elogind("Session Name \"%s\" -> Session \"%s\"",
                           session_name, s && s->id ? s->id : "NULL");
-#endif
+#endif // 0
         if (!s)
                 return 0;
 
@@ -320,7 +320,7 @@ int manager_get_user_by_pid(Manager *m, pid_t pid, User **user) {
         User *u;
 #else
         Session *s;
-#endif
+#endif // 0
         int r;
 
         assert(m);