Automated commit (/opt/dev/infra/gitclass.py)
This commit is contained in:
69
builder/compile.py
Normal file
69
builder/compile.py
Normal file
@@ -0,0 +1,69 @@
|
||||
import logging
|
||||
import os
|
||||
import shutil
|
||||
import subprocess
|
||||
##
|
||||
from . import constants
|
||||
|
||||
|
||||
_log = logging.getLogger()
|
||||
|
||||
|
||||
class Target(object):
|
||||
def __init__(self, target_xml):
|
||||
self.xml = target_xml
|
||||
self.subdir = self.xml.attrib.get('subDir', '.')
|
||||
self.base = self.xml.attrib.get('baseName')
|
||||
self.target = self.xml.text
|
||||
if not self.base:
|
||||
self.base = os.path.basename(self.target)
|
||||
|
||||
|
||||
class IpxeScript(object):
|
||||
def __init__(self, script_dir, script_xml):
|
||||
self.xml = script_xml
|
||||
self.fpath = os.path.join(os.path.abspath(os.path.expanduser(script_dir)),
|
||||
self.xml.text)
|
||||
self.prefix = self.xml.attrib['prefix']
|
||||
|
||||
|
||||
class Compiler(object):
|
||||
def __init__(self, builddir, destdir, upstream, patches, monkey_patches, build_xml):
|
||||
self.xml = build_xml
|
||||
self.build = os.path.abspath(os.path.expanduser(builddir))
|
||||
self.dest = os.path.abspath(os.path.expanduser(destdir))
|
||||
self.src = upstream.dest
|
||||
self.upstream = upstream
|
||||
self.patches = patches
|
||||
self.monkey_patches = monkey_patches
|
||||
self.targets = []
|
||||
self.scripts = []
|
||||
self._add_targets()
|
||||
|
||||
def _add_targets(self):
|
||||
roms = self.xml.findall('rom')
|
||||
if roms is None:
|
||||
|
||||
|
||||
def make(self):
|
||||
# NOTE: 1af41000 is the firmware used by virtIO
|
||||
self.prep()
|
||||
self.patch()
|
||||
|
||||
def patch(self):
|
||||
for m in self.monkey_patches:
|
||||
for pf in m.files:
|
||||
pf.patch()
|
||||
for p in self.patches:
|
||||
for pf in p.files:
|
||||
pf.patch()
|
||||
return()
|
||||
|
||||
def prep(self):
|
||||
if self.src != self.build:
|
||||
shutil.copytree(self.src, self.build, dirs_exist_ok = True)
|
||||
os.makedirs(self.dest)
|
||||
# These are standard.
|
||||
for d in constants.IPXE_CATEGORIES:
|
||||
dpath = os.path.join(self.dest, d)
|
||||
os.makedirs(dpath, exist_ok = True)
|
||||
Reference in New Issue
Block a user