Expand description
§alpm-db
A library and command line interface for alpm-db structures used in Arch Linux Package Management (ALPM).
§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
The alpm-db crate provides modules and binaries for working with several components of an alpm-db:
- The
descmodule allows writing and parsing of alpm-db-desc files, which describe the metadata of an installed package. Thealpm-db-descCLI can create, format, and validate these files. - The
filesmodule allows writing and parsing of alpm-db-files files, which provide file listings and information on files considered for backup of an installed package. Thealpm-db-filesCLI can create, format, and validate these files.
§Examples
§Library
§Handle alpm-db-desc files programmatically
Parsing alpm-db-descv1 files:
use std::str::FromStr;
use alpm_db::desc::DbDescFileV1;
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");Parsing alpm-db-descv2 files:
use std::str::FromStr;
use alpm_db::desc::DbDescFileV2;
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);§Handle alpm-db-files files programmatically
use std::{path::PathBuf, str::FromStr};
use alpm_db::files::{DbFiles, DbFilesV1};
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());§CLI
§alpm-db-desc
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.
§alpm-db-files
# 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"§Features
cli: adds dependencies required for thealpm-db-descandalpm-db-filescommand line interfaces._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.
Modules§
- desc
- Handling of alpm-db-desc file format versions.
- error 🔒
- Error handling.
- files
- The representation of alpm-db-files files.
Enums§
- Error
- The error that can occur when working with the ALPM database desc files.
Statics§
- LOCALES 🔒