diff options
Diffstat (limited to 'meta/recipes-core/systemd/systemd/0001-Revert-systemd-analyze-use-argparse-instead-of-getop.patch')
-rw-r--r-- | meta/recipes-core/systemd/systemd/0001-Revert-systemd-analyze-use-argparse-instead-of-getop.patch | 103 |
1 files changed, 103 insertions, 0 deletions
diff --git a/meta/recipes-core/systemd/systemd/0001-Revert-systemd-analyze-use-argparse-instead-of-getop.patch b/meta/recipes-core/systemd/systemd/0001-Revert-systemd-analyze-use-argparse-instead-of-getop.patch new file mode 100644 index 0000000000..7de2705ace --- /dev/null +++ b/meta/recipes-core/systemd/systemd/0001-Revert-systemd-analyze-use-argparse-instead-of-getop.patch | |||
@@ -0,0 +1,103 @@ | |||
1 | From 2003e63f48cee2f497de7b90b66284f98c1c9919 Mon Sep 17 00:00:00 2001 | ||
2 | From: Koen Kooi <koen@dominion.thruhere.net> | ||
3 | Date: Mon, 10 Dec 2012 12:24:32 +0100 | ||
4 | Subject: [PATCH 1/2] Revert "systemd-analyze: use argparse instead of getopt" | ||
5 | |||
6 | This reverts commit 0c0271841ab45595f71528c50bcf1904d4b841d5. | ||
7 | |||
8 | Argparse is broken in current OE python | ||
9 | --- | ||
10 | src/analyze/systemd-analyze | 60 ++++++++++++++++++++++++++++--------------- | ||
11 | 1 files changed, 39 insertions(+), 21 deletions(-) | ||
12 | |||
13 | diff --git a/src/analyze/systemd-analyze b/src/analyze/systemd-analyze | ||
14 | index 88699d6..87a83dd 100755 | ||
15 | --- a/src/analyze/systemd-analyze | ||
16 | +++ b/src/analyze/systemd-analyze | ||
17 | @@ -1,7 +1,6 @@ | ||
18 | #!/usr/bin/python | ||
19 | |||
20 | -import sys, os | ||
21 | -import argparse | ||
22 | +import getopt, sys, os | ||
23 | from gi.repository import Gio | ||
24 | try: | ||
25 | import cairo | ||
26 | @@ -76,6 +75,20 @@ def draw_text(context, x, y, text, size = 12, r = 0, g = 0, b = 0, vcenter = 0.5 | ||
27 | |||
28 | context.restore() | ||
29 | |||
30 | +def usage(): | ||
31 | + sys.stdout.write("""systemd-analyze [--user] time | ||
32 | +systemd-analyze [--user] blame | ||
33 | +systemd-analyze [--user] plot | ||
34 | + | ||
35 | +Process systemd profiling information | ||
36 | + | ||
37 | + -h --help Show this help | ||
38 | +""") | ||
39 | + | ||
40 | +def help(): | ||
41 | + usage() | ||
42 | + sys.exit() | ||
43 | + | ||
44 | def time(): | ||
45 | |||
46 | initrd_time, start_time, finish_time = acquire_start_time() | ||
47 | @@ -266,29 +279,34 @@ def plot(): | ||
48 | |||
49 | surface.finish() | ||
50 | |||
51 | -parser = argparse.ArgumentParser(formatter_class=argparse.RawDescriptionHelpFormatter, | ||
52 | - description='Process systemd profiling information', | ||
53 | - epilog='''\ | ||
54 | -time - print time spent in the kernel before reaching userspace | ||
55 | -blame - print list of running units ordered by time to init | ||
56 | -plot - output SVG graphic showing service initialization | ||
57 | -''') | ||
58 | - | ||
59 | -parser.add_argument('action', choices=('time', 'blame', 'plot'), | ||
60 | - default='time', nargs='?', | ||
61 | - help='action to perform (default: time)') | ||
62 | -parser.add_argument('--user', action='store_true', | ||
63 | - help='use the session bus') | ||
64 | +def unknown_verb(): | ||
65 | + sys.stderr.write("Unknown verb '%s'.\n" % args[0]) | ||
66 | + usage() | ||
67 | + sys.exit(1) | ||
68 | |||
69 | -args = parser.parse_args() | ||
70 | +bus = Gio.BusType.SYSTEM | ||
71 | |||
72 | -if args.user: | ||
73 | - bus = Gio.BusType.SESSION | ||
74 | -else: | ||
75 | - bus = Gio.BusType.SYSTEM | ||
76 | +try: | ||
77 | + opts, args = getopt.gnu_getopt(sys.argv[1:], "h", ["help", "user"]) | ||
78 | +except getopt.GetoptError as err: | ||
79 | + sys.stdout.write(str(err) + "\n") | ||
80 | + usage() | ||
81 | + sys.exit(2) | ||
82 | +for o, a in opts: | ||
83 | + if o in ("-h", "--help"): | ||
84 | + help() | ||
85 | + elif o == '--user': | ||
86 | + bus = Gio.BusType.SESSION | ||
87 | + else: | ||
88 | + assert False, "unhandled option" | ||
89 | |||
90 | verb = {'time' : time, | ||
91 | 'blame': blame, | ||
92 | 'plot' : plot, | ||
93 | + 'help' : help, | ||
94 | } | ||
95 | -verb.get(args.action)() | ||
96 | + | ||
97 | +if len(args) == 0: | ||
98 | + time() | ||
99 | +else: | ||
100 | + verb.get(args[0], unknown_verb)() | ||
101 | -- | ||
102 | 1.7.7.6 | ||
103 | |||