Skip to content

Commit 21e7e16

Browse files
committed
build-doc: make work when run from subdirectories
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.
1 parent b962ed6 commit 21e7e16

File tree

3 files changed

+34
-13
lines changed

3 files changed

+34
-13
lines changed

build

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -525,9 +525,21 @@ Which components to build. Default: qemu-buildroot
525525
self.sh.add_newlines(sorted(python3_pkgs))
526526
)
527527
if ruby_pkgs:
528-
# TODO fails without sudo and with --local on Ubuntu 18.04.
528+
# The right thing to do would be to use RVM and avoid sudo,
529+
# but we felt it was too much boilerplate for now.
530+
#
531+
# --user-install does work here, but we still need to add
532+
# the binary to PATH which is a pain:
533+
# https://stackoverflow.com/questions/31596273/install-gem-in-local-folder
529534
self.sh.run_cmd(['sudo', 'gem', 'install', 'bundler', LF])
530-
self.sh.run_cmd(['bundle', 'install', LF])
535+
# No ones knows how to do this without sudo:
536+
# https://stackoverflow.com/questions/16376995/bundler-cannot-install-any-gems-without-sudo/27677094
537+
self.sh.run_cmd([
538+
'sudo', LF,
539+
'bundle', LF,
540+
'install', LF,
541+
'--gemfile', os.path.join(self.env['root_dir'], 'Gemfile'), LF,
542+
])
531543
git_cmd_common = [
532544
'git', LF,
533545
'submodule', LF,

build-crosstool-ng

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -32,9 +32,9 @@ Build crosstool-NG with Newlib for bare metal compilation
3232
self.env['crosstool_ng_source_dir'],
3333
self.env['crosstool_ng_source_copy_dir'],
3434
)
35-
os.chdir(self.env['crosstool_ng_source_copy_dir'])
3635
self.sh.run_cmd(
3736
[os.path.join(self.env['crosstool_ng_source_copy_dir'], 'bootstrap'), LF],
37+
cwd=self.env['crosstool_ng_source_copy_dir'],
3838
)
3939
self.sh.run_cmd(
4040
[
@@ -44,8 +44,12 @@ Build crosstool-NG with Newlib for bare metal compilation
4444
os.path.join(os.curdir, 'configure'), LF,
4545
'--enable-local', LF,
4646
],
47+
cwd=self.env['crosstool_ng_source_copy_dir'],
48+
)
49+
self.sh.run_cmd(
50+
['make', '-j', str(self.env['nproc']), LF],
51+
cwd=self.env['crosstool_ng_source_copy_dir'],
4752
)
48-
self.sh.run_cmd(['make', '-j', str(self.env['nproc']), LF])
4953

5054
# Build the toolchain.
5155
self.sh.cp(
@@ -65,6 +69,7 @@ Build crosstool-NG with Newlib for bare metal compilation
6569
self.env['crosstool_ng_executable'], LF,
6670
'defconfig', LF,
6771
],
72+
cwd=self.env['crosstool_ng_source_copy_dir'],
6873
)
6974
self.sh.rmrf(defconfig_dest)
7075
self.sh.run_cmd(
@@ -73,6 +78,7 @@ Build crosstool-NG with Newlib for bare metal compilation
7378
'build', LF,
7479
'CT_JOBS={}'.format(str(self.env['nproc'])), LF,
7580
],
81+
cwd=self.env['crosstool_ng_source_copy_dir'],
7682
out_file=os.path.join(build_dir, self.env['repo_short_id'] + '.log'),
7783
delete_env=['LD_LIBRARY_PATH'],
7884
extra_paths=[self.env['ccache_dir']],

build-doc

Lines changed: 12 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -40,8 +40,8 @@ https://github.com/cirosantilli/linux-kernel-module-cheat#build-the-documentatio
4040
self.env['readme']
4141
]).splitlines():
4242
if not external_link_re.match(link):
43-
if not os.path.lexists(link):
44-
self.log_error('broken link: ' + link)
43+
if not os.path.lexists(os.path.join(self.env['root_dir'], link)):
44+
self.log_error('broken link to local file: ' + link)
4545
exit_status = 1
4646

4747
# Check that non-README links to README IDs exit.
@@ -53,13 +53,16 @@ https://github.com/cirosantilli/linux-kernel-module-cheat#build-the-documentatio
5353
self.env['readme']
5454
]).splitlines():
5555
header_ids.add(header_id)
56-
for grep_line in self.sh.check_output([
57-
'git',
58-
'grep',
59-
'--fixed-strings',
60-
self.env['github_repo_id_url'] + '#',
61-
LF
62-
]).splitlines():
56+
for grep_line in self.sh.check_output(
57+
[
58+
'git',
59+
'grep',
60+
'--fixed-strings',
61+
self.env['github_repo_id_url'] + '#',
62+
LF
63+
],
64+
cwd=self.env['root_dir']
65+
).splitlines():
6366
url_index = grep_line.index(self.env['github_repo_id_url'])
6467
hash_start_index = url_index + len(self.env['github_repo_id_url'])
6568
if len(grep_line) > hash_start_index:

0 commit comments

Comments
 (0)