]> git.ipfire.org Git - thirdparty/openembedded/openembedded-core.git/commitdiff
scripts/install-buildtools: add an option to specify where downloads go
authorAlexander Kanavin <alex@linutronix.de>
Thu, 13 Mar 2025 17:22:22 +0000 (18:22 +0100)
committerRichard Purdie <richard.purdie@linuxfoundation.org>
Mon, 17 Mar 2025 16:35:52 +0000 (16:35 +0000)
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.

Signed-off-by: Alexander Kanavin <alex@linutronix.de>
Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
scripts/install-buildtools

index 639ebb12d7882764c867d42e640b373ab3f60e48..6287416c9a73caf3ff60ea9ed4e055c0980d6836 100755 (executable)
@@ -142,6 +142,9 @@ def main():
                         default=DEFAULT_INSTALL_DIR,
                         help='directory where buildtools SDK will be installed (optional)',
                         action='store')
+    parser.add_argument('--downloads-directory',
+                        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)',
+                        action='store')
     parser.add_argument('-r', '--release',
                         default=DEFAULT_RELEASE,
                         help='Yocto Project release string for SDK which will be '
@@ -235,11 +238,12 @@ def main():
                 safe_filename = quote(filename)
                 buildtools_url = "%s/%s/buildtools/%s" % (base_url, args.release, safe_filename)
 
-    tmpsdk_dir = tempfile.mkdtemp()
+    sdk_dir = args.downloads_directory or tempfile.mkdtemp()
+    os.makedirs(sdk_dir, exist_ok=True)
     try:
         # Fetch installer
         logger.info("Fetching buildtools installer")
-        tmpbuildtools = os.path.join(tmpsdk_dir, filename)
+        tmpbuildtools = os.path.join(sdk_dir, filename)
         ret = subprocess.call("wget -q -O %s %s" %
                               (tmpbuildtools, buildtools_url), shell=True)
         if ret != 0:
@@ -252,7 +256,7 @@ def main():
             checksum_type = "sha256sum"
             check_url = "{}.{}".format(buildtools_url, checksum_type)
             checksum_filename = "{}.{}".format(filename, checksum_type)
-            tmpbuildtools_checksum = os.path.join(tmpsdk_dir, checksum_filename)
+            tmpbuildtools_checksum = os.path.join(sdk_dir, checksum_filename)
             ret = subprocess.call("wget -q -O %s %s" %
                                     (tmpbuildtools_checksum, check_url), shell=True)
             if ret != 0:
@@ -347,7 +351,8 @@ def main():
 
     finally:
         # cleanup tmp directory
-        shutil.rmtree(tmpsdk_dir)
+        if not args.downloads_directory:
+            shutil.rmtree(sdk_dir)
 
 
 if __name__ == '__main__':