Fathi Boudra | cd8f58d | 2012-06-15 17:43:39 +0300 | [diff] [blame] | 1 | #!/usr/bin/python |
| 2 | |
Andy Doan | df9dfd7 | 2012-04-26 13:45:15 -0500 | [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 | |
| 24 | from linaro_fetch_image import fetch_image |
| 25 | |
Ricardo Salveti de Araujo | ec7366a | 2012-07-25 12:36:06 -0300 | [diff] [blame] | 26 | from build_images import build_image, compress_image |
Andy Doan | df9dfd7 | 2012-04-26 13:45:15 -0500 | [diff] [blame] | 27 | |
| 28 | import argparse |
| 29 | import os |
| 30 | import re |
| 31 | |
| 32 | def get_image_name(odir, hwpack_url, binary): |
| 33 | path = '%s/%s' % (odir, binary) |
| 34 | if not os.path.exists(path): |
| 35 | os.makedirs(path) |
| 36 | hwpack = re.search(r'hwpack_linaro-(.*)_armhf', hwpack_url).group(1) |
| 37 | return "%s/%s-%s.img" %(path,hwpack,binary) |
| 38 | |
| 39 | def url_to_hwpack(url): |
| 40 | ''' convert a URL like: |
Fathi Boudra | 684e5e4 | 2012-11-30 04:19:33 +0100 | [diff] [blame] | 41 | http://snapshots.linaro.org/SERIE/hwpacks/HWPACK_NAME/HWPACK_BUILD_NUMBER/HWPACK_FILE_NAME |
Andy Doan | df9dfd7 | 2012-04-26 13:45:15 -0500 | [diff] [blame] | 42 | into lt-panda |
| 43 | ''' |
| 44 | return re.search(r'hwpack_linaro-(.*)_\d+', url).group(1) |
| 45 | |
| 46 | def main(): |
| 47 | p = argparse.ArgumentParser(description= |
| 48 | 'Builds a matrix of builds from the latest build on ' |
| 49 | 'snapshots.linaro.org or release images on releases.linaro.org') |
| 50 | |
| 51 | p.add_argument('-o', dest='out_dir', default='./out', |
| 52 | help='The out directory for downloaded and built files, default=./') |
| 53 | p.add_argument('-w', dest='hwpacks', action='append', required=True, |
| 54 | help='The hwpacks urls generate images for.') |
| 55 | p.add_argument('-b', dest='binary', required=True, |
| 56 | help='The URL of the RFS') |
| 57 | p.add_argument('-t', dest='binary_type', required=True, |
| 58 | help='The binary type, eg nano,ubuntu-desktop') |
| 59 | |
| 60 | args = p.parse_args() |
| 61 | |
| 62 | dm = fetch_image.DownloadManager(args.out_dir) |
| 63 | |
| 64 | rfsf = dm.download(args.binary, None) |
| 65 | |
| 66 | lmc = '%s/linaro-image-tools/linaro-media-create' % args.out_dir |
| 67 | odir = '%s/pre-built' % args.out_dir |
| 68 | |
| 69 | for url in args.hwpacks: |
| 70 | hwpack = url_to_hwpack(url) |
| 71 | hwpf = dm.download(url, None) |
| 72 | imgfile = get_image_name(odir,url,args.binary_type) |
| 73 | build_image(lmc, imgfile, hwpack, hwpf, args.binary_type, rfsf) |
Ricardo Salveti de Araujo | ec7366a | 2012-07-25 12:36:06 -0300 | [diff] [blame] | 74 | compress_image(imgfile) |
Andy Doan | df9dfd7 | 2012-04-26 13:45:15 -0500 | [diff] [blame] | 75 | |
| 76 | if __name__ == '__main__': |
| 77 | main() |
| 78 | |