161.25. srecord-1.65
HEX, S-record and TI-TXT conversion, fill, CRC and offset
| Version | 1.65, release 1 |
| Shelf | embedded — Microcontroller and bare-metal development: cross toolchains, C libraries, flashers, debug probes and serial consoles |
| Phase | 41_system (System), 484 of 1047 in build order |
| Licence | GPL-3.0-or-later |
| Homepage | https://srecord.sourceforge.net/ |
| Build time | 0.6 SBU |
| Installed size | 2.8 MiB in 51 files |
| Recipe | ports/core/embedded/srecord/kpkgbuild |
About
SRecord converts and manipulates the files that carry firmware images: Intel HEX, Motorola S-record, TI-TXT, raw binary and several dozen others. srec_cat reads any of them, crops, fills gaps, moves data to another offset, adds CRCs, checksums and message digests, and writes the result in any format; srec_cmp compares two images and srec_info describes one. These are the steps between a linker’s output and what a programmer or bootloader accepts.
Why it is in KDOS
The comment above sdcc and srecord in script/phases/41_system/packages.d/embedded.txt:
The 8-bit families gcc has no back end for at all: 8051, STM8, Z80 and PDK.
Sources
srecord-1.65.tar.gz(790.4 KiB)
sha2568d4ae753d10db0e40882e1cfbc78fe08b9d148be917ea7accc58843ac13566d6
upstream: https://github.com/sierrafoxtrot/srecord/archive/refs/tags/v1.65.tar.gz
archive copy: sources-2/embedded--srecord-1.65.tar.gz
Dependencies
Depends on: cmake, boost, libgcrypt, doxygen.
Required by: no port names it.
Patches
build.sh applies these; kpkg applies nothing by itself.
build-fixes.patch— Two changes. Inetc/configure.cmake,find_package(Doxygen REQUIRED doxygen dot)loses itsdotcomponent, so graphviz is not required; it would only draw call and collaboration graphs into the API documentation, which upstream installs under itswebsitecomponent andbuild.shneither builds nor installs. (Doxygen itself stays required by configure, which is why doxygen is independs.) Insrecord/input/file/hp64k.h, it adds#include <cstdint>, because the header usesuint16_twithout including anything that declares it, which the tree’s GCC rejects.
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 srecord'
What kpkg does
kpkg runs these steps, in this order, as root inside the chroot. The port directory is /ports/core/embedded/srecord.
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/embedded/srecord
echo '8d4ae753d10db0e40882e1cfbc78fe08b9d148be917ea7accc58843ac13566d6 srecord-1.65.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/srecord
SRC=$SRC_ROOT/srecord-1.65
PKG=$SRC_ROOT/pkg
rm -rf "$SRC_ROOT"
mkdir -p "$SRC" "$PKG"
tar --no-same-permissions --warning=no-unknown-keyword -xf srecord-1.65.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/build-fixes.patch"
mkdir -p build && cd build
cmake .. -DCMAKE_POLICY_VERSION_MINIMUM=3.5 -DCMAKE_BUILD_TYPE=Release \
-DCMAKE_INSTALL_PREFIX=/usr \
-DBUILD_SHARED_LIBS=ON \
-DHAVE_LIBGCRYPT=ON -DHAVE_GCRY_MD_HD_T=ON
make srec_cat srec_cmp srec_info srecord
install -Dm755 srec_cat/srec_cat $PKG/usr/bin/srec_cat
install -Dm755 srec_cmp/srec_cmp $PKG/usr/bin/srec_cmp
install -Dm755 srec_info/srec_info $PKG/usr/bin/srec_info
srec_man() {
while IFS= read -r line || [ -n "$line" ]; do
case $line in
'.so '*)
inc=${line#.so }
if [ -f "doc/$inc" ]; then srec_man "doc/$inc"; else srec_man "../doc/$inc"; fi
;;
*)
printf '%s\n' "$line"
;;
esac
done < "$1"
}
for s in 1 5; do
install -d $PKG/usr/share/man/man$s
for m in ../doc/man$s/*.$s; do
srec_man "$m" > $PKG/usr/share/man/man$s/${m##*/}
done
done
The switches, and why each is set:
-DBUILD_SHARED_LIBS=ON— Has no effect on this build: the one library,lib_srecord, is declaredSTATICby upstream, is linked into the three programs, and is not installed.-DHAVE_LIBGCRYPT=ON,-DHAVE_GCRY_MD_HD_T=ON— Upstream turns these on, with the SHA-224 and Whirlpool ones beside them, only when it findsgcrypt.h, and has no switch that requires libgcrypt.srecord/config.hneeds both before it compiles any of the libgcrypt digest filters (MD5, RIPEMD-160, the SHA family and Whirlpool); set outright, they turn a missing libgcrypt into a compile error instead of ansrec_catwithout those filters.make srec_cat srec_cmp srec_info srecord— The three programs by name instead ofall. Thedocdirectory is part of every build, and its targets, whichallincludes, run groff and ps2pdf to make HTML pages and PDF manuals; neither groff nor Ghostscript is in this port’sdepends.allalso holds the library’sdoxygentarget, which runs Doxygen over its headers.srecordmatches no target: make takes it for the build tree’ssrecorddirectory and does nothing for it.
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/srecord, 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 srecord-1.65-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/srecord, and runs the triggers its paths call for.
Contents
Installed programs: srec_cat, srec_cmp, srec_info.
Installed directories: /usr/share/licenses/srecord.
Short descriptions
srec_cat |
manipulate EPROM load files |
srec_cmp |
compare two EPROM load files for equality |
srec_info |
information about EPROM load files |
Notes
The manual pages are installed by build.sh from doc/man1 and doc/man5, not by the doc targets. Upstream’s pages pull shared sections in with .so requests that name other files of the source; the srec_man function in build.sh follows each .so and writes the included text in its place, so every installed page stands alone.