public inbox for openembedded-core@lists.openembedded.org
 help / color / mirror / Atom feed
From: "Tim Orling" <timothy.t.orling@linux.intel.com>
To: openembedded-core@lists.openembedded.org
Cc: kai.kang@windriver.com, randy.macleod@windriver.com,
	Tim Orling <timothy.t.orling@linux.intel.com>
Subject: [PATCH v2 6/6] install-buildtools: bump default to yocto-3.1_M3, fixes
Date: Tue, 31 Mar 2020 13:03:06 -0700	[thread overview]
Message-ID: <20200331200306.36942-6-timothy.t.orling@linux.intel.com> (raw)
In-Reply-To: <20200331200306.36942-1-timothy.t.orling@linux.intel.com>

Add ability to check md5sum (yocto-3.1_M2 and before) or sha256
(yocto-3.1_M3 and beyond).

Make regex for path in checksum file optional, since
for yocto-3.1_M3 the format is <checksum>  <filename>,
but prior releases was <checksum>  <path><filename>

Signed-off-by: Tim Orling <timothy.t.orling@linux.intel.com>
---
 scripts/install-buildtools | 51 ++++++++++++++++++++++----------------
 1 file changed, 30 insertions(+), 21 deletions(-)

diff --git a/scripts/install-buildtools b/scripts/install-buildtools
index 49cab1345a..92fb1eb7d2 100755
--- a/scripts/install-buildtools
+++ b/scripts/install-buildtools
@@ -11,14 +11,14 @@
 #  Example usage (extended buildtools from milestone):
 #    (1) using --url and --filename
 #        $ install-buildtools \
-#          --url http://downloads.yoctoproject.org/releases/yocto/milestones/yocto-3.1_M2/buildtools \
-#          --filename x86_64-buildtools-extended-nativesdk-standalone-3.0+snapshot-20200122.sh
+#          --url http://downloads.yoctoproject.org/releases/yocto/milestones/yocto-3.1_M3/buildtools \
+#          --filename x86_64-buildtools-extended-nativesdk-standalone-3.0+snapshot-20200315.sh
 #    (2) using --base-url, --release, --installer-version and --build-date
 #        $ install-buildtools \
 #          --base-url http://downloads.yoctoproject.org/releases/yocto \
-#          --release yocto-3.1_M2 \
+#          --release yocto-3.1_M3 \
 #          --installer-version 3.0+snapshot
-#          --build-date 202000122
+#          --build-date 202000315
 #
 #  Example usage (standard buildtools from release):
 #    (3) using --url and --filename
@@ -61,9 +61,9 @@ logger = scriptutils.logger_create(PROGNAME, stream=sys.stdout)
 
 DEFAULT_INSTALL_DIR: str = os.path.join(os.path.split(scripts_path)[0],'buildtools')
 DEFAULT_BASE_URL: str = 'http://downloads.yoctoproject.org/releases/yocto'
-DEFAULT_RELEASE: str = 'yocto-3.1_M2'
+DEFAULT_RELEASE: str = 'yocto-3.1_M3'
 DEFAULT_INSTALLER_VERSION: str = '3.0+snapshot'
-DEFAULT_BUILDDATE: str = "20200122"
+DEFAULT_BUILDDATE: str = "20200315"
 
 
 def main():
@@ -189,31 +189,40 @@ def main():
         if args.check:
             import bb
             logger.info("Fetching buildtools installer checksum")
-            check_url = "{}.md5sum".format(buildtools_url)
-            checksum_filename = "%s.md5sum" % filename
-            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<md5sum>[0-9a-f]+)\s\s(?P<path>.*/)(?P<filename>.*)$")
+            checksum_type = ""
+            for checksum_type in ["md5sum", "sha256"]: 
+                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
+            regex = re.compile(r"^(?P<checksum>[0-9a-f]+)\s\s(?P<path>.*/)?(?P<filename>.*)$")
             with open(tmpbuildtools_checksum, 'rb') as f:
                 original = f.read()
                 m = re.search(regex, original.decode("utf-8"))
-                logger.debug("md5sum: %s" % m.group('md5sum'))
+                logger.debug("checksum regex match: %s" % m)
+                logger.debug("checksum: %s" % m.group('checksum'))
                 logger.debug("path: %s" % m.group('path'))
                 logger.debug("filename: %s" % m.group('filename'))
                 if filename != m.group('filename'):
                     logger.error("Filename does not match name in checksum")
                     return 1
-                md5sum = m.group('md5sum')
-            md5value = bb.utils.md5_file(tmpbuildtools)
-            if md5sum == md5value:
-                logger.info("Checksum success")
+                checksum = m.group('checksum')
+            if checksum_type == "md5sum":
+                checksum_value = bb.utils.md5_file(tmpbuildtools)
+            else:
+                checksum_value = bb.utils.sha256_file(tmpbuildtools)
+            if checksum == checksum_value:
+                    logger.info("Checksum success")
             else:
                 logger.error("Checksum %s expected. Actual checksum is %s." %
-                             (md5sum, md5value))
+                             (checksum, checksum_value))
 
         # Make installer executable
         logger.info("Making installer executable")
-- 
2.24.0


      parent reply	other threads:[~2020-03-31 20:03 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-03-31 20:03 [PATCH v2 1/6] scripts/install-buildtools: improvements Tim Orling
2020-03-31 20:03 ` [PATCH v2 2/6] oe-buildenv-internal: python 3.5 as min version Tim Orling
2020-03-31 20:03 ` [PATCH v2 3/6] sanity.bbclass: recommend using install-buildtools Tim Orling
2020-03-31 20:03 ` [PATCH v2 4/6] lib/oe/utils.py: add get_host_compiler_version() Tim Orling
2020-03-31 20:03 ` [PATCH v2 5/6] sanity.bbclass: add test for gcc < 5.0 Tim Orling
2020-03-31 20:03 ` Tim Orling [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20200331200306.36942-6-timothy.t.orling@linux.intel.com \
    --to=timothy.t.orling@linux.intel.com \
    --cc=kai.kang@windriver.com \
    --cc=openembedded-core@lists.openembedded.org \
    --cc=randy.macleod@windriver.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox