alpm-db
A library for Arch Linux Package Management (ALPM) system databases.
Documentation
- https://alpm.archlinux.page/rustdoc/alpm_db/ for development version of the crate.
- https://docs.rs/alpm-db-desc/latest/alpm_db/ for released version of the crate.
Overview
alpm-db crate contains desc module, which provides functionality for writing
and parsing of ALPM DB desc files.
These desc files describe the metadata of installed packages on a
system relying on ALPM.
They contain fields such as the package name, version, architecture,
and dependencies.
It also contains a commandline interface (CLI) binary alpm-db-desc,
which can be used to create, parse, format and validate ALPM DB desc files.
Examples
Library
Parsing alpm-db-descv1 files:
use std::str::FromStr; use alpm_db::desc::DbDescFileV1; fn main() -> Result<(), alpm_db::Error> { let desc_data = r#"%NAME% foo %VERSION% 1.0.0-1 %BASE% foo %DESC% An example package %URL% https://example.org %ARCH% x86_64 %BUILDDATE% 1733737242 %INSTALLDATE% 1733737243 %PACKAGER% Foobar McFooface <foobar@mcfooface.org> %SIZE% 123 %VALIDATION% pgp "#; let desc = DbDescFileV1::from_str(desc_data)?; assert_eq!(desc.name.to_string(), "foo"); assert_eq!(desc.arch.to_string(), "x86_64"); Ok(()) }
Parsing alpm-db-descv2 files:
use std::str::FromStr; use alpm_db::desc::DbDescFileV2; fn main() -> Result<(), alpm_db::Error> { let desc_data = r#"%NAME% foo %VERSION% 1.0.0-1 %BASE% foo %DESC% An example package %URL% https://example.org %ARCH% x86_64 %BUILDDATE% 1733737242 %INSTALLDATE% 1733737243 %PACKAGER% Foobar McFooface <foobar@mcfooface.org> %SIZE% 123 %VALIDATION% pgp %XDATA% pkgtype = pkg key2 = value2 "#; let desc = DbDescFileV2::from_str(desc_data)?; assert_eq!(desc.name.to_string(), "foo"); assert_eq!(desc.arch.to_string(), "x86_64"); assert_eq!(desc.xdata.len(), 2); Ok(()) }
Commandline
Create a database desc file and format it as JSON:
cat > "$DBDESC_INPUT" <<'EOF'
%NAME%
foo
%VERSION%
1.0.0-1
%BASE%
foo
%DESC%
An example package
%URL%
https://example.org/
%ARCH%
x86_64
%BUILDDATE%
1733737242
%INSTALLDATE%
1733737243
%PACKAGER%
Foobar McFooface <foobar@mcfooface.org>
%SIZE%
123
%VALIDATION%
pgp
EOF
alpm-db-desc format "$DBDESC_INPUT" --output-format json --pretty > "$DBDESC_OUTPUT"
The output file ($DBDESC_OUTPUT) contains the structured JSON representation of
the parsed desc data.
Features
cli: enables the commandline interface for thealpm-db-descbinary._winnow-debug: enables thewinnow/debugfeature for step-by-step parser debugging.
Contributing
Please refer to the contribution guidelines to learn how to contribute to this project.
License
This project can be used under the terms of the Apache-2.0 or MIT. Contributions to this project, unless noted otherwise, are automatically licensed under the terms of both of those licenses.