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

68.4. git-lfs-3.8.0

Git extension that stores large files out of band

Version 3.8.0, release 1
Shelf vcs — Version control and diff/merge tools
Phase 40_lang (Languages), 185 of 186 in build order
Licence MIT
Homepage https://git-lfs.com/
Build time 0.8 SBU
Installed size 14.8 MiB in 42 files
Recipe ports/core/vcs/git-lfs/kpkgbuild

About

Git LFS stores large files outside a git repository: the repository holds small pointer files, and the lfs filter swaps them for the real content on checkout and back on commit. Without it a clone of such a repository still succeeds, and checks out the pointer files in place of the files. It is a Go program built with cgo off from its vendor bundle, the second sha256 = line, which ports/fetch generates with go mod vendor (see Vendoring).

Why it is in KDOS

The comment above it in script/phases/40_lang/packages.d/vcs.txt:

Repositories that store large files through Git LFS. Without it a clone of one SUCCEEDS and checks out pointer files in place of the files.

Sources

Dependencies

Depends on: go, git, asciidoctor.

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/40_lang/phase.env && kpkg install git-lfs'

What kpkg does

kpkg runs these steps, in this order, as root inside the chroot. The port directory is /ports/core/vcs/git-lfs.

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/vcs/git-lfs
echo 'a12ecfc17ebee002d1f6acca79442029d41cbf5e5b4ba9e02249ed96de20300f  git-lfs-3.8.0.tar.gz' | sha256sum -c -
echo '9a26f096c43266cccec19774c45cfa8fb9ff42c2303c1d8feb709619fc893259  git-lfs-vendor-3.8.0.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/git-lfs
SRC=$SRC_ROOT/git-lfs-3.8.0
PKG=$SRC_ROOT/pkg
rm -rf "$SRC_ROOT"
mkdir -p "$SRC" "$PKG"
tar --no-same-permissions --warning=no-unknown-keyword -xf git-lfs-3.8.0.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 generate ./commands
go build -mod=vendor \
	-ldflags "-s -w -X github.com/git-lfs/git-lfs/v3/config.Vendor=KDOS -X github.com/git-lfs/git-lfs/v3/config.GitCommit=v$version" \
	-o git-lfs
install -Dm755 git-lfs $PKG/usr/bin/git-lfs
for sh in bash zsh fish; do
	HOME="$PWD/.home" ./git-lfs completion $sh > git-lfs.$sh
done
install -Dm644 git-lfs.bash $PKG/usr/share/bash-completion/completions/git-lfs
install -Dm644 git-lfs.zsh  $PKG/usr/share/zsh/site-functions/_git-lfs
install -Dm644 git-lfs.fish $PKG/usr/share/fish/vendor_completions.d/git-lfs.fish

_mk="VERSION=v$version GIT_LFS_SHA=v$version"
make $_mk $(make -s $_mk --eval='kdos-man-list: ; @echo $(MAN_ROFF_TARGETS)' kdos-man-list)
for page in man/man*/*.[1-8]; do
	install -Dm644 "$page" -t "$PKG/usr/share/man/man${page##*.}"
done

install -Dm644 /dev/stdin "$PKG/etc/gitconfig" <<'GITCONFIG'
[filter "lfs"]
	clean = git-lfs clean -- %f
	smudge = git-lfs smudge -- %f
	process = git-lfs filter-process
	required = true
GITCONFIG

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/git-lfs, 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 git-lfs-3.8.0-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/git-lfs, and runs the triggers its paths call for.

Contents

Installed programs: git-lfs.

Installed directories: /usr/share/licenses/git-lfs.

Short descriptions

git-lfs Work with large files in Git repositories

Notes

go generate ./commands must come before go build. It runs docs/man/mangen.go, which writes commands/mancontent_gen.go, the text of git lfs help <command>, from the pages under docs/man; the release archive does not carry that file.

The manual pages are built with asciidoctor from upstream’s own list, MAN_ROFF_TARGETS, which names each page under its section’s directory, man/man1, man/man5 or man/man7. make man would also write an HTML copy of every page, so build.sh asks the Makefile for the list and builds only those targets. The list is printed by the recipe of a rule given with --eval: a recipe is expanded when it runs, after the Makefile has been read, while an --eval string is read before any makefile, so a prerequisite list written there would expand to nothing.

The package owns /etc/gitconfig, which registers the lfs filter for every user, the block git lfs install --system would write. Git hands file content to git-lfs only through that filter, so the program alone changes no checkout. Owned by the package, the filter is removed with it; left behind, a filter marked required would fail every checkout of an LFS repository on a missing program. Another port that installs /etc/gitconfig stops at the conflict scan unless its recipe names git-lfs in replaces.