85.4. micro-2.0.15
Terminal text editor with familiar keybindings and mouse support (Go)
| Version | 2.0.15, release 1 |
| Shelf | editors — Text editors, IDEs, notebooks and REPLs |
| Phase | 41_system (System), 451 of 1047 in build order |
| Licence | MIT |
| Homepage | https://micro-editor.github.io/ |
| Build time | 0.4 SBU |
| Installed size | 14.7 MiB in 5 files |
| Recipe | ports/core/editors/micro/kpkgbuild |
About
micro is a terminal text editor with the keys of a desktop editor: Ctrl-S saves, Ctrl-Q quits, Ctrl-C and Ctrl-V copy and paste, and the mouse selects, alongside syntax highlighting, multiple cursors, split panes and Lua plugins. It is a single statically linked Go program, built here with upstream’s make build from a vendored module bundle. The port installs it with its manual page and a desktop entry, Editor (micro), which opens it in a terminal and claims plain text and common source-file types.
Sources
micro-2.0.15.tar.gz(576.4 KiB)
sha256612c775321c268c8f9e1767505ff378bca9b9ab66f5c41b69ecb2464ecf15084
upstream: https://github.com/zyedidia/micro/archive/v2.0.15.tar.gz
archive copy: sources-2/editors--micro-2.0.15.tar.gzmicro-vendor-2.0.15.tar.xz(1.2 MiB)
sha256b215e155ea3784a36ac661c3e18fe3f8fec22863d6c7e2f0793169f024cb1066
a vendor bundle: the dependencies upstream’s own tool would download, packed once
archive copy: sources-2/editors--micro-vendor-2.0.15.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 micro'
What kpkg does
kpkg runs these steps, in this order, as root inside the chroot. The port directory is /ports/core/editors/micro.
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/editors/micro
echo '612c775321c268c8f9e1767505ff378bca9b9ab66f5c41b69ecb2464ecf15084 micro-2.0.15.tar.gz' | sha256sum -c -
echo 'b215e155ea3784a36ac661c3e18fe3f8fec22863d6c7e2f0793169f024cb1066 micro-vendor-2.0.15.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/micro
SRC=$SRC_ROOT/micro-2.0.15
PKG=$SRC_ROOT/pkg
rm -rf "$SRC_ROOT"
mkdir -p "$SRC" "$PKG"
tar --no-same-permissions --warning=no-unknown-keyword -xf micro-2.0.15.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 build VERSION=$version HASH=
install -Dm755 micro $PKG/usr/bin/micro
install -Dm644 assets/packaging/micro.1 $PKG/usr/share/man/man1/micro.1
install -d "$PKG/usr/share/applications"
cat > "$PKG/usr/share/applications/micro.desktop" <<'EOF'
[Desktop Entry]
Type=Application
Name=Editor (micro)
GenericName=Text Editor
Comment=Edit text with micro
Exec=micro %F
Icon=text-x-generic
Terminal=true
Categories=Utility;TextEditor;
Keywords=editor;text;micro;
MimeType=text/plain;text/markdown;text/x-csrc;text/x-chdr;text/x-c++src;text/x-python;text/x-shellscript;application/json;application/xml;application/x-yaml;text/x-makefile;
EOF
chmod 644 "$PKG/usr/share/applications/micro.desktop"
The switches, and why each is set:
VERSION=$version— The version compiled into the program, whichmicro --versionprints. Upstream’s makefile computes it withtools/build-version.go, which asksgit describeand answers0.0.0-unknownwhen the source is not a git checkout.HASH=— The commit hash compiled in beside it, which the makefile takes fromgit rev-parse; there is no repository, so it is set empty.
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/micro, 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 micro-2.0.15-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/micro, and runs the triggers its paths call for.
Contents
Installed programs: micro.
Installed directories: /usr/share/licenses/micro.
Short descriptions
micro |
A modern and intuitive terminal-based text editor |
Notes
make buildis two steps. It runsgo generate ./runtime, which writes the header files of the syntax definitions underruntime/syntax(the program embeds that directory, the colour schemes, the help pages and the plugins withgo:embed), thenbuild-quick, which isgo build -trimpath -ldflags "-s -w …" ./cmd/micro. The makefile passes-s -witself, which the tree requires of every Go build (see go). It names no-mod=vendor: Go uses thevendor/directory the bundle unpacks on its own, becausego.moddeclares a Go version from 1.14 on.- The build date is the source date. The makefile’s
DATEcomes fromtools/build-date.go, which usesSOURCE_DATE_EPOCHwhen it is set, as it is for every build here, and the current time otherwise. - The desktop entry is the recipe’s own.
build.shwritesmicro.desktop; upstream’sassets/packaging/micro.desktopis not installed.