diff options
| -rwxr-xr-x | scripts/install-buildtools | 51 |
1 files 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 @@ | |||
| 11 | # Example usage (extended buildtools from milestone): | 11 | # Example usage (extended buildtools from milestone): |
| 12 | # (1) using --url and --filename | 12 | # (1) using --url and --filename |
| 13 | # $ install-buildtools \ | 13 | # $ install-buildtools \ |
| 14 | # --url http://downloads.yoctoproject.org/releases/yocto/milestones/yocto-3.1_M2/buildtools \ | 14 | # --url http://downloads.yoctoproject.org/releases/yocto/milestones/yocto-3.1_M3/buildtools \ |
| 15 | # --filename x86_64-buildtools-extended-nativesdk-standalone-3.0+snapshot-20200122.sh | 15 | # --filename x86_64-buildtools-extended-nativesdk-standalone-3.0+snapshot-20200315.sh |
| 16 | # (2) using --base-url, --release, --installer-version and --build-date | 16 | # (2) using --base-url, --release, --installer-version and --build-date |
| 17 | # $ install-buildtools \ | 17 | # $ install-buildtools \ |
| 18 | # --base-url http://downloads.yoctoproject.org/releases/yocto \ | 18 | # --base-url http://downloads.yoctoproject.org/releases/yocto \ |
| 19 | # --release yocto-3.1_M2 \ | 19 | # --release yocto-3.1_M3 \ |
| 20 | # --installer-version 3.0+snapshot | 20 | # --installer-version 3.0+snapshot |
| 21 | # --build-date 202000122 | 21 | # --build-date 202000315 |
| 22 | # | 22 | # |
| 23 | # Example usage (standard buildtools from release): | 23 | # Example usage (standard buildtools from release): |
| 24 | # (3) using --url and --filename | 24 | # (3) using --url and --filename |
| @@ -61,9 +61,9 @@ logger = scriptutils.logger_create(PROGNAME, stream=sys.stdout) | |||
| 61 | 61 | ||
| 62 | DEFAULT_INSTALL_DIR: str = os.path.join(os.path.split(scripts_path)[0],'buildtools') | 62 | DEFAULT_INSTALL_DIR: str = os.path.join(os.path.split(scripts_path)[0],'buildtools') |
| 63 | DEFAULT_BASE_URL: str = 'http://downloads.yoctoproject.org/releases/yocto' | 63 | DEFAULT_BASE_URL: str = 'http://downloads.yoctoproject.org/releases/yocto' |
| 64 | DEFAULT_RELEASE: str = 'yocto-3.1_M2' | 64 | DEFAULT_RELEASE: str = 'yocto-3.1_M3' |
| 65 | DEFAULT_INSTALLER_VERSION: str = '3.0+snapshot' | 65 | DEFAULT_INSTALLER_VERSION: str = '3.0+snapshot' |
| 66 | DEFAULT_BUILDDATE: str = "20200122" | 66 | DEFAULT_BUILDDATE: str = "20200315" |
| 67 | 67 | ||
| 68 | 68 | ||
| 69 | def main(): | 69 | def main(): |
| @@ -189,31 +189,40 @@ def main(): | |||
| 189 | if args.check: | 189 | if args.check: |
| 190 | import bb | 190 | import bb |
| 191 | logger.info("Fetching buildtools installer checksum") | 191 | logger.info("Fetching buildtools installer checksum") |
| 192 | check_url = "{}.md5sum".format(buildtools_url) | 192 | checksum_type = "" |
| 193 | checksum_filename = "%s.md5sum" % filename | 193 | for checksum_type in ["md5sum", "sha256"]: |
| 194 | tmpbuildtools_checksum = os.path.join(tmpsdk_dir, checksum_filename) | 194 | check_url = "{}.{}".format(buildtools_url, checksum_type) |
| 195 | ret = subprocess.call("wget -q -O %s %s" % | 195 | checksum_filename = "{}.{}".format(filename, checksum_type) |
| 196 | (tmpbuildtools_checksum, check_url), shell=True) | 196 | tmpbuildtools_checksum = os.path.join(tmpsdk_dir, checksum_filename) |
| 197 | if ret != 0: | 197 | ret = subprocess.call("wget -q -O %s %s" % |
| 198 | logger.error("Could not download file from %s" % check_url) | 198 | (tmpbuildtools_checksum, check_url), shell=True) |
| 199 | return ret | 199 | if ret == 0: |
| 200 | regex = re.compile(r"^(?P<md5sum>[0-9a-f]+)\s\s(?P<path>.*/)(?P<filename>.*)$") | 200 | break |
| 201 | else: | ||
| 202 | if ret != 0: | ||
| 203 | logger.error("Could not download file from %s" % check_url) | ||
| 204 | return ret | ||
| 205 | regex = re.compile(r"^(?P<checksum>[0-9a-f]+)\s\s(?P<path>.*/)?(?P<filename>.*)$") | ||
| 201 | with open(tmpbuildtools_checksum, 'rb') as f: | 206 | with open(tmpbuildtools_checksum, 'rb') as f: |
| 202 | original = f.read() | 207 | original = f.read() |
| 203 | m = re.search(regex, original.decode("utf-8")) | 208 | m = re.search(regex, original.decode("utf-8")) |
| 204 | logger.debug("md5sum: %s" % m.group('md5sum')) | 209 | logger.debug("checksum regex match: %s" % m) |
| 210 | logger.debug("checksum: %s" % m.group('checksum')) | ||
| 205 | logger.debug("path: %s" % m.group('path')) | 211 | logger.debug("path: %s" % m.group('path')) |
| 206 | logger.debug("filename: %s" % m.group('filename')) | 212 | logger.debug("filename: %s" % m.group('filename')) |
| 207 | if filename != m.group('filename'): | 213 | if filename != m.group('filename'): |
| 208 | logger.error("Filename does not match name in checksum") | 214 | logger.error("Filename does not match name in checksum") |
| 209 | return 1 | 215 | return 1 |
| 210 | md5sum = m.group('md5sum') | 216 | checksum = m.group('checksum') |
| 211 | md5value = bb.utils.md5_file(tmpbuildtools) | 217 | if checksum_type == "md5sum": |
| 212 | if md5sum == md5value: | 218 | checksum_value = bb.utils.md5_file(tmpbuildtools) |
| 213 | logger.info("Checksum success") | 219 | else: |
| 220 | checksum_value = bb.utils.sha256_file(tmpbuildtools) | ||
| 221 | if checksum == checksum_value: | ||
| 222 | logger.info("Checksum success") | ||
| 214 | else: | 223 | else: |
| 215 | logger.error("Checksum %s expected. Actual checksum is %s." % | 224 | logger.error("Checksum %s expected. Actual checksum is %s." % |
| 216 | (md5sum, md5value)) | 225 | (checksum, checksum_value)) |
| 217 | 226 | ||
| 218 | # Make installer executable | 227 | # Make installer executable |
| 219 | logger.info("Making installer executable") | 228 | logger.info("Making installer executable") |
