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
zbar-0.23.93.tar.gz(985.7 KiB)
sha256212dfab527894b8bcbcc7cd1d43d63f5604a07473d31a5f02889e372614ebe28
upstream: https://github.com/mchehab/zbar/archive/refs/tags/0.23.93.tar.gz
archive copy: sources-3/image-libs--zbar-0.23.93.tar.gz
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.
--without-gtk, line 20: gtk3 (explained with the switches below)--without-python, line 23: python3--without-xv, line 26: libXv (explained with the switches below)--without-graphicsmagick, line 29: graphicsmagick
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:
autoreconf -f -i— The source is GitHub’s archive of the release tag, which carriesconfigure.acand no generatedconfigure.XML_CATALOG_FILES=/etc/xml/catalog— Names the XML catalogue libxml2 reads, the same file libxml2 reads when the variable is unset, so the export names the default. The manual pages are DocBook rendered byxmlto, which names the DocBook stylesheet by its sourceforge URL; only docbook-xsl’s catalogue entry maps that to the installed copy, and without a cataloguexsltproctries to fetch it and the build stops insidexmlto.--without-gtk,--without-qt— Build no GTK or Qt widgets. They draw zbar’s X overlay into an X window id, which a Wayland-native GTK or Qt window does not have, and upstream marks its Qt 6 widget broken.--without-java,--without-python— No Java or Python bindings.--without-gir— No introspection data; it describes the GTK widget, which is off.--with-x— Build the X11 viewfinder ofzbarcam, the one front end built. Without itzbarcamruns only with--nodisplayand the camera is aimed blind; with it the picture is an X window under Xwayland.--with-xshm— Use the MIT shared-memory extension of libXext, so the picture is not copied through the X socket. Upstream’s default,check, uses it only if found; named, a missing extension stops the configure.--without-xv— No XVideo; the XImage path draws the picture, and XVideo under Xwayland depends on the GPU driver.--enable-video— Camera support through Video4Linux 2; upstream’s default, named.--with-imagemagick,--without-graphicsmagick— Read image files through imagemagick’s MagickWand. With the GraphicsMagick fallback left at its default,check, a MagickWand that pkg-config does not find turns image scanning off with only a notice andzbarimgis not built; ruled out, a missing ImageMagick stops the configure.--with-jpeg— JPEG image conversions in libzbar, through libjpeg-turbo; upstream’s default,check, uses it only if found.--with-dbus— Letzbarcamandzbarimgpublish each decoded code on D-Bus, asorg.linuxtv.Zbar, with the bus policy file installed for it. Upstream’s default,check, uses libdbus only if found; named, a missing one stops the configure.--enable-doc— Build the manual pages; upstream’s default, named.XMLTO=xmlto— Namexmltoinstead of searching for it.--enable-doconly asks, and a missingxmltoturns the manual pages off with no message; named, the program is run at build time and its absence stops the build.ac_cv_header_libv4l2_h=yes— Takelibv4l2.has present.zbarcamreads a camera through libv4l2 when configure finds that header, which converts the pixel formats many webcams deliver and zbar cannot read raw; there is no switch for it. Preset, configure goes on toPKG_CHECK_MODULES([V4L2], [libv4l2]), which fails when v4l-utils is missing, instead of building azbarcamthat cannot see those cameras.
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.