file_type=$(file -b "$INPUT_BIN")
A user named Sarah downloaded the new Pkg. In the old days, she would have had to unzip Bin, move him, and hope he worked. But not today.
She typed: sudo apt install ./prime-calculator_1.0_amd64.deb
The Package Manager read Pkg's manifest. It checked the database.
"Ah," the Manager said, "This package requires libmath. I shall fetch it."
Once the dependencies were satisfied, Pkg unfolded. He gently placed Bin into /usr/bin, right where he belonged. He placed the config file into /etc.
Sarah typed prime-calculator into her terminal. It worked instantly. Bin was running, but he was safe now. He was tracked, he was managed, and he could be cleanly removed with a single command if he was ever no longer needed.
Before attempting any conversion, you must identify what you are actually holding.
| Tool | Platform | Purpose |
|----------|--------------|--------------|
| make_pkg | Windows/PS3 SDK | Official PKG creation |
| ps3tools | Linux/macOS | BIN analysis, PKG unpack |
| TrueAncestor PKG Repacker | Windows | GUI for PS3 PKG |
| ps4-pkg-tool | Cross-platform | PS4 PKG creation (fake) |
| pkg2zip | Cross-platform | Extract PKG to BIN/folder |
| PKGBUILD (makepkg) | Arch Linux | Linux .pkg from binary |
Before diving into the "how," it's crucial to understand the "why." Why would a developer or system administrator convert a simple binary into a .pkg?
| Feature | Raw Binary | PKG Package |
|---------|------------|-------------|
| Install path | Manual: cp mybin /usr/local/bin | Automatic, configurable (/usr/local, /Applications, /Library/Frameworks) |
| Uninstallation | Manual deletion | Can integrate with pkgutil --forget or uninstall scripts |
| Permissions | User must chmod +x | Setuid, sticky bits, ownership preserved |
| Receipts | None | Stored in SQLite database for version tracking |
| Scripted actions | None | Pre/post install scripts to configure services, create users, set up launch daemons |
| Code signing | Possible but rare | Required for distribution (notarization) |
| GUI deployment | Terminal only | Double-click installer + Apple Remote Desktop / Jamf Pro support |
Use cases: