diff --git a/src/pylorax/__init__.py b/src/pylorax/__init__.py index fac2a755..ffef6c3e 100644 --- a/src/pylorax/__init__.py +++ b/src/pylorax/__init__.py @@ -281,7 +281,8 @@ class Lorax(BaseLoraxClass): # write .buildstamp buildstamp = BuildStamp(self.product.name, self.product.version, - self.product.bugurl, self.product.isfinal, self.arch.buildarch) + self.product.bugurl, self.product.isfinal, + self.arch.buildarch, self.product.variant) buildstamp.write(joinpaths(self.inroot, ".buildstamp")) diff --git a/src/pylorax/buildstamp.py b/src/pylorax/buildstamp.py index 42199445..0925be73 100644 --- a/src/pylorax/buildstamp.py +++ b/src/pylorax/buildstamp.py @@ -27,11 +27,12 @@ import datetime class BuildStamp(object): - def __init__(self, product, version, bugurl, isfinal, buildarch): + def __init__(self, product, version, bugurl, isfinal, buildarch, variant=""): self.product = product self.version = version self.bugurl = bugurl self.isfinal = isfinal + self.variant = variant now = datetime.datetime.now() now = now.strftime("%Y%m%d%H%M") @@ -54,5 +55,7 @@ class BuildStamp(object): fobj.write("BugURL={0.bugurl}\n".format(self)) fobj.write("IsFinal={0.isfinal}\n".format(self)) fobj.write("UUID={0.uuid}\n".format(self)) + if self.variant: + fobj.write("Variant={0.variant}\n".format(self)) fobj.write("[Compose]\n") fobj.write("Lorax={0}\n".format(vernum)) diff --git a/src/pylorax/cmdline.py b/src/pylorax/cmdline.py index 1b6662d5..e1e004a7 100644 --- a/src/pylorax/cmdline.py +++ b/src/pylorax/cmdline.py @@ -46,7 +46,7 @@ def lorax_parser(): optional.add_argument("-m", "--mirrorlist", help="mirrorlist repository (may be listed multiple times)", metavar="REPOSITORY", action="append", default=[]) - optional.add_argument("-t", "--variant", + optional.add_argument("-t", "--variant", default="", help="variant name", metavar="VARIANT") optional.add_argument("-b", "--bugurl", help="bug reporting URL for the product", metavar="URL", diff --git a/tests/pylorax/test_buildstamp.py b/tests/pylorax/test_buildstamp.py index b33d5fad..73959ad1 100644 --- a/tests/pylorax/test_buildstamp.py +++ b/tests/pylorax/test_buildstamp.py @@ -11,7 +11,8 @@ class BuildStampTestCase(unittest.TestCase): '0.1', 'https://github.com/rhinstaller/lorax/issues', True, - 'noarch' + 'noarch', + 'Server' ) def test_write_produces_file_with_expected_content(self): @@ -19,5 +20,6 @@ class BuildStampTestCase(unittest.TestCase): with patch.object(out_file, 'close'): with patch.object(buildstamp, 'open', return_value=out_file): self.bstamp.write('/tmp/stamp.ini') - self.assertIn("[Main]\nProduct=Lorax Tests\nVersion=0.1\nBugURL=https://github.com/rhinstaller/lorax/issues\nIsFinal=True", out_file.getvalue()) - self.assertIn("[Compose]\nLorax=devel", out_file.getvalue()) + self.assertIn("[Main]\nProduct=Lorax Tests\nVersion=0.1\nBugURL=https://github.com/rhinstaller/lorax/issues\nIsFinal=True\n", out_file.getvalue()) + # Skip UUID which is between IsFinal and Variant + self.assertIn("Variant=Server\n[Compose]\nLorax=devel", out_file.getvalue())