Andy Doan | df9dfd7 | 2012-04-26 13:45:15 -0500 | [diff] [blame^] | 1 | #!/usr/bin/env python |
| 2 | # Copyright (C) 2012 Linaro |
| 3 | # |
| 4 | # Author: Andy Doan <andy.doan@linaro.org> |
| 5 | # |
| 6 | # This file is part of Linaro Daily Prebuilt Images. |
| 7 | # |
| 8 | # Linaro Daily Prebuilt Images is free software; you can redistribute it and/or |
| 9 | # modify it under the terms of the GNU General Public License |
| 10 | # as published by the Free Software Foundation; either version 2 |
| 11 | # of the License, or (at your option) any later version. |
| 12 | # |
| 13 | # Linaro Daily Prebuilt Images is distributed in the hope that it will be useful, |
| 14 | # but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 15 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 16 | # GNU General Public License for more details. |
| 17 | # |
| 18 | # You should have received a copy of the GNU General Public License |
| 19 | # along with Linaro Image Tools; if not, write to the Free Software |
| 20 | # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, |
| 21 | # USA. |
| 22 | |
| 23 | from linaro_fetch_image import fetch_image |
| 24 | |
| 25 | from build_images import build_image |
| 26 | |
| 27 | import argparse |
| 28 | import os |
| 29 | import re |
| 30 | |
| 31 | def get_image_name(odir, hwpack_url, binary): |
| 32 | path = '%s/%s' % (odir, binary) |
| 33 | if not os.path.exists(path): |
| 34 | os.makedirs(path) |
| 35 | hwpack = re.search(r'hwpack_linaro-(.*)_armhf', hwpack_url).group(1) |
| 36 | return "%s/%s-%s.img" %(path,hwpack,binary) |
| 37 | |
| 38 | def url_to_hwpack(url): |
| 39 | ''' convert a URL like: |
| 40 | http://snapshots.linaro.org/precise/hwpacks/lt-panda/113/hwpack_linaro-lt-panda_20120426-113_armhf_supported.tar.gz |
| 41 | into lt-panda |
| 42 | ''' |
| 43 | return re.search(r'hwpack_linaro-(.*)_\d+', url).group(1) |
| 44 | |
| 45 | def main(): |
| 46 | p = argparse.ArgumentParser(description= |
| 47 | 'Builds a matrix of builds from the latest build on ' |
| 48 | 'snapshots.linaro.org or release images on releases.linaro.org') |
| 49 | |
| 50 | p.add_argument('-o', dest='out_dir', default='./out', |
| 51 | help='The out directory for downloaded and built files, default=./') |
| 52 | p.add_argument('-w', dest='hwpacks', action='append', required=True, |
| 53 | help='The hwpacks urls generate images for.') |
| 54 | p.add_argument('-b', dest='binary', required=True, |
| 55 | help='The URL of the RFS') |
| 56 | p.add_argument('-t', dest='binary_type', required=True, |
| 57 | help='The binary type, eg nano,ubuntu-desktop') |
| 58 | |
| 59 | args = p.parse_args() |
| 60 | |
| 61 | dm = fetch_image.DownloadManager(args.out_dir) |
| 62 | |
| 63 | rfsf = dm.download(args.binary, None) |
| 64 | |
| 65 | lmc = '%s/linaro-image-tools/linaro-media-create' % args.out_dir |
| 66 | odir = '%s/pre-built' % args.out_dir |
| 67 | |
| 68 | for url in args.hwpacks: |
| 69 | hwpack = url_to_hwpack(url) |
| 70 | hwpf = dm.download(url, None) |
| 71 | imgfile = get_image_name(odir,url,args.binary_type) |
| 72 | build_image(lmc, imgfile, hwpack, hwpf, args.binary_type, rfsf) |
| 73 | |
| 74 | if __name__ == '__main__': |
| 75 | main() |
| 76 | |