luarocks

package
v0.3.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Nov 16, 2026 License: MIT Imports: 18 Imported by: 0

Documentation

Overview

Package luarocks indexes root-level rockspecs and rocks and derives the LuaRocks manifest consumed by the native client. A rockspec or rock is stored at the repository root under its flat file name, <name>-<version>-<revision>.rockspec or <name>-<version>-<revision>.<arch>.rock, and its rockspec, read from the stored bytes (from inside the ZIP for a rock), must name the package and version the file name does. The package index holds a version per <version>-<revision>, and the work queue writes the manifest files the client reads, manifest and manifest-5.1 to manifest-5.5, from the stored files.

Role

artifacts module, ecosystem layer: the LuaRocks rockspec and rock index rules of the LuaRocks slice. Its Handler plugs into the item service through the format hooks (decision 0032), so every write in a LuaRocks repository reaches it whichever API carried it; the slice's http package (artifacts/ecosystem/luarocks/http) serves the native LuaRocks protocol over what it keeps.

Inputs

  • Driving: the format registry (artifacts/ecosystem), which hands the item service's hooks for luarocks repositories to Handler; the work queue (decision 0033), which runs the manifest work (Work, KindManifest) and every format's reindex through it; and the protocol, which parses flat file names (Parse), checks an upstream rockspec or rock before a remote caches it (ValidateContent), and maps an uploaded rockspec to the numeric version id the upload client sends back, and that id back to the rockspec (VersionID and VersionFile).
  • Driven: the format hooks' environment (format.Env): its blobs hold the files; its store holds the items, their properties and the package index (artifacts/core/pkgindex), which Reindex rebuilds from an AQL search of the stored files; its work queue takes the manifest work (Enqueue); and Derive writes each manifest file. The generic deploy policy (artifacts/ecosystem/generic), which Handler embeds, is the first check Admit applies, and a rock's ZIP is scanned within bounds by platform/archive.
  • Settings: none.

Outputs

  • Handler: the hooks that check a file once before its transaction (Inspect); admit only a valid rockspec or rock at a valid root file name (Admit); set a stored file's properties, sync its version and queue the manifest (Deployed); queue the manifest for a delete (Deleting) and sync the versions a delete touched (Deleted); keep a file's .asc signature with it (Sidecars); name the manifest work a manifest read waits for (WorkKinds and Owed) and queue a missing manifest when it is read (Resolve); class the manifest files as derived (Classify); rebuild the index (Reindex); and write the manifests (Work).
  • The package index: a package per name, with a version per <version>-<revision>, whose files are its rockspec and rocks.
  • The luarocks.name, luarocks.version, luarocks.revision and luarocks.arch item properties (PropName, PropVersion, PropRevision and PropArch) on each stored file.
  • The manifest files: manifest, and manifest-5.1 to manifest-5.5, each filtered by the simple Lua version constraints of the matching rockspec, written as Lua assignments in luarocks-admin's form.
  • The rules the protocol shares: Identity, Parse, ValidateContent, VersionID, VersionFile, ManifestPath and KindManifest.

Invariants

  • Only the flat root layout the native client searches is indexed: a file name is <name>-<version>-<revision> with .rockspec or .<arch>.rock, and the trailing revision belongs to the version.
  • A rockspec is at most 1 MiB with no NUL byte, and assigns package and version once each, matching its file name. A rock is a ZIP of at most 10,000 entries and 256 MiB unpacked, holding only regular files and folders at clean paths, every entry read to its end, and an embedded <name>-<version>.rockspec that passes the same check.
  • Only content that breaks those rules is refused. A stored rockspec or rock that cannot be read is no fault of the file: the read's error returns as it is and fails the write (500).
  • The manifests are derived only in local and federated repositories, never in a remote's cache, and hold at most 100,000 entries and 32 MiB. A manifest read there waits for owed work, and a read of a missing manifest queues it.
  • Names and versions are quoted in a manifest, never evaluated as Lua source.
  • The items keep the property names, so they never change; their exact 7.x spelling is inferred and recorded on #216.

