Skip to content
This repository was archived by the owner on Jul 21, 2026. It is now read-only.

file: add the compression-aware identification CLI - #30

Closed
brandonpayton wants to merge 6 commits into
migrate/libmagic-dependency-rootfrom
migrate/file-cli
Closed

file: add the compression-aware identification CLI#30
brandonpayton wants to merge 6 commits into
migrate/libmagic-dependency-rootfrom
migrate/file-cli

Conversation

@brandonpayton

@brandonpayton brandonpayton commented Jul 11, 2026

Copy link
Copy Markdown
Member

Purpose

Migrate the registry file package into Homebrew as the command-line consumer of the complete tap libmagic database. The CLI follows Homebrew's standard file-formula name because File is a reserved Ruby class; the tap alias file preserves the expected user-facing package name.

This removes the registry package's 14,000-line magic.lite workaround. Normal file invocations now load the full compiled database from the stable libmagic opt path.

Implementation

  • builds only upstream file(1), replacing the sibling libmagic.la dependency with the installed static tap contract
  • requires the matching libmagic 5.45 version
  • carries explicit static compression dependencies and validates pkg-config propagation
  • instruments the final Wasm executable for its retained fork/posix_spawn fallback path
  • installs only bin/file and file(1); libmagic remains the sole owner of the library and database
  • adds the standard tap alias file -> file-formula

Evidence

  • source reinstall passed in an isolated ABI-18 Homebrew prefix
  • literal brew test --keep-tmp --verbose passed
  • Node tests cover the default database, WebAssembly recognition, PDF MIME output, stdin, symlink/no-dereference and -L behavior, plus zlib, gzip, bzip2, and xz -z decoding
  • Chromium BrowserKernel produced the same WebAssembly/PDF/compression classifications with guest PATH=/no-such-path
  • the installed binary contains only the libmagic opt database path
  • direct Wasm inspection shows kernel_fork, all five wpk_fork exports, no Asyncify exports, and __abi_version returning 18
  • clean-prefix brew audit --strict and brew style passed
  • git diff --check passed

Dependencies

This PR is intentionally stacked on #29, which is stacked on compression-library PR #25.

Platform gates before bottle publication/merge:

The pthread fork-continuation fix and ABI 18 transition from #867 are merged. Final bottle order is bzip2/xz (#25), libmagic (#29), then this File consumer; the poured chain must pass stock guest Node and Chromium validation.

The branch was transplanted semantic-preservingly onto current libmagic head 991712b at File head 5735ce1. The stable patch ID and Formula/Alias/README blobs are byte-identical to the functionally validated head. Post-restack validation through scripts/dev-shell.sh passed Homebrew Ruby syntax, the current support suite (21 runs/186 assertions), brew style, and git diff --check.

Do not merge until the dependency stack and platform gates are ready. No pre-final bottle is accepted for publication.

@brandonpayton

Copy link
Copy Markdown
Member Author

Independent devil review found no blockers.

The review specifically confirmed:

  • FileFormula plus the tracked Aliases/file symlink is the correct reserved-name handling
  • static dependencies and pkg-config propagation are explicit
  • the formula builds only the CLI against external libmagic and installs only file plus file(1)
  • the stable libmagic opt database path, skip_clean, and final fork instrumentation are present
  • tests cover default DB, MIME, stdin, symlink semantics, zlib, gzip, bzip2, and xz
  • BSD-2-Clause-Darwin matches the CLI source license

Residual: the committed Node compression test inherits PATH. Built-in-only proof therefore rests on the recorded Chromium run with guest PATH=/no-such-path plus the underlying libmagic runtime test; the reviewer considered that evidence adequate.

Install and exercise the upstream libbz2 and liblzma consumer surfaces so dependent Kandelo formulae can link built-in compression support instead of spawning fallback tools.
Build libbz2 and liblzma objects as PIC so Kandelo shared Wasm consumers can link the published archives. Exercise each archive through pkg-config, a real side-module link, dlopen, and dlsym under the Kandelo runtime; retain liblzma's pthread metadata contract explicitly.
Build the full version-matched magic.mgc with a native FILE_COMPILE helper, link the target library to declared compression dependencies, and validate the fixed-record database under Kandelo.
@brandonpayton
brandonpayton force-pushed the migrate/libmagic-dependency-root branch from 6f3c169 to 991712b Compare July 11, 2026 22:20
@brandonpayton
brandonpayton force-pushed the migrate/libmagic-dependency-root branch 3 times, most recently from 991712b to 3784d6b Compare July 12, 2026 02:01
@brandonpayton
brandonpayton deleted the branch migrate/libmagic-dependency-root July 12, 2026 02:21
@brandonpayton

Copy link
Copy Markdown
Member Author

Replaced by #69 after libmagic merged. GitHub auto-closed this stacked PR when its base branch was deleted, and then marked it non-reopenable once the File head was transplanted onto current main. #69 contains the same File formula body plus the canonical installed-tap loader, directly based on main.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant