109.3. restic-0.19.1
Deduplicating backup program, a single static binary
| Version | 0.19.1, release 1 |
| Shelf | transfer — File transfer, synchronisation, backup and BitTorrent |
| Phase | 41_system (System), 978 of 1047 in build order |
| Licence | BSD-2-Clause |
| Homepage | https://restic.net/ |
| Build time | 1.8 SBU |
| Installed size | 45.9 MiB in 41 files |
| Recipe | ports/core/transfer/restic/kpkgbuild |
About
restic makes deduplicated, encrypted backups into a repository, on a local disk or one of the remote backends it speaks, such as SFTP or its own REST server, and restores from it. restic mount shows the snapshots as a filesystem through FUSE, running fuse’s setuid fusermount to mount, which is why fuse is in depends.
Why it is in KDOS
The comment above restic and rclone in script/phases/41_system/packages.d/transfer.txt:
A backup tool is one static binary or it is not a backup tool: the repository has to restore from a machine that is NOT this one.
rclone checkis the only thing here that compares two trees by content and says what differs.
Sources
restic-0.19.1.tar.gz(23.0 MiB)
sha256bb9b1a19040744d26d8a79be029d4e6b189c45ccc9d8831d7fe367d3c33df725
upstream: https://github.com/restic/restic/archive/refs/tags/v0.19.1.tar.gz
archive copy: sources-4/transfer--restic-0.19.1.tar.gzrestic-vendor-0.19.1.tar.xz(4.5 MiB)
sha2569ee5edf4e17edea993c81cfe9de96e4bddb3d14709f19af7b49d486ec2c41a1c
a vendor bundle: the dependencies upstream’s own tool would download, packed once
archive copy: sources-4/transfer--restic-vendor-0.19.1.tar.xz
Dependencies
Required by (2): deja-dup, kup.
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 restic'
What kpkg does
kpkg runs these steps, in this order, as root inside the chroot. The port directory is /ports/core/transfer/restic.
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/transfer/restic
echo 'bb9b1a19040744d26d8a79be029d4e6b189c45ccc9d8831d7fe367d3c33df725 restic-0.19.1.tar.gz' | sha256sum -c -
echo '9ee5edf4e17edea993c81cfe9de96e4bddb3d14709f19af7b49d486ec2c41a1c restic-vendor-0.19.1.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/restic
SRC=$SRC_ROOT/restic-0.19.1
PKG=$SRC_ROOT/pkg
rm -rf "$SRC_ROOT"
mkdir -p "$SRC" "$PKG"
tar --no-same-permissions --warning=no-unknown-keyword -xf restic-0.19.1.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 CGO_ENABLED=0
go build -mod=vendor -ldflags "-s -w -X main.version=$version" -o restic ./cmd/restic
install -Dm755 restic $PKG/usr/bin/restic
install -dm755 $PKG/usr/share/man/man1
install -dm755 $PKG/usr/share/bash-completion/completions
install -dm755 $PKG/usr/share/zsh/site-functions
install -dm755 $PKG/usr/share/fish/vendor_completions.d
./restic generate --man $PKG/usr/share/man/man1
./restic generate --bash-completion $PKG/usr/share/bash-completion/completions/restic
./restic generate --zsh-completion $PKG/usr/share/zsh/site-functions/_restic
./restic generate --fish-completion $PKG/usr/share/fish/vendor_completions.d/restic.fish
The switches, and why each is set:
CGO_ENABLED=0— Build without cgo. The binary then links no C library and needs no shared library at run time. It is still a position-independent executable, from the-buildmode=piein the tree’sGOFLAGS, and asks for musl’s loader,/lib/ld-musl-x86_64.so.1, so it starts only where that file exists.-X main.version=$version— Upstream’sbuild.gosets the same variable. This release declares nomain.version:restic versionreports the constant ininternal/global, which is the source’s own version, and the Go linker ignores an-Xthat names no variable.
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/restic, 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 restic-0.19.1-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/restic, and runs the triggers its paths call for.
Contents
Installed programs: restic.
Installed directories: /usr/share/licenses/restic.
Short descriptions
restic |
Backup and restore files |
Notes
The modules come from the vendor bundle, restic-vendor-<version>.tar.xz, made by ports/fetch with go mod vendor and unpacked into the top of the source tree; go build -mod=vendor builds from it alone (see Vendoring).
The manual pages and the completions are written by the binary just built, restic generate, so they always describe the commands of the version installed. generate creates neither the directory --man writes into nor the one above a completion file, which is why build.sh makes all four directories first.