Fathi Boudra | cd8f58d | 2012-06-15 17:43:39 +0300 | [diff] [blame] | 1 | #!/usr/bin/python |
| 2 | |
Andy Doan | 15aa23b | 2012-02-02 16:40:58 -0600 | [diff] [blame] | 3 | # Copyright (C) 2012 Linaro |
| 4 | # |
| 5 | # Author: Andy Doan <andy.doan@linaro.org> |
| 6 | # |
| 7 | # This file is part of Linaro Daily Prebuilt Images. |
| 8 | # |
| 9 | # Linaro Daily Prebuilt Images is free software; you can redistribute it and/or |
| 10 | # modify it under the terms of the GNU General Public License |
| 11 | # as published by the Free Software Foundation; either version 2 |
| 12 | # of the License, or (at your option) any later version. |
| 13 | # |
| 14 | # Linaro Daily Prebuilt Images is distributed in the hope that it will be useful, |
| 15 | # but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 16 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 17 | # GNU General Public License for more details. |
| 18 | # |
| 19 | # You should have received a copy of the GNU General Public License |
| 20 | # along with Linaro Image Tools; if not, write to the Free Software |
| 21 | # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, |
| 22 | # USA. |
| 23 | |
Andy Doan | fccf484 | 2012-03-08 10:42:19 -0600 | [diff] [blame] | 24 | from linaro_fetch_image import fetch_image |
Andy Doan | 15aa23b | 2012-02-02 16:40:58 -0600 | [diff] [blame] | 25 | from linaro_image_tools import cmd_runner |
| 26 | |
Andy Doan | 8ff38f0 | 2012-02-20 16:32:37 -0600 | [diff] [blame] | 27 | import crawler |
| 28 | |
Andy Doan | 15aa23b | 2012-02-02 16:40:58 -0600 | [diff] [blame] | 29 | import argparse |
Andy Doan | 15aa23b | 2012-02-02 16:40:58 -0600 | [diff] [blame] | 30 | import datetime |
Ricardo Salveti de Araujo | b39eb80 | 2012-06-23 00:55:31 -0300 | [diff] [blame] | 31 | import time |
Andy Doan | 3634c47 | 2012-04-17 12:50:58 -0500 | [diff] [blame] | 32 | import hashlib |
Andy Doan | c6500af | 2012-03-15 14:44:39 -0500 | [diff] [blame] | 33 | import os |
Andy Doan | 15aa23b | 2012-02-02 16:40:58 -0600 | [diff] [blame] | 34 | import re |
Andy Doan | e449bce | 2012-03-21 15:22:31 -0500 | [diff] [blame] | 35 | import urlparse |
Andy Doan | 35ee9dc | 2012-05-11 01:10:12 -0500 | [diff] [blame] | 36 | import string |
Andy Doan | 15aa23b | 2012-02-02 16:40:58 -0600 | [diff] [blame] | 37 | |
Andy Doan | ea2e1ea | 2012-04-23 11:56:29 -0500 | [diff] [blame] | 38 | class HwPack: |
| 39 | def __init__(self, lmcname, eula=False, pre_inst_script=None): |
| 40 | self.lmcname = lmcname |
| 41 | if eula: |
| 42 | self.eula = 'EULA.txt' |
| 43 | else: |
Andy Doan | 4aabf02 | 2012-04-26 14:30:29 -0500 | [diff] [blame] | 44 | self.eula = 'OPEN-EULA.txt' |
Andy Doan | ea2e1ea | 2012-04-23 11:56:29 -0500 | [diff] [blame] | 45 | self.pre_inst_script = pre_inst_script |
| 46 | |
| 47 | def do_eula(self, imgfile): |
| 48 | fname = '%s/%s' % (os.path.dirname(imgfile), self.eula) |
| 49 | with file(fname, 'a'): |
| 50 | pass #just need the file to exist |
| 51 | |
Andy Doan | 15aa23b | 2012-02-02 16:40:58 -0600 | [diff] [blame] | 52 | # a mapping of hwpack name to l-m-c name |
| 53 | HWPACKS = { |
Andy Doan | ea2e1ea | 2012-04-23 11:56:29 -0500 | [diff] [blame] | 54 | 'beagleboard': HwPack('beagle'), |
| 55 | 'overo': HwPack('overo'), |
| 56 | 'lt-panda': HwPack('panda'), |
Andy Doan | 7a8cc10 | 2012-04-26 09:25:33 -0500 | [diff] [blame] | 57 | 'lt-panda-x11-base': HwPack('panda'), |
Ricardo Salveti de Araujo | 90fe78d | 2012-07-29 00:51:57 -0300 | [diff] [blame] | 58 | 'ti-panda-x11-base': HwPack('panda'), |
Andy Doan | ea2e1ea | 2012-04-23 11:56:29 -0500 | [diff] [blame] | 59 | 'lt-mx5': HwPack('mx53loco'), |
| 60 | 'lt-mx6': HwPack('mx6qsabrelite'), |
Andy Doan | 490f620 | 2012-04-25 10:56:08 -0500 | [diff] [blame] | 61 | 'lt-origen': HwPack('origen'), |
| 62 | 'leb-origen': HwPack('origen'), |
Andy Doan | ea2e1ea | 2012-04-23 11:56:29 -0500 | [diff] [blame] | 63 | 'lt-snowball': HwPack('snowball_sd', True, 'ste-preinstall.sh'), |
| 64 | 'lt-snowball-x11-base': HwPack('snowball_sd', True, 'ste-preinstall.sh'), |
Ricardo Salveti de Araujo | a798c50 | 2012-06-27 19:05:10 -0300 | [diff] [blame] | 65 | 'lt-vexpress': HwPack('vexpress'), |
Andy Doan | edffb5d | 2012-04-25 11:22:19 -0500 | [diff] [blame] | 66 | 'vexpress': HwPack('vexpress'), |
Ricardo Salveti de Araujo | 688f24f | 2012-10-17 02:40:36 -0300 | [diff] [blame] | 67 | 'vexpress64': HwPack('vexpress'), |
Andy Doan | ea2e1ea | 2012-04-23 11:56:29 -0500 | [diff] [blame] | 68 | 'efikamx': HwPack('efikamx'), |
| 69 | 'igep': HwPack('igep'), |
Andy Doan | 15aa23b | 2012-02-02 16:40:58 -0600 | [diff] [blame] | 70 | } |
| 71 | # a mapping of binary image to its image_file size |
| 72 | BINARIES = { |
Andy Doan | 4202d88 | 2012-03-29 21:36:09 -0500 | [diff] [blame] | 73 | # release images |
Andy Doan | 08485da | 2012-05-31 22:24:29 +0800 | [diff] [blame] | 74 | 'nano': '1G', #512 is big enough, but this gives us free disk space |
Andy Doan | 4202d88 | 2012-03-29 21:36:09 -0500 | [diff] [blame] | 75 | 'alip': '2G', |
| 76 | 'ubuntu-desktop': '3G', |
| 77 | 'linarotv-xbmc': '3G', |
Ricardo Salveti de Araujo | 688f24f | 2012-10-17 02:40:36 -0300 | [diff] [blame] | 78 | 'minimal-armv8': '512M', |
Ricardo Salveti de Araujo | d0fe5c4 | 2012-10-17 03:29:58 -0300 | [diff] [blame] | 79 | 'lamp-armv8': '2G', |
| 80 | 'sdk-armv8': '2G', |
Andy Doan | 15aa23b | 2012-02-02 16:40:58 -0600 | [diff] [blame] | 81 | } |
| 82 | |
Fathi Boudra | 75e299a | 2012-08-26 19:04:03 +0300 | [diff] [blame] | 83 | SNAPSHOTS_URL = "http://snapshots.linaro.org" |
| 84 | |
Andy Doan | 15aa23b | 2012-02-02 16:40:58 -0600 | [diff] [blame] | 85 | def today(): |
| 86 | d = datetime.date.today() |
| 87 | return "%d%02d%02d" % (d.year, d.month, d.day) |
| 88 | |
Ricardo Salveti de Araujo | b39eb80 | 2012-06-23 00:55:31 -0300 | [diff] [blame] | 89 | def download(dm, url): |
| 90 | print "INFO: Fetching", url |
| 91 | before = time.time() |
| 92 | dfile = dm.download(url, None, verbose=False) |
| 93 | delta_min, delta_secs = divmod(int(time.time() - before), 60) |
| 94 | print "INFO: Downloaded file '%s' in %d min(s) and %d sec(s)" % ( |
| 95 | dfile, delta_min, delta_secs) |
| 96 | return dfile |
| 97 | |
Andy Doan | 15aa23b | 2012-02-02 16:40:58 -0600 | [diff] [blame] | 98 | def compress_image(imgfile): |
Ricardo Salveti de Araujo | ba7dacf | 2012-06-23 01:08:24 -0300 | [diff] [blame] | 99 | print "INFO: compressing %s" % imgfile |
Ricardo Salveti de Araujo | d678850 | 2012-06-23 01:19:18 -0300 | [diff] [blame] | 100 | before = time.time() |
Ricardo Salveti de Araujo | 7edc48b | 2012-06-23 03:55:04 -0300 | [diff] [blame] | 101 | args = ('gzip', imgfile) |
Andy Doan | 15aa23b | 2012-02-02 16:40:58 -0600 | [diff] [blame] | 102 | cmd_runner.run(args).wait() |
Ricardo Salveti de Araujo | d678850 | 2012-06-23 01:19:18 -0300 | [diff] [blame] | 103 | delta_min, delta_secs = divmod(int(time.time() - before), 60) |
| 104 | print "INFO: file compressed in %d min(s) and %d sec(s)" % ( |
| 105 | delta_min, delta_secs) |
Ricardo Salveti de Araujo | 7edc48b | 2012-06-23 03:55:04 -0300 | [diff] [blame] | 106 | return '%s.gz' % imgfile |
Andy Doan | 23ce4e1 | 2012-03-21 12:46:21 -0500 | [diff] [blame] | 107 | |
Ricardo Salveti de Araujo | d3743e9 | 2012-08-15 01:50:10 -0300 | [diff] [blame] | 108 | def zsync_image(platform, imgfile): |
Ricardo Salveti de Araujo | ba7dacf | 2012-06-23 01:08:24 -0300 | [diff] [blame] | 109 | print "INFO: making zsync file for %s" % imgfile |
Ricardo Salveti de Araujo | d678850 | 2012-06-23 01:19:18 -0300 | [diff] [blame] | 110 | before = time.time() |
Fathi Boudra | 75e299a | 2012-08-26 19:04:03 +0300 | [diff] [blame] | 111 | basepath = "%s/%s/pre-built" % (SNAPSHOTS_URL, platform) |
Paul Larson | 2a8e67b | 2012-08-06 09:47:14 -0500 | [diff] [blame] | 112 | imgpath=os.sep.join(imgfile.split(os.sep)[-3:]) |
| 113 | zurl=basepath + os.sep + imgpath |
| 114 | args = ('zsyncmake', '-b 2048', '-u', zurl, '-o', '%s.zsync' % imgfile, |
| 115 | imgfile) |
Andy Doan | 23ce4e1 | 2012-03-21 12:46:21 -0500 | [diff] [blame] | 116 | cmd_runner.run(args).wait() |
Ricardo Salveti de Araujo | d678850 | 2012-06-23 01:19:18 -0300 | [diff] [blame] | 117 | delta_min, delta_secs = divmod(int(time.time() - before), 60) |
| 118 | print "INFO: zsync generated in %d min(s) and %d sec(s)" % ( |
| 119 | delta_min, delta_secs) |
Andy Doan | 15aa23b | 2012-02-02 16:40:58 -0600 | [diff] [blame] | 120 | |
Andy Doan | 3634c47 | 2012-04-17 12:50:58 -0500 | [diff] [blame] | 121 | def md5sum(fname): |
| 122 | md5 = hashlib.md5() |
| 123 | with open(fname, 'rb') as f: |
| 124 | while True: |
| 125 | data = f.read(4096) |
| 126 | if not data: break |
| 127 | md5.update(data) |
| 128 | return md5.hexdigest() |
| 129 | |
Ricardo Salveti de Araujo | 7edc48b | 2012-06-23 03:55:04 -0300 | [diff] [blame] | 130 | def create_image_info(infofile, gzfile, binary_file, hwpack_url, rootfs_url): |
Ricardo Salveti de Araujo | b93a7ec | 2012-05-29 14:07:53 -0300 | [diff] [blame] | 131 | ''' prints out the md5sum and hwpack/rootfs info for the given image |
Andy Doan | 3634c47 | 2012-04-17 12:50:58 -0500 | [diff] [blame] | 132 | ''' |
Ricardo Salveti de Araujo | 7edc48b | 2012-06-23 03:55:04 -0300 | [diff] [blame] | 133 | print "INFO: building image info for: %s" % gzfile |
| 134 | md5 = md5sum(gzfile) |
Andy Doan | 3634c47 | 2012-04-17 12:50:58 -0500 | [diff] [blame] | 135 | |
| 136 | binary_file = os.path.basename(binary_file) |
Andy Doan | 35ee9dc | 2012-05-11 01:10:12 -0500 | [diff] [blame] | 137 | tfile = '%s/image_info_template.html' % os.path.dirname(__file__) |
Andy Doan | 3634c47 | 2012-04-17 12:50:58 -0500 | [diff] [blame] | 138 | |
Andy Doan | 35ee9dc | 2012-05-11 01:10:12 -0500 | [diff] [blame] | 139 | tmpl = None |
| 140 | with open(tfile) as f: |
| 141 | buff = f.read() |
| 142 | tmpl = string.Template(buff) |
| 143 | |
| 144 | title = 'Pre-Built Image Info' |
Ricardo Salveti de Araujo | b93a7ec | 2012-05-29 14:07:53 -0300 | [diff] [blame] | 145 | |
| 146 | # build hwpack manifest and rootfs packages links |
| 147 | hwpack_re = re.search(r'(hwpack_linaro.*\d\w*)(.*)$', hwpack_url) |
| 148 | hwpack_name = "".join(hwpack_re.groups()) |
| 149 | hwpack_manifest = hwpack_name + '.manifest.txt' |
| 150 | hwpack_manifest_url = re.sub('.tar.gz$', '.manifest.txt', hwpack_url) |
| 151 | |
| 152 | rootfs_re = re.search(r'(linaro-.*\d)(.*)$', rootfs_url) |
| 153 | rootfs_name = "".join(rootfs_re.groups()) |
| 154 | rootfs_packages = rootfs_name + '.packages' |
| 155 | rootfs_packages_url = re.sub('.tar.gz$', '.packages', rootfs_url) |
| 156 | |
Ricardo Salveti de Araujo | 894040a | 2012-05-29 14:07:55 -0300 | [diff] [blame] | 157 | # try to get information from Jenkins, if available |
| 158 | jenkins_buildn = os.environ.get('BUILD_NUMBER') or 'Not Found' |
| 159 | jenkins_build_url = os.environ.get('BUILD_URL') or 'http://ci.linaro.org' |
| 160 | |
Ricardo Salveti de Araujo | b93a7ec | 2012-05-29 14:07:53 -0300 | [diff] [blame] | 161 | buff = tmpl.substitute( |
Ricardo Salveti de Araujo | 7edc48b | 2012-06-23 03:55:04 -0300 | [diff] [blame] | 162 | title=title, md5=md5, image_name=os.path.basename(gzfile), |
Ricardo Salveti de Araujo | b93a7ec | 2012-05-29 14:07:53 -0300 | [diff] [blame] | 163 | hwpack_name=hwpack_name, hwpack_url=hwpack_url, |
| 164 | rootfs_name=rootfs_name, rootfs_url=rootfs_url, |
| 165 | hwpack_manifest_name=hwpack_manifest, |
| 166 | hwpack_manifest_url=hwpack_manifest_url, |
| 167 | rootfs_packages_name=rootfs_packages, |
Ricardo Salveti de Araujo | 894040a | 2012-05-29 14:07:55 -0300 | [diff] [blame] | 168 | rootfs_packages_url=rootfs_packages_url, |
| 169 | jenkins_buildn=jenkins_buildn, |
| 170 | jenkins_build_url=jenkins_build_url) |
Andy Doan | 3c0c389 | 2012-04-25 11:09:53 -0500 | [diff] [blame] | 171 | with open(infofile, 'w') as f: |
Andy Doan | 35ee9dc | 2012-05-11 01:10:12 -0500 | [diff] [blame] | 172 | f.write(buff) |
Andy Doan | 3634c47 | 2012-04-17 12:50:58 -0500 | [diff] [blame] | 173 | |
Ricardo Salveti de Araujo | 688f24f | 2012-10-17 02:40:36 -0300 | [diff] [blame] | 174 | def build_image(lmc, imgfile, hwpack, hwpack_file, binary, |
| 175 | binary_file, fastmodel=False): |
Ricardo Salveti de Araujo | ba7dacf | 2012-06-23 01:08:24 -0300 | [diff] [blame] | 176 | print "INFO: building image: %s" % imgfile |
Andy Doan | ea2e1ea | 2012-04-23 11:56:29 -0500 | [diff] [blame] | 177 | hwpi = HWPACKS[hwpack] |
Andy Doan | 15aa23b | 2012-02-02 16:40:58 -0600 | [diff] [blame] | 178 | size = BINARIES[binary] |
| 179 | |
Andy Doan | c6500af | 2012-03-15 14:44:39 -0500 | [diff] [blame] | 180 | args = [lmc, |
Andy Doan | 15aa23b | 2012-02-02 16:40:58 -0600 | [diff] [blame] | 181 | '--image_size', size, |
| 182 | '--hwpack-force-yes', |
| 183 | '--hwpack', hwpack_file, |
| 184 | '--binary', binary_file, |
Andy Doan | c6500af | 2012-03-15 14:44:39 -0500 | [diff] [blame] | 185 | ] |
| 186 | |
Ricardo Salveti de Araujo | 688f24f | 2012-10-17 02:40:36 -0300 | [diff] [blame] | 187 | if fastmodel: |
| 188 | args += ['--dev', 'fastmodel', |
| 189 | '--output-directory', os.path.dirname(imgfile), |
| 190 | '--image_file', os.path.basename(imgfile)] |
| 191 | else: |
| 192 | args += ['--dev', hwpi.lmcname, |
| 193 | '--image_file', imgfile] |
| 194 | |
Andy Doan | ea2e1ea | 2012-04-23 11:56:29 -0500 | [diff] [blame] | 195 | if hwpi.pre_inst_script is not None: |
Andy Doan | c6500af | 2012-03-15 14:44:39 -0500 | [diff] [blame] | 196 | sdir = os.path.abspath(os.path.dirname(__file__)) |
Andy Doan | ea2e1ea | 2012-04-23 11:56:29 -0500 | [diff] [blame] | 197 | script = "%s/%s" % (sdir, hwpi.pre_inst_script) |
Andy Doan | c6500af | 2012-03-15 14:44:39 -0500 | [diff] [blame] | 198 | print "using presintall script: %s" % script |
| 199 | args.append('--preinstall-script') |
| 200 | args.append(script) |
| 201 | |
Ricardo Salveti de Araujo | ba7dacf | 2012-06-23 01:08:24 -0300 | [diff] [blame] | 202 | print "INFO: running l-m-c:", " ".join([str(arg) for arg in args]) |
| 203 | |
Andy Doan | ea2e1ea | 2012-04-23 11:56:29 -0500 | [diff] [blame] | 204 | hwpi.do_eula(imgfile) |
Ricardo Salveti de Araujo | d678850 | 2012-06-23 01:19:18 -0300 | [diff] [blame] | 205 | |
| 206 | # some useful information so we know how much time it took per lmc run |
| 207 | before = time.time() |
Andy Doan | 15aa23b | 2012-02-02 16:40:58 -0600 | [diff] [blame] | 208 | cmd_runner.run(args, as_root=True).wait() |
Ricardo Salveti de Araujo | d678850 | 2012-06-23 01:19:18 -0300 | [diff] [blame] | 209 | delta_min, delta_secs = divmod(int(time.time() - before), 60) |
| 210 | print "INFO: linaro-media-create took %d min(s) and %d sec(s) to run" % ( |
| 211 | delta_min, delta_secs) |
Andy Doan | 15aa23b | 2012-02-02 16:40:58 -0600 | [diff] [blame] | 212 | |
Andy Doan | 184cd3b | 2012-03-29 22:20:02 -0500 | [diff] [blame] | 213 | class SnapshotCrawler: |
Ricardo Salveti de Araujo | 0352cb9 | 2012-06-22 21:48:34 -0300 | [diff] [blame] | 214 | def __init__(self, platform, hwpacks, binaries): |
Andy Doan | 184cd3b | 2012-03-29 22:20:02 -0500 | [diff] [blame] | 215 | self.platform = platform |
| 216 | self.hwpacks = hwpacks |
| 217 | self.binaries = binaries |
Andy Doan | e449bce | 2012-03-21 15:22:31 -0500 | [diff] [blame] | 218 | |
Andy Doan | 184cd3b | 2012-03-29 22:20:02 -0500 | [diff] [blame] | 219 | def get_binaries(self): |
| 220 | '''return a hash table of binary->url''' |
| 221 | binaryf = {} |
| 222 | for binary in self.binaries: |
Fathi Boudra | 75e299a | 2012-08-26 19:04:03 +0300 | [diff] [blame] | 223 | url = "%s/%s/images/%s" % (SNAPSHOTS_URL, self.platform, binary) |
Andy Doan | 184cd3b | 2012-03-29 22:20:02 -0500 | [diff] [blame] | 224 | (date, url) = crawler.latest_rfs(url) |
Andy Doan | 4202d88 | 2012-03-29 21:36:09 -0500 | [diff] [blame] | 225 | binaryf[binary] = url |
Andy Doan | 4202d88 | 2012-03-29 21:36:09 -0500 | [diff] [blame] | 226 | |
Andy Doan | 184cd3b | 2012-03-29 22:20:02 -0500 | [diff] [blame] | 227 | return binaryf |
Andy Doan | a397737 | 2012-03-29 12:22:44 -0500 | [diff] [blame] | 228 | |
Ricardo Salveti de Araujo | 0352cb9 | 2012-06-22 21:48:34 -0300 | [diff] [blame] | 229 | def get_hwpacks(self): |
| 230 | '''return a hash table of hwpack->urls (date, url)''' |
| 231 | hwpackf = {} |
| 232 | for hwpack in self.hwpacks: |
Fathi Boudra | 75e299a | 2012-08-26 19:04:03 +0300 | [diff] [blame] | 233 | url = "%s/%s/hwpacks/%s" % (SNAPSHOTS_URL, self.platform, hwpack) |
Ricardo Salveti de Araujo | 0352cb9 | 2012-06-22 21:48:34 -0300 | [diff] [blame] | 234 | hwpackf[hwpack] = crawler.latest_hwpacks(url) |
| 235 | |
| 236 | return hwpackf |
Andy Doan | 4202d88 | 2012-03-29 21:36:09 -0500 | [diff] [blame] | 237 | |
Andy Doan | 184cd3b | 2012-03-29 22:20:02 -0500 | [diff] [blame] | 238 | def get_image_name(self, odir, hwpack, hwpack_url, binary): |
| 239 | |
Fathi Boudra | 684e5e4 | 2012-11-30 04:19:33 +0100 | [diff] [blame^] | 240 | #convert a url like: |
| 241 | # http://snapshots.linaro.org/SERIE/hwpacks/HWPACK_NAME/HWPACK_BUILD_NUMBER/HWPACK_FILE_NAME |
Andy Doan | 184cd3b | 2012-03-29 22:20:02 -0500 | [diff] [blame] | 242 | # to: |
Fathi Boudra | 684e5e4 | 2012-11-30 04:19:33 +0100 | [diff] [blame^] | 243 | # SERIE/pre-built/HWPACK_NAME/HWPACK_BUILD_NUMBER/HWPACK_FILE_NAME.img |
Andy Doan | 184cd3b | 2012-03-29 22:20:02 -0500 | [diff] [blame] | 244 | path = urlparse.urlparse(hwpack_url).path |
Andy Doan | 66e2d5c | 2012-04-18 23:01:59 -0500 | [diff] [blame] | 245 | parts = path.split('/') |
| 246 | name = parts[-1] #use for the file name below |
| 247 | path = '/'.join(parts[-3:-1]) |
Andy Doan | 184cd3b | 2012-03-29 22:20:02 -0500 | [diff] [blame] | 248 | |
| 249 | path = '%s/%s' % (odir, path) |
| 250 | if not os.path.exists(path): |
| 251 | os.makedirs(path) |
Andy Doan | 66e2d5c | 2012-04-18 23:01:59 -0500 | [diff] [blame] | 252 | |
| 253 | date = re.search(r'_(\d+-\d+)_', name).group(1) |
Ricardo Salveti de Araujo | 99d5248 | 2012-06-22 16:05:09 -0300 | [diff] [blame] | 254 | return "%s/%s-%s_%s_%s.img" % (path, hwpack, self.platform, binary, date) |
Andy Doan | 184cd3b | 2012-03-29 22:20:02 -0500 | [diff] [blame] | 255 | |
Andy Doan | 15aa23b | 2012-02-02 16:40:58 -0600 | [diff] [blame] | 256 | def main(): |
Andy Doan | 15aa23b | 2012-02-02 16:40:58 -0600 | [diff] [blame] | 257 | hwpacks = HWPACKS.keys() |
| 258 | binaries = BINARIES.keys() |
| 259 | |
| 260 | p = argparse.ArgumentParser(description= |
Andy Doan | a397737 | 2012-03-29 12:22:44 -0500 | [diff] [blame] | 261 | 'Builds a matrix of builds from the latest build on ' |
| 262 | 'snapshots.linaro.org or release images on releases.linaro.org') |
Andy Doan | 15aa23b | 2012-02-02 16:40:58 -0600 | [diff] [blame] | 263 | |
Andy Doan | 94bfe31 | 2012-02-09 17:57:29 -0800 | [diff] [blame] | 264 | p.add_argument('-o', dest='out_dir', default='./out', |
Andy Doan | 15aa23b | 2012-02-02 16:40:58 -0600 | [diff] [blame] | 265 | help='The out directory for downloaded and built files, default=./') |
Ricardo Salveti de Araujo | 0352cb9 | 2012-06-22 21:48:34 -0300 | [diff] [blame] | 266 | p.add_argument('-d', dest='date', default="", |
| 267 | help='The date (YYYYMMDD) as reference for hwpack') |
Andy Doan | 15aa23b | 2012-02-02 16:40:58 -0600 | [diff] [blame] | 268 | p.add_argument('-w', dest='hwpacks', action='append', |
| 269 | help='The hwpacks to generate for, default=%s' % |
| 270 | ', '.join(hwpacks)) |
| 271 | p.add_argument('-b', dest='binaries', action='append', |
| 272 | help='The binaries to generate for, default=%s' % |
| 273 | ', '.join(binaries)) |
Fathi Boudra | 684e5e4 | 2012-11-30 04:19:33 +0100 | [diff] [blame^] | 274 | p.add_argument('-p', dest='platform', default='quantal', |
| 275 | help='The platform, default=quantal') |
Andy Doan | 4202d88 | 2012-03-29 21:36:09 -0500 | [diff] [blame] | 276 | p.add_argument('-r', dest='release', action='store_true', default=False, |
| 277 | help='If this is for release images. NOTE: the "date" arg' |
| 278 | 'will then become the cycle ie -d 12.03') |
Ricardo Salveti de Araujo | 688f24f | 2012-10-17 02:40:36 -0300 | [diff] [blame] | 279 | p.add_argument('-f', dest='fastmodel', action='store_true', |
| 280 | help='Build for the fastmodel target (for vexpress hwpack)') |
| 281 | |
Andy Doan | 15aa23b | 2012-02-02 16:40:58 -0600 | [diff] [blame] | 282 | |
| 283 | args = p.parse_args() |
Andy Doan | a397737 | 2012-03-29 12:22:44 -0500 | [diff] [blame] | 284 | |
Andy Doan | 15aa23b | 2012-02-02 16:40:58 -0600 | [diff] [blame] | 285 | if args.hwpacks: |
| 286 | hwpacks = args.hwpacks |
| 287 | if args.binaries: |
| 288 | binaries = args.binaries |
| 289 | |
Andy Doan | 1c6ef8b | 2012-04-23 12:28:50 -0500 | [diff] [blame] | 290 | crawler.cookie_setup() |
| 291 | |
Andy Doan | 15aa23b | 2012-02-02 16:40:58 -0600 | [diff] [blame] | 292 | dm = fetch_image.DownloadManager(args.out_dir) |
Andy Doan | 15aa23b | 2012-02-02 16:40:58 -0600 | [diff] [blame] | 293 | |
Andy Doan | 4202d88 | 2012-03-29 21:36:09 -0500 | [diff] [blame] | 294 | if args.release: |
Andy Doan | 184cd3b | 2012-03-29 22:20:02 -0500 | [diff] [blame] | 295 | site = ReleaseCrawler(args.date, args.platform, hwpacks, binaries) |
Andy Doan | 4202d88 | 2012-03-29 21:36:09 -0500 | [diff] [blame] | 296 | else: |
Ricardo Salveti de Araujo | 0352cb9 | 2012-06-22 21:48:34 -0300 | [diff] [blame] | 297 | site = SnapshotCrawler(args.platform, hwpacks, binaries) |
Andy Doan | 184cd3b | 2012-03-29 22:20:02 -0500 | [diff] [blame] | 298 | |
Ricardo Salveti de Araujo | 0352cb9 | 2012-06-22 21:48:34 -0300 | [diff] [blame] | 299 | hwpackf = site.get_hwpacks() |
Andy Doan | 184cd3b | 2012-03-29 22:20:02 -0500 | [diff] [blame] | 300 | binaryf = site.get_binaries() |
Andy Doan | 15aa23b | 2012-02-02 16:40:58 -0600 | [diff] [blame] | 301 | |
Andy Doan | b00dbc0 | 2012-03-15 16:23:06 -0500 | [diff] [blame] | 302 | lmc = '%s/linaro-image-tools/linaro-media-create' % args.out_dir |
Andy Doan | 184cd3b | 2012-03-29 22:20:02 -0500 | [diff] [blame] | 303 | odir = '%s/pre-built' % args.out_dir |
Andy Doan | b00dbc0 | 2012-03-15 16:23:06 -0500 | [diff] [blame] | 304 | |
Andy Doan | 15aa23b | 2012-02-02 16:40:58 -0600 | [diff] [blame] | 305 | for hwpack in hwpacks: |
Ricardo Salveti de Araujo | 0352cb9 | 2012-06-22 21:48:34 -0300 | [diff] [blame] | 306 | url = None |
| 307 | # check if the user wanted a hwpack from a specific date |
| 308 | if args.date: |
| 309 | try: |
| 310 | dates = [elem[0] for elem in hwpackf[hwpack]] |
| 311 | index = dates.index(args.date) |
| 312 | url = hwpackf[hwpack][index][1] |
| 313 | except: |
| 314 | print "ERROR: Could not find hwpack '%s' with date '%s'" \ |
| 315 | ", skipping pre-built image for it" % (hwpack, args.date) |
| 316 | else: |
| 317 | # just grab the latest hwpack |
| 318 | try: |
| 319 | url = hwpackf[hwpack][0][1] |
| 320 | except: |
| 321 | print "ERROR: Could not find a valid hwpack url for '%s'" \ |
| 322 | ", skipping pre-built image for it" % (hwpack) |
Andy Doan | b00dbc0 | 2012-03-15 16:23:06 -0500 | [diff] [blame] | 323 | |
Andy Doan | 2cfe5e6 | 2012-02-09 17:41:45 -0800 | [diff] [blame] | 324 | if url is not None and url is not False: |
Ricardo Salveti de Araujo | b39eb80 | 2012-06-23 00:55:31 -0300 | [diff] [blame] | 325 | hwpf = download(dm, url) |
Andy Doan | 15aa23b | 2012-02-02 16:40:58 -0600 | [diff] [blame] | 326 | for binary in binaries: |
Ricardo Salveti de Araujo | b93a7ec | 2012-05-29 14:07:53 -0300 | [diff] [blame] | 327 | # create the image and metadata |
Ricardo Salveti de Araujo | 99d5248 | 2012-06-22 16:05:09 -0300 | [diff] [blame] | 328 | imgfile = site.get_image_name(odir, hwpack, url, binary) |
Ricardo Salveti de Araujo | b93a7ec | 2012-05-29 14:07:53 -0300 | [diff] [blame] | 329 | infofile = '%s.html' % os.path.splitext(imgfile)[0] |
Ricardo Salveti de Araujo | b39eb80 | 2012-06-23 00:55:31 -0300 | [diff] [blame] | 330 | rfsf = download(dm, binaryf[binary]) |
Ricardo Salveti de Araujo | 688f24f | 2012-10-17 02:40:36 -0300 | [diff] [blame] | 331 | build_image(lmc, imgfile, hwpack, hwpf, binary, rfsf, |
| 332 | args.fastmodel) |
Ricardo Salveti de Araujo | 7edc48b | 2012-06-23 03:55:04 -0300 | [diff] [blame] | 333 | gzfile = compress_image(imgfile) |
Ricardo Salveti de Araujo | d3743e9 | 2012-08-15 01:50:10 -0300 | [diff] [blame] | 334 | zsync_image(args.platform, gzfile) |
Ricardo Salveti de Araujo | 688f24f | 2012-10-17 02:40:36 -0300 | [diff] [blame] | 335 | # TODO: Add support for OE based images |
| 336 | if args.platform != "openembedded": |
| 337 | create_image_info(infofile, gzfile, |
| 338 | imgfile, url, binaryf[binary]) |
Andy Doan | 15aa23b | 2012-02-02 16:40:58 -0600 | [diff] [blame] | 339 | |
| 340 | if __name__ == '__main__': |
| 341 | main() |
| 342 | |