Skip to the text
KDOS
Menu
kdos.dev KDOS from Scratch KDOS 0.2 · 4dd4a10 · 2026-11-30 Contents Index

245.2. zbar-0.23.93

Read a QR or barcode from an image or a camera

Version 0.23.93, release 1
Shelf image-libs — Raster image formats, codecs, metadata, processing, barcodes, and terminal image output
Phase 43_toolkits (Toolkits), 88 of 344 in build order
Licence LGPL-2.1-or-later
Homepage https://github.com/mchehab/zbar
Build time 0.8 SBU
Installed size 559.3 KiB in 30 files
Recipe ports/core/image-libs/zbar/kpkgbuild

About

ZBar reads barcodes and QR codes: zbarimg from an image file and zbarcam from a camera, each printing the decoded text, with the libzbar library under both. It is the other direction from qrencode: zbarimg reads a QR code out of a screenshot, so a code on the screen becomes text without a phone, and zbarcam reads one held up to the camera.

Why it is in KDOS

The comment above it in script/phases/43_toolkits/packages.d/image-libs.txt:

The other direction from qrencode: zbarimg reads a QR out of a screenshot, so a code on the screen becomes text on the clipboard without a phone, and zbarcam reads one held up to the camera.

Sources

Dependencies

Depends on: autoconf, automake, libtool, pkgconf, gettext, libjpeg-turbo, imagemagick, dbus, xmlto, docbook-xsl, libxslt, v4l-utils, libX11, libXext, libSM, libICE.

Required by (1): gst-plugins-bad.

Optional, off in KDOS

These switches in build.sh turn off a feature whose library is a port here. The recipe may turn each off on purpose, or because the library was not yet a port when the recipe was written; this list cannot tell which.

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/43_toolkits/phase.env && kpkg install zbar'

What kpkg does

kpkg runs these steps, in this order, as root inside the chroot. The port directory is /ports/core/image-libs/zbar.

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/image-libs/zbar
echo '212dfab527894b8bcbcc7cd1d43d63f5604a07473d31a5f02889e372614ebe28  zbar-0.23.93.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/zbar
SRC=$SRC_ROOT/zbar-0.23.93
PKG=$SRC_ROOT/pkg
rm -rf "$SRC_ROOT"
mkdir -p "$SRC" "$PKG"
tar --no-same-permissions --warning=no-unknown-keyword -xf zbar-0.23.93.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:

autoreconf -f -i

export XML_CATALOG_FILES=/etc/xml/catalog

./configure \
	--prefix=/usr \
	--libdir=/usr/lib \
	--disable-static \
	--without-gtk \
	--without-qt \
	--without-java \
	--without-python \
	--with-x \
	--with-xshm \
	--without-xv \
	--enable-video \
	--with-imagemagick \
	--without-graphicsmagick \
	--without-gir \
	--with-jpeg \
	--with-dbus \
	--enable-doc \
	--enable-nls \
	XMLTO=xmlto \
	ac_cv_header_libv4l2_h=yes
if grep -q '^#define X_DISPLAY_MISSING' include/config.h; then
	echo "zbar: libX11 not found, zbarcam would have no window" >&2
	exit 1
fi
make
make DESTDIR=$PKG install

install -d "$PKG/usr/share/applications"
cat > "$PKG/usr/share/applications/zbarcam.desktop" <<'DESKTOP'
[Desktop Entry]
Type=Application
Name=Barcode Scanner
GenericName=QR and Barcode Reader
Comment=Read QR codes and barcodes held up to the camera
Exec=zbarcam
Icon=camera-web
Terminal=true
NoDisplay=true
Categories=AudioVideo;Video;
Keywords=qr;barcode;scan;camera;zbar;
DESKTOP
chmod 644 "$PKG/usr/share/applications/zbarcam.desktop"

The switches, and why each is set:

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/zbar, 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 zbar-0.23.93-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/zbar, and runs the triggers its paths call for.

Contents

Installed programs: zbarcam, zbarimg.

Installed libraries: libzbar.so.

Installed directories: /usr/include/zbar, /usr/share/doc/zbar, /usr/share/licenses/zbar.

Short descriptions

zbarcam scan and decode bar codes from a video device
zbarimg scan and decode bar codes from image file(s)
zbar.pc bar code scanning and decoding

Notes

configure detects X rather than requiring it, so build.sh fails the build when the generated include/config.h defines X_DISPLAY_MISSING: without libX11 zbarcam would have no window.

The desktop entry that build.sh writes runs zbarcam in a terminal (Terminal=true): the camera picture is its own window, and each code it reads is printed where it can be copied. The entry is NoDisplay=true: on a machine with no /dev/video0 zbarcam exits at once, so it is started from a prompt.