meta2deps.py (49caa483b3fafffd9cf5197eb30e8bb235aa7410) | meta2deps.py (ef0b253881c9546ff88d3ed8480df7c791b3ddff) |
---|---|
1#!/usr/bin/env python 2 3from __future__ import print_function 4 5""" 6This script parses each "meta" file and extracts the 7information needed to deduce build and src dependencies. 8 --- 23 unchanged lines hidden (view full) --- 32 33'V' the filemon version, this record is used as a clue 34 that we have reached the interesting bit. 35 36""" 37 38""" 39RCSid: | 1#!/usr/bin/env python 2 3from __future__ import print_function 4 5""" 6This script parses each "meta" file and extracts the 7information needed to deduce build and src dependencies. 8 --- 23 unchanged lines hidden (view full) --- 32 33'V' the filemon version, this record is used as a clue 34 that we have reached the interesting bit. 35 36""" 37 38""" 39RCSid: |
40 $Id: meta2deps.py,v 1.28 2020/05/16 23:21:48 sjg Exp $ | 40 $Id: meta2deps.py,v 1.30 2020/06/08 23:05:00 sjg Exp $ |
41 42 Copyright (c) 2011-2019, Simon J. Gerraty 43 Copyright (c) 2011-2017, Juniper Networks, Inc. 44 All rights reserved. 45 46 Redistribution and use in source and binary forms, with or without 47 modification, are permitted provided that the following conditions 48 are met: --- 27 unchanged lines hidden (view full) --- 76 77def resolve(path, cwd, last_dir=None, debug=0, debug_out=sys.stderr): 78 """ 79 Return an absolute path, resolving via cwd or last_dir if needed. 80 """ 81 if path.endswith('/.'): 82 path = path[0:-2] 83 if len(path) > 0 and path[0] == '/': | 41 42 Copyright (c) 2011-2019, Simon J. Gerraty 43 Copyright (c) 2011-2017, Juniper Networks, Inc. 44 All rights reserved. 45 46 Redistribution and use in source and binary forms, with or without 47 modification, are permitted provided that the following conditions 48 are met: --- 27 unchanged lines hidden (view full) --- 76 77def resolve(path, cwd, last_dir=None, debug=0, debug_out=sys.stderr): 78 """ 79 Return an absolute path, resolving via cwd or last_dir if needed. 80 """ 81 if path.endswith('/.'): 82 path = path[0:-2] 83 if len(path) > 0 and path[0] == '/': |
84 return path | 84 if os.path.exists(path): 85 return path 86 if debug > 2: 87 print("skipping non-existent:", path, file=debug_out) 88 return None |
85 if path == '.': 86 return cwd 87 if path.startswith('./'): 88 return cwd + path[1:] 89 if last_dir == cwd: 90 last_dir = None 91 for d in [last_dir, cwd]: 92 if not d: --- 41 unchanged lines hidden (view full) --- 134def abspath(path, cwd, last_dir=None, debug=0, debug_out=sys.stderr): 135 """ 136 Return an absolute path, resolving via cwd or last_dir if needed. 137 this gets called a lot, so we try to avoid calling realpath. 138 """ 139 rpath = resolve(path, cwd, last_dir, debug, debug_out) 140 if rpath: 141 path = rpath | 89 if path == '.': 90 return cwd 91 if path.startswith('./'): 92 return cwd + path[1:] 93 if last_dir == cwd: 94 last_dir = None 95 for d in [last_dir, cwd]: 96 if not d: --- 41 unchanged lines hidden (view full) --- 138def abspath(path, cwd, last_dir=None, debug=0, debug_out=sys.stderr): 139 """ 140 Return an absolute path, resolving via cwd or last_dir if needed. 141 this gets called a lot, so we try to avoid calling realpath. 142 """ 143 rpath = resolve(path, cwd, last_dir, debug, debug_out) 144 if rpath: 145 path = rpath |
146 elif len(path) > 0 and path[0] == '/': 147 return None |
|
142 if (path.find('/') < 0 or 143 path.find('./') > 0 or 144 path.endswith('/..')): 145 path = cleanpath(path) 146 return path 147 148def sort_unique(list, cmp=None, key=None, reverse=False): 149 list.sort(cmp, key, reverse) --- 320 unchanged lines hidden (view full) --- 470 if w[0] == 'F': 471 npid = int(w[2]) 472 pid_cwd[npid] = cwd 473 pid_last_dir[npid] = cwd 474 last_pid = npid 475 continue 476 elif w[0] == 'C': 477 cwd = abspath(w[2], cwd, None, self.debug, self.debug_out) | 148 if (path.find('/') < 0 or 149 path.find('./') > 0 or 150 path.endswith('/..')): 151 path = cleanpath(path) 152 return path 153 154def sort_unique(list, cmp=None, key=None, reverse=False): 155 list.sort(cmp, key, reverse) --- 320 unchanged lines hidden (view full) --- 476 if w[0] == 'F': 477 npid = int(w[2]) 478 pid_cwd[npid] = cwd 479 pid_last_dir[npid] = cwd 480 last_pid = npid 481 continue 482 elif w[0] == 'C': 483 cwd = abspath(w[2], cwd, None, self.debug, self.debug_out) |
484 if not cwd: 485 cwd = w[2] 486 if self.debug > 1: 487 print("missing cwd=", cwd, file=self.debug_out) |
|
478 if cwd.endswith('/.'): 479 cwd = cwd[0:-2] 480 self.last_dir = pid_last_dir[pid] = cwd 481 pid_cwd[pid] = cwd 482 if self.debug > 1: 483 print("cwd=", cwd, file=self.debug_out) 484 continue 485 486 if w[2] in self.seen: 487 if self.debug > 2: 488 print("seen:", w[2], file=self.debug_out) 489 continue 490 # file operations 491 if w[0] in 'ML': 492 # these are special, tread src as read and 493 # target as write | 488 if cwd.endswith('/.'): 489 cwd = cwd[0:-2] 490 self.last_dir = pid_last_dir[pid] = cwd 491 pid_cwd[pid] = cwd 492 if self.debug > 1: 493 print("cwd=", cwd, file=self.debug_out) 494 continue 495 496 if w[2] in self.seen: 497 if self.debug > 2: 498 print("seen:", w[2], file=self.debug_out) 499 continue 500 # file operations 501 if w[0] in 'ML': 502 # these are special, tread src as read and 503 # target as write |
494 self.parse_path(w[1].strip("'"), cwd, 'R', w) 495 self.parse_path(w[2].strip("'"), cwd, 'W', w) | 504 self.parse_path(w[2].strip("'"), cwd, 'R', w) 505 self.parse_path(w[3].strip("'"), cwd, 'W', w) |
496 continue 497 elif w[0] in 'ERWS': 498 path = w[2] 499 self.parse_path(path, cwd, w[0], w) 500 501 if not file: 502 f.close() 503 --- 54 unchanged lines hidden (view full) --- 558 return 559 if os.path.isdir(path): 560 if op in 'RW': 561 self.last_dir = path; 562 if self.debug > 1: 563 print("ldir=", self.last_dir, file=self.debug_out) 564 return 565 | 506 continue 507 elif w[0] in 'ERWS': 508 path = w[2] 509 self.parse_path(path, cwd, w[0], w) 510 511 if not file: 512 f.close() 513 --- 54 unchanged lines hidden (view full) --- 568 return 569 if os.path.isdir(path): 570 if op in 'RW': 571 self.last_dir = path; 572 if self.debug > 1: 573 print("ldir=", self.last_dir, file=self.debug_out) 574 return 575 |
566 if op in 'ERW': | 576 if op in 'ER': |
567 # finally, we get down to it 568 if dir == self.cwd or dir == self.curdir: 569 return 570 if self.is_src(base, dir, rdir): 571 self.seenit(w[2]) 572 if not rdir: 573 return 574 --- 181 unchanged lines hidden --- | 577 # finally, we get down to it 578 if dir == self.cwd or dir == self.curdir: 579 return 580 if self.is_src(base, dir, rdir): 581 self.seenit(w[2]) 582 if not rdir: 583 return 584 --- 181 unchanged lines hidden --- |