Go-based POSIX package manager that builds source, packs PAX-format tar archives, resolves dependencies, and manages installations with no external runtime requirements.
  • Go 96.6%
  • Shell 3.4%
Find a file
Repository files (latest commit first)
Filename Latest commit message Latest commit date
Mike 'Fuzzy' Partin 637c00ef6d
All checks were successful
Test and Release / test (pull_request) Successful in 1m28s
Test and Release / lint (pull_request) Successful in 1m40s
feat: add comprehensive command-line tests and improve help output
fix: standardize exit codes for command-line errors
refactor: enhance help messaging for all subcommands
test: introduce integration tests for command-line interface
chore: update test infrastructure and documentation

# Previous message:
Phase 11: add integration tests for commands, exit codes, and help

Closes #0659, #0655, #0656, #0657, #0658
Closes #0662, #0660, #0661
Closes #0666, #0663, #0664, #0665
Closes #0669, #0667, #0668

- Add test_commands.sh: verifies all top-level commands and subcommands
- Add test_exit_codes.sh: verifies exit codes 0, 1, 2
- Add test_help.sh: verifies help format and stderr output
- Update run_tests.sh to export TPKG and PATH
- Fix group command exit codes: --help exits 0, no-args exits 2
- Deprecation tests: N/A since deprecated commands were removed
2026-06-19 14:44:22 -07:00
.forgejo/workflows fix: update test runner path to use PWD variable 2026-06-15 04:55:25 -07:00
cmd/tpkg feat: add comprehensive command-line tests and improve help output 2026-06-19 14:44:22 -07:00
contrib feat: add bootstrap script for tpkg installation 2026-06-15 05:00:22 -07:00
docs feat: implement environment variable overrides and documentation 2026-06-19 11:04:22 -07:00
internal feat: add shell completion support for bash and zsh 2026-06-19 13:42:39 -07:00
man feat: remove deprecated commands and flags from tpkg 2026-06-19 14:38:46 -07:00
pkg/models feat: implement package.json schema validation and update roadmap 2026-06-18 21:45:06 -07:00
roadmaps feat: implement command registry and refactor main.go to use it 2026-06-19 11:49:35 -07:00
tests feat: add comprehensive command-line tests and improve help output 2026-06-19 14:44:22 -07:00
tpkgs@cf58c8096c chore: update tpkgs submodule to latest commit 2026-06-19 10:25:07 -07:00
vendor feat: add progress bar for downloads with terminal detection 2026-06-15 19:35:44 -07:00
.gitignore feat: remove deprecated commands and flags from tpkg 2026-06-19 14:38:46 -07:00
.gitmodules feat: add tpkgs submodule and repository layout documentation 2026-06-18 21:41:31 -07:00
.golangci.yml feat: add ci workflow and golangci-lint configuration 2026-06-15 03:11:46 -07:00
.markdownlint.yaml feat: add markdownlint and pre-commit configuration files 2026-06-15 02:52:39 -07:00
.pre-commit-config.yaml feat: add vendor directory for dsnet/compress dependency and update pre-commit hooks to exclude vendor files 2026-06-15 03:14:36 -07:00
go.mod fix: downgrade go version to 1.24.11 in go.mod 2026-06-19 10:16:47 -07:00
go.sum feat: add progress bar for downloads with terminal detection 2026-06-15 19:35:44 -07:00
LICENSE feat: add MIT license file for project attribution 2026-06-19 10:49:37 -07:00
README.md docs: update README to remove quick start section and fix codeblock language 2026-06-19 10:36:52 -07:00
ROADMAP.md feat: add comprehensive command-line tests and improve help output 2026-06-19 14:44:22 -07:00

tpkg — POSIX package builder and manager

tpkg is a minimalist, POSIX-compliant packaging tool written in Go. It builds software from source, packs it into compressed tar archives with PAX extended headers, installs packages to the system, and resolves dependencies — all without dpkg, RPM, or any external package format.

