| Crates.io | alpm-db |
| lib.rs | alpm-db |
| version | 0.2.1 |
| created_at | 2025-11-15 16:18:12.834251+00 |
| updated_at | 2026-01-11 14:29:37.435393+00 |
| description | Library and command line interface for handling alpm-db structures |
| homepage | https://alpm.archlinux.page |
| repository | https://gitlab.archlinux.org/archlinux/alpm/alpm |
| max_upload_size | |
| id | 1934521 |
| size | 310,261 |
A library and command line interface for alpm-db structures used in Arch Linux Package Management (ALPM).
The alpm-db crate provides modules and binaries for working with several components of an alpm-db:
desc module allows writing and parsing of alpm-db-desc files, which describe the metadata of an installed package.
The alpm-db-desc CLI can create, format, and validate these files.files module allows writing and parsing of alpm-db-files files, which provide file listings and information on files considered for backup of an installed package.
The alpm-db-files CLI can create, format, and validate these files.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%
sha256
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%
sha256
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(())
# }
use std::{path::PathBuf, str::FromStr};
use alpm_db::files::{DbFiles, DbFilesV1};
# fn main() -> testresult::TestResult {
let data = r#"%FILES%
usr/
usr/bin/
usr/bin/foo
"#;
let paths = vec![
PathBuf::from("usr/"),
PathBuf::from("usr/bin/"),
PathBuf::from("usr/bin/foo"),
];
// Create a DbFiles from a string.
let files_from_str = DbFiles::V1(DbFilesV1::from_str(data)?);
// Create a DbFiles from list of paths.
let files_from_paths = DbFiles::V1(DbFilesV1::try_from(paths)?);
assert_eq!(files_from_str.as_ref(), files_from_paths.as_ref());
# Ok(())
# }
Create a database desc file from CLI arguments:
alpm-db-desc create v2 \
--name foo \
--version 1.0.0-1 \
--base foo \
--description "An example package" \
--url https://example.org/ \
--arch x86_64 \
--builddate 1733737242 \
--installdate 1733737243 \
--packager "Foobar McFooface <foobar@mcfooface.org>" \
--size 123 \
--validation sha256 \
--validation pgp \
--optdepends libfoo,libbar \
--optdepends "libdesc: Optional dependency with description" \
--xdata pkgtype=pkg \
"$DBDESC"
The output file ($DBDESC) contains the desc data in alpm-db-descv1 format.
Format db desc data as JSON:
alpm-db-desc format "$DBDESC" --output-format json --pretty > "$DBDESC_JSON"
The output file ($DBDESC_JSON) contains the structured JSON representation of
the parsed desc data.
# Create an alpm-db-files file from an input directory.
alpm-db-files create --output "$ALPM_DB_FILES_CREATE_OUTPUT" "$ALPM_DB_FILES_CREATE_INPUT_DIR"
# Format an alpm-db-files file as JSON.
alpm-db-files format --input-file "$ALPM_DB_FILES_FORMAT_INPUT_FILE" --output "$ALPM_DB_FILES_FORMAT_OUTPUT" --pretty
# Validate an alpm-db-files file.
alpm-db-files validate --input-file "$ALPM_DB_FILES_VALIDATE_INPUT_FILE"
cli: adds dependencies required for the alpm-db-desc and alpm-db-files command line interfaces._winnow-debug: enables the winnow/debug feature for step-by-step parser debugging.Please refer to the contribution guidelines to learn how to contribute to this project.
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.