Skip to main content

pkgforge

CI Docs Python License: MIT

Stage files into a build root and record their intended install metadata (mode, owner, group, type, and free-form key/value meta) in a file DB (JSON Lines, YAML, or SQLite), then dump that DB into packaging manifests — an RPM %files list or Debian install + permissions files.

pkgforge is a small, dependency-light helper for unattended build pipelines on Linux: install a source into place, remember how it should be owned and permissioned, and emit that record for the packager.

Install

pip install pkgforge

Requires Python 3.9+. Runtime operations use POSIX facilities (chmod, chown, symlinks, hardlinks), so runtime targets Linux; the CLI and --help import cleanly on any platform. Tar-family archives extract via stdlib tarfile — no external archiver needed; bsdtar is only a fallback for other formats (e.g. .iso).

Quick start

export PKGFORGE_ROOT=/tmp/stage PKGFORGE_DB=/tmp/files.jsonl

pkgforge initdb
pkgforge install -p -m 755 -o root -g root ./build/tool /usr/bin
pkgforge install -p -m 640 -o root -g adm  ./tool.conf  /etc
pkgforge scan --missing /usr
pkgforge dbdump -f rpmspecfiles rpm-files.txt
pkgforge dbdump -f debian debian/

See examples/stage_and_package.sh for a runnable end-to-end walkthrough.

Commands

Command Purpose
initdb create or reset (truncate) the file DB
install [opts] SRC… DEST stage a source and record its entry
scan [opts] PATH walk a path and record an entry per file (--missing fills gaps)
compact collapse an append-log DB to one record per live path
dbdump -f FORMAT [OUT] render the DB into a packaging manifest

Global options (also read from the environment):

Option Env Meaning
--db PATH PKGFORGE_DB file DB to read/write (- for stdout/stdin)
--db-format FMT PKGFORGE_DB_FORMAT backend: jsonl / yaml / sqlite (else from the --db suffix)
--buildroot DIR PKGFORGE_ROOT staging root that maps to / in the DB

Global flags work before or after the subcommand.

Storage backends

The file DB has three interchangeable backends — every command behaves the same regardless of which is used:

Format Extensions Model
jsonl (default) .jsonl, .ndjson append-only JSON Lines
yaml .yaml, .yml append-only YAML
sqlite .db, .sqlite, .sqlite3 SQLite store, upserted in place

The backend is picked from the --db extension (override with --db-format); reading an existing file auto-detects its actual format.

Dump formats

Format Output
rpmspecfiles RPM %files lines (%attr(...), %dir, meta.rpmprefix) to a file or -
debian install + permissions files into an output directory (or -, sectioned)
# rpmspecfiles
%attr(755,root,root) "/usr/bin/tool"
%config %attr(640,root,adm) "/etc/tool.conf"

# debian/install            # debian/permissions
usr/bin/tool usr/bin        /usr/bin/tool 755 root root
etc/tool.conf etc           /etc/tool.conf 640 root adm

File entries

Each entry records mode (octal string, e.g. 644), owner, group, type (file/directory/symlink), and a meta map. Two sentinels defer a field to the staged file: - ("leave at OS default") and -- ("resolve from disk").

Exclude / filter syntax

An --exclude statement is an optional leading ! (negate), zero or more inline tests, and a trailing glob:

(?type:file)**/*.pyc        # every .pyc file
!(?meta:keep=1)**/tmp/**     # keep entries tagged keep=1 under tmp/

Tests are (?type:file|directory|symlink) and (?meta:key=value); prefix a test name with ! ((?!type:file)) to invert just that test.

Documentation

Full docs at https://jose-pr.github.io/pkgforge/ — command reference, file-DB model, exclude grammar, dump formats, and the API reference.

Development

git clone https://github.com/jose-pr/pkgforge && cd pkgforge
python -m venv .venv && . .venv/bin/activate
pip install -e ".[dev,docs]"

pytest -q                       # tests
python benchmarks/run.py        # benchmarks (add --save to record)
mkdocs serve                    # docs preview at http://127.0.0.1:8000

License

MIT — see LICENSE.

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

pkgforge-0.1.1.tar.gz (41.9 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

pkgforge-0.1.1-py3-none-any.whl (31.4 kB view details)

Uploaded Python 3

File details

Details for the file pkgforge-0.1.1.tar.gz.

File metadata

  • Download URL: pkgforge-0.1.1.tar.gz
  • Upload date:
  • Size: 41.9 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/7.0.0 CPython/3.13.14

File hashes

Hashes for pkgforge-0.1.1.tar.gz
Algorithm Hash digest
SHA256 f409b85baf0d813e8bdb11eb8e4144f0458e2547d71bafff9428eadf4291f4d2
MD5 e1753bcc36e0b2553dd9dfc6ea80ba91
BLAKE2b-256 6aa41d7e016c1197fcaddc101afa0eac07764c1745227070792e55080b13fc73

See more details on using hashes here.

Provenance

The following attestation bundles were made for pkgforge-0.1.1.tar.gz:

Publisher: release.yml on jose-pr/pkgforge

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file pkgforge-0.1.1-py3-none-any.whl.

File metadata

  • Download URL: pkgforge-0.1.1-py3-none-any.whl
  • Upload date:
  • Size: 31.4 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/7.0.0 CPython/3.13.14

File hashes

Hashes for pkgforge-0.1.1-py3-none-any.whl
Algorithm Hash digest
SHA256 ab2f7484ccf37cf4326738eb98f5c34b16b1be3a6ad277be26e0bf81ba2cc2ec
MD5 b1dcb47df0d62f382965001e9dc891ef
BLAKE2b-256 f7c9c782e1e74afed5ca6e98877ac45ec9a8bc52d02ebca12ea2a4ebd369925a

See more details on using hashes here.

Provenance

The following attestation bundles were made for pkgforge-0.1.1-py3-none-any.whl:

Publisher: release.yml on jose-pr/pkgforge

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Release history Release notifications | RSS feed

0.1.2

2 files

This release

0.1.1 This release

2 files

0.1.0

2 files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page