Skip to content

feat(mtools): add mtools package#207

Open
norrietaylor wants to merge 3 commits into
mainfrom
pkg/add-mtools
Open

feat(mtools): add mtools package#207
norrietaylor wants to merge 3 commits into
mainfrom
pkg/add-mtools

Conversation

@norrietaylor
Copy link
Copy Markdown
Member

@norrietaylor norrietaylor commented May 29, 2026

Adds the mtools package, providing mmd/mcopy/mformat. Needed to populate the FAT EFI System Partition image without loop-mounting (works in an unprivileged sandbox) for the upcoming minimal-vm-image assembly package.

Source: mtools 4.0.49 from GNU FTP, sha256 10cd1111da87bf2400a380c1639a6cba8bfb937a24f9c51f5f88d393ae5f6f76 (downloaded + hashed locally).

Build: autotools. ./configure --prefix=/usr --disable-floppyd --without-x, make, make DESTDIR=$OUTPUT_DIR install. --disable-floppyd --without-x keeps the dep set to glibc only. Deps: base-bootstrap, make, toolchain (build) + glibc (runtime).

Outputs: usr/bin/* (mtools + command symlinks).

Validation: builds from source in the Linux sandbox — minimal package mtools completes successfully and minimal check --packages mtools passes (incl. the FAT roundtrip standalone test); the minimal build CI check (external Linux build) is green. (mformat/mmd/mcopy roundtrip + mtools --version were also verified on a macOS dev host.)

Summary by CodeRabbit

  • New Features
    • Added mtools package with complete build configuration and comprehensive test suite including smoke tests and functional validation.

Review Change Stack

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai Bot commented May 29, 2026

📝 Walkthrough

Walkthrough

This PR introduces the mtools package (version 4.0.49) to the minimal packages collection. The change includes a Nickel build specification that defines dependencies, output artifacts, and test cases, plus a shell build script that configures and compiles mtools with reproducible build flags for multiple architectures.

Changes

mtools Package Addition

Layer / File(s) Summary
Build specification with metadata and tests
packages/mtools/build.ncl
Package version is pinned to 4.0.49 with source tarball URL and sha256 checksum. Build dependencies are composed from shared modules (minimal base, bootstrap, make, toolchain, glibc). Output globs capture binaries in /usr/bin/, man pages in /usr/share/man/, and info pages. Package metadata includes upstream version and repology project tracking. Two tests are defined: smoketest invokes mtools --version for basic functionality, and mmd_mcopy_roundtrip creates a FAT disk image, formats it, writes and copies files both directions, then verifies roundtrip content integrity.
Build script implementation
packages/mtools/build.sh
Script extracts the versioned tarball, detects architecture via uname -m, and exports CFLAGS and CXXFLAGS with -O2, debug reproducibility settings (-fdebug-types-section), and deterministic path mapping (-ffile-prefix-map=$(pwd)=/builddir). Link flags disable the build-id hash (--build-id=none) for reproducibility. The autotools configure step targets /usr, disables the floppyd daemon, and excludes X11 support. Build runs make -j$(nproc) in parallel and installs via make DESTDIR=$OUTPUT_DIR install.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~12 minutes

Poem

🐰 A new package hops into the fold,
With mtools at version four-point-oh so bold,
Reproducible flags make the build stay true,
FAT disks are copied both ways through and through,
Minimal and mighty, the toolchain renews!

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Title check ✅ Passed The title 'feat(mtools): add mtools package' clearly and concisely describes the main change—introducing a new mtools package to the codebase.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch pkg/add-mtools

Comment @coderabbitai help to get the list of available commands and usage tips.

Copy link
Copy Markdown
Contributor

@coderabbitai coderabbitai Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🧹 Nitpick comments (1)
packages/mtools/build.sh (1)

22-23: 💤 Low value

Consider quoting $OUTPUT_DIR for defensive coding.

While unlikely to cause issues in the controlled build environment, quoting $OUTPUT_DIR on line 23 would prevent potential word-splitting if the path unexpectedly contains spaces.

🛡️ Proposed defensive fix
-make DESTDIR=$OUTPUT_DIR install
+make DESTDIR="$OUTPUT_DIR" install
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@packages/mtools/build.sh` around lines 22 - 23, The make invocation uses an
unquoted variable in the DESTDIR assignment (make DESTDIR=$OUTPUT_DIR install);
update it to quote the variable (make DESTDIR="$OUTPUT_DIR" install) to avoid
word-splitting if OUTPUT_DIR contains spaces—edit the build.sh invocation that
calls make with DESTDIR to wrap $OUTPUT_DIR in double quotes.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Nitpick comments:
In `@packages/mtools/build.sh`:
- Around line 22-23: The make invocation uses an unquoted variable in the
DESTDIR assignment (make DESTDIR=$OUTPUT_DIR install); update it to quote the
variable (make DESTDIR="$OUTPUT_DIR" install) to avoid word-splitting if
OUTPUT_DIR contains spaces—edit the build.sh invocation that calls make with
DESTDIR to wrap $OUTPUT_DIR in double quotes.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

Run ID: 26d64394-21e6-43ce-a83a-f9408c397fc3

📥 Commits

Reviewing files that changed from the base of the PR and between 3ae4553 and b767682.

📒 Files selected for processing (3)
  • packages/mtools/NOTES.md
  • packages/mtools/build.ncl
  • packages/mtools/build.sh

norrietaylor and others added 2 commits May 28, 2026 23:28
The "minimal build" CI was failing for two reasons:

1. ftp.gnu.org returns HTTP 403 to the build fetcher, so the source
   download failed. Switch to the kernel.org GNU mirror (same byte-for-byte
   tarball; sha256 unchanged: 10cd1111...).

2. mtools installs several /bin/sh helper scripts (mcomp, uz/lz, mxtar,
   tgz, mcheck, amuFormat.sh). The post-build "missing runtime_deps" checker
   flagged that no runtime dep provides /bin/sh. Add bash (provides usr/bin/sh)
   to runtime_deps.

Build and `min check --packages mtools` now both pass cleanly.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant