Stage files into a build root and record their install metadata for packaging
Project description
pkgforge
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.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file pkgforge-0.1.0.tar.gz.
File metadata
- Download URL: pkgforge-0.1.0.tar.gz
- Upload date:
- Size: 33.6 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
5cc20afee5227c9cd17e3106b029f1fd24ca0b36e0add3983b44750533f4955a
|
|
| MD5 |
18fe3a6bb77d65d28b74ba3ad16c279f
|
|
| BLAKE2b-256 |
57884be2f395c0970089b082da2f79fcc815d4afdf02a0ae3225a75c125b7a46
|
Provenance
The following attestation bundles were made for pkgforge-0.1.0.tar.gz:
Publisher:
release.yml on jose-pr/pkgforge
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
pkgforge-0.1.0.tar.gz -
Subject digest:
5cc20afee5227c9cd17e3106b029f1fd24ca0b36e0add3983b44750533f4955a - Sigstore transparency entry: 2195357512
- Sigstore integration time:
-
Permalink:
jose-pr/pkgforge@16ea5c57589503eb83d6ca3d7c721a3c0ecac554 -
Branch / Tag:
refs/tags/v0.1.0 - Owner: https://github.com/jose-pr
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
release.yml@16ea5c57589503eb83d6ca3d7c721a3c0ecac554 -
Trigger Event:
push
-
Statement type:
File details
Details for the file pkgforge-0.1.0-py3-none-any.whl.
File metadata
- Download URL: pkgforge-0.1.0-py3-none-any.whl
- Upload date:
- Size: 22.6 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
4530bc15d592d86140fa5ff44b1179889f9927a1837bd30226f9d76f2760d249
|
|
| MD5 |
9c1b0a17c58eaa6a9289e688f19181b7
|
|
| BLAKE2b-256 |
de5f2d23c849db61f25a0c2e97d88c2d5fd27e2a90274df7c891ae5ccd5990c0
|
Provenance
The following attestation bundles were made for pkgforge-0.1.0-py3-none-any.whl:
Publisher:
release.yml on jose-pr/pkgforge
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
pkgforge-0.1.0-py3-none-any.whl -
Subject digest:
4530bc15d592d86140fa5ff44b1179889f9927a1837bd30226f9d76f2760d249 - Sigstore transparency entry: 2195357534
- Sigstore integration time:
-
Permalink:
jose-pr/pkgforge@16ea5c57589503eb83d6ca3d7c721a3c0ecac554 -
Branch / Tag:
refs/tags/v0.1.0 - Owner: https://github.com/jose-pr
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
release.yml@16ea5c57589503eb83d6ca3d7c721a3c0ecac554 -
Trigger Event:
push
-
Statement type: