331.2. sc-im-0.8.5
Terminal spreadsheet with vi keys
| Version | 0.8.5, release 2 |
| Shelf | office — Office suites, word processors, spreadsheets, presentations, accounting and finance, and office-format import libraries |
| Phase | 44_apps (Applications), 311 of 422 in build order |
| Licence | BSD-4-Clause |
| Homepage | https://github.com/andmarti1424/sc-im |
| Build time | 0.5 SBU |
| Installed size | 575.1 KiB in 14 files |
| Recipe | ports/core/office/sc-im/kpkgbuild |
About
sc-im is a spreadsheet for the terminal with vi-style keys, descended from sc. Because a spreadsheet is a grid of cells, it runs at the console font with nothing lost. It reads and writes its own .sc files and CSV, reads .xlsx and .ods through libxml2 and libzip, writes .xlsx through libxlsxwriter, runs Lua scripts, and plots through gnuplot.
Why it is in KDOS
The comment above it in script/phases/44_apps/packages.d/office.txt:
A spreadsheet is a grid of cells, which is what this whole desktop is — so it runs on tty1 at the console font with no compromise. libxml2 and libzip are what let it read the .xlsx a spreadsheet actually arrives as, and libxlsxwriter is what lets it write one back.
Sources
sc-im-0.8.5.tar.gz(1.6 MiB)
sha25649adb76fc55bc3e6ea8ee414f41428db4aef947e247718d9210be8d14a6524bd
upstream: https://github.com/andmarti1424/sc-im/archive/refs/tags/v0.8.5.tar.gz
archive copy: sources-3/office--sc-im-0.8.5.tar.gz
Dependencies
Depends on: ncurses, libxml2, libzip, libxlsxwriter, pkgconf, bison, lua, gnuplot, wl-clipboard.
Required by: no port names it.
Patches
build.sh applies these; kpkg applies nothing by itself.
wayland-clipboard.patch— Default the clipboard commands to wl-copy and wl-pasteThe Makefile hard-codes xclip for :ccopy and :cpaste with `CFLAGS +=`, which a flag passed from outside cannot override.
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/44_apps/phase.env && kpkg install sc-im'
What kpkg does
kpkg runs these steps, in this order, as root inside the chroot. The port directory is /ports/core/office/sc-im.
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/office/sc-im
echo '49adb76fc55bc3e6ea8ee414f41428db4aef947e247718d9210be8d14a6524bd sc-im-0.8.5.tar.gz' | 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/sc-im
SRC=$SRC_ROOT/sc-im-0.8.5
PKG=$SRC_ROOT/pkg
rm -rf "$SRC_ROOT"
mkdir -p "$SRC" "$PKG"
tar --no-same-permissions --warning=no-unknown-keyword -xf sc-im-0.8.5.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:
patch -p1 -i $PORT_SRC/wayland-clipboard.patch
cd src
export CFLAGS="$CFLAGS -Wno-error"
make prefix=/usr LUA_PKGNAME=lua CPPFLAGS=-g0
make prefix=/usr LUA_PKGNAME=lua THEMEDIR=/usr/share/sc-im/themes DESTDIR=$PKG install
install -d "$PKG/usr/share/applications"
cat > "$PKG/usr/share/applications/sc-im.desktop" <<'EOF'
[Desktop Entry]
Type=Application
Name=Spreadsheet
GenericName=Spreadsheet
Comment=A spreadsheet on the grid
Exec=sc-im %f
Icon=x-office-spreadsheet
Terminal=true
Categories=Office;Spreadsheet;
Keywords=spreadsheet;cells;calc;sc-im;
EOF
chmod 644 "$PKG/usr/share/applications/sc-im.desktop"
The switches, and why each is set:
-Wno-error— exported inCFLAGS. It turns any-Werrorback into plain warnings; this release’s makefile adds none of its own.LUA_PKGNAME=lua— thepkg-configname of the Lua that scripting links. Left unset, the makefile takes the highest-versionedluaX.Ynamepkg-configlists, so the result would follow which of lua and lua54 happened to be installed.luais the lua port’s own.pcfile, which lua54 does not install.CPPFLAGS=-g0— the makefile adds-gtoCFLAGS, and make’s built-in compile rule putsCPPFLAGSafterCFLAGS, so-g0cancels it and no object carries debug information.THEMEDIR=/usr/share/sc-im/themes— install the colour themes beside sc-im’s other data. Upstream’s default is$(prefix)/share/themes, the directory that holds desktop toolkit themes.
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/sc-im, 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 sc-im-0.8.5-2.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/sc-im, and runs the triggers its paths call for.
Contents
Installed programs: sc-im, scopen.
Installed directories: /usr/share/licenses/sc-im, /usr/share/sc-im.
Short descriptions
sc-im |
A curses based, vim-like spreadsheet calculator |
Notes
The CFLAGS are exported, never passed on the make command line. The makefile builds its whole configuration with CFLAGS += (the help path, the configuration directory, the history file, the ncurses and colour switches and every other -D the source reads), and a command-line assignment would replace all of it; the build then fails on 'CONFIG_DIR' undeclared. Exported, the tree’s flags are the base and the makefile appends to them. For the same reason the clipboard commands cannot be set from outside, which is what wayland-clipboard.patch is for: :ccopy and :cpaste go through wl-copy and wl-paste from wl-clipboard instead of xclip.
The .xlsx and .ods readers, the .xlsx writer, Lua and plotting are all probes with no flag: the makefile asks pkg-config for libxml-2.0 and libzip, for xlsxwriter and for the Lua package, and defines GNUPLOT only when which gnuplot answers at build time. A failed probe leaves the feature out of a build that otherwise succeeds, which is why each of those is in depends. Legacy .xls import needs libxls, which is not a port, so that probe finds nothing.
The desktop entry is KDOS’s own, with Terminal=true.