From f4948a759857bfb9cdb2e6ae602a6fb40ad91600 Mon Sep 17 00:00:00 2001 From: Chris Lumens Date: Thu, 9 Sep 2010 13:21:09 -0400 Subject: Convert .buildstamp into a .ini-style file. --- pyanaconda/product.py | 57 ++++++++++++++++++++------------------------------- 1 file changed, 22 insertions(+), 35 deletions(-) (limited to 'pyanaconda/product.py') diff --git a/pyanaconda/product.py b/pyanaconda/product.py index e271b4502..49ec57311 100644 --- a/pyanaconda/product.py +++ b/pyanaconda/product.py @@ -17,44 +17,31 @@ # along with this program. If not, see . # +import ConfigParser import os -if os.access("/tmp/product/.buildstamp", os.R_OK): - path = "/tmp/product/.buildstamp" -elif os.access("/.buildstamp", os.R_OK): - path = "/.buildstamp" -elif os.environ.has_key("PRODBUILDPATH") and \ - os.access(os.environ["PRODBUILDPATH"], os.R_OK): - path = os.environ["PRODBUILDPATH"] -else: - path = None +# First, load in the defaults. In order of precedence: contents of +# .buildstamp, environment, stupid last ditch hardcoded defaults. +config = ConfigParser.ConfigParser({"Arch": os.environ.get("ANACONDA_PRODUCTARCH", ""), + "BugURL": os.environ.get("ANACONDA_BUGURL", "your distribution provided bug reporting tool"), + "IsBeta": os.environ.get("ANACONDA_ISBETA", "true").lower() == "true", + "Product": os.environ.get("ANACONDA_PRODUCTNAME", "anaconda"), + "UUID": "", + "Version": os.environ.get("ANACONDA_PRODUCTVERSION", "bluesky")} + ) -productStamp = "" -productName = "anaconda" -productVersion = "bluesky" -productArch = None -bugUrl = "your distribution provided bug reporting tool." +# Now read in the .buildstamp file, wherever it may be. +config.read(["/tmp/product/.buildstamp", "/.buildstamp", os.environ.get("PRODBUILDPATH", "")]) -if path is not None: - f = open(path, "r") - lines = f.readlines() - del f - if len(lines) >= 3: - productStamp = lines[0][:-1] - productArch = productStamp[productStamp.index(".")+1:] - productName = lines[1][:-1] - productVersion = lines[2][:-1] - if len(lines) >= 4: - bugUrl = lines[3][:-1] +# Set up some variables we import throughout, applying a couple transforms as necessary. +bugUrl = config.get("Main", "BugURL") +isBeta = config.get("Main", "IsBeta").lower() != "false" +productArch = config.get("Main", "Arch") +productName = config.get("Main", "Product") +productStamp = config.get("Main", "UUID") +productVersion = config.get("Main", "Version") -if os.environ.has_key("ANACONDA_PRODUCTNAME"): - productName = os.environ["ANACONDA_PRODUCTNAME"] -if os.environ.has_key("ANACONDA_PRODUCTVERSION"): - productVersion = os.environ["ANACONDA_PRODUCTVERSION"] -if os.environ.has_key("ANACONDA_PRODUCTARCH"): - productArch = os.environ["ANACONDA_PRODUCTARCH"] -if os.environ.has_key("ANACONDA_BUGURL"): - bugUrl = os.environ["ANACONDA_BUGURL"] - -if productVersion == "development": # hack to transform for now +if not productArch: + productArch = productStamp[productStamp.index(".")+1:] +if productVersion == "development": productVersion = "rawhide" -- cgit