| #!/usr/bin/python |
| |
| # Copyright (C) 2012 Linaro |
| # |
| # Author: Andy Doan <andy.doan@linaro.org> |
| # |
| # This file is part of Linaro Daily Prebuilt Images. |
| # |
| # Linaro Daily Prebuilt Images is free software; you can redistribute it and/or |
| # modify it under the terms of the GNU General Public License |
| # as published by the Free Software Foundation; either version 2 |
| # of the License, or (at your option) any later version. |
| # |
| # Linaro Daily Prebuilt Images is distributed in the hope that it will be useful, |
| # but WITHOUT ANY WARRANTY; without even the implied warranty of |
| # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| # GNU General Public License for more details. |
| # |
| # You should have received a copy of the GNU General Public License |
| # along with Linaro Image Tools; if not, write to the Free Software |
| # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, |
| # USA. |
| |
| from linaro_fetch_image import fetch_image |
| |
| from build_images import build_image, compress_image |
| |
| import argparse |
| import os |
| import re |
| |
| def get_image_name(odir, hwpack_url, binary): |
| path = '%s/%s' % (odir, binary) |
| if not os.path.exists(path): |
| os.makedirs(path) |
| hwpack = re.search(r'hwpack_linaro-(.*)_armhf', hwpack_url).group(1) |
| return "%s/%s-%s.img" %(path,hwpack,binary) |
| |
| def url_to_hwpack(url): |
| ''' convert a URL like: |
| http://snapshots.linaro.org/SERIE/hwpacks/HWPACK_NAME/HWPACK_BUILD_NUMBER/HWPACK_FILE_NAME |
| into lt-panda |
| ''' |
| return re.search(r'hwpack_linaro-(.*)_\d+', url).group(1) |
| |
| def main(): |
| p = argparse.ArgumentParser(description= |
| 'Builds a matrix of builds from the latest build on ' |
| 'snapshots.linaro.org or release images on releases.linaro.org') |
| |
| p.add_argument('-o', dest='out_dir', default='./out', |
| help='The out directory for downloaded and built files, default=./') |
| p.add_argument('-w', dest='hwpacks', action='append', required=True, |
| help='The hwpacks urls generate images for.') |
| p.add_argument('-b', dest='binary', required=True, |
| help='The URL of the RFS') |
| p.add_argument('-t', dest='binary_type', required=True, |
| help='The binary type, eg nano,ubuntu-desktop') |
| |
| args = p.parse_args() |
| |
| dm = fetch_image.DownloadManager(args.out_dir) |
| |
| rfsf = dm.download(args.binary, None) |
| |
| lmc = '%s/linaro-image-tools/linaro-media-create' % args.out_dir |
| odir = '%s/pre-built' % args.out_dir |
| |
| for url in args.hwpacks: |
| hwpack = url_to_hwpack(url) |
| hwpf = dm.download(url, None) |
| imgfile = get_image_name(odir,url,args.binary_type) |
| build_image(lmc, imgfile, hwpack, hwpf, args.binary_type, rfsf) |
| compress_image(imgfile) |
| |
| if __name__ == '__main__': |
| main() |
| |