SPB Git

Repository Public

packages.md 3.2 KB

# Packages

A package is a folder of Sonata modules that several projects can share: patterns, functions, instrument definitions. Packages are plain files. Nothing in a package is ever executed: there is no install script, and a package can only contain Sonata sources and documentation.

# Layout

text
riffs/
  package.json        name, version, license, dependencies
  src/blues.sonata    modules: `import riffs.blues`
  examples/*.sonata   optional
  tests/*.sonata      optional
  docs/*.md  README*  LICENSE*  CHANGELOG.md   optional
json
{
  "name": "riffs",
  "version": "1.0.0",
  "license": "MIT",
  "description": "Two blues riffs",
  "dependencies": { "scales": "^1.2.0" }
}

Names are lower-case letters, digits and _, starting with a letter (they are the first word of an import). Versions are MAJOR.MINOR.PATCH, optionally with a pre-release tag (1.0.0-rc.1). A dependency requirement is an exact version, ^1.2.0 (compatible), ~1.2.0 (patches only), >=1.2.0 or *. A license is required.

# Commands

bash
sonata pkg pack riffs                       # writes riffs-1.0.0.sonatapkg after compiling every module
sonata pkg verify riffs-1.0.0.sonatapkg     # structure, manifest, every file against its hash
sonata pkg install riffs-1.0.0.sonatapkg --project MySong.sonataproject
sonata pkg list   --project MySong.sonataproject
sonata pkg check  --project MySong.sonataproject    # tampering, missing files, unmet dependencies
sonata pkg remove riffs --project MySong.sonataproject
sonata pkg resolve riffs@^1.0.0 --from ~/Packages --project MySong.sonataproject

--project is the folder that receives packages/ and sonata.lock; without it, the current folder. A source compiled from that folder (or a project package) can then write:

text
import riffs.blues

The project's own modules are looked up first, then installed packages.

# What is guaranteed

  • Reproducible archives. Packing the same folder twice gives the same bytes: files are sorted, timestamps and owners are fixed.
  • Verified content. Every file is listed with its SHA-256 in MANIFEST.sha256; verify, install and check compare each file to it. sonata.lock records the SHA-256 of each installed archive.
  • Safe extraction. An archive is refused as a whole if it contains a link, a device, an absolute path, .., a hidden file, a file outside the allowed folders, a duplicate, a file over 4 MiB, more than 2000 entries or more than 64 MiB in total. Nothing is written before the whole archive has passed.
  • Atomic installation. Files are written beside the destination and moved into place in one step; an installed package is replaced only with --force.
  • Deterministic resolution. resolve picks, for each package, the highest version that satisfies every requirement, whatever the order of the files in the folder; one version per package; a conflict is an error that names who requires what.

# What does not exist

There is no remote registry and no download: packages come from files you have. Pre-release versions are chosen only when a requirement names one. Packages cannot carry audio samples in this version.

Files main
Menu

Theme