152.4. doxx-0.1.4
A .docx reader in the terminal
| Version | 0.1.4, release 1 |
| Shelf | documents — PDF, PostScript, DjVu, EPUB, CHM and DOCX viewers, libraries and tools, and ebook managers |
| Phase | 41_system (System), 415 of 1047 in build order |
| Licence | MIT |
| Homepage | https://github.com/bgreenwell/doxx |
| Build time | 7.8 SBU |
| Installed size | 8.0 MiB in 3 files |
| Recipe | ports/core/documents/doxx/kpkgbuild |
About
doxx opens a Word .docx file in the terminal: it renders the headings, paragraphs, lists and tables, lets the reader search and jump through an outline, and can export the document as Markdown, plain text, ANSI-coloured text or JSON, or its tables alone as CSV. It is a Rust program built from a vendored crate bundle. The port also writes a desktop entry for it, so a .docx file opened from the desktop can open in doxx in a terminal.
Sources
doxx-0.1.4.tar.gz(4.3 MiB)
sha25672af676ca30b27adc7a13b17a48aac88589c940accba28453f3d94a861bed961
upstream: https://github.com/bgreenwell/doxx/archive/refs/tags/v0.1.4.tar.gz
archive copy: sources-1/documents--doxx-0.1.4.tar.gzdoxx-vendor-0.1.4.tar.xz(47.0 MiB)
sha256bea81f0c6705e49e7dade437514dceb234e45cdd3eff01b2cad17cb621f67978
a vendor bundle: the dependencies upstream’s own tool would download, packed once
archive copy: sources-1/documents--doxx-vendor-0.1.4.tar.xz
Dependencies
Required by: no port names it.
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 doxx'
What kpkg does
kpkg runs these steps, in this order, as root inside the chroot. The port directory is /ports/core/documents/doxx.
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/documents/doxx
echo '72af676ca30b27adc7a13b17a48aac88589c940accba28453f3d94a861bed961 doxx-0.1.4.tar.gz' | sha256sum -c -
echo 'bea81f0c6705e49e7dade437514dceb234e45cdd3eff01b2cad17cb621f67978 doxx-vendor-0.1.4.tar.xz' | 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/doxx
SRC=$SRC_ROOT/doxx-0.1.4
PKG=$SRC_ROOT/pkg
rm -rf "$SRC_ROOT"
mkdir -p "$SRC" "$PKG"
tar --no-same-permissions --warning=no-unknown-keyword -xf doxx-0.1.4.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:
tar xf $PORT_SRC/${name}-vendor-${version}.tar.xz
export RUSTFLAGS="-C target-feature=-crt-static"
cargo build --release --frozen --offline
readelf -d target/release/doxx | grep -q 'NEEDED.*\[libzstd\.so\.1\]'
install -Dm755 target/release/doxx "$PKG/usr/bin/doxx"
install -d "$PKG/usr/share/applications"
cat > "$PKG/usr/share/applications/doxx.desktop" <<'DESKTOP'
[Desktop Entry]
Type=Application
Name=Word Document
GenericName=Document Viewer
Comment=Read a .docx in the terminal
Exec=doxx %f
Icon=x-office-document
Terminal=true
NoDisplay=true
MimeType=application/vnd.openxmlformats-officedocument.wordprocessingml.document;
Categories=Office;Viewer;
DESKTOP
chmod 644 "$PKG/usr/share/applications/doxx.desktop"
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/doxx, 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 doxx-0.1.4-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/doxx, and runs the triggers its paths call for.
Contents
Installed programs: doxx.
Installed directories: /usr/share/licenses/doxx.
Notes
- Zstandard is the system’s. The
zipcrate reads Zstandard-compressed archive members throughzstd-sys, and the tree’s environment setsZSTD_SYS_USE_PKG_CONFIG=1for every Rust build from40_langon, so it links zstd instead of compiling its own copy (see rust).RUSTFLAGScarries-C target-feature=-crt-staticbecause the musl target links statically otherwise, and a static binary cannot take the system’s sharedlibzstd. Thereadelf -dline aftercargo buildstops the build unless the binary nameslibzstd.so.1among the shared libraries it needs. - The desktop entry is a handler, not a launcher.
build.shwritesdoxx.desktopwithMimeType=set to the.docxtype,Terminal=trueandNoDisplay=true. ItsMimeType=line is how a document opened from the file manager reaches doxx;NoDisplay=truekeeps it out of the Start menu and the launcher. The rules for such entries are in Desktop entries belong to the port.