diff mbox series

[2/2] scripts/install-buildtools: write download URLs to files for traceability

Message ID 20250311104152.393470-2-alex.kanavin@gmail.com
State New
Headers show
Series [1/2] scripts/install-buildtools: add an option to preserve downloads | expand

Commit Message

Alexander Kanavin March 11, 2025, 10:41 a.m. UTC
From: Alexander Kanavin <alex@linutronix.de>

This extends the previous commit, so that download URLs are preserved
in addition to actual artefacts. By default it's all written to a temporary
directory and erased together with artefacts, but users can choose
to preserve both:

$ install-buildtools -D --keep-downloads-directory=.
...

$ ls -1
buildtools_url
check_url
x86_64-buildtools-extended-nativesdk-standalone-5.1.2.sh
x86_64-buildtools-extended-nativesdk-standalone-5.1.2.sh.sha256sum

Signed-off-by: Alexander Kanavin <alex@linutronix.de>
---
 scripts/install-buildtools | 4 ++++
 1 file changed, 4 insertions(+)

Comments

Richard Purdie March 13, 2025, 11:17 a.m. UTC | #1
On Tue, 2025-03-11 at 11:41 +0100, Alexander Kanavin via lists.openembedded.org wrote:
> From: Alexander Kanavin <alex@linutronix.de>
> 
> This extends the previous commit, so that download URLs are preserved
> in addition to actual artefacts. By default it's all written to a temporary
> directory and erased together with artefacts, but users can choose
> to preserve both:
> 
> $ install-buildtools -D --keep-downloads-directory=.
> ...
> 
> $ ls -1
> buildtools_url
> check_url
> x86_64-buildtools-extended-nativesdk-standalone-5.1.2.sh
> x86_64-buildtools-extended-nativesdk-standalone-5.1.2.sh.sha256sum
> 
> Signed-off-by: Alexander Kanavin <alex@linutronix.de>
> ---
>  scripts/install-buildtools | 4 ++++
>  1 file changed, 4 insertions(+)
> 
> diff --git a/scripts/install-buildtools b/scripts/install-buildtools
> index 1a68aad53e7..7bd6556edf6 100755
> --- a/scripts/install-buildtools
> +++ b/scripts/install-buildtools
> @@ -243,6 +243,8 @@ def main():
>          # Fetch installer
>          logger.info("Fetching buildtools installer")
>          tmpbuildtools = os.path.join(sdk_dir, filename)
> +        with open(os.path.join(sdk_dir, 'buildtools_url'), 'w') as f:
> +            f.write(buildtools_url)
>          ret = subprocess.call("wget -q -O %s %s" %
>                                (tmpbuildtools, buildtools_url), shell=True)
>          if ret != 0:
> @@ -256,6 +258,8 @@ def main():
>              check_url = "{}.{}".format(buildtools_url, checksum_type)
>              checksum_filename = "{}.{}".format(filename, checksum_type)
>              tmpbuildtools_checksum = os.path.join(sdk_dir, checksum_filename)
> +            with open(os.path.join(sdk_dir, 'check_url'), 'w') as f:
> +                f.write(check_url)
>              ret = subprocess.call("wget -q -O %s %s" %
>                                      (tmpbuildtools_checksum, check_url), shell=True)
>              if ret != 0:
> 


The naming of "check_url" needs to be changed. I appreciate you've used
a variable name from the code however when you see this file in
isolation in a directory, you'd have no real idea what it is (a
checksum for the downloaded file). "buildtools_url.checksum" might be
even clearer?

Cheers,

Richard
diff mbox series

Patch

diff --git a/scripts/install-buildtools b/scripts/install-buildtools
index 1a68aad53e7..7bd6556edf6 100755
--- a/scripts/install-buildtools
+++ b/scripts/install-buildtools
@@ -243,6 +243,8 @@  def main():
         # Fetch installer
         logger.info("Fetching buildtools installer")
         tmpbuildtools = os.path.join(sdk_dir, filename)
+        with open(os.path.join(sdk_dir, 'buildtools_url'), 'w') as f:
+            f.write(buildtools_url)
         ret = subprocess.call("wget -q -O %s %s" %
                               (tmpbuildtools, buildtools_url), shell=True)
         if ret != 0:
@@ -256,6 +258,8 @@  def main():
             check_url = "{}.{}".format(buildtools_url, checksum_type)
             checksum_filename = "{}.{}".format(filename, checksum_type)
             tmpbuildtools_checksum = os.path.join(sdk_dir, checksum_filename)
+            with open(os.path.join(sdk_dir, 'check_url'), 'w') as f:
+                f.write(check_url)
             ret = subprocess.call("wget -q -O %s %s" %
                                     (tmpbuildtools_checksum, check_url), shell=True)
             if ret != 0: