check_whence: error if symlinks are in-tree
Currently we have no symlinks in-tree. Add a simple check, ensuring they don't get added in the future. This allows us to remove the clunky symlink checking code in copy-firmware.sh v2: - tweak helper to produce link and target (based off Adam's patch) v3: - honour quoted target/linkname Signed-off-by: Emil Velikov <emil.l.velikov@gmail.com> Signed-off-by: Josh Boyer <jwboyer@kernel.org>
This commit is contained in:
parent
f2671b1f50
commit
77f92e0b9d
|
@ -36,6 +36,23 @@ def list_whence_files():
|
||||||
yield match.group(1).replace("\ ", " ").replace("\"", "")
|
yield match.group(1).replace("\ ", " ").replace("\"", "")
|
||||||
continue
|
continue
|
||||||
|
|
||||||
|
def list_links_list():
|
||||||
|
with open('WHENCE', encoding='utf-8') as whence:
|
||||||
|
for line in whence:
|
||||||
|
match = re.match(r'Link:\s*(.*)', line)
|
||||||
|
if match:
|
||||||
|
linkname, target = match.group(1).split("->")
|
||||||
|
|
||||||
|
linkname = linkname.strip().replace("\ ", " ").replace("\"", "")
|
||||||
|
target = target.strip().replace("\ ", " ").replace("\"", "")
|
||||||
|
|
||||||
|
# Link target is relative to the link
|
||||||
|
target = os.path.join(os.path.dirname(linkname), target)
|
||||||
|
target = os.path.normpath(target)
|
||||||
|
|
||||||
|
yield (linkname, target)
|
||||||
|
continue
|
||||||
|
|
||||||
def list_git():
|
def list_git():
|
||||||
with os.popen('git ls-files') as git_files:
|
with os.popen('git ls-files') as git_files:
|
||||||
for line in git_files:
|
for line in git_files:
|
||||||
|
@ -45,6 +62,7 @@ def main():
|
||||||
ret = 0
|
ret = 0
|
||||||
whence_list = list(list_whence())
|
whence_list = list(list_whence())
|
||||||
whence_files = list(list_whence_files())
|
whence_files = list(list_whence_files())
|
||||||
|
links_list = list(list_links_list())
|
||||||
known_files = set(name for name in whence_list if not name.endswith('/')) | \
|
known_files = set(name for name in whence_list if not name.endswith('/')) | \
|
||||||
set(['check_whence.py', 'configure', 'Makefile',
|
set(['check_whence.py', 'configure', 'Makefile',
|
||||||
'README', 'copy-firmware.sh', 'WHENCE'])
|
'README', 'copy-firmware.sh', 'WHENCE'])
|
||||||
|
@ -65,6 +83,10 @@ def main():
|
||||||
name)
|
name)
|
||||||
ret = 1
|
ret = 1
|
||||||
|
|
||||||
|
for name in set(link[0] for link in links_list if os.path.islink(link[0])):
|
||||||
|
sys.stderr.write('E: %s listed in WHENCE as Link, is in tree\n' % name)
|
||||||
|
ret = 1
|
||||||
|
|
||||||
for name in sorted(list(known_files - git_files)):
|
for name in sorted(list(known_files - git_files)):
|
||||||
sys.stderr.write('E: %s listed in WHENCE does not exist\n' % name)
|
sys.stderr.write('E: %s listed in WHENCE does not exist\n' % name)
|
||||||
ret = 1
|
ret = 1
|
||||||
|
|
Loading…
Reference in New Issue