68.1. lazygit-0.65.1
Terminal UI for git commands
| Version | 0.65.1, release 1 |
| Shelf | vcs — Version control and diff/merge tools |
| Phase | 40_lang (Languages), 182 of 186 in build order |
| Licence | MIT |
| Homepage | https://github.com/jesseduffield/lazygit |
| Build time | 0.4 SBU |
| Installed size | 21.3 MiB in 4 files |
| Recipe | ports/core/vcs/lazygit/kpkgbuild |
About
lazygit is a terminal interface to git: it stages files and single lines, commits, branches, rebases interactively and resolves conflicts from panels driven by the keyboard, running the git command underneath, which is why git is in depends. Where tig reads a repository, lazygit acts on one.
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).
Sources
lazygit-0.65.1.tar.gz(4.7 MiB)
sha256df30ec1a5032b3c5672a30090fe787fb32d4122fd996d6d85e1d10135acfbc89
upstream: https://github.com/jesseduffield/lazygit/archive/v0.65.1.tar.gz
archive copy: sources-4/vcs--lazygit-0.65.1.tar.gzlazygit-vendor-0.65.1.tar.xz(1.9 MiB)
sha2567be5963b66d40203a64d1c4b78c294ad72a92ac91f4933f686edf6b7321c1d68
a vendor bundle: the dependencies upstream’s own tool would download, packed once
archive copy: sources-4/vcs--lazygit-vendor-0.65.1.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/40_lang/phase.env && kpkg install lazygit'
What kpkg does
kpkg runs these steps, in this order, as root inside the chroot. The port directory is /ports/core/vcs/lazygit.
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/lazygit
echo 'df30ec1a5032b3c5672a30090fe787fb32d4122fd996d6d85e1d10135acfbc89 lazygit-0.65.1.tar.gz' | sha256sum -c -
echo '7be5963b66d40203a64d1c4b78c294ad72a92ac91f4933f686edf6b7321c1d68 lazygit-vendor-0.65.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/lazygit
SRC=$SRC_ROOT/lazygit-0.65.1
PKG=$SRC_ROOT/pkg
rm -rf "$SRC_ROOT"
mkdir -p "$SRC" "$PKG"
tar --no-same-permissions --warning=no-unknown-keyword -xf lazygit-0.65.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 -ldflags "-s -w -X main.version=$version" -o lazygit
install -Dm755 lazygit $PKG/usr/bin/lazygit
install -d "$PKG/usr/share/applications"
cat > "$PKG/usr/share/applications/lazygit.desktop" <<'EOF'
[Desktop Entry]
Type=Application
Name=Git
GenericName=Version Control
Comment=Stage, commit, branch and merge
Exec=lazygit
Icon=vcs-normal
Terminal=true
Categories=Development;RevisionControl;
Keywords=git;commit;branch;merge;diff;lazygit;
EOF
chmod 644 "$PKG/usr/share/applications/lazygit.desktop"
install -d "$PKG/usr/share/kio/servicemenus"
cat > "$PKG/usr/share/kio/servicemenus/lazygit.desktop" <<'EOF'
[Desktop Entry]
Type=Service
MimeType=inode/directory;
Actions=gitstatus;
X-KDE-Priority=TopLevel
[Desktop Action gitstatus]
Name=Git Status Here
Icon=vcs-normal
Exec=konsole --workdir %f -e lazygit
EOF
chmod 644 "$PKG/usr/share/kio/servicemenus/lazygit.desktop"
The switches, and why each is set:
-X main.version=$version— set theversionvariable of lazygit’smainpackage at link time, whichlazygit --versionprints. Without it lazygit falls back to the commit Go records from version control, and-buildvcs=falsein the exportedGOFLAGSrecords none, so it would reportunversioned. It shares one-ldflagsstring with-s -w, because a second-ldflagswould replace the first (see go).
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/lazygit, 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 lazygit-0.65.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/lazygit, and runs the triggers its paths call for.
Contents
Installed programs: lazygit.
Installed directories: /usr/share/licenses/lazygit.
Notes
The release archive already carries a vendor/ tree, and the bundle is unpacked over it. go build is given no -mod=vendor: when a vendor/modules.txt is present and go.mod declares a Go version of 1.14 or later, as lazygit’s does, the go command builds from vendor/ by default.
build.sh writes the package’s own desktop entry, lazygit.desktop, named Git in the menu, with Terminal=true, so the launcher opens lazygit in the session’s terminal (see Desktop entries belong to the port). It also writes a Dolphin service menu, /usr/share/kio/servicemenus/lazygit.desktop, which adds Git Status Here to a folder’s right-click menu and opens lazygit in Konsole in that folder. KIO does not check a service menu’s TryExec, so the menu ships with the program it runs rather than with the desktop.