References

Status

Implemented P9b (newly identified Artifactory formats). Moved here in P9d.

Testing

  • luarocks_test.go: identity and rockspec admission, and a manifest the native client reads as Lua assignments.
  • edge_test.go: stored-content checks, the manifest hooks' boundaries, admission and manifest size bounds, read faults, a missing package or version, and a search fault that publishes no manifest.
  • readfault_test.go: a rock whose content fails a read at any point, on a store with ReadAt or one that can only seek, returns the read's error, and bad rocks keep their 400 refusals.
  • contract_test.go (external, luarocks_test): the format contract (artifacts/core/formattest) and the public registry's dotted package names.

Index

Constants

View Source
const (
	// KindManifest is the work kind that rebuilds a repository's manifest
	// files, keyed by the repository. The persistent work queue stores it
	// with each item, so it never changes.
	KindManifest = "luarocks.manifest"
	// ManifestPath is the path of the plain manifest at the repository root;
	// the Lua version variants are manifest-5.1 to manifest-5.5.
	ManifestPath = "manifest"
	// PropName is the property that holds a file's package name. The items
	// keep this name and the other luarocks.* names below, so they never
	// change.
	PropName = "luarocks.name" // [I] exact 7.161.32 property spelling: #216
	// PropVersion is the property that holds a file's version, its revision
	// included.
	PropVersion = "luarocks.version"
	// PropRevision is the property that holds a file's revision.
	PropRevision = "luarocks.revision"
	// PropArch is the property that holds a rock's architecture, or
	// rockspec for a rockspec.
	PropArch = "luarocks.arch"
)

Variables

This section is empty.

Functions

func Serves

func Serves(t repo.PackageType) bool

Serves reports whether t is the LuaRocks package type.

func ValidateContent

func ValidateContent(ctx context.Context, rc io.ReadSeeker, size int64, id Identity) error

ValidateContent checks complete rock bytes before a remote cache publishes them. The same admission rules protect local uploads and remote downloads. Content that breaks them is refused with a format.RejectionError; a read of rc that fails is no fault of the rock, and returns as a plain error, which a write answers 500.

func VersionID

func VersionID(ctx context.Context, st format.Store, c repo.Config, id Identity) (int64, error)

VersionID returns the package index's id for id's version: the number the native upload client receives after a rockspec upload and sends back with the rock, which VersionFile maps back. A missing package or version fails with an error that wraps the store's.

Types

type Handler

type Handler struct{ generic.Handler }

Handler is the LuaRocks format's hooks: it admits a rockspec or rock only at a valid root file name with a rockspec that matches it, indexes each stored file as a version of its package, keeps a file's .asc signature with it, and has the work queue derive the manifest files of local and federated repositories. It embeds the generic hooks.

func (Handler) Admit

func (Handler) Admit(
	ctx context.Context,
	env format.Env,
	c repo.Config,
	w format.Write,
) (format.Write, error)

Admit applies the generic deploy policy, wrapping its refusal, then passes a checksum deploy and a write to a remote's cache. Any other write of a .rockspec or .rock must use a valid root file name (400), and its content must pass ValidateContent; Admit reuses Inspect's check when it covers the same content and file name, and checks the stored content itself otherwise. Other files pass.

func (Handler) Classify

func (Handler) Classify(_ repo.Config, path string) format.Class

Classify classes the manifest files as derived, so replication and federation skip them and each side builds its own, and every other path as unique content.

func (Handler) Deleted

func (Handler) Deleted(
	ctx context.Context,
	env format.Env,
	c repo.Config,
	removed []model.Item,
) error

Deleted syncs each version a delete touched from its files still stored. A version left without files needs nothing: the item service has already unlinked and pruned it.

func (Handler) Deleting

func (Handler) Deleting(ctx context.Context, env format.Env, c repo.Config, it model.Item) error

Deleting queues the manifest work when a rockspec, rock or manifest file of a local or federated repository is about to be deleted; folders and other files change nothing.

func (Handler) Deployed

func (Handler) Deployed(ctx context.Context, env format.Env, c repo.Config, it model.Item) error

Deployed indexes a stored file at a valid root file name in the tree the package index reads: it sets the file's luarocks.* properties, syncs its version from every stored file of that version, and queues the manifest work, as a stored manifest file does too. Folders and other items change nothing, and the work is queued only in a local or federated repository.

func (Handler) Inspect

func (Handler) Inspect(
	ctx context.Context,
	env format.Env,
	_ repo.Config,
	w format.Write,
) (any, error)

Inspect checks the stored content of a write to a valid root file name (Parse) before the write's transaction, so Admit need not check it again. A write to any other path, or without content, inspects nothing. Content that fails ValidateContent is refused (400, or 413 for a rockspec over 1 MiB); content that cannot be opened or read fails the write (500).

func (Handler) Owed

func (Handler) Owed(c repo.Config, cached bool, path string) []format.WorkRef

Owed names the manifest work that a download of a manifest file from a local or federated repository must see done first, so a client never reads a manifest that lags a completed write; other downloads owe nothing.

func (Handler) Reindex

func (Handler) Reindex(ctx context.Context, env format.Env, c repo.Config) error

Reindex rebuilds the package index in one transaction from every stored rockspec and rock at a valid root file name in the tree the index reads: it checks each file's content again, sets its properties, groups the files by package and version, reconciles the index and queues the manifest work. A file whose content no longer passes fails the reindex.

func (Handler) Resolve

func (Handler) Resolve(
	ctx context.Context,
	env format.Env,
	c repo.Config,
	d format.Download,
) (string, error)

Resolve leaves every path as it is. When a download asks for a manifest file of a local or federated repository that holds neither the file nor queued manifest work, it queues the work, which Owed then makes the download wait for. A store or work queue fault fails the download.

func (Handler) Sidecars

func (Handler) Sidecars(_ repo.Config, p string) []string

Sidecars names the .asc signature that a rockspec or rock at a valid root file name owns, so the item service deletes, copies, moves and restores it with its owner; other files own none.

func (Handler) Work

func (Handler) Work(ctx context.Context, env format.Env, work work.WorkItem) error

Work builds one plain Lua manifest and the five version-specific variants the current LuaRocks client requests. The tree is read afresh on each run, so queued bursts and restores settle to the final committed state.

func (Handler) WorkKinds

func (Handler) WorkKinds() []string

WorkKinds names the format's one work kind, KindManifest.

type Identity

type Identity struct{ Name, Version, Revision, Arch string }

Identity is the package coordinate read from a flat LuaRocks filename.

func Parse

func Parse(path string) (Identity, bool)

Parse accepts only the root layout the native client searches. The final -revision is part of LuaRocks' version, not a separate indexed version.

func VersionFile

func VersionFile(
	ctx context.Context,
	st format.Store,
	c repo.Config,
	wanted int64,
) (Identity, error)

VersionFile resolves the numeric version id returned to the native upload client. It returns the rockspec's flat filename and refuses a version that has since been deleted. Scanning packages avoids ephemeral server state.

Directories

Path Synopsis
Package luarockshttp serves local and federated LuaRocks repositories through the native flat rocks-server URL and the native upload API, and remote and virtual ones through the same URL, on Artifactory's /artifactory/api/luarocks/{repo} prefix: the manifest files and the rockspecs and rocks they name, and the upload client's tool version, rockspec check and rockspec and rock uploads.
Package luarockshttp serves local and federated LuaRocks repositories through the native flat rocks-server URL and the native upload API, and remote and virtual ones through the same URL, on Artifactory's /artifactory/api/luarocks/{repo} prefix: the manifest files and the rockspecs and rocks they name, and the upload client's tool version, rockspec check and rockspec and rock uploads.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL