From 21e7e168085fb6a1c508b64983d9d58a42e4e624 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ciro=20Santilli=20=E5=85=AD=E5=9B=9B=E4=BA=8B=E4=BB=B6=20?= =?UTF-8?q?=E6=B3=95=E8=BD=AE=E5=8A=9F?= Date: Fri, 21 Jun 2019 00:00:00 +0000 Subject: [PATCH] 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. --- build | 16 ++++++++++++++-- build-crosstool-ng | 10 ++++++++-- build-doc | 21 ++++++++++++--------- 3 files changed, 34 insertions(+), 13 deletions(-) diff --git a/build b/build index f1106af..8547136 100755 --- a/build +++ b/build @@ -525,9 +525,21 @@ Which components to build. Default: qemu-buildroot self.sh.add_newlines(sorted(python3_pkgs)) ) if ruby_pkgs: - # TODO fails without sudo and with --local on Ubuntu 18.04. + # The right thing to do would be to use RVM and avoid sudo, + # but we felt it was too much boilerplate for now. + # + # --user-install does work here, but we still need to add + # the binary to PATH which is a pain: + # https://stackoverflow.com/questions/31596273/install-gem-in-local-folder self.sh.run_cmd(['sudo', 'gem', 'install', 'bundler', LF]) - self.sh.run_cmd(['bundle', 'install', LF]) + # No ones knows how to do this without sudo: + # https://stackoverflow.com/questions/16376995/bundler-cannot-install-any-gems-without-sudo/27677094 + self.sh.run_cmd([ + 'sudo', LF, + 'bundle', LF, + 'install', LF, + '--gemfile', os.path.join(self.env['root_dir'], 'Gemfile'), LF, + ]) git_cmd_common = [ 'git', LF, 'submodule', LF, diff --git a/build-crosstool-ng b/build-crosstool-ng index 7d476f8..cf01c07 100755 --- a/build-crosstool-ng +++ b/build-crosstool-ng @@ -32,9 +32,9 @@ Build crosstool-NG with Newlib for bare metal compilation self.env['crosstool_ng_source_dir'], self.env['crosstool_ng_source_copy_dir'], ) - os.chdir(self.env['crosstool_ng_source_copy_dir']) self.sh.run_cmd( [os.path.join(self.env['crosstool_ng_source_copy_dir'], 'bootstrap'), LF], + cwd=self.env['crosstool_ng_source_copy_dir'], ) self.sh.run_cmd( [ @@ -44,8 +44,12 @@ Build crosstool-NG with Newlib for bare metal compilation os.path.join(os.curdir, 'configure'), LF, '--enable-local', LF, ], + cwd=self.env['crosstool_ng_source_copy_dir'], + ) + self.sh.run_cmd( + ['make', '-j', str(self.env['nproc']), LF], + cwd=self.env['crosstool_ng_source_copy_dir'], ) - self.sh.run_cmd(['make', '-j', str(self.env['nproc']), LF]) # Build the toolchain. self.sh.cp( @@ -65,6 +69,7 @@ Build crosstool-NG with Newlib for bare metal compilation self.env['crosstool_ng_executable'], LF, 'defconfig', LF, ], + cwd=self.env['crosstool_ng_source_copy_dir'], ) self.sh.rmrf(defconfig_dest) self.sh.run_cmd( @@ -73,6 +78,7 @@ Build crosstool-NG with Newlib for bare metal compilation 'build', LF, 'CT_JOBS={}'.format(str(self.env['nproc'])), LF, ], + cwd=self.env['crosstool_ng_source_copy_dir'], out_file=os.path.join(build_dir, self.env['repo_short_id'] + '.log'), delete_env=['LD_LIBRARY_PATH'], extra_paths=[self.env['ccache_dir']], diff --git a/build-doc b/build-doc index 751ff70..1432cb3 100755 --- a/build-doc +++ b/build-doc @@ -40,8 +40,8 @@ https://github.com/cirosantilli/linux-kernel-module-cheat#build-the-documentatio self.env['readme'] ]).splitlines(): if not external_link_re.match(link): - if not os.path.lexists(link): - self.log_error('broken link: ' + 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. @@ -53,13 +53,16 @@ https://github.com/cirosantilli/linux-kernel-module-cheat#build-the-documentatio 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 - ]).splitlines(): + 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: