Crate alpm_srcinfo

Source
Expand description

§alpm-srcinfo

A library and command line tool for the specification, parsing and linting of Arch Linux Package Management (ALPM) SRCINFO files.

SRCINFO files describe a PKGBUILD file in a way that doesn’t require an interactive shell to evaluate it.

§Documentation

§Examples

§Commandline

§Inspect SRCINFO packages

The following command takes a .SRCINFO file and outputs the merged and compiled details of all (split-)packages for a specific architecture as structured data.

cat > "$SRCINFO_TEMPFILE" << EOF
pkgbase = example
    pkgver = 1.0.0
    epoch = 1
    pkgrel = 1
    pkgdesc = A project that does something
    url = https://example.org/
    arch = x86_64
    depends = glibc
    optdepends = python: for special-python-script.py
    makedepends = cmake
    checkdepends = extra-test-tool

pkgname = example
    depends = glibc
    depends = gcc-libs
EOF

alpm-srcinfo format-packages "$SRCINFO_TEMPFILE" --architecture x86_64 --pretty > "$SRCINFO_OUTPUT"
§PKGBUILD to SRCINFO conversion

The following command takes a PKGBUILD file and outputs a .SRCINFO from the extracted metadata.

alpm-srcinfo create "$PKGBUILD_IN" > "$SRCINFO_OUT"

§Library

use alpm_srcinfo::{SourceInfoV1, MergedPackage};
use alpm_types::{Architecture, PackageRelation, Name};

let source_info_data = r#"
pkgbase = example
    pkgver = 1.0.0
    epoch = 1
    pkgrel = 1
    pkgdesc = A project that does something
    url = https://example.org/
    arch = x86_64
    depends = glibc
    optdepends = python: for special-python-script.py
    makedepends = cmake
    checkdepends = extra-test-tool

pkgname = example
    depends = glibc
    depends = gcc-libs
"#;

// Parse the file. This errors if the file cannot be parsed, is missing data or contains invalid data.
let source_info = SourceInfoV1::from_string(source_info_data)?;

// Get all merged package representations for the x86_64 architecture.
let mut packages: Vec<MergedPackage> = source_info.packages_for_architecture(Architecture::X86_64).collect();
let package = packages.remove(0);

assert_eq!(package.name, Name::new("example")?);
assert_eq!(package.architecture, Architecture::X86_64);
assert_eq!(package.dependencies, vec![
    PackageRelation::new(Name::new("glibc")?, None),
    PackageRelation::new(Name::new("gcc-libs")?, None)
]);

§Features

  • cli adds the commandline handling needed for the alpm-srcinfo binary (enabled by default).
  • _winnow-debug enables the winnow/debug feature, which shows the exact parsing process of winnow.

§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.

Re-exports§

pub use error::Error;
pub use source_info::SourceInfo;
pub use source_info::v1::SourceInfoV1;
pub use source_info::v1::merged::MergedPackage;

Modules§

cli
Commandline argument handling.
commands
Functions called from the binary.
error
All error types that are exposed by this crate.
pkgbuild_bridge
Convert untyped and unchecked BridgeOutput into a well-formed SourceInfoV1.
schema 🔒
Schemas for SRCINFO data.
source_info
Data representations and integrations for reading of SRCINFO data.

Enums§

SourceInfoSchema
An enum tracking all available SRCINFO schemas.