blob: 49db08476aed589714cb2559099758e566873e96 [file] [log] [blame]
Fathi Boudracd8f58d2012-06-15 17:43:39 +03001#!/usr/bin/python
2
Andy Doandf9dfd72012-04-26 13:45:15 -05003# 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
24from linaro_fetch_image import fetch_image
25
Ricardo Salveti de Araujoec7366a2012-07-25 12:36:06 -030026from build_images import build_image, compress_image
Andy Doandf9dfd72012-04-26 13:45:15 -050027
28import argparse
29import os
30import re
31
32def 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
39def url_to_hwpack(url):
40 ''' convert a URL like:
Fathi Boudra684e5e42012-11-30 04:19:33 +010041 http://snapshots.linaro.org/SERIE/hwpacks/HWPACK_NAME/HWPACK_BUILD_NUMBER/HWPACK_FILE_NAME
Andy Doandf9dfd72012-04-26 13:45:15 -050042 into lt-panda
43 '''
44 return re.search(r'hwpack_linaro-(.*)_\d+', url).group(1)
45
46def 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 Araujoec7366a2012-07-25 12:36:06 -030074 compress_image(imgfile)
Andy Doandf9dfd72012-04-26 13:45:15 -050075
76if __name__ == '__main__':
77 main()
78