Remove workdir/path from BuildStamp, DiscInfo, TreeInfo
This allows us to create these objects without needing workdir, which means we can use them outside of __init__.py. We can also write them directly to their final destination instead of writing them to the workdir and then copying them in.
This commit is contained in:
parent
9b9f021caf
commit
756b44948e
@ -33,7 +33,6 @@ import sys
|
||||
import os
|
||||
import ConfigParser
|
||||
import tempfile
|
||||
import shutil
|
||||
import glob
|
||||
import math
|
||||
import subprocess
|
||||
@ -215,11 +214,10 @@ class Lorax(BaseLoraxClass):
|
||||
self.installtree.yum.process_transaction(skipbroken)
|
||||
|
||||
# write .buildstamp
|
||||
buildstamp = BuildStamp(self.workdir, self.product.name, self.product.version,
|
||||
buildstamp = BuildStamp(self.product.name, self.product.version,
|
||||
self.product.bugurl, self.product.is_beta, self.arch.buildarch)
|
||||
|
||||
buildstamp.write()
|
||||
shutil.copy2(buildstamp.path, self.installtree.root)
|
||||
buildstamp.write(joinpaths(self.installtree.root, ".buildstamp"))
|
||||
|
||||
logger.debug("saving pkglists to %s", self.workdir)
|
||||
dname = joinpaths(self.workdir, "pkglists")
|
||||
@ -273,13 +271,11 @@ class Lorax(BaseLoraxClass):
|
||||
self.installtree.get_anaconda_portions()
|
||||
|
||||
# write .discinfo
|
||||
discinfo = DiscInfo(self.workdir, self.product.release, self.arch.basearch)
|
||||
discinfo.write()
|
||||
|
||||
shutil.copy2(discinfo.path, self.outputdir)
|
||||
discinfo = DiscInfo(self.product.release, self.arch.basearch)
|
||||
discinfo.write(joinpaths(self.outputdir, ".discinfo"))
|
||||
|
||||
# create .treeinfo
|
||||
treeinfo = TreeInfo(self.workdir, self.product.name, self.product.version,
|
||||
treeinfo = TreeInfo(self.product.name, self.product.version,
|
||||
self.product.variant, self.arch.basearch)
|
||||
|
||||
# get the image class
|
||||
@ -318,9 +314,7 @@ class Lorax(BaseLoraxClass):
|
||||
logger.info("creating boot iso")
|
||||
i.create_boot(efiboot=None) # FIXME restore proper EFI function
|
||||
|
||||
treeinfo.write()
|
||||
|
||||
shutil.copy2(treeinfo.path, self.outputdir)
|
||||
treeinfo.write(joinpaths(self.outputdir, ".treeinfo"))
|
||||
|
||||
def get_buildarch(self):
|
||||
# get architecture of the available anaconda package
|
||||
|
@ -23,14 +23,11 @@ import logging
|
||||
logger = logging.getLogger("pylorax.buildstamp")
|
||||
|
||||
import datetime
|
||||
from sysutils import joinpaths
|
||||
|
||||
|
||||
class BuildStamp(object):
|
||||
|
||||
def __init__(self, workdir, product, version, bugurl, is_beta, buildarch):
|
||||
self.path = joinpaths(workdir, ".buildstamp")
|
||||
|
||||
def __init__(self, product, version, bugurl, is_beta, buildarch):
|
||||
self.product = product
|
||||
self.version = version
|
||||
self.bugurl = bugurl
|
||||
@ -40,9 +37,9 @@ class BuildStamp(object):
|
||||
now = now.strftime("%Y%m%d%H%M")
|
||||
self.uuid = "{0}.{1}".format(now, buildarch)
|
||||
|
||||
def write(self):
|
||||
def write(self, outfile):
|
||||
logger.info("writing .buildstamp file")
|
||||
with open(self.path, "w") as fobj:
|
||||
with open(outfile, "w") as fobj:
|
||||
fobj.write("[Main]\n")
|
||||
fobj.write("Product={0.product}\n".format(self))
|
||||
fobj.write("Version={0.version}\n".format(self))
|
||||
|
@ -23,20 +23,17 @@ import logging
|
||||
logger = logging.getLogger("pylorax.discinfo")
|
||||
|
||||
import time
|
||||
from sysutils import joinpaths
|
||||
|
||||
|
||||
class DiscInfo(object):
|
||||
|
||||
def __init__(self, workdir, release, basearch):
|
||||
self.path = joinpaths(workdir, ".discinfo")
|
||||
|
||||
def __init__(self, release, basearch):
|
||||
self.release = release
|
||||
self.basearch = basearch
|
||||
|
||||
def write(self):
|
||||
def write(self, outfile):
|
||||
logger.info("writing .discinfo file")
|
||||
with open(self.path, "w") as fobj:
|
||||
with open(outfile, "w") as fobj:
|
||||
fobj.write("{0:f}\n".format(time.time()))
|
||||
fobj.write("{0.release}\n".format(self))
|
||||
fobj.write("{0.basearch}\n".format(self))
|
||||
|
@ -24,15 +24,13 @@ logger = logging.getLogger("pylorax.treeinfo")
|
||||
|
||||
import ConfigParser
|
||||
import time
|
||||
from sysutils import joinpaths
|
||||
|
||||
|
||||
class TreeInfo(object):
|
||||
|
||||
def __init__(self, workdir, product, version, variant, basearch,
|
||||
def __init__(self, product, version, variant, basearch,
|
||||
packagedir=""):
|
||||
|
||||
self.path = joinpaths(workdir, ".treeinfo")
|
||||
self.c = ConfigParser.ConfigParser()
|
||||
|
||||
section = "general"
|
||||
@ -52,7 +50,7 @@ class TreeInfo(object):
|
||||
|
||||
map(lambda (key, value): self.c.set(section, key, value), data.items())
|
||||
|
||||
def write(self):
|
||||
def write(self, outfile):
|
||||
logger.info("writing .treeinfo file")
|
||||
with open(self.path, "w") as fobj:
|
||||
with open(outfile, "w") as fobj:
|
||||
self.c.write(fobj)
|
||||
|
Loading…
Reference in New Issue
Block a user