diff options
author | Tim Orling <timothy.t.orling@linux.intel.com> | 2020-03-31 13:03:06 -0700 |
---|---|---|
committer | Richard Purdie <richard.purdie@linuxfoundation.org> | 2020-04-01 11:44:24 +0100 |
commit | 4787c97874b37bc1748e615cb15c321d777388c4 (patch) | |
tree | 8094ab139d5b88fa6cc592bf2b57b5c49ce8c2ed /scripts/install-buildtools | |
parent | 37833137005980c41bc2c898d0e011f74da8cf8c (diff) | |
download | poky-4787c97874b37bc1748e615cb15c321d777388c4.tar.gz |
install-buildtools: bump default to yocto-3.1_M3, fixes
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>
(From OE-Core rev: cb1c98f38755b8340140125064c21e407f39db74)
Signed-off-by: Tim Orling <timothy.t.orling@linux.intel.com>
Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
Diffstat (limited to 'scripts/install-buildtools')
-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") |