Features

  • Build — execute build steps in an isolated temp directory, capture stdout/stderr, abort on failure.
  • Pack — create .tpkg.gz or .tpkg.bz2 archives with PAX extended headers and a replicated PKG-INFO file for integrity validation.
  • Install — install from a local .tpkg.gz file or resolve by name from a repository index. Detects file conflicts and prevents overwrites.
  • Remove — uninstall by package name, remove files in reverse order, clean up empty directories, update the database.
  • Dependency resolution — semver constraint parsing (>=, <=, =, ~>), transitive dependency resolution, cycle detection, topological install order.
  • Repository support — JSON-based repo index, tpkg update to refresh metadata, name-based install with full dep graph resolution.
  • Staging--root flag for container-safe installs to alternate roots; DESTDIR support in build steps.
  • POSIX sh test harness — shell-based integration tests covering pack roundtrip, conflict detection, root isolation, and dependency resolution.
  • No runtime dependencies — single static binary, pure Go, no external package manager required.

Installation

From source

go install git.lan.thwap.org/thwap/tpkg/cmd/tpkg@latest

Bootstrap script

sh -c "$(curl -fsSL https://git.lan.thwap.org/thwap/tpkg/raw/branch/main/contrib/bootstrap.sh)"

Or clone and run manually:

git clone https://git.lan.thwap.org/thwap/tpkg.git
cd tpkg
go build -o tpkg ./cmd/tpkg
install tpkg /usr/local/bin/

Usage

Creating a package

Create a package.yaml in your source tree:

name: hello
version: 1.0.0
build_steps:
  - ./configure --prefix=/usr
  - make
install_steps:
  - make install DESTDIR="$DESTDIR"
artifacts:
  - usr/bin/hello

Build and pack:

tpkg build --source=.
tpkg pack --source=./pkg --output=hello-1.0.0.tpkg.gz

Installing a package

# From a file
tpkg install hello-1.0.0.tpkg.gz

# With staging (no writes outside root)
tpkg install --root=/tmp/staging hello-1.0.0.tpkg.gz

# From a repository by name
tpkg install --repo=/var/lib/tpkg/repo.json hello

Removing a package

tpkg remove hello

Repository management

# Refresh the local repo index
tpkg update --url=https://repo.example.com/tpkg/repo.json

package.yaml reference

Field Type Description
name string Package name (required)
version string Semver major.minor.patch (required)
dependencies map name: constraint pairs (>=, <=, =, ~>)
build_steps list Shell commands run via sh -c during tpkg build
install_steps list Commands run with DESTDIR set to the staging root
artifacts list Files/dirs to include in the package archive

Archive format

tpkg archives are standard tar streams (optionally gzip or bzip2 compressed) with the following structure:

  1. PAX global extended header (TypeXGlobalHeader) — metadata (name, version, dependencies) as PAX key-value records.
  2. PKG-INFO — plain-text file replicating the PAX records for validation.
  3. File entries — each artifact as a regular tar entry.

On extraction, the PAX records and PKG-INFO are compared; any mismatch causes the operation to abort.

Database

Installed packages are tracked in /var/lib/tpkg/db.json (or under the --root prefix). Each entry records the package name, version, and a file manifest with SHA-256 checksums.

Commands

Command Description
tpkg build Run build steps in an isolated temp directory
tpkg pack Create a .tpkg.gz/.tpkg.bz2 archive from a staged root
tpkg install Install a package (from .tpkg.gz file or repo name)
tpkg remove Uninstall a package by name
tpkg update Refresh the local repository index

Development

Prerequisites

  • Go 1.25+

Building

git clone https://git.lan.thwap.org/thwap/tpkg.git
cd tpkg
go build -o tpkg ./cmd/tpkg

Running tests

# Go unit tests
go test ./...

# Shell integration test harness
go build -o tpkg ./cmd/tpkg
PATH="$PWD:$PATH" sh tests/run_tests.sh

Linting

golangci-lint run --config=.golangci.yml ./...

Project structure

├── cmd/tpkg/           # CLI entry point
│   ├── main.go        # Command dispatch
│   ├── pack.go        # tpkg pack
│   ├── build.go       # tpkg build
│   ├── install.go     # tpkg install
│   ├── remove.go      # tpkg remove
│   └── update.go      # tpkg update
├── internal/
│   ├── archive/       # PAX tar archive creation/extraction
│   ├── builder/       # Isolated build step execution
│   ├── compress/      # gzip/bzip2 compression wrappers
│   ├── db/            # Installed package database (JSON)
│   ├── pax/           # PAX extended header read/write
│   ├── resolver/      # Dependency graph resolver
│   └── version/       # Semver parsing and constraint matching
├── pkg/models/         # Core data structures
├── tests/              # POSIX shell test harness
├── man/                # Man page sources (mdoc)
└── contrib/            # Bootstrap script and example files

License

MIT