218.1. digital-0.31
Digital logic designer and circuit simulator for teaching, with FSM and HDL export (Java Swing)
| Version | 0.31, release 1 |
| Shelf | eda — Electronics: schematic and PCB, circuit simulation, antenna modelling, FPGA synthesis and simulation, logic analysers and bench instruments |
| Phase | 42_graphics (Graphics Stack), 86 of 189 in build order |
| Licence | GPL-3.0-only |
| Homepage | https://github.com/hneemann/Digital |
| Build time | 0.7 SBU |
| Installed size | 12.0 MiB in 346 files |
| Recipe | ports/core/eda/digital/kpkgbuild |
About
Digital is a digital logic designer and circuit simulator made for teaching: gates, flip-flops, memories and whole processors drawn as circuits and simulated, with truth tables, state machines, and export to VHDL and Verilog. It is a Java Swing program; on KDOS it is an X11 client under Xwayland. The port compiles it, and the libraries it uses, from source with javac alone, without upstream’s Maven build.
Sources
digital-0.31.tar.gz(12.7 MiB)
sha256c17f68c8e9cf80a13f8deb70ecb36d937c4abfec5fbc73d5d9c43b1d7f0f81ef
upstream: https://github.com/hneemann/Digital/archive/refs/tags/v0.31.tar.gz
archive copy: sources-2/eda--digital-0.31.tar.gzxstream-1.4.20-sources.jar(444.8 KiB)
sha25635f61c5d3f59a8b88cbcca90196ad4355666de185d1584b24e4f2a3a851ae7aa
upstream: https://repo1.maven.org/maven2/com/thoughtworks/xstream/xstream/1.4.20/xstream-1.4.20-sources.jar
archive copy: sources-2/eda--xstream-1.4.20-sources.jarmxparser-1.2.2-sources.jar(30.2 KiB)
sha256b2e72350ce8b2f287c0cd435a338c17705f9047857c52a709e223af2f5cbb0de
upstream: https://repo1.maven.org/maven2/io/github/x-stream/mxparser/1.2.2/mxparser-1.2.2-sources.jar
archive copy: sources-2/eda--mxparser-1.2.2-sources.jarxmlpull-api-v1-abeaa4aa87b2625af70c32f658f44e11355fe568.tar.gz(641.1 KiB)
sha2562a1a71a1e413f15211225c919285516be82050e26d596e4a70bcf24d5fbae59c
upstream: https://github.com/aslom/xmlpull-api-v1/archive/abeaa4aa87b2625af70c32f658f44e11355fe568.tar.gz
archive copy: sources-2/eda--xmlpull-api-v1-abeaa4aa87b2625af70c32f658f44e11355fe568.tar.gzslf4j-api-1.7.24-sources.jar(54.2 KiB)
sha2566ba37c84d993aa9e284c6008bd31caf5ec7dd2a928cb6dadb529867d83cde952
upstream: https://repo1.maven.org/maven2/org/slf4j/slf4j-api/1.7.24/slf4j-api-1.7.24-sources.jar
archive copy: sources-2/eda--slf4j-api-1.7.24-sources.jarslf4j-simple-1.7.24-sources.jar(12.2 KiB)
sha2564b58609f91908771dbfd5439d0664531413f65ef041b1af5b40f0902cfa97108
upstream: https://repo1.maven.org/maven2/org/slf4j/slf4j-simple/1.7.24/slf4j-simple-1.7.24-sources.jar
archive copy: sources-2/eda--slf4j-simple-1.7.24-sources.jarjson-20220924-sources.jar(66.0 KiB)
sha256e70ce6536fc0352c6a8d398b0e534f9213938431b3ad470c0bedb50c063fbde3
upstream: https://repo1.maven.org/maven2/org/json/json/20220924/json-20220924-sources.jar
archive copy: sources-2/eda--json-20220924-sources.jar
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/42_graphics/phase.env && kpkg install digital'
What kpkg does
kpkg runs these steps, in this order, as root inside the chroot. The port directory is /ports/core/eda/digital.
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/eda/digital
echo 'c17f68c8e9cf80a13f8deb70ecb36d937c4abfec5fbc73d5d9c43b1d7f0f81ef digital-0.31.tar.gz' | sha256sum -c -
echo '35f61c5d3f59a8b88cbcca90196ad4355666de185d1584b24e4f2a3a851ae7aa xstream-1.4.20-sources.jar' | sha256sum -c -
echo 'b2e72350ce8b2f287c0cd435a338c17705f9047857c52a709e223af2f5cbb0de mxparser-1.2.2-sources.jar' | sha256sum -c -
echo '2a1a71a1e413f15211225c919285516be82050e26d596e4a70bcf24d5fbae59c xmlpull-api-v1-abeaa4aa87b2625af70c32f658f44e11355fe568.tar.gz' | sha256sum -c -
echo '6ba37c84d993aa9e284c6008bd31caf5ec7dd2a928cb6dadb529867d83cde952 slf4j-api-1.7.24-sources.jar' | sha256sum -c -
echo '4b58609f91908771dbfd5439d0664531413f65ef041b1af5b40f0902cfa97108 slf4j-simple-1.7.24-sources.jar' | sha256sum -c -
echo 'e70ce6536fc0352c6a8d398b0e534f9213938431b3ad470c0bedb50c063fbde3 json-20220924-sources.jar' | 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/digital
SRC=$SRC_ROOT/digital-0.31
PKG=$SRC_ROOT/pkg
rm -rf "$SRC_ROOT"
mkdir -p "$SRC" "$PKG"
tar --no-same-permissions --warning=no-unknown-keyword -xf digital-0.31.tar.gz -C "$SRC" --strip-components=1
cp xstream-1.4.20-sources.jar "$SRC"
cp mxparser-1.2.2-sources.jar "$SRC"
tar --no-same-permissions --warning=no-unknown-keyword -xf xmlpull-api-v1-abeaa4aa87b2625af70c32f658f44e11355fe568.tar.gz -C "$SRC_ROOT"
cp slf4j-api-1.7.24-sources.jar "$SRC"
cp slf4j-simple-1.7.24-sources.jar "$SRC"
cp json-20220924-sources.jar "$SRC"
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 recipe’s helpers _maven, _xstream, _mxparser, _xmlpull, _slf4j, _json and the five paths PKGNAME, PORT_SRC, SRC_ROOT, SRC and PKG set as shell variables. Its body, verbatim:
_dep=build/depsrc
mkdir -p "$_dep" build/classes
for _j in xstream-$_xstream mxparser-$_mxparser json-$_json slf4j-api-$_slf4j; do
unzip -q -o "$_j-sources.jar" -d "$_dep"
done
rm -rf "$_dep/org/slf4j/impl"
unzip -q -o "slf4j-simple-$_slf4j-sources.jar" -d "$_dep"
rm -rf "$_dep/META-INF"
_opt='^import (net\.sf\.cglib|org\.dom4j|org\.jdom2?|nu\.xom|org\.kxml2|org\.xmlpull\.mxp1|org\.codehaus|org\.joda|com\.ctc|com\.bea|javax\.activation|javax\.xml\.bind)\.'
{
find src/main/java -name '*.java'
find "$_dep/com/thoughtworks/xstream" -name '*.java' -exec grep -LE "$_opt" {} +
} | LC_ALL=C sort > build/sources.list
javac -encoding UTF-8 -nowarn -proc:none -implicit:class \
-d build/classes \
-sourcepath "$_dep:$SRC_ROOT/xmlpull-api-v1-$_xmlpull/src/java/api:src/main/java" \
@build/sources.list
cp -r src/main/resources/. build/classes/
_time=$(date -u -d "@$SOURCE_DATE_EPOCH" '+%Y-%m-%d %H:%M')
printf 'Main-Class: de.neemann.digital.gui.Main\nBuild-SCM-Revision: v%s-kdos\nBuild-Time: %s\nSplashScreen-Image: icons/splash.png\n' \
"$version" "$_time" > build/manifest.txt
( cd build/classes && find . -type f | LC_ALL=C sort | sed 's/.*/"&"/' > ../classes.list )
( cd build/classes && jar --create --file ../Digital.jar --manifest ../manifest.txt \
--date="$(date -u -d "@$SOURCE_DATE_EPOCH" '+%Y-%m-%dT%H:%M:%SZ')" @../classes.list )
install -Dm644 build/Digital.jar "$PKG/usr/share/digital/Digital.jar"
for _d in src/main/dig/*/; do
install -d "$PKG/usr/share/digital/examples/$(basename "$_d")"
cp -r "$_d". "$PKG/usr/share/digital/examples/$(basename "$_d")/"
done
install -d "$PKG/usr/bin"
cat > "$PKG/usr/bin/digital" <<'LAUNCHER'
#!/bin/sh
exec java -jar /usr/share/digital/Digital.jar "$@"
LAUNCHER
chmod 755 "$PKG/usr/bin/digital"
install -Dm644 distribution/linux/digital-simulator.xml \
"$PKG/usr/share/mime/packages/digital-simulator.xml"
install -Dm644 src/main/resources/icons/icon128.png \
"$PKG/usr/share/icons/hicolor/128x128/apps/digital.png"
install -d "$PKG/usr/share/applications"
cat > "$PKG/usr/share/applications/digital.desktop" <<'DESKTOP'
[Desktop Entry]
Type=Application
Name=Digital
GenericName=Logic Simulator
Comment=Design and simulate digital logic circuits
Exec=digital %f
Icon=digital
Terminal=false
StartupWMClass=de-neemann-digital-gui-Main
Categories=Education;Electronics;Engineering;
MimeType=text/x-digital;
Keywords=logic;circuit;simulator;gate;flip-flop;fsm;vhdl;verilog;
DESKTOP
chmod 644 "$PKG/usr/share/applications/digital.desktop"
The switches, and why each is set:
-sourcepath "$_dep:$SRC_ROOT/xmlpull-api-v1-$_xmlpull/src/java/api:src/main/java",-implicit:class— Letjavacfind every class it is not handed on the command line in the unpacked dependency sources (XStream, MXParser, the XML Pull API, org.json, SLF4J) and in Digital’s own tree, and write a class file for each one it compiles that way. MXParser, the XML Pull API, org.json and SLF4J are not on the command line, so of those only the classes that Digital and XStream reach are compiled.-encoding UTF-8— Read the sources as UTF-8, whatever the build’s locale.-proc:none— Run no annotation processors.-nowarn— Print no compiler warnings.
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/digital, 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 digital-0.31-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/digital, and runs the triggers its paths call for.
Contents
Installed programs: digital.
Installed directories: /usr/share/digital, /usr/share/licenses/digital.
Notes
- Every dependency is a source jar. The recipe takes each library Digital needs from Maven Central as its published
-sources.jar, and the XML Pull API from its git archive, each with its ownsha256 =line;build.shunpacks them intobuild/depsrc. slf4j-api’s sources carry placeholder binders,org/slf4j/impl, that its own jar leaves out, sobuild.shremoves them and unpacks slf4j-simple’s binders in their place. - All of XStream is compiled, with exceptions. XStream loads its mappers and converters by name at run time, so
-implicit:classalone would miss them:build.shhandsjavacevery XStream source file except those that import a library this system does not carry (CGLIB, dom4j, JDOM, XOM, kXML2, XPP3, Jettison and the otherorg.codehauspackages, Joda, Woodstox, BEA’s StAX, JavaBeans Activation and JAXB; the list is the_optpattern inbuild.sh). XStream probes for those drivers and converters and skips the ones that are missing. - The jar is reproducible. The class and resource files go into
Digital.jarsorted by name, one quoted name per line because some resource names contain spaces, with every entry datedSOURCE_DATE_EPOCH. The manifest’sBuild-Timeis the same date. - No update check. The About box reads
Build-SCM-Revisionfrom the manifest, and Digital asksapi.github.comfor a newer release only when that revision is known and at most seven characters long.build.shwritesv<version>-kdos, which is longer, so it never asks. - The launcher and the entry.
/usr/bin/digitalruns the jar with openjdk’sjava. The menu entry’sStartupWMClassisde-neemann-digital-gui-Main, the main class with its dots turned into dashes, which is theWM_CLASSSwing gives the window. The entry claimstext/x-digital, the MIME type of Digital’s own circuit files, whose definition the port installs from upstream’sdigital-simulator.xml.