1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
//! # Srcinfo
//!
//! Srcinfo is a parser for makepkg's .SRCINFO file format.
//!
//! Srcinfo focuses on correctness of parsing, especially
//! with split packages and architecture specific fields.
//!
//! Srcinfo only aims to parse. This crate does not attempt to
//! perform any version comparison, dependency checking or any other
//! extra functionality.
//!
//! ## Quickstart
//!
//! [`Srcinfo`] is the main type for this crate.
//!
//! ```
//! # use srcinfo::Error;
//! use srcinfo::{Srcinfo, ArchVec};
//!
//! # fn test() -> Result<(), Error> {
//! // Create a srcinfo from a string
//! let srcinfo: Srcinfo = "
//! pkgbase = example
//! pkgver = 1.5.0
//! pkgrel = 5
//!
//! pkgname = example".parse()?;
//!
//! // Or a file
//! # let srcinfo = Srcinfo::from_path("tests/srcinfo/libc++")?;
//! let srcinfo = Srcinfo::from_path(".SRCINFO")?;
//!
//! // Reading global fields
//! // These fields were declared at the top of the PKGBUILD but may be overridden per package
//! println!("srcinfo {}-{}:", srcinfo.pkgbase(), srcinfo.version());
//!
//! // Print header comment
//! for comment in srcinfo.comment().lines() {
//! println!("comment: {}", comment);
//! }
//!
//! println!("url: {}", srcinfo.url().unwrap_or("none"));
//! for arch in srcinfo.arch() {
//! println!("arch: {}", arch);
//! }
//!
//! // reading makedepends and makedepends_$ARCH fields
//! for depends_arch in srcinfo.makedepends() {
//! for depend in depends_arch {
//! match depends_arch.arch() {
//! Some(arch) => println!("depend_{}: {}", arch, depend),
//! None => println!("depend: {}", depend),
//! }
//! }
//! }
//!
//! // Iterate through all the packages in this srcinfo
//! for pkg in srcinfo.pkgs() {
//! println!("pkg: {}", pkg.pkgname());
//! }
//!
//! // Get a specific package from the .SRCINFO
//! let pkg = srcinfo.pkg("libc++").unwrap();
//! println!("pkg: {}", pkg.pkgname());
//!
//! // Get the architectures of the package (may differ from the global architecture)
//! for arch in pkg.arch() {
//! println!("{} arch: {}", pkg.pkgname(), arch);
//! }
//!
//! // Get the depends of an x86_64 system
//! // This includes the `depends` and `depends_x86_64` fields
//! for depend in pkg.depends().arch("x86_64") {
//! println!("depend: {}", depend);
//! }
//!
//! // Convert the .SRCINFO back into a string
//! // the new sring will semanticly match the original .SRCINFO
//! // but field order and whitespace will change, comments will be removed
//! let srcinfo = srcinfo.to_string();
//! # Ok(())
//! # }
//! ```
pub use crate*;
pub use crate*;
pub use crate*;