summaryrefslogtreecommitdiffstats
path: root/scripts
diff options
context:
space:
mode:
authorAlexander Kanavin <alex@linutronix.de>2025-03-13 18:22:22 +0100
committerRichard Purdie <richard.purdie@linuxfoundation.org>2025-03-17 17:09:22 +0000
commit157685ca87e19a334bf49cd64737e73b745959b5 (patch)
tree92d7e8bcda83ba9dffbd0180557a2c343555feb9 /scripts
parentae398ec14ea31fd8a7e57979e27b39c8d31dd10e (diff)
downloadpoky-157685ca87e19a334bf49cd64737e73b745959b5.tar.gz
scripts/install-buildtools: add an option to specify where downloads go
By default the script puts everything it downloads into a temporary directory and erases it after unpacking and installing the buildtools. This isn't great for traceability and reproducibility of builds (being able to see what was downloaded exactly, and being able to reproduce setting up a build, especially if the buildtools download location isn't available for whatever reason). This commit adds an option to download items into a specified directory and keep them there. I would particularly like to use it with bitbake-setup, where an optional feature to install the buildtools (exact implementation details tbd) would ensure the tarball remains available on local disk. (From OE-Core rev: fc8cedd899f7e5d06215a71808dd0827ccdcf849) Signed-off-by: Alexander Kanavin <alex@linutronix.de> Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
Diffstat (limited to 'scripts')
-rwxr-xr-xscripts/install-buildtools13
1 files changed, 9 insertions, 4 deletions
diff --git a/scripts/install-buildtools b/scripts/install-buildtools
index 639ebb12d7..6287416c9a 100755
--- a/scripts/install-buildtools
+++ b/scripts/install-buildtools
@@ -142,6 +142,9 @@ def main():
142 default=DEFAULT_INSTALL_DIR, 142 default=DEFAULT_INSTALL_DIR,
143 help='directory where buildtools SDK will be installed (optional)', 143 help='directory where buildtools SDK will be installed (optional)',
144 action='store') 144 action='store')
145 parser.add_argument('--downloads-directory',
146 help='use this directory for tarball/checksum downloads and do not erase them (default is a temporary directory which is deleted after unpacking and installing the buildtools)',
147 action='store')
145 parser.add_argument('-r', '--release', 148 parser.add_argument('-r', '--release',
146 default=DEFAULT_RELEASE, 149 default=DEFAULT_RELEASE,
147 help='Yocto Project release string for SDK which will be ' 150 help='Yocto Project release string for SDK which will be '
@@ -235,11 +238,12 @@ def main():
235 safe_filename = quote(filename) 238 safe_filename = quote(filename)
236 buildtools_url = "%s/%s/buildtools/%s" % (base_url, args.release, safe_filename) 239 buildtools_url = "%s/%s/buildtools/%s" % (base_url, args.release, safe_filename)
237 240
238 tmpsdk_dir = tempfile.mkdtemp() 241 sdk_dir = args.downloads_directory or tempfile.mkdtemp()
242 os.makedirs(sdk_dir, exist_ok=True)
239 try: 243 try:
240 # Fetch installer 244 # Fetch installer
241 logger.info("Fetching buildtools installer") 245 logger.info("Fetching buildtools installer")
242 tmpbuildtools = os.path.join(tmpsdk_dir, filename) 246 tmpbuildtools = os.path.join(sdk_dir, filename)
243 ret = subprocess.call("wget -q -O %s %s" % 247 ret = subprocess.call("wget -q -O %s %s" %
244 (tmpbuildtools, buildtools_url), shell=True) 248 (tmpbuildtools, buildtools_url), shell=True)
245 if ret != 0: 249 if ret != 0:
@@ -252,7 +256,7 @@ def main():
252 checksum_type = "sha256sum" 256 checksum_type = "sha256sum"
253 check_url = "{}.{}".format(buildtools_url, checksum_type) 257 check_url = "{}.{}".format(buildtools_url, checksum_type)
254 checksum_filename = "{}.{}".format(filename, checksum_type) 258 checksum_filename = "{}.{}".format(filename, checksum_type)
255 tmpbuildtools_checksum = os.path.join(tmpsdk_dir, checksum_filename) 259 tmpbuildtools_checksum = os.path.join(sdk_dir, checksum_filename)
256 ret = subprocess.call("wget -q -O %s %s" % 260 ret = subprocess.call("wget -q -O %s %s" %
257 (tmpbuildtools_checksum, check_url), shell=True) 261 (tmpbuildtools_checksum, check_url), shell=True)
258 if ret != 0: 262 if ret != 0:
@@ -347,7 +351,8 @@ def main():
347 351
348 finally: 352 finally:
349 # cleanup tmp directory 353 # cleanup tmp directory
350 shutil.rmtree(tmpsdk_dir) 354 if not args.downloads_directory:
355 shutil.rmtree(sdk_dir)
351 356
352 357
353if __name__ == '__main__': 358if __name__ == '__main__':