mirror of
https://github.com/cirosantilli/linux-kernel-module-cheat.git
synced 2026-01-23 10:15:57 +01:00
This in particular had broken ./build --download-dependencies -aA -aa -ax all not sure why, but there must be a change in directory somewhere then. The only chdir we do in this repo was for ctng crap, I'm also restoring that chdir back after we are done.
81 lines
2.8 KiB
Python
Executable File
81 lines
2.8 KiB
Python
Executable File
#!/usr/bin/env python3
|
|
|
|
import re
|
|
|
|
import common
|
|
from shell_helpers import LF
|
|
import os
|
|
import subprocess
|
|
|
|
class Main(common.LkmcCliFunction):
|
|
def __init__(self):
|
|
super().__init__(
|
|
defaults = {
|
|
'show_time': False,
|
|
},
|
|
description='''\
|
|
https://github.com/cirosantilli/linux-kernel-module-cheat#build-the-documentation
|
|
''',
|
|
)
|
|
|
|
def timed_main(self):
|
|
asciidoctor_dir = os.path.join(self.env['root_dir'], 'asciidoctor')
|
|
exit_status = self.sh.run_cmd(
|
|
[
|
|
'asciidoctor', LF,
|
|
'--failure-level', 'info', LF,
|
|
'--require', os.path.join(asciidoctor_dir, 'link-target-up.rb'), LF,
|
|
'--out-file', self.env['readme_out'], LF,
|
|
'--trace', LF,
|
|
'--verbose', LF,
|
|
self.env['readme'], LF,
|
|
],
|
|
out_file=self.env['build_doc_log'],
|
|
)
|
|
|
|
# Check that all local files linked from README exist.
|
|
external_link_re = re.compile('^https?://')
|
|
for link in self.sh.check_output([
|
|
os.path.join(asciidoctor_dir, 'extract-link-targets'),
|
|
self.env['readme']
|
|
]).splitlines():
|
|
if not external_link_re.match(link):
|
|
if not os.path.lexists(os.path.join(self.env['root_dir'], link)):
|
|
self.log_error('broken link to local file: ' + link)
|
|
exit_status = 1
|
|
|
|
# Check that non-README links to README IDs exit.
|
|
header_ids = set()
|
|
grep_line_location_re = re.compile('^(.*?:\d+):')
|
|
grep_line_hash_re = re.compile('^([a-z0-9_-]+)')
|
|
for header_id in self.sh.check_output([
|
|
os.path.join(asciidoctor_dir, 'extract-header-ids'),
|
|
self.env['readme']
|
|
]).splitlines():
|
|
header_ids.add(header_id)
|
|
for grep_line in self.sh.check_output(
|
|
[
|
|
'git',
|
|
'grep',
|
|
'--fixed-strings',
|
|
self.env['github_repo_id_url'] + '#',
|
|
LF
|
|
],
|
|
cwd=self.env['root_dir']
|
|
).splitlines():
|
|
url_index = grep_line.index(self.env['github_repo_id_url'])
|
|
hash_start_index = url_index + len(self.env['github_repo_id_url'])
|
|
if len(grep_line) > hash_start_index:
|
|
hash_str = grep_line_hash_re.search(grep_line[hash_start_index + 1:]).group(1)
|
|
if not hash_str in header_ids:
|
|
self.log_error('broken link to {} at {}'.format(
|
|
hash_str,
|
|
grep_line_location_re.search(grep_line).group(1))
|
|
)
|
|
exit_status = 1
|
|
|
|
return exit_status
|
|
|
|
if __name__ == '__main__':
|
|
Main().cli()
|