1#!/usr/bin/python 2########################################################################## 3# Copyright (c) 2016 ETH Zurich. 4# All rights reserved. 5# 6# This file is distributed under the terms in the attached LICENSE file. 7# If you do not find this file, copies can be found by writing to: 8# ETH Zurich D-INFK, CAB F.78, Universitaetstr. 6, CH-8092 Zurich, 9# Attn: Systems Group. 10# 11# Create a Barrelfish EFI image 12# 13########################################################################## 14 15import argparse 16import subprocess 17import os 18 19import harness.efiimage 20 21class FileExists(object): 22 23 def __call__(self, string): 24 if os.path.isfile(string): 25 return os.path.abspath(string) 26 else: 27 message = _("not a file '%s'") 28 raise argparse.ArgumentTypeError(msg) 29 30parser = argparse.ArgumentParser() 31parser.add_argument("image", help="image file to create") 32parser.add_argument("content", 33 help="files to include in the image", 34 nargs='+', 35 type=FileExists()) 36parser.add_argument("--size", help="image size", type=int, default=200) 37parser.add_argument("--create", help="create image, even if exists", 38 action="store_true") 39 40args = parser.parse_args() 41 42 43efi = harness.efiimage.EFIImage(args.image, args.size) 44if args.create or not os.path.isfile(args.image): 45 efi.create() 46for f in args.content: 47 efi.addFile(f, f) 48 49