88.7. protobuf-c-1.5.2
Protocol Buffers for C — the runtime library and the protoc-gen-c code generator
| Version | 1.5.2, release 1 |
| Shelf | formats — Data-format and serialisation libraries (XML, JSON, YAML, TOML, INI, RDF, protobuf, thrift), plus data query and convert tools |
| Phase | 41_system (System), 256 of 1047 in build order |
| Licence | BSD-2-Clause |
| Homepage | https://github.com/protobuf-c/protobuf-c |
| Build time | 1.0 SBU |
| Installed size | 509.1 KiB in 10 files |
| Recipe | ports/core/formats/protobuf-c/kpkgbuild |
About
protobuf-c is Protocol Buffers for C: libprotobuf-c, a small C runtime that encodes and decodes messages, and protoc-gen-c, a plugin for protobuf’s protoc that generates C code from a .proto file (protoc --c_out=). In this tree libomemo-c, the OMEMO encryption library of XMPP clients, builds its message code with it.
Sources
protobuf-c-1.5.2.tar.gz(520.0 KiB)
sha256e2c86271873a79c92b58fef7ebf8de1aa0df4738347a8bd5d4e65a80a16d0d24
upstream: https://github.com/protobuf-c/protobuf-c/releases/download/v1.5.2/protobuf-c-1.5.2.tar.gz
archive copy: sources-2/formats--protobuf-c-1.5.2.tar.gz
Dependencies
Depends on: protobuf, pkgconf.
Required by (1): libomemo-c.
Patches
build.sh applies these; kpkg applies nothing by itself.
protobuf-34-field-label.patch— Fix compilation against protobuf v34
Installation
From the repository root, inside the build container, this is the line kdosbuild runs for the port:
script/chroot/exec.sh bash -c 'source script/phases/41_system/phase.env && kpkg install protobuf-c'
What kpkg does
kpkg runs these steps, in this order, as root inside the chroot. The port directory is /ports/core/formats/protobuf-c.
1. Verify every declared source. Each file a sha256 = line names, found in the port directory or in /var/cache/kpkg/sources, must hash to its line; a mismatch stops the build before anything is unpacked.
cd /ports/core/formats/protobuf-c
echo 'e2c86271873a79c92b58fef7ebf8de1aa0df4738347a8bd5d4e65a80a16d0d24 protobuf-c-1.5.2.tar.gz' | sha256sum -c -
2. Unpack. The work directory is emptied and the first source is unpacked into $SRC with its top directory stripped; any later tarball lands unstripped beside it in $SRC_ROOT, and a file that is not a tarball is copied into $SRC.
SRC_ROOT=/var/cache/kpkg/work/protobuf-c
SRC=$SRC_ROOT/protobuf-c-1.5.2
PKG=$SRC_ROOT/pkg
rm -rf "$SRC_ROOT"
mkdir -p "$SRC" "$PKG"
tar --no-same-permissions --warning=no-unknown-keyword -xf protobuf-c-1.5.2.tar.gz -C "$SRC" --strip-components=1
Every config.guess and config.sub older than automake’s is then replaced with automake’s, so a configure script recognises the musl target.
3. Build. build.sh is sourced in a subshell under set -e, from $SRC, with name, version, release and the five paths PKGNAME, PORT_SRC, SRC_ROOT, SRC and PKG set as shell variables. Its body, verbatim:
patch -p1 -i "$PORT_SRC/protobuf-34-field-label.patch"
./configure --prefix=/usr --libdir=/usr/lib --disable-static --enable-protoc
make
make DESTDIR=$PKG install
The switches, and why each is set:
--enable-protoc— Buildprotoc-gen-c, the code generator. On is upstream’s default, and configure then stops unless protobuf’s compiler headers andprotocare installed. The generator is the only part of the package that links protobuf’s C++ libraries: the runtime is plain C with no dependencies.
The common switches of each build system are explained in the Flag glossary.
4. Package. kpkg removes libtool archives, the info directory index, mimeinfo.cache and every fonts.dir from $PKG, copies the source’s licence files into /usr/share/licenses/protobuf-c, prunes what the image does not ship, lints the tree and rolls it reproducibly:
tar --sort=name --format=gnu --numeric-owner --owner=0 --group=0 \
--mtime=@$SOURCE_DATE_EPOCH \
--use-compress-program='xz -9 -T0 --block-size=32MiB --no-adjust' \
-cf protobuf-c-1.5.2-1.tar.xz -C "$PKG" .
5. Adopt. kpkgadd installs the package’s files over the root, refusing a path another package owns, records the file list in /var/lib/kpkg/db/protobuf-c, and runs the triggers its paths call for.
Contents
Installed programs: protoc-c, protoc-gen-c.
Installed libraries: libprotobuf-c.so.
Installed directories: /usr/include/google/protobuf-c, /usr/include/protobuf-c, /usr/share/licenses/protobuf-c.
Short descriptions
libprotobuf-c.pc |
Protocol Buffers implementation in C |
Notes
protoc-gen-c is compiled against libprotoc’s C++ API, which changes from one protobuf release to the next. protobuf-34-field-label.patch replaces every call to FieldDescriptor::label(), which the protobuf this tree builds does not provide, with a helper built on is_repeated() and is_required(). Because the generator links protobuf’s versioned libraries, a protobuf bump means rebuilding this port.