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 |
| 30 | import bz2 |
| 31 | import datetime |
Ricardo Salveti de Araujo | b39eb80 | 2012-06-23 00:55:31 -0300 | [diff] [blame^] | 32 | import time |
Andy Doan | 3634c47 | 2012-04-17 12:50:58 -0500 | [diff] [blame] | 33 | import hashlib |
Andy Doan | c6500af | 2012-03-15 14:44:39 -0500 | [diff] [blame] | 34 | import os |
Andy Doan | 15aa23b | 2012-02-02 16:40:58 -0600 | [diff] [blame] | 35 | import re |
Andy Doan | e449bce | 2012-03-21 15:22:31 -0500 | [diff] [blame] | 36 | import urlparse |
Andy Doan | 35ee9dc | 2012-05-11 01:10:12 -0500 | [diff] [blame] | 37 | import string |
Andy Doan | 4202d88 | 2012-03-29 21:36:09 -0500 | [diff] [blame] | 38 | import sys |
Andy Doan | 15aa23b | 2012-02-02 16:40:58 -0600 | [diff] [blame] | 39 | |
Andy Doan | ea2e1ea | 2012-04-23 11:56:29 -0500 | [diff] [blame] | 40 | class HwPack: |
| 41 | def __init__(self, lmcname, eula=False, pre_inst_script=None): |
| 42 | self.lmcname = lmcname |
| 43 | if eula: |
| 44 | self.eula = 'EULA.txt' |
| 45 | else: |
Andy Doan | 4aabf02 | 2012-04-26 14:30:29 -0500 | [diff] [blame] | 46 | self.eula = 'OPEN-EULA.txt' |
Andy Doan | ea2e1ea | 2012-04-23 11:56:29 -0500 | [diff] [blame] | 47 | self.pre_inst_script = pre_inst_script |
| 48 | |
| 49 | def do_eula(self, imgfile): |
| 50 | fname = '%s/%s' % (os.path.dirname(imgfile), self.eula) |
| 51 | with file(fname, 'a'): |
| 52 | pass #just need the file to exist |
| 53 | |
Andy Doan | 15aa23b | 2012-02-02 16:40:58 -0600 | [diff] [blame] | 54 | # a mapping of hwpack name to l-m-c name |
| 55 | HWPACKS = { |
Andy Doan | ea2e1ea | 2012-04-23 11:56:29 -0500 | [diff] [blame] | 56 | 'beagleboard': HwPack('beagle'), |
| 57 | 'overo': HwPack('overo'), |
| 58 | 'lt-panda': HwPack('panda'), |
Andy Doan | 7a8cc10 | 2012-04-26 09:25:33 -0500 | [diff] [blame] | 59 | 'lt-panda-x11-base': HwPack('panda'), |
Andy Doan | ea2e1ea | 2012-04-23 11:56:29 -0500 | [diff] [blame] | 60 | 'lt-mx5': HwPack('mx53loco'), |
| 61 | 'lt-mx6': HwPack('mx6qsabrelite'), |
Andy Doan | 490f620 | 2012-04-25 10:56:08 -0500 | [diff] [blame] | 62 | 'lt-origen': HwPack('origen'), |
| 63 | 'leb-origen': HwPack('origen'), |
Andy Doan | ea2e1ea | 2012-04-23 11:56:29 -0500 | [diff] [blame] | 64 | 'lt-snowball': HwPack('snowball_sd', True, 'ste-preinstall.sh'), |
| 65 | 'lt-snowball-x11-base': HwPack('snowball_sd', True, 'ste-preinstall.sh'), |
Andy Doan | edffb5d | 2012-04-25 11:22:19 -0500 | [diff] [blame] | 66 | 'vexpress': HwPack('vexpress'), |
Andy Doan | ea2e1ea | 2012-04-23 11:56:29 -0500 | [diff] [blame] | 67 | 'efikamx': HwPack('efikamx'), |
| 68 | 'igep': HwPack('igep'), |
Andy Doan | 15aa23b | 2012-02-02 16:40:58 -0600 | [diff] [blame] | 69 | } |
| 70 | # a mapping of binary image to its image_file size |
| 71 | BINARIES = { |
Andy Doan | 4202d88 | 2012-03-29 21:36:09 -0500 | [diff] [blame] | 72 | # release images |
Andy Doan | 08485da | 2012-05-31 22:24:29 +0800 | [diff] [blame] | 73 | '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] | 74 | 'alip': '2G', |
| 75 | 'ubuntu-desktop': '3G', |
| 76 | 'linarotv-xbmc': '3G', |
Andy Doan | 15aa23b | 2012-02-02 16:40:58 -0600 | [diff] [blame] | 77 | } |
| 78 | |
Andy Doan | 15aa23b | 2012-02-02 16:40:58 -0600 | [diff] [blame] | 79 | def today(): |
| 80 | d = datetime.date.today() |
| 81 | return "%d%02d%02d" % (d.year, d.month, d.day) |
| 82 | |
Ricardo Salveti de Araujo | b39eb80 | 2012-06-23 00:55:31 -0300 | [diff] [blame^] | 83 | def download(dm, url): |
| 84 | print "INFO: Fetching", url |
| 85 | before = time.time() |
| 86 | dfile = dm.download(url, None, verbose=False) |
| 87 | delta_min, delta_secs = divmod(int(time.time() - before), 60) |
| 88 | print "INFO: Downloaded file '%s' in %d min(s) and %d sec(s)" % ( |
| 89 | dfile, delta_min, delta_secs) |
| 90 | return dfile |
| 91 | |
Andy Doan | 15aa23b | 2012-02-02 16:40:58 -0600 | [diff] [blame] | 92 | def compress_image(imgfile): |
| 93 | print "compressing %s" % imgfile |
| 94 | args = ('bzip2', imgfile) |
| 95 | cmd_runner.run(args).wait() |
Andy Doan | 23ce4e1 | 2012-03-21 12:46:21 -0500 | [diff] [blame] | 96 | return '%s.bz2' % imgfile |
| 97 | |
| 98 | def zsync_image(imgfile): |
| 99 | print "making zsync file for %s" % imgfile |
| 100 | args = ('zsyncmake', '-o', '%s.zsync'%imgfile, imgfile) |
| 101 | cmd_runner.run(args).wait() |
Andy Doan | 15aa23b | 2012-02-02 16:40:58 -0600 | [diff] [blame] | 102 | |
Andy Doan | 3634c47 | 2012-04-17 12:50:58 -0500 | [diff] [blame] | 103 | def md5sum(fname): |
| 104 | md5 = hashlib.md5() |
| 105 | with open(fname, 'rb') as f: |
| 106 | while True: |
| 107 | data = f.read(4096) |
| 108 | if not data: break |
| 109 | md5.update(data) |
| 110 | return md5.hexdigest() |
| 111 | |
Ricardo Salveti de Araujo | b93a7ec | 2012-05-29 14:07:53 -0300 | [diff] [blame] | 112 | def create_image_info(infofile, bz2file, binary_file, hwpack_url, rootfs_url): |
| 113 | ''' prints out the md5sum and hwpack/rootfs info for the given image |
Andy Doan | 3634c47 | 2012-04-17 12:50:58 -0500 | [diff] [blame] | 114 | ''' |
| 115 | print "building image info for: %s" % bz2file |
| 116 | md5 = md5sum(bz2file) |
| 117 | |
| 118 | binary_file = os.path.basename(binary_file) |
Andy Doan | 35ee9dc | 2012-05-11 01:10:12 -0500 | [diff] [blame] | 119 | tfile = '%s/image_info_template.html' % os.path.dirname(__file__) |
Andy Doan | 3634c47 | 2012-04-17 12:50:58 -0500 | [diff] [blame] | 120 | |
Andy Doan | 35ee9dc | 2012-05-11 01:10:12 -0500 | [diff] [blame] | 121 | tmpl = None |
| 122 | with open(tfile) as f: |
| 123 | buff = f.read() |
| 124 | tmpl = string.Template(buff) |
| 125 | |
| 126 | title = 'Pre-Built Image Info' |
Ricardo Salveti de Araujo | b93a7ec | 2012-05-29 14:07:53 -0300 | [diff] [blame] | 127 | |
| 128 | # build hwpack manifest and rootfs packages links |
| 129 | hwpack_re = re.search(r'(hwpack_linaro.*\d\w*)(.*)$', hwpack_url) |
| 130 | hwpack_name = "".join(hwpack_re.groups()) |
| 131 | hwpack_manifest = hwpack_name + '.manifest.txt' |
| 132 | hwpack_manifest_url = re.sub('.tar.gz$', '.manifest.txt', hwpack_url) |
| 133 | |
| 134 | rootfs_re = re.search(r'(linaro-.*\d)(.*)$', rootfs_url) |
| 135 | rootfs_name = "".join(rootfs_re.groups()) |
| 136 | rootfs_packages = rootfs_name + '.packages' |
| 137 | rootfs_packages_url = re.sub('.tar.gz$', '.packages', rootfs_url) |
| 138 | |
Ricardo Salveti de Araujo | 894040a | 2012-05-29 14:07:55 -0300 | [diff] [blame] | 139 | # try to get information from Jenkins, if available |
| 140 | jenkins_buildn = os.environ.get('BUILD_NUMBER') or 'Not Found' |
| 141 | jenkins_build_url = os.environ.get('BUILD_URL') or 'http://ci.linaro.org' |
| 142 | |
Ricardo Salveti de Araujo | b93a7ec | 2012-05-29 14:07:53 -0300 | [diff] [blame] | 143 | buff = tmpl.substitute( |
| 144 | title=title, md5=md5, image_name=os.path.basename(bz2file), |
| 145 | hwpack_name=hwpack_name, hwpack_url=hwpack_url, |
| 146 | rootfs_name=rootfs_name, rootfs_url=rootfs_url, |
| 147 | hwpack_manifest_name=hwpack_manifest, |
| 148 | hwpack_manifest_url=hwpack_manifest_url, |
| 149 | rootfs_packages_name=rootfs_packages, |
Ricardo Salveti de Araujo | 894040a | 2012-05-29 14:07:55 -0300 | [diff] [blame] | 150 | rootfs_packages_url=rootfs_packages_url, |
| 151 | jenkins_buildn=jenkins_buildn, |
| 152 | jenkins_build_url=jenkins_build_url) |
Andy Doan | 3c0c389 | 2012-04-25 11:09:53 -0500 | [diff] [blame] | 153 | with open(infofile, 'w') as f: |
Andy Doan | 35ee9dc | 2012-05-11 01:10:12 -0500 | [diff] [blame] | 154 | f.write(buff) |
Andy Doan | 3634c47 | 2012-04-17 12:50:58 -0500 | [diff] [blame] | 155 | |
Andy Doan | b00dbc0 | 2012-03-15 16:23:06 -0500 | [diff] [blame] | 156 | def build_image(lmc, imgfile, hwpack, hwpack_file, binary, binary_file): |
Andy Doan | 15aa23b | 2012-02-02 16:40:58 -0600 | [diff] [blame] | 157 | print "building image: %s" % imgfile |
Andy Doan | ea2e1ea | 2012-04-23 11:56:29 -0500 | [diff] [blame] | 158 | hwpi = HWPACKS[hwpack] |
Andy Doan | 15aa23b | 2012-02-02 16:40:58 -0600 | [diff] [blame] | 159 | size = BINARIES[binary] |
| 160 | |
Andy Doan | 4fa16dc | 2012-02-09 17:47:45 -0800 | [diff] [blame] | 161 | print 'running l-m-c: %s' % lmc |
Andy Doan | c6500af | 2012-03-15 14:44:39 -0500 | [diff] [blame] | 162 | args = [lmc, |
Andy Doan | ea2e1ea | 2012-04-23 11:56:29 -0500 | [diff] [blame] | 163 | '--dev', hwpi.lmcname, |
Andy Doan | 15aa23b | 2012-02-02 16:40:58 -0600 | [diff] [blame] | 164 | '--image_file', imgfile, |
| 165 | '--image_size', size, |
| 166 | '--hwpack-force-yes', |
| 167 | '--hwpack', hwpack_file, |
| 168 | '--binary', binary_file, |
Andy Doan | c6500af | 2012-03-15 14:44:39 -0500 | [diff] [blame] | 169 | ] |
| 170 | |
Andy Doan | ea2e1ea | 2012-04-23 11:56:29 -0500 | [diff] [blame] | 171 | if hwpi.pre_inst_script is not None: |
Andy Doan | c6500af | 2012-03-15 14:44:39 -0500 | [diff] [blame] | 172 | sdir = os.path.abspath(os.path.dirname(__file__)) |
Andy Doan | ea2e1ea | 2012-04-23 11:56:29 -0500 | [diff] [blame] | 173 | script = "%s/%s" % (sdir, hwpi.pre_inst_script) |
Andy Doan | c6500af | 2012-03-15 14:44:39 -0500 | [diff] [blame] | 174 | print "using presintall script: %s" % script |
| 175 | args.append('--preinstall-script') |
| 176 | args.append(script) |
| 177 | |
Andy Doan | ea2e1ea | 2012-04-23 11:56:29 -0500 | [diff] [blame] | 178 | hwpi.do_eula(imgfile) |
Andy Doan | 15aa23b | 2012-02-02 16:40:58 -0600 | [diff] [blame] | 179 | cmd_runner.run(args, as_root=True).wait() |
Andy Doan | 15aa23b | 2012-02-02 16:40:58 -0600 | [diff] [blame] | 180 | |
Andy Doan | 184cd3b | 2012-03-29 22:20:02 -0500 | [diff] [blame] | 181 | class SnapshotCrawler: |
Ricardo Salveti de Araujo | 0352cb9 | 2012-06-22 21:48:34 -0300 | [diff] [blame] | 182 | def __init__(self, platform, hwpacks, binaries): |
Andy Doan | 184cd3b | 2012-03-29 22:20:02 -0500 | [diff] [blame] | 183 | self.platform = platform |
| 184 | self.hwpacks = hwpacks |
| 185 | self.binaries = binaries |
Andy Doan | e449bce | 2012-03-21 15:22:31 -0500 | [diff] [blame] | 186 | |
Andy Doan | 184cd3b | 2012-03-29 22:20:02 -0500 | [diff] [blame] | 187 | def get_binaries(self): |
| 188 | '''return a hash table of binary->url''' |
| 189 | binaryf = {} |
| 190 | for binary in self.binaries: |
Andy Doan | 540a4b1 | 2012-04-17 11:48:11 -0500 | [diff] [blame] | 191 | url = 'http://snapshots.linaro.org/%s/images/%s' % (self.platform, binary) |
Andy Doan | 184cd3b | 2012-03-29 22:20:02 -0500 | [diff] [blame] | 192 | (date, url) = crawler.latest_rfs(url) |
Andy Doan | 4202d88 | 2012-03-29 21:36:09 -0500 | [diff] [blame] | 193 | binaryf[binary] = url |
Andy Doan | 4202d88 | 2012-03-29 21:36:09 -0500 | [diff] [blame] | 194 | |
Andy Doan | 184cd3b | 2012-03-29 22:20:02 -0500 | [diff] [blame] | 195 | return binaryf |
Andy Doan | a397737 | 2012-03-29 12:22:44 -0500 | [diff] [blame] | 196 | |
Ricardo Salveti de Araujo | 0352cb9 | 2012-06-22 21:48:34 -0300 | [diff] [blame] | 197 | def get_hwpacks(self): |
| 198 | '''return a hash table of hwpack->urls (date, url)''' |
| 199 | hwpackf = {} |
| 200 | for hwpack in self.hwpacks: |
| 201 | url = 'http://snapshots.linaro.org/%s/hwpacks/%s' % (self.platform, hwpack) |
| 202 | hwpackf[hwpack] = crawler.latest_hwpacks(url) |
| 203 | |
| 204 | return hwpackf |
Andy Doan | 4202d88 | 2012-03-29 21:36:09 -0500 | [diff] [blame] | 205 | |
Andy Doan | 184cd3b | 2012-03-29 22:20:02 -0500 | [diff] [blame] | 206 | def get_image_name(self, odir, hwpack, hwpack_url, binary): |
| 207 | |
| 208 | #covert a url like: |
Andy Doan | 540a4b1 | 2012-04-17 11:48:11 -0500 | [diff] [blame] | 209 | # http://snapshots.linaro.org/precise/hwpacks/lt-panda/87/hwpack_linaro-lt-panda_20120417-87_armhf_supported.tar.gz |
Andy Doan | 184cd3b | 2012-03-29 22:20:02 -0500 | [diff] [blame] | 210 | # to: |
Andy Doan | 66e2d5c | 2012-04-18 23:01:59 -0500 | [diff] [blame] | 211 | # precise/pre-built/lt-panda/87/<file>.img |
Andy Doan | 184cd3b | 2012-03-29 22:20:02 -0500 | [diff] [blame] | 212 | path = urlparse.urlparse(hwpack_url).path |
Andy Doan | 66e2d5c | 2012-04-18 23:01:59 -0500 | [diff] [blame] | 213 | parts = path.split('/') |
| 214 | name = parts[-1] #use for the file name below |
| 215 | path = '/'.join(parts[-3:-1]) |
Andy Doan | 184cd3b | 2012-03-29 22:20:02 -0500 | [diff] [blame] | 216 | |
| 217 | path = '%s/%s' % (odir, path) |
| 218 | if not os.path.exists(path): |
| 219 | os.makedirs(path) |
Andy Doan | 66e2d5c | 2012-04-18 23:01:59 -0500 | [diff] [blame] | 220 | |
| 221 | date = re.search(r'_(\d+-\d+)_', name).group(1) |
Ricardo Salveti de Araujo | 99d5248 | 2012-06-22 16:05:09 -0300 | [diff] [blame] | 222 | 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] | 223 | |
Andy Doan | 15aa23b | 2012-02-02 16:40:58 -0600 | [diff] [blame] | 224 | def main(): |
Andy Doan | 15aa23b | 2012-02-02 16:40:58 -0600 | [diff] [blame] | 225 | hwpacks = HWPACKS.keys() |
| 226 | binaries = BINARIES.keys() |
| 227 | |
| 228 | p = argparse.ArgumentParser(description= |
Andy Doan | a397737 | 2012-03-29 12:22:44 -0500 | [diff] [blame] | 229 | 'Builds a matrix of builds from the latest build on ' |
| 230 | 'snapshots.linaro.org or release images on releases.linaro.org') |
Andy Doan | 15aa23b | 2012-02-02 16:40:58 -0600 | [diff] [blame] | 231 | |
Andy Doan | 94bfe31 | 2012-02-09 17:57:29 -0800 | [diff] [blame] | 232 | p.add_argument('-o', dest='out_dir', default='./out', |
Andy Doan | 15aa23b | 2012-02-02 16:40:58 -0600 | [diff] [blame] | 233 | help='The out directory for downloaded and built files, default=./') |
Ricardo Salveti de Araujo | 0352cb9 | 2012-06-22 21:48:34 -0300 | [diff] [blame] | 234 | p.add_argument('-d', dest='date', default="", |
| 235 | help='The date (YYYYMMDD) as reference for hwpack') |
Andy Doan | 15aa23b | 2012-02-02 16:40:58 -0600 | [diff] [blame] | 236 | p.add_argument('-w', dest='hwpacks', action='append', |
| 237 | help='The hwpacks to generate for, default=%s' % |
| 238 | ', '.join(hwpacks)) |
| 239 | p.add_argument('-b', dest='binaries', action='append', |
| 240 | help='The binaries to generate for, default=%s' % |
| 241 | ', '.join(binaries)) |
Andy Doan | 540a4b1 | 2012-04-17 11:48:11 -0500 | [diff] [blame] | 242 | p.add_argument('-p', dest='platform', default='precise', |
| 243 | help='The platform, default=precise') |
Andy Doan | 4202d88 | 2012-03-29 21:36:09 -0500 | [diff] [blame] | 244 | p.add_argument('-r', dest='release', action='store_true', default=False, |
| 245 | help='If this is for release images. NOTE: the "date" arg' |
| 246 | 'will then become the cycle ie -d 12.03') |
Andy Doan | 15aa23b | 2012-02-02 16:40:58 -0600 | [diff] [blame] | 247 | |
| 248 | args = p.parse_args() |
Andy Doan | a397737 | 2012-03-29 12:22:44 -0500 | [diff] [blame] | 249 | |
Andy Doan | 15aa23b | 2012-02-02 16:40:58 -0600 | [diff] [blame] | 250 | if args.hwpacks: |
| 251 | hwpacks = args.hwpacks |
| 252 | if args.binaries: |
| 253 | binaries = args.binaries |
| 254 | |
Andy Doan | 1c6ef8b | 2012-04-23 12:28:50 -0500 | [diff] [blame] | 255 | crawler.cookie_setup() |
| 256 | |
Andy Doan | 15aa23b | 2012-02-02 16:40:58 -0600 | [diff] [blame] | 257 | dm = fetch_image.DownloadManager(args.out_dir) |
Andy Doan | 15aa23b | 2012-02-02 16:40:58 -0600 | [diff] [blame] | 258 | |
Andy Doan | 4202d88 | 2012-03-29 21:36:09 -0500 | [diff] [blame] | 259 | if args.release: |
Andy Doan | 184cd3b | 2012-03-29 22:20:02 -0500 | [diff] [blame] | 260 | site = ReleaseCrawler(args.date, args.platform, hwpacks, binaries) |
Andy Doan | 4202d88 | 2012-03-29 21:36:09 -0500 | [diff] [blame] | 261 | else: |
Ricardo Salveti de Araujo | 0352cb9 | 2012-06-22 21:48:34 -0300 | [diff] [blame] | 262 | site = SnapshotCrawler(args.platform, hwpacks, binaries) |
Andy Doan | 184cd3b | 2012-03-29 22:20:02 -0500 | [diff] [blame] | 263 | |
Ricardo Salveti de Araujo | 0352cb9 | 2012-06-22 21:48:34 -0300 | [diff] [blame] | 264 | hwpackf = site.get_hwpacks() |
Andy Doan | 184cd3b | 2012-03-29 22:20:02 -0500 | [diff] [blame] | 265 | binaryf = site.get_binaries() |
Andy Doan | 15aa23b | 2012-02-02 16:40:58 -0600 | [diff] [blame] | 266 | |
Andy Doan | b00dbc0 | 2012-03-15 16:23:06 -0500 | [diff] [blame] | 267 | lmc = '%s/linaro-image-tools/linaro-media-create' % args.out_dir |
Andy Doan | 184cd3b | 2012-03-29 22:20:02 -0500 | [diff] [blame] | 268 | odir = '%s/pre-built' % args.out_dir |
Andy Doan | b00dbc0 | 2012-03-15 16:23:06 -0500 | [diff] [blame] | 269 | |
Andy Doan | 15aa23b | 2012-02-02 16:40:58 -0600 | [diff] [blame] | 270 | for hwpack in hwpacks: |
Ricardo Salveti de Araujo | 0352cb9 | 2012-06-22 21:48:34 -0300 | [diff] [blame] | 271 | url = None |
| 272 | # check if the user wanted a hwpack from a specific date |
| 273 | if args.date: |
| 274 | try: |
| 275 | dates = [elem[0] for elem in hwpackf[hwpack]] |
| 276 | index = dates.index(args.date) |
| 277 | url = hwpackf[hwpack][index][1] |
| 278 | except: |
| 279 | print "ERROR: Could not find hwpack '%s' with date '%s'" \ |
| 280 | ", skipping pre-built image for it" % (hwpack, args.date) |
| 281 | else: |
| 282 | # just grab the latest hwpack |
| 283 | try: |
| 284 | url = hwpackf[hwpack][0][1] |
| 285 | except: |
| 286 | print "ERROR: Could not find a valid hwpack url for '%s'" \ |
| 287 | ", skipping pre-built image for it" % (hwpack) |
Andy Doan | b00dbc0 | 2012-03-15 16:23:06 -0500 | [diff] [blame] | 288 | |
Andy Doan | 2cfe5e6 | 2012-02-09 17:41:45 -0800 | [diff] [blame] | 289 | if url is not None and url is not False: |
Ricardo Salveti de Araujo | b39eb80 | 2012-06-23 00:55:31 -0300 | [diff] [blame^] | 290 | hwpf = download(dm, url) |
Andy Doan | 15aa23b | 2012-02-02 16:40:58 -0600 | [diff] [blame] | 291 | for binary in binaries: |
Ricardo Salveti de Araujo | b93a7ec | 2012-05-29 14:07:53 -0300 | [diff] [blame] | 292 | # create the image and metadata |
Ricardo Salveti de Araujo | 99d5248 | 2012-06-22 16:05:09 -0300 | [diff] [blame] | 293 | imgfile = site.get_image_name(odir, hwpack, url, binary) |
Ricardo Salveti de Araujo | b93a7ec | 2012-05-29 14:07:53 -0300 | [diff] [blame] | 294 | infofile = '%s.html' % os.path.splitext(imgfile)[0] |
Ricardo Salveti de Araujo | b39eb80 | 2012-06-23 00:55:31 -0300 | [diff] [blame^] | 295 | rfsf = download(dm, binaryf[binary]) |
Andy Doan | b00dbc0 | 2012-03-15 16:23:06 -0500 | [diff] [blame] | 296 | build_image(lmc, imgfile, hwpack, hwpf, binary, rfsf) |
Ricardo Salveti de Araujo | b93a7ec | 2012-05-29 14:07:53 -0300 | [diff] [blame] | 297 | bz2file = compress_image(imgfile) |
| 298 | zsync_image(bz2file) |
| 299 | create_image_info(infofile, bz2file, |
| 300 | imgfile, url, binaryf[binary]) |
Andy Doan | 15aa23b | 2012-02-02 16:40:58 -0600 | [diff] [blame] | 301 | |
| 302 | if __name__ == '__main__': |
| 303 | main() |
| 304 | |