buildcommands: Don't attach hostname and build date to version on a clean build
Most builds will be direclty from git - removing the hostname and build date should permit reproducible binaries in that common case. Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
This commit is contained in:
parent
acd94909bc
commit
947ffe706d
|
@ -466,14 +466,18 @@ def git_version():
|
||||||
logging.debug("Got git version: %s" % (repr(ver),))
|
logging.debug("Got git version: %s" % (repr(ver),))
|
||||||
return ver
|
return ver
|
||||||
|
|
||||||
def build_version(extra):
|
def build_version(extra, cleanbuild):
|
||||||
version = git_version()
|
version = git_version()
|
||||||
if not version:
|
if not version:
|
||||||
|
cleanbuild = False
|
||||||
version = "?"
|
version = "?"
|
||||||
btime = time.strftime("%Y%m%d_%H%M%S")
|
elif 'dirty' in version:
|
||||||
hostname = socket.gethostname()
|
cleanbuild = False
|
||||||
version = "%s-%s-%s%s" % (version, btime, hostname, extra)
|
if not cleanbuild:
|
||||||
return version
|
btime = time.strftime("%Y%m%d_%H%M%S")
|
||||||
|
hostname = socket.gethostname()
|
||||||
|
version = "%s-%s-%s" % (version, btime, hostname)
|
||||||
|
return version + extra
|
||||||
|
|
||||||
# Run "tool --version" for each specified tool and extract versions
|
# Run "tool --version" for each specified tool and extract versions
|
||||||
def tool_versions(tools):
|
def tool_versions(tools):
|
||||||
|
@ -515,7 +519,7 @@ class HandleVersions:
|
||||||
data['build_versions'] = self.toolstr
|
data['build_versions'] = self.toolstr
|
||||||
def generate_code(self, options):
|
def generate_code(self, options):
|
||||||
cleanbuild, self.toolstr = tool_versions(options.tools)
|
cleanbuild, self.toolstr = tool_versions(options.tools)
|
||||||
self.version = build_version(options.extra)
|
self.version = build_version(options.extra, cleanbuild)
|
||||||
sys.stdout.write("Version: %s\n" % (self.version,))
|
sys.stdout.write("Version: %s\n" % (self.version,))
|
||||||
return "\n// version: %s\n// build_versions: %s\n" % (
|
return "\n// version: %s\n// build_versions: %s\n" % (
|
||||||
self.version, self.toolstr)
|
self.version, self.toolstr)
|
||||||
|
|
Loading…
Reference in New Issue