93.7. lf-42
Terminal file manager (Go, single binary)
| Version | 42, release 1 |
| Shelf | files — File managers, disk-usage analysers, duplicate finders and file locators |
| Phase | 41_system (System), 505 of 1047 in build order |
| Licence | MIT |
| Homepage | https://github.com/gokcehan/lf |
| Build time | 0.1 SBU |
| Installed size | 6.7 MiB in 8 files |
| Recipe | ports/core/files/lf/kpkgbuild |
About
lf is a terminal file manager in the style of ranger, written in Go as a single binary: columns of parent, current and preview directories, vi-style keys, and commands that are shell snippets. KDOS seeds a configuration for it in /etc/skel/.config/lf/ (lfrc, and a preview script that shows text through bat); see configuration.
Sources
lf-42.tar.gz(201.0 KiB)
sha2567a8f7c2c86419270b713b6235dced7b9d0e68732e74a1e0f375f774fff4023ca
upstream: https://github.com/gokcehan/lf/archive/r42.tar.gz
archive copy: sources-2/files--lf-42.tar.gzlf-vendor-42.tar.xz(1.1 MiB)
sha256989ed818f8483cd19125c2239aede77b88b0a701ccfc7c5e037be90800ab3c4c
a vendor bundle: the dependencies upstream’s own tool would download, packed once
archive copy: sources-2/files--lf-vendor-42.tar.xz
Dependencies
Depends on: go.
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 lf'
What kpkg does
kpkg runs these steps, in this order, as root inside the chroot. The port directory is /ports/core/files/lf.
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/files/lf
echo '7a8f7c2c86419270b713b6235dced7b9d0e68732e74a1e0f375f774fff4023ca lf-42.tar.gz' | sha256sum -c -
echo '989ed818f8483cd19125c2239aede77b88b0a701ccfc7c5e037be90800ab3c4c lf-vendor-42.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/lf
SRC=$SRC_ROOT/lf-42
PKG=$SRC_ROOT/pkg
rm -rf "$SRC_ROOT"
mkdir -p "$SRC" "$PKG"
tar --no-same-permissions --warning=no-unknown-keyword -xf lf-42.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 -ldflags "-s -w -X main.gVersion=r$version" -o lf
install -Dm755 lf $PKG/usr/bin/lf
install -Dm644 lf.1 $PKG/usr/share/man/man1/lf.1
install -Dm644 etc/lfcd.sh $PKG/usr/share/lf/lfcd.sh
install -Dm644 etc/lf.bash $PKG/usr/share/bash-completion/completions/lf
install -Dm644 etc/lf.zsh $PKG/usr/share/zsh/site-functions/_lf
install -Dm644 etc/lf.fish $PKG/usr/share/fish/vendor_completions.d/lf.fish
install -d "$PKG/usr/share/applications"
cat > "$PKG/usr/share/applications/lf.desktop" <<'EOF'
[Desktop Entry]
Type=Application
Name=Files (lf)
GenericName=File Manager
Comment=Browse files with lf
Exec=lf %f
Icon=folder
Terminal=true
Categories=System;FileTools;FileManager;
Keywords=file;manager;browser;lf;
EOF
chmod 644 "$PKG/usr/share/applications/lf.desktop"
The switches, and why each is set:
-X main.gVersion=r$version— Stamps the release into thegVersionvariable thatlf -versionprints. Upstream names its releasesrand a number, so the stamp carries therthe recipe’sversionleaves out.
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/lf, 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 lf-42-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/lf, and runs the triggers its paths call for.
Contents
Installed programs: lf.
Installed directories: /usr/share/lf, /usr/share/licenses/lf.
Short descriptions
lf |
terminal file manager |
Notes
etc/lfcd.sh is installed to /usr/share/lf/lfcd.sh, and /etc/bash.bashrc sources it when lf is on the path. It defines lfcd, which runs lf -print-last-dir and leaves the shell in the directory lf quit in. The bashrc line sources the file only when it is readable, so with the file moved the shell has no lfcd and says nothing.
The Go modules come from the vendor bundle, lf-vendor-<version>.tar.xz, made by go mod vendor and pinned by its own sha256 = line; go build uses the vendor/ directory by default (see Vendoring).