99.16. hfsprogs-540.1.3
Apple HFS+ filesystem tools — mkfs.hfsplus and fsck.hfsplus, from Apple's diskdev_cmds
| Version | 540.1.3, release 3 |
| Shelf | filesystem — Filesystem utilities, FUSE, and network or encrypted filesystems |
| Phase | 41_system (System), 519 of 1047 in build order |
| Licence | APSL-2.0 |
| Homepage | https://src.fedoraproject.org/rpms/hfsplus-tools |
| Build time | 0.1 SBU |
| Installed size | 351.1 KiB in 8 files |
| Recipe | ports/core/filesystem/hfsprogs/kpkgbuild |
About
hfsprogs is mkfs.hfsplus and fsck.hfsplus, the tools that create and check Apple’s HFS+ filesystem. They are newfs_hfs and fsck_hfs from Apple’s diskdev_cmds, in the Linux port that Fedora distributes as hfsplus-tools, installed under the names fsck(8) and gparted look up. fsck.hfs is a link to fsck.hfsplus.
Sources
hfsprogs-540.1.3.tar.gz(401.6 KiB)
sha256b01b203a97f9a3bf36a027c13ddfc59292730552e62722d690d33bd5c24f5497
upstream: https://src.fedoraproject.org/repo/pkgs/hfsplus-tools/diskdev_cmds-540.1.linux3.tar.gz/0435afc389b919027b69616ad1b05709/diskdev_cmds-540.1.linux3.tar.gz
archive copy: sources-2/filesystem--hfsprogs-540.1.3.tar.gz
Dependencies
Depends on: clang, openssl, util-linux.
Required by (1): gparted.
Patches
build.sh applies these; kpkg applies nothing by itself.
fix-stdarg.patch— Fedora’s patch tofsck_hfs’s in-memory log, from the hfsplus-tools package itsPatch-Source:line names. In upstream’s sourceprint_to_mem()takes a type code, a format, one string and ava_list, and each caller passesNULLfor whichever of the last two it does not use. The patch splits it intovprint_to_mem(fmt, ap)and a variadicprint_to_mem(fmt, ...)and moves every caller to the one that fits, so noNULLis ever passed where ava_listis expected.musl-compat.patch— Lets the sources compile against musl: removes every#include <sys/sysctl.h>, a header musl does not have; includes<errno.h>in place of<sys/errno.h>; adds#include <sys/types.h>tocache.hand#include <sys/cdefs.h>tofsck_hfs.h,makehfs.candnewfs_hfs.c; and spells glibc’s__va_copyas the standardva_copy.
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 hfsprogs'
What kpkg does
kpkg runs these steps, in this order, as root inside the chroot. The port directory is /ports/core/filesystem/hfsprogs.
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/filesystem/hfsprogs
echo 'b01b203a97f9a3bf36a027c13ddfc59292730552e62722d690d33bd5c24f5497 hfsprogs-540.1.3.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/hfsprogs
SRC=$SRC_ROOT/hfsprogs-540.1.3
PKG=$SRC_ROOT/pkg
rm -rf "$SRC_ROOT"
mkdir -p "$SRC" "$PKG"
tar --no-same-permissions --warning=no-unknown-keyword -xf hfsprogs-540.1.3.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 recipe’s helpers _upver, _md5 and the five paths PKGNAME, PORT_SRC, SRC_ROOT, SRC and PKG set as shell variables. Its body, verbatim:
patch -p1 -i "$PORT_SRC/fix-stdarg.patch"
patch -p1 -i "$PORT_SRC/musl-compat.patch"
make \
CFLAGS="$CFLAGS -Wall -fblocks -I$PWD/BlocksRunTime -I$PWD/include -DDEBUG_BUILD=0 -D_FILE_OFFSET_BITS=64 -DLINUX=1 -DBSD=1 -DVERSION=\\\"$_upver\\\" '-D__P(x)=x'" \
LDFLAGS="$LDFLAGS -Wl,--build-id -L$PWD/BlocksRunTime"
install -Dm755 fsck_hfs.tproj/fsck_hfs "$PKG/usr/sbin/fsck.hfsplus"
install -Dm755 newfs_hfs.tproj/newfs_hfs "$PKG/usr/sbin/mkfs.hfsplus"
ln -s fsck.hfsplus "$PKG/usr/sbin/fsck.hfs"
install -Dm644 fsck_hfs.tproj/fsck_hfs.8 "$PKG/usr/share/man/man8/fsck.hfsplus.8"
install -Dm644 newfs_hfs.tproj/newfs_hfs.8 "$PKG/usr/share/man/man8/mkfs.hfsplus.8"
install -d "$PKG/usr/share/licenses/$name"
head -n 22 fsck_hfs.tproj/fsck_hfs.c > "$PKG/usr/share/licenses/$name/APSL-2.0"
install -m644 BlocksRunTime/LICENSE.TXT "$PKG/usr/share/licenses/$name/BlocksRunTime-LICENSE.TXT"
head -n 54 fsck_hfs.tproj/utilities.c | tail -n 32 > "$PKG/usr/share/licenses/$name/BSD-4-Clause-UC"
The switches, and why each is set:
-fblocks— Enables C blocks, the closure extension Apple’s code is written with. Only clang compiles it, which is why clang is independs: upstream’s makefile setsCC := clangitself, and the build does not override it.-I$PWD/BlocksRunTime— The blocks runtime headers. The source carries its own small runtime inBlocksRunTime/, built first aslibBlocksRunTime.aand linked intofsck_hfsthrough the-L$PWD/BlocksRunTimeinLDFLAGS.-DLINUX=1,-DBSD=1—BSDselects the Unix code over the classic Mac OS code that includes the Toolbox headers (MacTypes.h,Files.h), andLINUXselects the Linux paths over the Darwin ones within it (no IOKit, no CoreFoundation, nosys/disk.h).'-D__P(x)=x'— Defines__P(), the K&R prototype macro the sources declare their functions through. glibc’s<sys/cdefs.h>provides it; the<sys/cdefs.h>this build finds is libbsd’s, which does not. The single quotes keep the parentheses intact through the shell make runs each compile in.-DVERSION— The version stringfsck.hfsplus -vprints, set to upstream’s own spelling of the version, which the recipe’s_upverhelper rebuilds fromversion.-D_FILE_OFFSET_BITS=64,-DDEBUG_BUILD=0— Upstream’s own makefile flags, repeated because the command line replaces the makefile’sCFLAGSwhole.
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/hfsprogs, 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 hfsprogs-540.1.3-3.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/hfsprogs, and runs the triggers its paths call for.
Contents
Installed programs: fsck.hfs, fsck.hfsplus, mkfs.hfsplus.
Installed directories: /usr/share/licenses/hfsprogs.
Short descriptions
fsck.hfsplus |
HFS file system consistency check |
mkfs.hfsplus |
construct a new HFS Plus file system |
Notes
CFLAGS and LDFLAGS on the make command line are the tree’s exported flags followed by every entry of upstream’s own except -g3, plus the __P definition. The top-level makefile exports both to the per-directory makefiles, so a flag left off this line is missing from every compile.
The tarball unpacks to diskdev_cmds-<upstream version>, and the source is fetched from Fedora’s lookaside cache, whose URL carries the file’s MD5; the recipe keeps it in the _md5 helper, and a version bump changes both.
<sys/cdefs.h> is not part of musl. The copy the compile finds in /usr/include/sys is installed by libbsd, which the recipe’s depends does not name.