[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

generate Built-Using headers (was Re: post-jessie: header only C++ library package (static?))

On Mon, 20 Oct 2014, Osamu Aoki wrote:

> I see. By the way, I have never seen package using Build-Using in
> debian/control which is documented in policy.  Is there any automatic
> way to set the used-source:Version of package used?  Something like ...
> Built-Using: marisa (== ${used-source:Version})
> I can not find example stanza...

Unfortunately no.

mksh does this, but it’s rather complicated because of the way
the binaries in mksh are built (they can either depend on glibc
or klibc or dietlibc (actually, even two out of the three) plus
possibly gcc and possibly linux-libc-dev (klibc)).

The gist is:

debian/control contains:

| Built-Using: ${mksh:B-U}

The code generates (as a shell variable) the dependencies and
makes them available to dpkg-gencontrol by…
| echo "mksh:B-U=$buspkgs" >builddir/substvars
… which is then later (in binary-arch) added:
|	cat builddir/substvars >>debian/mksh.substvars

Now, what *is* in $buspkgs you ask?


In my case, I have two things that I track to go into B-U:

① filenames, for example $($CC -print-libgcc-file-name),
  i.e. /usr/lib/gcc/x86_64-linux-gnux32/4.9/libgcc.a

② package names, for example dietlibc-dev (must be installed)

But B-U wants *source* package names! So what to do:

ⓐ resolve filenames from ① to binary package names:

  filename=$($CC -print-libgcc-file-name)    # from above
  filename=$(readlink -f "$filename")        # realpath()ise
  x=$(dpkg -S "$filename")
  binpkg=${x%%: *}

ⓑ put list of binary packages from ⓐ and ② together

ⓒ resolve them into source packages:

  binpkgs='libgcc-4.9-dev:x32 dietlibc-dev'  # from above
  for x in $binpkgs; do
	dpkg-query -Wf '${source:Package} (= ${source:Version})\n' "$x"
  done | sort -u | {
	while IFS= read -r x; do
		test -n "$x" || continue
		test x"$x" = x" (= )" && continue
		echo "Built Using: $x"
		test -z "$buspkgs" || buspkgs="$buspkgs, "
	echo "mksh:B-U=$buspkgs" >builddir/substvars

There you have that line from above again. The code is a bit
complicated, but it ensures that every source package is only
referenced once (more nicely) and skips missing things.

All of this is POSIX sh safe, Debian Policy §10.4 compliant,
and works with bash, dash, mksh. (Note that shells are allowed
to differ what parts of “a | b | c” run in subshells and what
parts, if any, run in the main shell. Hence, the echo *must*
be inside the {…} behind the pipe; the $buspkgs variable may
be unset after the closing ‘}’!)

In your case, it’s probably much simpler. You have one binary
package, I think, for which you will want to record the source
package and its precise version number.

«MyISAM tables -will- get corrupted eventually. This is a fact of life. »
“mysql is about as much database as ms access” – “MSSQL at least descends
from a database” “it's a rebranded SyBase” “MySQL however was born from a
flatfile and went downhill from there” – “at least jetDB doesn’t claim to
be a database”	‣‣‣ Please, http://deb.li/mysql and MariaDB, finally die!

Reply to: