61 parser = argparse.ArgumentParser()
62
63 parser.add_argument(
64 '--executable-name',
65 dest='exec_name',
66 action='store',
67 required=True,
68 help='This is the name of the executable that we wish to layout debug symbols for.'
69 )
70 parser.add_argument(
71 '--executable-path',
72 dest='exec_path',
73 action='store',
74 required=True,
75 help='Path to the executable on the filesystem.'
76 )
77 parser.add_argument(
78 '--destination-base',
79 dest='dest',
80 action='store',
81 required=True,
82 help='Path to the base directory where the debug symbols are to be laid out.'
83 )
84 parser.add_argument(
85 '--stripped',
86 dest='stripped',
87 action='store_true',
88 default=True,
89 help='Executable at the specified path is stripped.'
90 )
91 parser.add_argument(
92 '--unstripped',
93 dest='stripped',
94 action='store_false',
95 help='Executable at the specified path is unstripped.'
96 )
97 parser.add_argument(
98 '--read-elf',
99 dest='read_elf',
100 action='store',
101 required=True,
102 help='Path to read-elf executable.'
103 )
104
105 args = parser.parse_args()
106 assert os.path.exists(args.exec_path), ('exec_path "%s" does not exist' % args.exec_path)
107 assert os.path.exists(args.dest), ('dest "%s" does not exist' % args.dest)
108 assert os.path.exists(args.read_elf), ('read_elf "%s" does not exist' % args.read_elf)
109
111 dbg_prefix_base = os.path.join(args.dest, parts['prefix_dir'])
112
113
114
115 try:
116 os.makedirs(dbg_prefix_base)
117 except OSError as e:
118 if e.errno != errno.EEXIST:
119 raise
120
121 if not os.path.exists(dbg_prefix_base):
122 print(
'Unable to create directory: %s.' % dbg_prefix_base)
123 return 1
124
125 dbg_suffix = ''
126 if not args.stripped:
127 dbg_suffix = '.debug'
128 dbg_file_name = '%s%s' % (parts['exec_name'], dbg_suffix)
129 dbg_file_path = os.path.join(dbg_prefix_base, dbg_file_name)
130
131
132
133 if os.path.exists(dbg_file_path)
and HashFile(args.exec_path) ==
HashFile(dbg_file_path):
134 return 0
135
136 shutil.copyfile(args.exec_path, dbg_file_path)
137
138
139 completion_file = os.path.join(args.dest, '.%s_dbg_success' % args.exec_name)
140 Touch(completion_file)
141
142 return 0
143
144
def print(*args, **kwargs)