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

294.1. testdisk-7.3pre20260819

Recover lost partitions and, as photorec and the QPhotoRec window, deleted files

Version 7.3pre20260819, release 1
Shelf disk — Block devices: partitioning, RAID, LVM, block encryption, SMART, NVMe, recovery, image writing and async I/O
Phase 44_apps (Applications), 56 of 422 in build order
Licence GPL-2.0-or-later
Homepage https://www.cgsecurity.org/wiki/TestDisk
Build time 1.3 SBU
Installed size 2.5 MiB in 17 files
Recipe ports/core/disk/testdisk/kpkgbuild

About

TestDisk recovers lost partitions and repairs partition tables and boot sectors; PhotoRec, built from the same source, recovers deleted files by carving them out of a disk, a memory card or a disk image by their content, whatever the filesystem. Both are terminal programs on ncurses; qphotorec is PhotoRec’s Qt 6 window. The port builds a pinned commit of upstream’s development line (_commit in the recipe).

Why it is in KDOS

The comment above it in script/phases/44_apps/packages.d/disk.txt:

testdisk/photorec is what runs when the partition table is the thing that is gone.

Sources

Dependencies

Depends on: autoconf, automake, pkgconf, ncurses, e2fsprogs, libjpeg-turbo, util-linux, zlib, ntfs-3g, libewf, qt6-qtbase, qt6-qtwayland, qt6-qttools.

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/44_apps/phase.env && kpkg install testdisk'

What kpkg does

kpkg runs these steps, in this order, as root inside the chroot. The port directory is /ports/core/disk/testdisk.

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/disk/testdisk
echo 'cf9f0ace44849b544dff1ff78a9eb89870b80a9655e5eefb3ddcc0ef078d7400  testdisk-7.3pre20260819.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/testdisk
SRC=$SRC_ROOT/testdisk-7.3pre20260819
PKG=$SRC_ROOT/pkg
rm -rf "$SRC_ROOT"
mkdir -p "$SRC" "$PKG"
tar --no-same-permissions --warning=no-unknown-keyword -xf testdisk-7.3pre20260819.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 recipe’s helpers _commit and the five paths PKGNAME, PORT_SRC, SRC_ROOT, SRC and PKG set as shell variables. Its body, verbatim:

autoreconf -f -i
./configure \
	--prefix=/usr \
	--enable-qt \
	--enable-sudo=no \
	--with-ncurses \
	--with-ext2fs \
	--with-jpeg \
	--with-ntfs3g \
	--without-ntfs \
	--without-reiserfs \
	--with-ewf \
	--with-iconv \
	--with-zlib \
	--with-uuid
for have in HAVE_LIBNTFS3G HAVE_LIBEWF_HANDLE_READ_BUFFER_AT_OFFSET \
	HAVE_LIBEWF_HANDLE_WRITE_BUFFER_AT_OFFSET; do
	grep -q "^#define $have 1" config.h || {
		echo "testdisk: $have not configured" >&2
		exit 1
	}
done
grep -q '^qphotorec_LDADD = .*-lQt6Widgets' src/Makefile || {
	echo "testdisk: QPhotoRec is not configured against Qt 6" >&2
	exit 1
}
make
make DESTDIR=$PKG install

install -d "$PKG/usr/share/applications"
cat > "$PKG/usr/share/applications/qphotorec.desktop" <<'DESKTOP'
[Desktop Entry]
Type=Application
Name=QPhotoRec
GenericName=Data Recovery
Comment=Recover deleted files from a disk, a memory card or a disk image
Exec=qphotorec
Icon=qphotorec
Terminal=false
StartupWMClass=qphotorec
Categories=Qt;System;Filesystem;
Keywords=recover;undelete;photorec;testdisk;carve;
DESKTOP
chmod 644 "$PKG/usr/share/applications/qphotorec.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/testdisk, 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 testdisk-7.3pre20260819-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/testdisk, and runs the triggers its paths call for.

Contents

Installed programs: fidentify, photorec, qphotorec, testdisk.

Installed directories: /usr/share/doc/testdisk, /usr/share/licenses/testdisk.

Short descriptions

fidentify Determine file type using PhotoRec database
photorec Recover lost files from harddisk, digital camera and cdrom
qphotorec Recover lost files from harddisk, digital camera and cdrom
testdisk Scan and repair disk partitions

Notes

The source is the archive of one commit, which carries configure.ac but no generated configure, so build.sh first runs autoreconf -f -i; autoconf and automake are in depends for it.

The configure only warns when ntfs-3g or libewf is missing, and drops Qt 6 without a word, so build.sh checks the result before it compiles: config.h must define HAVE_LIBNTFS3G and the two libewf functions HAVE_LIBEWF_HANDLE_READ_BUFFER_AT_OFFSET and HAVE_LIBEWF_HANDLE_WRITE_BUFFER_AT_OFFSET, the current libewf calls src/ewf.c reads and writes images with (without them it falls back to the older libewf_handle_read_random family), and qphotorec_LDADD in src/Makefile must link Qt6Widgets. A build that would lack any of them stops with a message naming it.

Upstream installs linux/qphotorec.desktop; build.sh writes its own over it. The replacement adds a Comment, search keywords and StartupWMClass=qphotorec, drops TryExec and Version, and runs plain qphotorec where upstream runs /usr/bin/qphotorec %F.