This is the mail archive of the
mailing list for the elfutils project.
Re: rfc/patch: user-agent distro-description for debuginfod http traffic
On Wed, Jan 08, 2020 at 10:11:25AM -0500, Frank Ch. Eigler wrote:
> > Eep. We really should pick up this info during runtime instead of
> > during build time.
> That's what I thought at first too. However, doing it at run time
> means doing work - a popen() etc. - over and over or saving in a
> locked global. Since on a normal machine, the distro doesn't change
> without elfutils also changing, it's practically a literal.
We are already opening some files to scan for cached files, open a
socket, download data, etc. I don't think one or two extra syscalls
are that much overhead.
> > We do want a reproducible build.
> Can you give an example? Bootstrapping a new distro version/arch?
Probably best explained at https://reproducible-builds.org/ most
distributions are participating.
> > And this will most likely produce wrong information if the package
> > build server is on a different OS or release than the OS/release it
> > is producing packages for. uname -sm might be "stable", but probably
> > not when cross- compiling.
> I wonder if the cross-compiled debuginfod-client case is worth
> worrying about.
I think it is.
> > But where does lsb_release come from? I don't have that on my
> > systems.
> BuildRequires: /usr/bin/lsb_release :-) It's a different package on
> different distros. And running at run time would make a Require:
> rather than a one-time BuildRequire:.
It looks like the new standard (since about 8 years) is os-release:
It looks like an easily parsable file format. The attached produces
some reasonable looking identification strings on a couple of my
systems out of the box:
Maybe something like that is usable?
struct utsname uts;
if (uname (&uts) == 0)
printf ("%s/%s %s\n", uts.sysname, uts.machine, uts.release);
f = fopen ("/etc/os-release", "r");
if (f == NULL)
f = fopen ("/usr/lib/os-release", "r");
char *id = NULL;
char *version = NULL;
if (f != NULL)
while (id == NULL || version == NULL)
char *s = &buf;
if (fgets (s, 128, f) == NULL)
int len = strlen (s);
if (len < 3)
if (s[len - 1] == '\n')
s[len - 1] = '\0';
char *v = strchr (s, '=');
if (v == NULL || strlen (v) < 2)
/* Split var and value. */
*v = '\0';
/* Remove optional quotes around value string. */
if (*v == '"' || *v == '\'')
s[len - 1] = '\0';
if (strcmp (s, "ID") == 0)
id = strdup (v);
if (strcmp (s, "VERSION_ID") == 0)
version = strdup (v);
printf ("%s/%s\n", id, version);