diff options
author | Alexander Kanavin <alex@linutronix.de> | 2025-09-29 14:56:09 +0200 |
---|---|---|
committer | Richard Purdie <richard.purdie@linuxfoundation.org> | 2025-10-04 11:16:43 +0100 |
commit | e6a1d91e64ab539c1025d5ae3dbe66b5f8ae6aa6 (patch) | |
tree | 73d2b5d6d3a87bc5ee90fedb8d63ccd0088cf317 /bitbake | |
parent | ec7c31497d261f0b8973e8d8aee876775b89b153 (diff) | |
download | poky-e6a1d91e64ab539c1025d5ae3dbe66b5f8ae6aa6.tar.gz |
bitbake: bitbake-setup: add 'install-buildtools' command
This basically calls install-buildtools from oe-core/poky, but
it ensures via command line parameters that the installation
location is stable and the downloads are preserved for reproducibility:
$ bin/bitbake-setup install-buildtools
Loading settings from /home/alex/bitbake-builds/bitbake-setup.conf
======
Buildtools archive is downloaded into /home/alex/bitbake-builds/yocto-master-testing/buildtools-downloads/20250319141333 and its content installed into /home/alex/bitbake-builds/yocto-master-testing/buildtools
... (output from install-buildtools script)
======
It also detects when buildtools are already installed, and will direct
users what to do:
======
alex@Zen2:/srv/work/alex/bitbake$ bin/bitbake-setup install-buildtools
Loading settings from /home/alex/bitbake-builds/bitbake-setup.conf
Buildtools are already installed in /home/alex/bitbake-builds/yocto-master-testing/buildtools.
If you wish to use them, you need to source the the environment setup script e.g.
$ . /home/alex/bitbake-builds/yocto-master-testing/buildtools/environment-setup-x86_64-pokysdk-linux
You can also re-run bitbake-setup install-buildtools with --force option to force a reinstallation
======
This commits includes fixes by Gyorgy Sarvari <skandigraun@gmail.com>
https://github.com/kanavin/bitbake/pull/2
(Bitbake rev: 9fb564b720ff5d29a245ec900c8996da7f5f24a6)
Signed-off-by: Alexander Kanavin <alex@linutronix.de>
Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
Diffstat (limited to 'bitbake')
-rwxr-xr-x | bitbake/bin/bitbake-setup | 26 | ||||
-rw-r--r-- | bitbake/lib/bb/tests/setup.py | 20 |
2 files changed, 46 insertions, 0 deletions
diff --git a/bitbake/bin/bitbake-setup b/bitbake/bin/bitbake-setup index 739474003f..d6509500d8 100755 --- a/bitbake/bin/bitbake-setup +++ b/bitbake/bin/bitbake-setup | |||
@@ -16,6 +16,8 @@ import stat | |||
16 | import tempfile | 16 | import tempfile |
17 | import configparser | 17 | import configparser |
18 | import datetime | 18 | import datetime |
19 | import glob | ||
20 | import subprocess | ||
19 | 21 | ||
20 | default_registry = 'git://github.com/kanavin/bitbake-setup-configurations.git;protocol=https;branch=main;rev=main' | 22 | default_registry = 'git://github.com/kanavin/bitbake-setup-configurations.git;protocol=https;branch=main;rev=main' |
21 | 23 | ||
@@ -554,6 +556,25 @@ def list_configs(settings, args, d): | |||
554 | json.dump(json_data, f, sort_keys=True, indent=4) | 556 | json.dump(json_data, f, sort_keys=True, indent=4) |
555 | print("Available configurations written into {}".format(args.write_json)) | 557 | print("Available configurations written into {}".format(args.write_json)) |
556 | 558 | ||
559 | def install_buildtools(settings, args, d): | ||
560 | buildtools_install_dir = os.path.join(args.build_dir, 'buildtools') | ||
561 | if os.path.exists(buildtools_install_dir): | ||
562 | if not args.force: | ||
563 | print("Buildtools are already installed in {}.".format(buildtools_install_dir)) | ||
564 | env_scripts = glob.glob(os.path.join(buildtools_install_dir, 'environment-setup-*')) | ||
565 | if env_scripts: | ||
566 | print("If you wish to use them, you need to source the environment setup script e.g.") | ||
567 | for s in env_scripts: | ||
568 | print("$ . {}".format(s)) | ||
569 | print("You can also re-run bitbake-setup install-buildtools with --force option to force a reinstallation.") | ||
570 | return | ||
571 | shutil.rmtree(buildtools_install_dir) | ||
572 | |||
573 | install_buildtools = os.path.join(args.build_dir, 'layers/oe-scripts/install-buildtools') | ||
574 | buildtools_download_dir = os.path.join(args.build_dir, 'buildtools-downloads/{}'.format(time.strftime("%Y%m%d%H%M%S"))) | ||
575 | print("Buildtools archive is downloaded into {} and its content installed into {}".format(buildtools_download_dir, buildtools_install_dir)) | ||
576 | subprocess.check_call("{} -d {} --downloads-directory {}".format(install_buildtools, buildtools_install_dir, buildtools_download_dir), shell=True) | ||
577 | |||
557 | def default_settings_path(top_dir): | 578 | def default_settings_path(top_dir): |
558 | return os.path.join(top_dir, 'bitbake-setup.conf') | 579 | return os.path.join(top_dir, 'bitbake-setup.conf') |
559 | 580 | ||
@@ -739,6 +760,11 @@ def main(): | |||
739 | add_build_dir_arg(parser_update) | 760 | add_build_dir_arg(parser_update) |
740 | parser_update.set_defaults(func=build_update) | 761 | parser_update.set_defaults(func=build_update) |
741 | 762 | ||
763 | parser_install_buildtools = subparsers.add_parser('install-buildtools', help='Install buildtools which can help fulfil missing or incorrect dependencies on the host machine') | ||
764 | add_build_dir_arg(parser_install_buildtools) | ||
765 | parser_install_buildtools.add_argument('--force', action='store_true', help='Force a reinstall of buildtools over the previous installation.') | ||
766 | parser_install_buildtools.set_defaults(func=install_buildtools) | ||
767 | |||
742 | parser_install_settings = subparsers.add_parser('install-settings', help='Write a settings file with default values into the top level directory (contains the location of build configuration registry, downloads directory and other settings specific to a top directory)') | 768 | parser_install_settings = subparsers.add_parser('install-settings', help='Write a settings file with default values into the top level directory (contains the location of build configuration registry, downloads directory and other settings specific to a top directory)') |
743 | add_top_dir_arg(parser_install_settings) | 769 | add_top_dir_arg(parser_install_settings) |
744 | parser_install_settings.set_defaults(func=write_settings) | 770 | parser_install_settings.set_defaults(func=write_settings) |
diff --git a/bitbake/lib/bb/tests/setup.py b/bitbake/lib/bb/tests/setup.py index ab4dbf7621..fb2c15f545 100644 --- a/bitbake/lib/bb/tests/setup.py +++ b/bitbake/lib/bb/tests/setup.py | |||
@@ -49,6 +49,21 @@ with open(os.path.join(builddir, 'init-build-env'), 'w') as f: | |||
49 | """ | 49 | """ |
50 | self.add_file_to_testrepo('scripts/oe-setup-build', oesetupbuild, script=True) | 50 | self.add_file_to_testrepo('scripts/oe-setup-build', oesetupbuild, script=True) |
51 | 51 | ||
52 | installbuildtools = """#!/usr/bin/env python3 | ||
53 | import getopt | ||
54 | import sys | ||
55 | import os | ||
56 | |||
57 | opts, args = getopt.getopt(sys.argv[1:], "d:", ["downloads-directory="]) | ||
58 | for option, value in opts: | ||
59 | if option == '-d': | ||
60 | installdir = value | ||
61 | |||
62 | print("Buildtools installed into {}".format(installdir)) | ||
63 | os.makedirs(installdir) | ||
64 | """ | ||
65 | self.add_file_to_testrepo('scripts/install-buildtools', installbuildtools, script=True) | ||
66 | |||
52 | bitbakeconfigbuild = """#!/usr/bin/env python3 | 67 | bitbakeconfigbuild = """#!/usr/bin/env python3 |
53 | import os | 68 | import os |
54 | import sys | 69 | import sys |
@@ -224,6 +239,11 @@ print("BBPATH is {{}}".format(os.environ["BBPATH"])) | |||
224 | out = self.runbbsetup("update") | 239 | out = self.runbbsetup("update") |
225 | self.assertIn("Configuration in {} has not changed".format(buildpath), out[0]) | 240 | self.assertIn("Configuration in {} has not changed".format(buildpath), out[0]) |
226 | 241 | ||
242 | # install buildtools | ||
243 | out = self.runbbsetup("install-buildtools") | ||
244 | self.assertIn("Buildtools installed into", out[0]) | ||
245 | self.assertTrue(os.path.exists(os.path.join(buildpath, 'buildtools'))) | ||
246 | |||
227 | # change a file in the test layer repo, make a new commit and | 247 | # change a file in the test layer repo, make a new commit and |
228 | # test that status/update correctly report the change and update the config | 248 | # test that status/update correctly report the change and update the config |
229 | prev_test_file_content = test_file_content | 249 | prev_test_file_content = test_file_content |