'Write build spec to fd.'

def WriteBuildYaml(self, fd, build_timestamp=True):

    output = {'Client.build_environment': rdf_client.Uname.FromCurrentSystem().signature(), 'Template.build_type': config.CONFIG.Get('ClientBuilder.build_type', context=self.context), 'Template.version_major': config.CONFIG.Get('Source.version_major', context=self.context), 'Template.version_minor': config.CONFIG.Get('Source.version_minor', context=self.context), 'Template.version_revision': config.CONFIG.Get('Source.version_revision', context=self.context), 'Template.version_release': config.CONFIG.Get('Source.version_release', context=self.context), 'Template.arch': config.CONFIG.Get('Client.arch', context=self.context)}
    if build_timestamp:
        output['Client.build_time'] = rdfvalue.RDFDatetime.Now()
    else:
        self.REQUIRED_BUILD_YAML_KEYS.remove('Client.build_time')
    for (key, value) in output.iteritems():
        output[key] = str(value)
    output['Template.build_context'] = self.context
    if (set(output.keys()) != self.REQUIRED_BUILD_YAML_KEYS):
        raise RuntimeError(('Bad    build.yaml:    expected    %s,    got    %s' % (self.REQUIRED_BUILD_YAML_KEYS, output.keys())))
    fd.write(yaml.dump(output))
