deb/control/package/
binary_control.rs

1// {{{ Copyright (c) Paul R. Tagliamonte <paultag@debian.org>, 2024
2//
3// Permission is hereby granted, free of charge, to any person obtaining a copy
4// of this software and associated documentation files (the "Software"), to deal
5// in the Software without restriction, including without limitation the rights
6// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
7// copies of the Software, and to permit persons to whom the Software is
8// furnished to do so, subject to the following conditions:
9//
10// The above copyright notice and this permission notice shall be included in
11// all copies or substantial portions of the Software.
12//
13// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
14// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
15// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
16// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
17// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
18// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
19// THE SOFTWARE. }}}
20
21use super::SourceName;
22use crate::{
23    architecture::Architecture,
24    control::{Number, Priority},
25    dependency::Dependency,
26    version::Version,
27};
28
29#[cfg(feature = "serde")]
30use ::serde::{Deserialize, Serialize};
31
32/// Debian binary (`.deb`) binary control file (sometimes called
33/// `DEBIAN/control` -- note the upper case), as seen in binary deb files.
34#[derive(Clone, Debug, PartialEq)]
35#[cfg_attr(feature = "serde", derive(Serialize, Deserialize))]
36#[cfg_attr(feature = "serde", serde(rename_all = "PascalCase"))]
37pub struct BinaryControl {
38    /// Binary package name
39    pub package: String,
40
41    /// The value of this field determines the package name, and is used to
42    /// generate file names by most installation tools.
43    pub source: Option<SourceName>,
44
45    /// Typically, this is the original package's [Version] number in whatever
46    /// form the program's author uses. It may also include a Debian revision
47    /// number (for non-native packages).
48    pub version: Version,
49
50    /// Archive Section that this package belongs to.
51    pub section: Option<String>,
52
53    /// Priority of the binary package.
54    pub priority: Option<Priority>,
55
56    /// Lists the [crate::architecture::Architecture] of the files contained
57    /// in this package. Common architectures are `amd64`, `armel`, `i386`,
58    /// ([crate::architecture::AMD64],
59    /// [crate::architecture::ARMEL],
60    /// [crate::architecture::I386]), etc.
61    pub architecture: Option<Architecture>,
62
63    /// If set, and set to "`yes`", this package is an essential package,
64    /// which has special-cased handling in `dpkg` and `apt`.
65    pub essential: Option<String>,
66
67    /// Size of the package's contents on-disk.
68    #[cfg_attr(feature = "serde", serde(rename = "Installed-Size"))]
69    pub installed_size: Option<Number<usize>>,
70
71    /// Name and email of the package's maintainer.
72    pub maintainer: String,
73
74    /// Description of this binary package's purpose.
75    pub description: String,
76
77    /// The upstream project home page url.
78    pub homepage: Option<String>,
79
80    /// Packages that this binary package requires be installed in order to
81    /// be fully installed.
82    pub depends: Option<Dependency>,
83
84    /// Packages which this binary package needs to be installed in all but
85    /// the most unusual installs. Removing one may cause breakage if their
86    /// purpose is not understood.
87    pub recommends: Option<Dependency>,
88
89    /// Packages which this binary package must not be installed at the same
90    /// time as.
91    pub conflicts: Option<Dependency>,
92
93    /// Packages which could be interesting to be installed along with this
94    /// package.
95    pub suggests: Option<Dependency>,
96
97    /// Virtual packages this package provides.
98    pub provides: Option<Dependency>,
99
100    /// Packages that were used to produce this binary file.
101    ///
102    /// This is used from within the archive to ensure that source packages
103    /// are not removed when their source is still included in a binary,
104    /// but it may also be helpful to use when tracking down issues or
105    /// triaging what packages need to be rebuilt.
106    #[cfg_attr(feature = "serde", serde(rename = "Built-Using"))]
107    pub built_using: Option<Dependency>,
108
109    /// Packages which will become broken by the installation of this binary
110    /// package.
111    pub breaks: Option<Dependency>,
112
113    /// Package makes another package better.
114    pub enhances: Option<Dependency>,
115
116    /// Packages which must be installed before this binary begins to
117    /// unpack.
118    pub pre_depends: Option<Dependency>,
119}
120
121// #[cfg(test)]
122// mod tests {
123//     #[cfg(feature = "serde")]
124//     use super::*;
125//
126//     #[cfg(feature = "serde")]
127//     mod serde {
128//         use super::*;
129//         use crate::{architecture, control::de};
130//
131//         macro_rules! test_package {
132//             ($name:ident, $data:expr, |$parsed:ident| $block:tt) => {
133//                 #[test]
134//                 fn $name() {
135//                     let $parsed = de::from_str::<Package>($data).unwrap();
136//                     $block
137//                 }
138//             };
139//         }
140// }
141
142// vim: foldmethod=marker