]> git.ipfire.org Git - pakfire.git/commitdiff
Add build information (like time, id and hostname) in packages.
authorMichael Tremer <michael.tremer@ipfire.org>
Fri, 25 Feb 2011 21:19:15 +0000 (22:19 +0100)
committerMichael Tremer <michael.tremer@ipfire.org>
Fri, 25 Feb 2011 21:19:15 +0000 (22:19 +0100)
pakfire/builder.py
pakfire/constants.py
pakfire/packages/packager.py

index 991b40969a3ae8eac65d8f62b9f57209db12e3c4..409560cd80e35a62d7c7388b51e07e6d0a6dc3a7 100644 (file)
@@ -7,6 +7,7 @@ import math
 import os
 import re
 import shutil
+import socket
 import stat
 import time
 
@@ -24,7 +25,7 @@ class Builder(object):
        # The version of the kernel this machine is running.
        kernel_version = os.uname()[2]
 
-       def __init__(self, pakfire, pkg, **settings):
+       def __init__(self, pakfire, pkg, build_id="", **settings):
                self.pakfire = pakfire
                self.pkg = pkg
 
@@ -41,9 +42,22 @@ class Builder(object):
                self._lock = None
                self.lock()
 
+               # Save the build time.
+               self.build_time = int(time.time())
+               self.build_id = build_id
+
                # Initialize the environment
                self.prepare()
 
+       @property
+       def info(self):
+               return {
+                       "build_date" : time.strftime("%a, %d %b %Y %H:%M:%S +0000", time.gmtime(self.build_time)),
+                       "build_host" : socket.gethostname(),
+                       "build_id"   : self.build_id,
+                       "build_time" : self.build_time,
+               }
+
        @property
        def path(self):
                return self.pakfire.path
index fa0a27656d9230f19d6f51f1ecd619b58c8d2581..0d3bc9b51ae626c12bcbae819c7a533f49d5d136 100644 (file)
@@ -57,9 +57,10 @@ BINARY_PACKAGE_META = """\
 VERSION="%(package_format)s"
 
 # Build information
-BUILD_DATE="XXX"
-BUILD_HOST="XXX"
-BUILD_ID="XXX"
+BUILD_DATE="%(build_date)s"
+BUILD_HOST="%(build_host)s"
+BUILD_ID="%(build_id)s"
+BUILD_TIME="%(build_time)s"
 
 # Distribution information
 DISTRO_NAME="%(distro_name)s"
index 57aa2dea1a8c5237cd7243f389c2a5da8f85df05..6fe99e4bc17abe6d15b8b66377b0c83c4457fb65 100644 (file)
@@ -194,6 +194,7 @@ class Packager(object):
                }
                self.info.update(self.pkg.info)
                self.info.update(self.pakfire.distro.info)
+               self.info.update(self.env.info)
 
                ### Create temporary files
                # Create temp directory to where we extract all files again and