Skip to contentSkip to conversation

install-buildtools: remove md5 checksum validation

PATCH New Aleksandar Nikolic 1 participant 4 messages Sep 23, 2024

lore
Share & tools
lore
#0 lore raw

PATCH 1/4 install-buildtools: remove md5 checksum validation

From: Aleksandar Nikolic <[email protected]>

No need to validate with the md5 checksum, as the file is not even uploaded to the Yocto release webpage (the download never failed due to a wrong indentation of an else statement). For validation purposes, use the sha256 checksum only.

(cherry picked from commit b740d2f9d40aef1e18c022d1e82b4fb2c5c1fc22)
---
 scripts/install-buildtools | 27 ++++++++++-----------------
 1 file changed, 10 insertions(+), 17 deletions(-)
scripts/install-buildtools +10 -17
index 2218f3ffac..a34474ea84 100755
@@ -238,19 +238,15 @@ def main():
         # Verify checksum
         if args.check:
             logger.info("Fetching buildtools installer checksum")
-            checksum_type = ""
-            for checksum_type in ["md5sum", "sha256sum"]:
-                check_url = "{}.{}".format(buildtools_url, checksum_type)
-                checksum_filename = "{}.{}".format(filename, checksum_type)
-                tmpbuildtools_checksum = os.path.join(tmpsdk_dir, checksum_filename)
-                ret = subprocess.call("wget -q -O %s %s" %
-                                      (tmpbuildtools_checksum, check_url), shell=True)
-                if ret == 0:
-                    break
-            else:
-                if ret != 0:
-                    logger.error("Could not download file from %s" % check_url)
-                    return ret
+            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)
+            ret = subprocess.call("wget -q -O %s %s" %
+                                    (tmpbuildtools_checksum, check_url), shell=True)
+            if ret != 0:
+                logger.error("Could not download file from %s" % check_url)
+                return ret
             regex = re.compile(r"^(?P<checksum>[0-9a-f]+)\s+(?P<path>.*/)?(?P<filename>.*)$")
             with open(tmpbuildtools_checksum, 'rb') as f:
                 original = f.read()
@@ -263,10 +259,7 @@ def main():
                     logger.error("Filename does not match name in checksum")
                     return 1
                 checksum = m.group('checksum')
-            if checksum_type == "md5sum":
-                checksum_value = md5_file(tmpbuildtools)
-            else:
-                checksum_value = sha256_file(tmpbuildtools)
+            checksum_value = sha256_file(tmpbuildtools)
             if checksum == checksum_value:
                     logger.info("Checksum success")
             else:
Signature · 1 line
2.25.1
#1 lore raw

PATCH 2/4 install-buildtools: fix "test installation" step

From: Aleksandar Nikolic <[email protected]>

The "Test installation" step fails with some harmless error messages (see [1]). This can however make a user think that the buildtools have not been installed correctly.

Two reasons for the error messages:
- some envvars in the environment-setup-<arch>-pokysdk-linux file start and end with double quotes (e.g., PATH) and are as such written into python os.environ. This leads that their usage is not valid later when testing the installation. This patch removes the double quotes before writing, if they are present.
- if installation directory (install_dir), given through the option --directory, is given as a relative path, checking if the path to a tool (e.g., gcc) in buildtools starts it will always fail. This patch converts the install_dir variable to an absolute path.

[1]
ERROR: Something went wrong: tar not found in ./build-tools
ERROR: Something went wrong: installation failed

(cherry picked from commit e4eb0b14ecf9bd2fba13260441c9d86eb348f41e)
---
 scripts/install-buildtools | 14 ++++++++++++--
 1 file changed, 12 insertions(+), 2 deletions(-)
scripts/install-buildtools +12 -2
index a34474ea84..4f85fe87d4 100755
@@ -102,6 +102,16 @@ def sha256_file(filename):
     import hashlib
     return _hasher(hashlib.sha256(), filename)
 
+def remove_quotes(var):
+    """
+    If a variable starts and ends with double quotes, remove them.
+    Assumption: if a variable starts with double quotes, it must also
+    end with them.
+    """
+    if var[0] == '"':
+        var = var[1:-1]
+    return var
+
 
 def main():
     global DEFAULT_INSTALL_DIR
@@ -273,7 +283,7 @@ def main():
         os.chmod(tmpbuildtools, st.st_mode | stat.S_IEXEC)
         logger.debug(os.stat(tmpbuildtools))
         if args.directory:
-            install_dir = args.directory
+            install_dir = os.path.abspath(args.directory)
             ret = subprocess.call("%s -d %s -y" %
                                   (tmpbuildtools, install_dir), shell=True)
         else:
@@ -294,7 +304,7 @@ def main():
                 if match:
                     env_var = match.group('env_var')
                     logger.debug("env_var: %s" % env_var)
-                    env_val = match.group('env_val')
+                    env_val = remove_quotes(match.group('env_val'))
                     logger.debug("env_val: %s" % env_val)
                     os.environ[env_var] = env_val
 
Signature · 1 line
2.25.1
#2 lore raw

PATCH 3/4 install-buildtools: update base-url, release and installer version

In reply to Aleksandar Nikolic

From: Aleksandar Nikolic <[email protected]>

Update the following default values:
- DEFAULT_BASE_URL (https instead of http)
- DEFAULT_RELEASE (5.0.1)
- DEFAULT_INSTALLER_VERSION (5.0.1)

(cherry picked from commit b2ebb965a5aa128b05ed7ddc9216171463777732)
---
 scripts/install-buildtools | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)
scripts/install-buildtools +3 -3
index 4f85fe87d4..5b86c13077 100755
@@ -56,9 +56,9 @@ PROGNAME = 'install-buildtools'
 logger = scriptutils.logger_create(PROGNAME, stream=sys.stdout)
 
 DEFAULT_INSTALL_DIR = os.path.join(os.path.split(scripts_path)[0],'buildtools')
-DEFAULT_BASE_URL = 'http://downloads.yoctoproject.org/releases/yocto'
-DEFAULT_RELEASE = 'yocto-4.1'
-DEFAULT_INSTALLER_VERSION = '4.1'
+DEFAULT_BASE_URL = 'https://downloads.yoctoproject.org/releases/yocto'
+DEFAULT_RELEASE = 'yocto-5.0.1'
+DEFAULT_INSTALLER_VERSION = '5.0.1'
 DEFAULT_BUILDDATE = '202110XX'
 
 # Python version sanity check
Signature · 1 line
2.25.1
#3 lore raw

PATCH 4/4 scripts/install-buildtools: Update to 5.0.3

In reply to Aleksandar Nikolic

From: Richard Purdie <[email protected]>

Update to the 5.0.3 release of the 5.0 series for buildtools.

(cherry picked from commit c922ca720a0c3b7b4d3d3187539e7cf77d93d457)
---
 scripts/install-buildtools | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
scripts/install-buildtools +2 -2
index 5b86c13077..92a4c9dfb1 100755
@@ -57,8 +57,8 @@ logger = scriptutils.logger_create(PROGNAME, stream=sys.stdout)
 
 DEFAULT_INSTALL_DIR = os.path.join(os.path.split(scripts_path)[0],'buildtools')
 DEFAULT_BASE_URL = 'https://downloads.yoctoproject.org/releases/yocto'
-DEFAULT_RELEASE = 'yocto-5.0.1'
-DEFAULT_INSTALLER_VERSION = '5.0.1'
+DEFAULT_RELEASE = 'yocto-5.0.3'
+DEFAULT_INSTALLER_VERSION = '5.0.3'
 DEFAULT_BUILDDATE = '202110XX'
 
 # Python version sanity check
Signature · 1 line
2.25.1