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:
Will Woods 2011-04-28 14:10:31 -04:00
parent 9b9f021caf
commit 756b44948e
4 changed files with 15 additions and 29 deletions

View File

@ -33,7 +33,6 @@ import sys
import os import os
import ConfigParser import ConfigParser
import tempfile import tempfile
import shutil
import glob import glob
import math import math
import subprocess import subprocess
@ -215,11 +214,10 @@ class Lorax(BaseLoraxClass):
self.installtree.yum.process_transaction(skipbroken) self.installtree.yum.process_transaction(skipbroken)
# write .buildstamp # 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) self.product.bugurl, self.product.is_beta, self.arch.buildarch)
buildstamp.write() buildstamp.write(joinpaths(self.installtree.root, ".buildstamp"))
shutil.copy2(buildstamp.path, self.installtree.root)
logger.debug("saving pkglists to %s", self.workdir) logger.debug("saving pkglists to %s", self.workdir)
dname = joinpaths(self.workdir, "pkglists") dname = joinpaths(self.workdir, "pkglists")
@ -273,13 +271,11 @@ class Lorax(BaseLoraxClass):
self.installtree.get_anaconda_portions() self.installtree.get_anaconda_portions()
# write .discinfo # write .discinfo
discinfo = DiscInfo(self.workdir, self.product.release, self.arch.basearch) discinfo = DiscInfo(self.product.release, self.arch.basearch)
discinfo.write() discinfo.write(joinpaths(self.outputdir, ".discinfo"))
shutil.copy2(discinfo.path, self.outputdir)
# create .treeinfo # 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) self.product.variant, self.arch.basearch)
# get the image class # get the image class
@ -318,9 +314,7 @@ class Lorax(BaseLoraxClass):
logger.info("creating boot iso") logger.info("creating boot iso")
i.create_boot(efiboot=None) # FIXME restore proper EFI function i.create_boot(efiboot=None) # FIXME restore proper EFI function
treeinfo.write() treeinfo.write(joinpaths(self.outputdir, ".treeinfo"))
shutil.copy2(treeinfo.path, self.outputdir)
def get_buildarch(self): def get_buildarch(self):
# get architecture of the available anaconda package # get architecture of the available anaconda package

View File

@ -23,14 +23,11 @@ import logging
logger = logging.getLogger("pylorax.buildstamp") logger = logging.getLogger("pylorax.buildstamp")
import datetime import datetime
from sysutils import joinpaths
class BuildStamp(object): class BuildStamp(object):
def __init__(self, workdir, product, version, bugurl, is_beta, buildarch): def __init__(self, product, version, bugurl, is_beta, buildarch):
self.path = joinpaths(workdir, ".buildstamp")
self.product = product self.product = product
self.version = version self.version = version
self.bugurl = bugurl self.bugurl = bugurl
@ -40,9 +37,9 @@ class BuildStamp(object):
now = now.strftime("%Y%m%d%H%M") now = now.strftime("%Y%m%d%H%M")
self.uuid = "{0}.{1}".format(now, buildarch) self.uuid = "{0}.{1}".format(now, buildarch)
def write(self): def write(self, outfile):
logger.info("writing .buildstamp file") logger.info("writing .buildstamp file")
with open(self.path, "w") as fobj: with open(outfile, "w") as fobj:
fobj.write("[Main]\n") fobj.write("[Main]\n")
fobj.write("Product={0.product}\n".format(self)) fobj.write("Product={0.product}\n".format(self))
fobj.write("Version={0.version}\n".format(self)) fobj.write("Version={0.version}\n".format(self))

View File

@ -23,20 +23,17 @@ import logging
logger = logging.getLogger("pylorax.discinfo") logger = logging.getLogger("pylorax.discinfo")
import time import time
from sysutils import joinpaths
class DiscInfo(object): class DiscInfo(object):
def __init__(self, workdir, release, basearch): def __init__(self, release, basearch):
self.path = joinpaths(workdir, ".discinfo")
self.release = release self.release = release
self.basearch = basearch self.basearch = basearch
def write(self): def write(self, outfile):
logger.info("writing .discinfo file") 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:f}\n".format(time.time()))
fobj.write("{0.release}\n".format(self)) fobj.write("{0.release}\n".format(self))
fobj.write("{0.basearch}\n".format(self)) fobj.write("{0.basearch}\n".format(self))

View File

@ -24,15 +24,13 @@ logger = logging.getLogger("pylorax.treeinfo")
import ConfigParser import ConfigParser
import time import time
from sysutils import joinpaths
class TreeInfo(object): class TreeInfo(object):
def __init__(self, workdir, product, version, variant, basearch, def __init__(self, product, version, variant, basearch,
packagedir=""): packagedir=""):
self.path = joinpaths(workdir, ".treeinfo")
self.c = ConfigParser.ConfigParser() self.c = ConfigParser.ConfigParser()
section = "general" section = "general"
@ -52,7 +50,7 @@ class TreeInfo(object):
map(lambda (key, value): self.c.set(section, key, value), data.items()) map(lambda (key, value): self.c.set(section, key, value), data.items())
def write(self): def write(self, outfile):
logger.info("writing .treeinfo file") logger.info("writing .treeinfo file")
with open(self.path, "w") as fobj: with open(outfile, "w") as fobj:
self.c.write(fobj) self.c.write(fobj)