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

68.2. gh-2.101.0

Official GitHub command-line client

Version 2.101.0, release 1
Shelf vcs — Version control and diff/merge tools
Phase 40_lang (Languages), 183 of 186 in build order
Licence MIT
Homepage https://cli.github.com/
Build time 1.1 SBU
Installed size 44.1 MiB in 234 files
Recipe ports/core/vcs/gh/kpkgbuild

About

gh is GitHub’s command-line client: pull requests, issues, releases, Actions runs and repositories from a terminal, and gh auth, which signs in to GitHub and can act as git’s credential helper for it. 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).

Upstream builds it through make, whose targets run script/build.go; bin/gh builds the program and manpages writes the manual pages under share/man/man1, which the port installs.

Sources

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

What kpkg does

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

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/gh
echo 'a266fe8575c0e061b987920c1831a15f71bf0036a8729a5ebb93c2fb0164899c  gh-2.101.0.tar.gz' | sha256sum -c -
echo 'f18d15be16175727302b7df3939029d31e44935ab633cc9a007c110a21ed6230  gh-vendor-2.101.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/gh
SRC=$SRC_ROOT/gh-2.101.0
PKG=$SRC_ROOT/pkg
rm -rf "$SRC_ROOT"
mkdir -p "$SRC" "$PKG"
tar --no-same-permissions --warning=no-unknown-keyword -xf gh-2.101.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
make GO_LDFLAGS="-s -w" GH_VERSION=$version bin/gh manpages
install -Dm755 bin/gh $PKG/usr/bin/gh
install -Dm644 share/man/man1/*.1 -t $PKG/usr/share/man/man1

for sh in bash zsh fish; do
	HOME="$PWD/.home" GH_CONFIG_DIR="$PWD/.home" bin/gh completion -s $sh > gh.$sh
done
install -Dm644 gh.bash $PKG/usr/share/bash-completion/completions/gh
install -Dm644 gh.zsh  $PKG/usr/share/zsh/site-functions/_gh
install -Dm644 gh.fish $PKG/usr/share/fish/vendor_completions.d/gh.fish

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/gh, 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 gh-2.101.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/gh, and runs the triggers its paths call for.

Contents

Installed programs: gh.

Installed directories: /usr/share/licenses/gh.

Short descriptions

gh GitHub CLI

Notes

The date gh --version prints is not the day of the build: script/build.go takes it from SOURCE_DATE_EPOCH, which the tree pins (see Reproducible packages).