Debian Codegraph @

src/cache.rs

raw symbols SCIP
1 //! Contains Cache related structs.
2
3 use stdrust-analyzer cargo std https://github.com/rust-lang/rust/library/std crate/::cellrust-analyzer cargo core https://github.com/rust-lang/rust/library/core cell/::OnceCellrust-analyzer cargo core https://github.com/rust-lang/rust/library/core cell/once/OnceCell#;
4 use stdrust-analyzer cargo std https://github.com/rust-lang/rust/library/std crate/::fsrust-analyzer cargo std https://github.com/rust-lang/rust/library/std fs/;
5 use stdrust-analyzer cargo std https://github.com/rust-lang/rust/library/std crate/::pathrust-analyzer cargo std https://github.com/rust-lang/rust/library/std path/::Pathrust-analyzer cargo std https://github.com/rust-lang/rust/library/std path/Path#;
6
7 use cxxrust-analyzer cargo cxx 1.0.199 crate/::{Exceptionrust-analyzer cargo cxx 1.0.199 exception/Exception#, UniquePtrrust-analyzer cargo cxx 1.0.199 unique_ptr/UniquePtr#};
8
9 use craterust-analyzer cargo rust-apt 0.8.0 crate/::configrust-analyzer cargo rust-apt 0.8.0 config/::{init_config_systemrust-analyzer cargo rust-apt 0.8.0 config/init_config_system()., Configrust-analyzer cargo rust-apt 0.8.0 config/Config#};
10 use craterust-analyzer cargo rust-apt 0.8.0 crate/::depcacherust-analyzer cargo rust-apt 0.8.0 depcache/::DepCacherust-analyzer cargo rust-apt 0.8.0 depcache/DepCache#;
11 use craterust-analyzer cargo rust-apt 0.8.0 crate/::errorrust-analyzer cargo rust-apt 0.8.0 error/::AptErrorsrust-analyzer cargo rust-apt 0.8.0 error/AptErrors#;
12 use craterust-analyzer cargo rust-apt 0.8.0 crate/::progressrust-analyzer cargo rust-apt 0.8.0 progress/::{AcquireProgressrust-analyzer cargo rust-apt 0.8.0 progress/AcquireProgress#, InstallProgressrust-analyzer cargo rust-apt 0.8.0 progress/InstallProgress#, OperationProgressrust-analyzer cargo rust-apt 0.8.0 progress/OperationProgress#};
13 use craterust-analyzer cargo rust-apt 0.8.0 crate/::rawrust-analyzer cargo rust-apt 0.8.0 raw/::{
14 create_cacherust-analyzer cargo rust-apt 0.8.0 cache/raw/create_cache()., create_pkgmanagerrust-analyzer cargo rust-apt 0.8.0 pkgmanager/raw/create_pkgmanager()., create_problem_resolverrust-analyzer cargo rust-apt 0.8.0 pkgmanager/raw/create_problem_resolver()., IntoRawIterrust-analyzer cargo rust-apt 0.8.0 raw/IntoRawIter#, IterPkgIteratorrust-analyzer cargo rust-apt 0.8.0 raw/IterPkgIterator#,
15 PackageManagerrust-analyzer cargo rust-apt 0.8.0 pkgmanager/raw/PackageManager#, PkgCacheFilerust-analyzer cargo rust-apt 0.8.0 cache/raw/PkgCacheFile#, PkgIteratorrust-analyzer cargo rust-apt 0.8.0 iterators/package/raw/PkgIterator#, ProblemResolverrust-analyzer cargo rust-apt 0.8.0 pkgmanager/raw/ProblemResolver#,
16 };
17 use craterust-analyzer cargo rust-apt 0.8.0 crate/::recordsrust-analyzer cargo rust-apt 0.8.0 records/::PackageRecordsrust-analyzer cargo rust-apt 0.8.0 records/PackageRecords#;
18 use craterust-analyzer cargo rust-apt 0.8.0 crate/::utilrust-analyzer cargo rust-apt 0.8.0 util/::{apt_lockrust-analyzer cargo rust-apt 0.8.0 util/apt_lock()., apt_unlockrust-analyzer cargo rust-apt 0.8.0 util/apt_unlock()., apt_unlock_innerrust-analyzer cargo rust-apt 0.8.0 util/apt_unlock_inner().};
19 use craterust-analyzer cargo rust-apt 0.8.0 crate/::Packagerust-analyzer cargo rust-apt 0.8.0 iterators/package/Package#;
20
21 /// Selection of Upgrade type
22 #[repr(i32)]
23 pub enum Upgraderust-analyzer cargo rust-apt 0.8.0 cache/Upgrade# {
24 /// Upgrade will Install new and Remove packages in addition to
25 /// upgrading them.
26 ///
27 /// Equivalent to `apt full-upgrade` and `apt-get dist-upgrade`.
28 FullUpgraderust-analyzer cargo rust-apt 0.8.0 cache/Upgrade#FullUpgrade# = 0,
29 /// Upgrade will Install new but not Remove packages.
30 ///
31 /// Equivalent to `apt upgrade`.
32 Upgraderust-analyzer cargo rust-apt 0.8.0 cache/Upgrade#Upgrade# = 1,
33 /// Upgrade will Not Install new or Remove packages.
34 ///
35 /// Equivalent to `apt-get upgrade`.
36 SafeUpgraderust-analyzer cargo rust-apt 0.8.0 cache/Upgrade#SafeUpgrade# = 3,
37 }
38
39 /// Selection of how to sort
40 enum Sortrust-analyzer cargo rust-apt 0.8.0 cache/Sort# {
41 /// Disable the sort method.
42 Disablerust-analyzer cargo rust-apt 0.8.0 cache/Sort#Disable#,
43 /// Enable the sort method.
44 Enablerust-analyzer cargo rust-apt 0.8.0 cache/Sort#Enable#,
45 /// Reverse the sort method.
46 Reverserust-analyzer cargo rust-apt 0.8.0 cache/Sort#Reverse#,
47 }
48
49 /// Determines how to sort packages from the Cache.
50 pub struct PackageSortrust-analyzer cargo rust-apt 0.8.0 cache/PackageSort# {
51 namesrust-analyzer cargo rust-apt 0.8.0 cache/PackageSort#names.: bool,
52 upgradablerust-analyzer cargo rust-apt 0.8.0 cache/PackageSort#upgradable.: Sortrust-analyzer cargo rust-apt 0.8.0 cache/Sort#,
53 virtual_pkgsrust-analyzer cargo rust-apt 0.8.0 cache/PackageSort#virtual_pkgs.: Sortrust-analyzer cargo rust-apt 0.8.0 cache/Sort#,
54 installedrust-analyzer cargo rust-apt 0.8.0 cache/PackageSort#installed.: Sortrust-analyzer cargo rust-apt 0.8.0 cache/Sort#,
55 auto_installedrust-analyzer cargo rust-apt 0.8.0 cache/PackageSort#auto_installed.: Sortrust-analyzer cargo rust-apt 0.8.0 cache/Sort#,
56 auto_removablerust-analyzer cargo rust-apt 0.8.0 cache/PackageSort#auto_removable.: Sortrust-analyzer cargo rust-apt 0.8.0 cache/Sort#,
57 }
58
59 impl Defaultrust-analyzer cargo core https://github.com/rust-lang/rust/library/core default/Default# for PackageSortrust-analyzer cargo rust-apt 0.8.0 cache/PackageSort# {
60 fn defaultrust-analyzer cargo rust-apt 0.8.0 cache/impl#[PackageSort][Default]default().() -> PackageSortrust-analyzer cargo rust-apt 0.8.0 cache/PackageSort# {
61 PackageSortrust-analyzer cargo rust-apt 0.8.0 cache/PackageSort# {
62 namesrust-analyzer cargo rust-apt 0.8.0 cache/PackageSort#names.: false,
63 upgradablerust-analyzer cargo rust-apt 0.8.0 cache/PackageSort#upgradable.: Sortrust-analyzer cargo rust-apt 0.8.0 cache/Sort#::Disablerust-analyzer cargo rust-apt 0.8.0 cache/Sort#Disable#,
64 virtual_pkgsrust-analyzer cargo rust-apt 0.8.0 cache/PackageSort#virtual_pkgs.: Sortrust-analyzer cargo rust-apt 0.8.0 cache/Sort#::Disablerust-analyzer cargo rust-apt 0.8.0 cache/Sort#Disable#,
65 installedrust-analyzer cargo rust-apt 0.8.0 cache/PackageSort#installed.: Sortrust-analyzer cargo rust-apt 0.8.0 cache/Sort#::Disablerust-analyzer cargo rust-apt 0.8.0 cache/Sort#Disable#,
66 auto_installedrust-analyzer cargo rust-apt 0.8.0 cache/PackageSort#auto_installed.: Sortrust-analyzer cargo rust-apt 0.8.0 cache/Sort#::Disablerust-analyzer cargo rust-apt 0.8.0 cache/Sort#Disable#,
67 auto_removablerust-analyzer cargo rust-apt 0.8.0 cache/PackageSort#auto_removable.: Sortrust-analyzer cargo rust-apt 0.8.0 cache/Sort#::Disablerust-analyzer cargo rust-apt 0.8.0 cache/Sort#Disable#,
68 }
69 }
70 }
71
72 impl PackageSortrust-analyzer cargo rust-apt 0.8.0 cache/PackageSort# {
73 /// Packages will be sorted by their names a -> z.
74 pub fn namesrust-analyzer cargo rust-apt 0.8.0 cache/impl#[PackageSort]names().(mut self) -> Selfrust-analyzer cargo rust-apt 0.8.0 cache/impl#[PackageSort] {
75 self.namesrust-analyzer cargo rust-apt 0.8.0 cache/PackageSort#names. = true;
76 self
77 }
78
79 /// Only packages that are upgradable will be included.
80 pub fn upgradablerust-analyzer cargo rust-apt 0.8.0 cache/impl#[PackageSort]upgradable().(mut self) -> Selfrust-analyzer cargo rust-apt 0.8.0 cache/impl#[PackageSort] {
81 self.upgradablerust-analyzer cargo rust-apt 0.8.0 cache/PackageSort#upgradable. = Sortrust-analyzer cargo rust-apt 0.8.0 cache/Sort#::Enablerust-analyzer cargo rust-apt 0.8.0 cache/Sort#Enable#;
82 self
83 }
84
85 /// Only packages that are NOT upgradable will be included.
86 pub fn not_upgradablerust-analyzer cargo rust-apt 0.8.0 cache/impl#[PackageSort]not_upgradable().(mut self) -> Selfrust-analyzer cargo rust-apt 0.8.0 cache/impl#[PackageSort] {
87 self.upgradablerust-analyzer cargo rust-apt 0.8.0 cache/PackageSort#upgradable. = Sortrust-analyzer cargo rust-apt 0.8.0 cache/Sort#::Reverserust-analyzer cargo rust-apt 0.8.0 cache/Sort#Reverse#;
88 self
89 }
90
91 /// Virtual packages will be included.
92 pub fn include_virtualrust-analyzer cargo rust-apt 0.8.0 cache/impl#[PackageSort]include_virtual().(mut self) -> Selfrust-analyzer cargo rust-apt 0.8.0 cache/impl#[PackageSort] {
93 self.virtual_pkgsrust-analyzer cargo rust-apt 0.8.0 cache/PackageSort#virtual_pkgs. = Sortrust-analyzer cargo rust-apt 0.8.0 cache/Sort#::Enablerust-analyzer cargo rust-apt 0.8.0 cache/Sort#Enable#;
94 self
95 }
96
97 /// Only Virtual packages will be included.
98 pub fn only_virtualrust-analyzer cargo rust-apt 0.8.0 cache/impl#[PackageSort]only_virtual().(mut self) -> Selfrust-analyzer cargo rust-apt 0.8.0 cache/impl#[PackageSort] {
99 self.virtual_pkgsrust-analyzer cargo rust-apt 0.8.0 cache/PackageSort#virtual_pkgs. = Sortrust-analyzer cargo rust-apt 0.8.0 cache/Sort#::Reverserust-analyzer cargo rust-apt 0.8.0 cache/Sort#Reverse#;
100 self
101 }
102
103 /// Only packages that are installed will be included.
104 pub fn installedrust-analyzer cargo rust-apt 0.8.0 cache/impl#[PackageSort]installed().(mut self) -> Selfrust-analyzer cargo rust-apt 0.8.0 cache/impl#[PackageSort] {
105 self.installedrust-analyzer cargo rust-apt 0.8.0 cache/PackageSort#installed. = Sortrust-analyzer cargo rust-apt 0.8.0 cache/Sort#::Enablerust-analyzer cargo rust-apt 0.8.0 cache/Sort#Enable#;
106 self
107 }
108
109 /// Only packages that are NOT installed will be included.
110 pub fn not_installedrust-analyzer cargo rust-apt 0.8.0 cache/impl#[PackageSort]not_installed().(mut self) -> Selfrust-analyzer cargo rust-apt 0.8.0 cache/impl#[PackageSort] {
111 self.installedrust-analyzer cargo rust-apt 0.8.0 cache/PackageSort#installed. = Sortrust-analyzer cargo rust-apt 0.8.0 cache/Sort#::Reverserust-analyzer cargo rust-apt 0.8.0 cache/Sort#Reverse#;
112 self
113 }
114
115 /// Only packages that are auto installed will be included.
116 pub fn auto_installedrust-analyzer cargo rust-apt 0.8.0 cache/impl#[PackageSort]auto_installed().(mut self) -> Selfrust-analyzer cargo rust-apt 0.8.0 cache/impl#[PackageSort] {
117 self.auto_installedrust-analyzer cargo rust-apt 0.8.0 cache/PackageSort#auto_installed. = Sortrust-analyzer cargo rust-apt 0.8.0 cache/Sort#::Enablerust-analyzer cargo rust-apt 0.8.0 cache/Sort#Enable#;
118 self
119 }
120
121 /// Only packages that are manually installed will be included.
122 pub fn manually_installedrust-analyzer cargo rust-apt 0.8.0 cache/impl#[PackageSort]manually_installed().(mut self) -> Selfrust-analyzer cargo rust-apt 0.8.0 cache/impl#[PackageSort] {
123 self.auto_installedrust-analyzer cargo rust-apt 0.8.0 cache/PackageSort#auto_installed. = Sortrust-analyzer cargo rust-apt 0.8.0 cache/Sort#::Reverserust-analyzer cargo rust-apt 0.8.0 cache/Sort#Reverse#;
124 self
125 }
126
127 /// Only packages that are auto removable will be included.
128 pub fn auto_removablerust-analyzer cargo rust-apt 0.8.0 cache/impl#[PackageSort]auto_removable().(mut self) -> Selfrust-analyzer cargo rust-apt 0.8.0 cache/impl#[PackageSort] {
129 self.auto_removablerust-analyzer cargo rust-apt 0.8.0 cache/PackageSort#auto_removable. = Sortrust-analyzer cargo rust-apt 0.8.0 cache/Sort#::Enablerust-analyzer cargo rust-apt 0.8.0 cache/Sort#Enable#;
130 self
131 }
132
133 /// Only packages that are NOT auto removable will be included.
134 pub fn not_auto_removablerust-analyzer cargo rust-apt 0.8.0 cache/impl#[PackageSort]not_auto_removable().(mut self) -> Selfrust-analyzer cargo rust-apt 0.8.0 cache/impl#[PackageSort] {
135 self.auto_removablerust-analyzer cargo rust-apt 0.8.0 cache/PackageSort#auto_removable. = Sortrust-analyzer cargo rust-apt 0.8.0 cache/Sort#::Reverserust-analyzer cargo rust-apt 0.8.0 cache/Sort#Reverse#;
136 self
137 }
138 }
139
140 /// The main struct for accessing any and all `apt` data.
141 pub struct Cacherust-analyzer cargo rust-apt 0.8.0 cache/Cache# {
142 pub(craterust-analyzer cargo rust-apt 0.8.0 crate/) ptrrust-analyzer cargo rust-apt 0.8.0 cache/Cache#ptr.: UniquePtrrust-analyzer cargo cxx 1.0.199 unique_ptr/UniquePtr#<PkgCacheFilerust-analyzer cargo rust-apt 0.8.0 cache/raw/PkgCacheFile#>,
143 depcacherust-analyzer cargo rust-apt 0.8.0 cache/Cache#depcache.: OnceCellrust-analyzer cargo core https://github.com/rust-lang/rust/library/core cell/once/OnceCell#<DepCacherust-analyzer cargo rust-apt 0.8.0 depcache/DepCache#>,
144 recordsrust-analyzer cargo rust-apt 0.8.0 cache/Cache#records.: OnceCellrust-analyzer cargo core https://github.com/rust-lang/rust/library/core cell/once/OnceCell#<PackageRecordsrust-analyzer cargo rust-apt 0.8.0 records/PackageRecords#>,
145 pkgmanagerrust-analyzer cargo rust-apt 0.8.0 cache/Cache#pkgmanager.: OnceCellrust-analyzer cargo core https://github.com/rust-lang/rust/library/core cell/once/OnceCell#<UniquePtrrust-analyzer cargo cxx 1.0.199 unique_ptr/UniquePtr#<PackageManagerrust-analyzer cargo rust-apt 0.8.0 pkgmanager/raw/PackageManager#>>,
146 problem_resolverrust-analyzer cargo rust-apt 0.8.0 cache/Cache#problem_resolver.: OnceCellrust-analyzer cargo core https://github.com/rust-lang/rust/library/core cell/once/OnceCell#<UniquePtrrust-analyzer cargo cxx 1.0.199 unique_ptr/UniquePtr#<ProblemResolverrust-analyzer cargo rust-apt 0.8.0 pkgmanager/raw/ProblemResolver#>>,
147 local_debsrust-analyzer cargo rust-apt 0.8.0 cache/Cache#local_debs.: Vecrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/Vec#<Stringrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/String#>,
148 }
149
150 impl Cacherust-analyzer cargo rust-apt 0.8.0 cache/Cache# {
151 /// Initialize the configuration system, open and return the cache.
152 /// This is the entry point for all operations of this crate.
153 ///
154 /// `local_files` allows you to temporarily add local files to the cache, as
155 /// long as they are one of the following:
156 ///
157 /// - `*.deb` or `*.ddeb` files
158 /// - `Packages` and `Sources` files from apt repositories. These files can
159 /// be compressed.
160 /// - `*.dsc` or `*.changes` files
161 /// - A valid directory containing the file `./debian/control`
162 ///
163 /// This function returns an [`AptErrors`] if any of the files cannot
164 /// be found or are invalid.
165 ///
166 /// Note that if you run [`Cache::commit`] or [`Cache::update`],
167 /// You will be required to make a new cache to perform any further changes
168 pub fn newrust-analyzer cargo rust-apt 0.8.0 cache/impl#[Cache]new().<T: AsRefrust-analyzer cargo core https://github.com/rust-lang/rust/library/core convert/AsRef#<str>>(local_files: &[T]) -> Resultrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#<Cacherust-analyzer cargo rust-apt 0.8.0 cache/Cache#, AptErrorsrust-analyzer cargo rust-apt 0.8.0 error/AptErrors#> {
169 let volatile_files: Vecrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/Vec#<_> = local_files.iterrust-analyzer cargo core https://github.com/rust-lang/rust/library/core slice/impl#[`[T]`]iter().().maprust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/traits/iterator/Iterator#map().(|d| d.as_refrust-analyzer cargo core https://github.com/rust-lang/rust/library/core convert/AsRef#as_ref().()).collectrust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/traits/iterator/Iterator#collect().();
170
171 init_config_systemrust-analyzer cargo rust-apt 0.8.0 config/init_config_system().();
172 Okrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Ok#(Cacherust-analyzer cargo rust-apt 0.8.0 cache/Cache# {
173 ptrrust-analyzer cargo rust-apt 0.8.0 cache/Cache#ptr.: create_cacherust-analyzer cargo rust-apt 0.8.0 cache/raw/create_cache().(&volatile_files)?rust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`][Try]branch().,
174 depcacherust-analyzer cargo rust-apt 0.8.0 cache/Cache#depcache.: OnceCellrust-analyzer cargo core https://github.com/rust-lang/rust/library/core cell/once/OnceCell#::newrust-analyzer cargo core https://github.com/rust-lang/rust/library/core cell/once/impl#[`OnceCell<T>`]new().(),
175 recordsrust-analyzer cargo rust-apt 0.8.0 cache/Cache#records.: OnceCellrust-analyzer cargo core https://github.com/rust-lang/rust/library/core cell/once/OnceCell#::newrust-analyzer cargo core https://github.com/rust-lang/rust/library/core cell/once/impl#[`OnceCell<T>`]new().(),
176 pkgmanagerrust-analyzer cargo rust-apt 0.8.0 cache/Cache#pkgmanager.: OnceCellrust-analyzer cargo core https://github.com/rust-lang/rust/library/core cell/once/OnceCell#::newrust-analyzer cargo core https://github.com/rust-lang/rust/library/core cell/once/impl#[`OnceCell<T>`]new().(),
177 problem_resolverrust-analyzer cargo rust-apt 0.8.0 cache/Cache#problem_resolver.: OnceCellrust-analyzer cargo core https://github.com/rust-lang/rust/library/core cell/once/OnceCell#::newrust-analyzer cargo core https://github.com/rust-lang/rust/library/core cell/once/impl#[`OnceCell<T>`]new().(),
178 local_debsrust-analyzer cargo rust-apt 0.8.0 cache/Cache#local_debs.: volatile_files
179 .into_iterrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/impl#[`Vec<T, A>`][IntoIterator]into_iter().()
180 .filterrust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/traits/iterator/Iterator#filter().(|f| f.ends_withrust-analyzer cargo core https://github.com/rust-lang/rust/library/core str/impl#[str]ends_with().(".deb"))
181 .maprust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/traits/iterator/Iterator#map().(|f| f.to_stringrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/impl#[T][ToString]to_string().())
182 .collectrust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/traits/iterator/Iterator#collect().(),
183 })
184 }
185
186 /// Internal Method for generating the package list.
187 pub fn raw_pkgsrust-analyzer cargo rust-apt 0.8.0 cache/impl#[Cache]raw_pkgs().(&self) -> impl Iteratorrust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/traits/iterator/Iterator#<Itemrust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/traits/iterator/Iterator#Item# = UniquePtrrust-analyzer cargo cxx 1.0.199 unique_ptr/UniquePtr#<PkgIteratorrust-analyzer cargo rust-apt 0.8.0 iterators/package/raw/PkgIterator#>> {
188 unsafe { self.beginrust-analyzer cargo rust-apt 0.8.0 cache/raw/impl#[PkgCacheFile]begin().().raw_iterrust-analyzer cargo rust-apt 0.8.0 raw/impl#[`UniquePtr<PkgIterator>`][IntoRawIter]raw_iter().() }
189 }
190
191 /// Get the DepCache
192 pub fn depcacherust-analyzer cargo rust-apt 0.8.0 cache/impl#[Cache]depcache().(&self) -> &DepCacherust-analyzer cargo rust-apt 0.8.0 depcache/DepCache# {
193 self.depcacherust-analyzer cargo rust-apt 0.8.0 cache/Cache#depcache.
194 .get_or_initrust-analyzer cargo core https://github.com/rust-lang/rust/library/core cell/once/impl#[`OnceCell<T>`]get_or_init().(|| DepCacherust-analyzer cargo rust-apt 0.8.0 depcache/DepCache#::newrust-analyzer cargo rust-apt 0.8.0 depcache/impl#[DepCache]new().(unsafe { self.create_depcacherust-analyzer cargo rust-apt 0.8.0 cache/raw/impl#[PkgCacheFile]create_depcache().() }))
195 }
196
197 /// Get the PkgRecords
198 pub fn recordsrust-analyzer cargo rust-apt 0.8.0 cache/impl#[Cache]records().(&self) -> &PackageRecordsrust-analyzer cargo rust-apt 0.8.0 records/PackageRecords# {
199 self.recordsrust-analyzer cargo rust-apt 0.8.0 cache/Cache#records.
200 .get_or_initrust-analyzer cargo core https://github.com/rust-lang/rust/library/core cell/once/impl#[`OnceCell<T>`]get_or_init().(|| PackageRecordsrust-analyzer cargo rust-apt 0.8.0 records/PackageRecords#::newrust-analyzer cargo rust-apt 0.8.0 records/impl#[PackageRecords]new().(unsafe { self.create_recordsrust-analyzer cargo rust-apt 0.8.0 cache/raw/impl#[PkgCacheFile]create_records().() }))
201 }
202
203 /// Get the PkgManager
204 pub fn pkg_managerrust-analyzer cargo rust-apt 0.8.0 cache/impl#[Cache]pkg_manager().(&self) -> &PackageManagerrust-analyzer cargo rust-apt 0.8.0 pkgmanager/raw/PackageManager# {
205 self.pkgmanagerrust-analyzer cargo rust-apt 0.8.0 cache/Cache#pkgmanager.
206 .get_or_initrust-analyzer cargo core https://github.com/rust-lang/rust/library/core cell/once/impl#[`OnceCell<T>`]get_or_init().(|| unsafe { create_pkgmanagerrust-analyzer cargo rust-apt 0.8.0 pkgmanager/raw/create_pkgmanager().(self.depcacherust-analyzer cargo rust-apt 0.8.0 cache/impl#[Cache]depcache().()) })
207 }
208
209 /// Get the ProblemResolver
210 pub fn resolverrust-analyzer cargo rust-apt 0.8.0 cache/impl#[Cache]resolver().(&self) -> &ProblemResolverrust-analyzer cargo rust-apt 0.8.0 pkgmanager/raw/ProblemResolver# {
211 self.problem_resolverrust-analyzer cargo rust-apt 0.8.0 cache/Cache#problem_resolver.
212 .get_or_initrust-analyzer cargo core https://github.com/rust-lang/rust/library/core cell/once/impl#[`OnceCell<T>`]get_or_init().(|| unsafe { create_problem_resolverrust-analyzer cargo rust-apt 0.8.0 pkgmanager/raw/create_problem_resolver().(self.depcacherust-analyzer cargo rust-apt 0.8.0 cache/impl#[Cache]depcache().()) })
213 }
214
215 /// Iterate through the packages in a random order
216 pub fn iterrust-analyzer cargo rust-apt 0.8.0 cache/impl#[Cache]iter().(&self) -> CacheIterrust-analyzer cargo rust-apt 0.8.0 cache/CacheIter# {
217 CacheIterrust-analyzer cargo rust-apt 0.8.0 cache/CacheIter# {
218 pkgsrust-analyzer cargo rust-apt 0.8.0 cache/CacheIter#pkgs.: unsafe { self.beginrust-analyzer cargo rust-apt 0.8.0 cache/raw/impl#[PkgCacheFile]begin().().raw_iterrust-analyzer cargo rust-apt 0.8.0 raw/impl#[`UniquePtr<PkgIterator>`][IntoRawIter]raw_iter().() },
219 cacherust-analyzer cargo rust-apt 0.8.0 cache/CacheIter#cache.: self,
220 }
221 }
222
223 /// An iterator of packages in the cache.
224 pub fn packagesrust-analyzer cargo rust-apt 0.8.0 cache/impl#[Cache]packages().(&self, sort: &PackageSortrust-analyzer cargo rust-apt 0.8.0 cache/PackageSort#) -> impl Iteratorrust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/traits/iterator/Iterator#<Itemrust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/traits/iterator/Iterator#Item# = Packagerust-analyzer cargo rust-apt 0.8.0 iterators/package/Package#> {
225 let mut pkg_list = vecrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc macros/vec!![];
226 for pkg in self.raw_pkgsrust-analyzer cargo rust-apt 0.8.0 cache/impl#[Cache]raw_pkgs().() {
227 match sort.virtual_pkgsrust-analyzer cargo rust-apt 0.8.0 cache/PackageSort#virtual_pkgs. {
228 // Virtual packages are enabled, include them.
229 // This works differently than the rest. I should probably change defaults.
230 Sortrust-analyzer cargo rust-apt 0.8.0 cache/Sort#::Enablerust-analyzer cargo rust-apt 0.8.0 cache/Sort#Enable# => {},
231 // If disabled and pkg has no versions, exclude
232 Sortrust-analyzer cargo rust-apt 0.8.0 cache/Sort#::Disablerust-analyzer cargo rust-apt 0.8.0 cache/Sort#Disable# => {
233 if unsafe { pkg.versionsrust-analyzer cargo rust-apt 0.8.0 iterators/package/raw/impl#[PkgIterator]versions().().endrust-analyzer cargo rust-apt 0.8.0 iterators/version/raw/impl#[VerIterator]end().() } {
234 continue;
235 }
236 },
237 // If reverse and the package has versions, exclude
238 // This section is for if you only want virtual packages
239 Sortrust-analyzer cargo rust-apt 0.8.0 cache/Sort#::Reverserust-analyzer cargo rust-apt 0.8.0 cache/Sort#Reverse# => {
240 if unsafe { !rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/bit/impl#[bool][Not]not().pkg.versionsrust-analyzer cargo rust-apt 0.8.0 iterators/package/raw/impl#[PkgIterator]versions().().endrust-analyzer cargo rust-apt 0.8.0 iterators/version/raw/impl#[VerIterator]end().() } {
241 continue;
242 }
243 },
244 }
245
246 match sort.upgradablerust-analyzer cargo rust-apt 0.8.0 cache/PackageSort#upgradable. {
247 // Virtual packages are enabled, include them.
248 Sortrust-analyzer cargo rust-apt 0.8.0 cache/Sort#::Disablerust-analyzer cargo rust-apt 0.8.0 cache/Sort#Disable# => {},
249 // If disabled and pkg has no versions, exclude
250 Sortrust-analyzer cargo rust-apt 0.8.0 cache/Sort#::Enablerust-analyzer cargo rust-apt 0.8.0 cache/Sort#Enable# => {
251 // If the package isn't installed, then it can not be upgradable
252 if unsafe { pkg.current_versionrust-analyzer cargo rust-apt 0.8.0 iterators/package/raw/impl#[PkgIterator]current_version().().endrust-analyzer cargo rust-apt 0.8.0 iterators/version/raw/impl#[VerIterator]end().() }
253 || !rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/bit/impl#[bool][Not]not().self.depcacherust-analyzer cargo rust-apt 0.8.0 cache/impl#[Cache]depcache().().is_upgradablerust-analyzer cargo rust-apt 0.8.0 depcache/raw/impl#[PkgDepCache]is_upgradable().(&pkg)
254 {
255 continue;
256 }
257 },
258 // If reverse and the package is installed and upgradable, exclude
259 // This section is for if you only want packages that are not upgradable
260 Sortrust-analyzer cargo rust-apt 0.8.0 cache/Sort#::Reverserust-analyzer cargo rust-apt 0.8.0 cache/Sort#Reverse# => {
261 if unsafe { !rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/bit/impl#[bool][Not]not().pkg.current_versionrust-analyzer cargo rust-apt 0.8.0 iterators/package/raw/impl#[PkgIterator]current_version().().endrust-analyzer cargo rust-apt 0.8.0 iterators/version/raw/impl#[VerIterator]end().() }
262 && self.depcacherust-analyzer cargo rust-apt 0.8.0 cache/impl#[Cache]depcache().().is_upgradablerust-analyzer cargo rust-apt 0.8.0 depcache/raw/impl#[PkgDepCache]is_upgradable().(&pkg)
263 {
264 continue;
265 }
266 },
267 }
268
269 match sort.installedrust-analyzer cargo rust-apt 0.8.0 cache/PackageSort#installed. {
270 // Installed Package is Disabled, so we keep them
271 Sortrust-analyzer cargo rust-apt 0.8.0 cache/Sort#::Disablerust-analyzer cargo rust-apt 0.8.0 cache/Sort#Disable# => {},
272 Sortrust-analyzer cargo rust-apt 0.8.0 cache/Sort#::Enablerust-analyzer cargo rust-apt 0.8.0 cache/Sort#Enable# => {
273 if unsafe { pkg.current_versionrust-analyzer cargo rust-apt 0.8.0 iterators/package/raw/impl#[PkgIterator]current_version().().endrust-analyzer cargo rust-apt 0.8.0 iterators/version/raw/impl#[VerIterator]end().() } {
274 continue;
275 }
276 },
277 // Only include installed packages.
278 Sortrust-analyzer cargo rust-apt 0.8.0 cache/Sort#::Reverserust-analyzer cargo rust-apt 0.8.0 cache/Sort#Reverse# => {
279 if unsafe { !rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/bit/impl#[bool][Not]not().pkg.current_versionrust-analyzer cargo rust-apt 0.8.0 iterators/package/raw/impl#[PkgIterator]current_version().().endrust-analyzer cargo rust-apt 0.8.0 iterators/version/raw/impl#[VerIterator]end().() } {
280 continue;
281 }
282 },
283 }
284
285 match sort.auto_installedrust-analyzer cargo rust-apt 0.8.0 cache/PackageSort#auto_installed. {
286 // Installed Package is Disabled, so we keep them
287 Sortrust-analyzer cargo rust-apt 0.8.0 cache/Sort#::Disablerust-analyzer cargo rust-apt 0.8.0 cache/Sort#Disable# => {},
288 Sortrust-analyzer cargo rust-apt 0.8.0 cache/Sort#::Enablerust-analyzer cargo rust-apt 0.8.0 cache/Sort#Enable# => {
289 if !rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/bit/impl#[bool][Not]not().self.depcacherust-analyzer cargo rust-apt 0.8.0 cache/impl#[Cache]depcache().().is_auto_installedrust-analyzer cargo rust-apt 0.8.0 depcache/raw/impl#[PkgDepCache]is_auto_installed().(&pkg) {
290 continue;
291 }
292 },
293 // Only include installed packages.
294 Sortrust-analyzer cargo rust-apt 0.8.0 cache/Sort#::Reverserust-analyzer cargo rust-apt 0.8.0 cache/Sort#Reverse# => {
295 if self.depcacherust-analyzer cargo rust-apt 0.8.0 cache/impl#[Cache]depcache().().is_auto_installedrust-analyzer cargo rust-apt 0.8.0 depcache/raw/impl#[PkgDepCache]is_auto_installed().(&pkg) {
296 continue;
297 }
298 },
299 }
300
301 match sort.auto_removablerust-analyzer cargo rust-apt 0.8.0 cache/PackageSort#auto_removable. {
302 // auto_removable is Disabled, so we keep them
303 Sortrust-analyzer cargo rust-apt 0.8.0 cache/Sort#::Disablerust-analyzer cargo rust-apt 0.8.0 cache/Sort#Disable# => {},
304 // If the package is not auto removable skip it.
305 Sortrust-analyzer cargo rust-apt 0.8.0 cache/Sort#::Enablerust-analyzer cargo rust-apt 0.8.0 cache/Sort#Enable# => {
306 // If the Package isn't auto_removable skip
307 if !rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/bit/impl#[bool][Not]not().self.depcacherust-analyzer cargo rust-apt 0.8.0 cache/impl#[Cache]depcache().().is_garbagerust-analyzer cargo rust-apt 0.8.0 depcache/raw/impl#[PkgDepCache]is_garbage().(&pkg) {
308 continue;
309 }
310 },
311 // If the package is auto removable skip it.
312 Sortrust-analyzer cargo rust-apt 0.8.0 cache/Sort#::Reverserust-analyzer cargo rust-apt 0.8.0 cache/Sort#Reverse# => {
313 if self.depcacherust-analyzer cargo rust-apt 0.8.0 cache/impl#[Cache]depcache().().is_garbagerust-analyzer cargo rust-apt 0.8.0 depcache/raw/impl#[PkgDepCache]is_garbage().(&pkg) {
314 continue;
315 }
316 },
317 }
318
319 // If this is reached we're clear to include the package.
320 pkg_list.pushrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/impl#[`Vec<T, A>`]push().(pkg);
321 }
322
323 if sort.namesrust-analyzer cargo rust-apt 0.8.0 cache/PackageSort#names. {
324 pkg_list.sort_by_cached_keyrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc slice/impl#[`[T]`]sort_by_cached_key().(|pkg| pkg.namerust-analyzer cargo rust-apt 0.8.0 iterators/package/raw/impl#[PkgIterator]name().().to_stringrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/impl#[T][ToString]to_string().());
325 }
326
327 pkg_list.into_iterrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/impl#[`Vec<T, A>`][IntoIterator]into_iter().().maprust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/traits/iterator/Iterator#map().(|pkg| Packagerust-analyzer cargo rust-apt 0.8.0 iterators/package/Package#::newrust-analyzer cargo rust-apt 0.8.0 iterators/package/impl#[`Package<'a>`]new().(self, pkg))
328 }
329
330 /// Updates the package cache and returns a Result
331 ///
332 /// Here is an example of how you may parse the Error messages.
333 ///
334 /// ```
335 /// use rust_apt::new_cache;
336 /// use rust_apt::progress::AcquireProgress;
337 ///
338 /// let cache = new_cache!().unwrap();
339 /// let mut progress = AcquireProgress::apt();
340
341 /// if let Err(e) = cache.update(&mut progress) {
342 /// for error in e.iter() {
343 /// if error.is_error {
344 /// println!("Error: {}", error.msg);
345 /// } else {
346 /// println!("Warning: {}", error.msg);
347 /// }
348 /// }
349 /// }
350 /// ```
351 /// # Known Errors:
352 /// * E:Could not open lock file /var/lib/apt/lists/lock - open (13: Permission denied)
353 /// * E:Unable to lock directory /var/lib/apt/lists/
354 pub fn updaterust-analyzer cargo rust-apt 0.8.0 cache/impl#[Cache]update().(self, progress: &mut AcquireProgressrust-analyzer cargo rust-apt 0.8.0 progress/AcquireProgress#) -> Resultrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#<(), AptErrorsrust-analyzer cargo rust-apt 0.8.0 error/AptErrors#> {
355 Okrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Ok#(self.ptrrust-analyzer cargo rust-apt 0.8.0 cache/Cache#ptr..updaterust-analyzer cargo rust-apt 0.8.0 cache/raw/impl#[PkgCacheFile]update().(progress.mut_statusrust-analyzer cargo rust-apt 0.8.0 progress/impl#[`AcquireProgress<'a>`]mut_status().())?rust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`][Try]branch().)
356 }
357
358 /// Mark all packages for upgrade
359 ///
360 /// # Example:
361 ///
362 /// ```
363 /// use rust_apt::new_cache;
364 /// use rust_apt::cache::Upgrade;
365 ///
366 /// let cache = new_cache!().unwrap();
367 ///
368 /// cache.upgrade(Upgrade::FullUpgrade).unwrap();
369 /// ```
370 pub fn upgraderust-analyzer cargo rust-apt 0.8.0 cache/impl#[Cache]upgrade().(&self, upgrade_type: Upgraderust-analyzer cargo rust-apt 0.8.0 cache/Upgrade#) -> Resultrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#<(), AptErrorsrust-analyzer cargo rust-apt 0.8.0 error/AptErrors#> {
371 let mut progress = OperationProgressrust-analyzer cargo rust-apt 0.8.0 progress/OperationProgress#::quietrust-analyzer cargo rust-apt 0.8.0 progress/impl#[`OperationProgress<'a>`]quiet().();
372 Okrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Ok#(self
373 .depcacherust-analyzer cargo rust-apt 0.8.0 cache/impl#[Cache]depcache().()
374 .upgraderust-analyzer cargo rust-apt 0.8.0 depcache/raw/impl#[PkgDepCache]upgrade().(progress.pinrust-analyzer cargo rust-apt 0.8.0 progress/impl#[`OperationProgress<'a>`]pin().().as_mutrust-analyzer cargo core https://github.com/rust-lang/rust/library/core pin/impl#[`Pin<Ptr>`]as_mut().(), upgrade_type as i32)?rust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`][Try]branch().)
375 }
376
377 /// Resolve dependencies with the changes marked on all packages. This marks
378 /// additional packages for installation/removal to satisfy the dependency
379 /// chain.
380 ///
381 /// Note that just running a `mark_*` function on a package doesn't
382 /// guarantee that the selected state will be kept during dependency
383 /// resolution. If you need such, make sure to run
384 /// [`crate::Package::protect`] after marking your requested
385 /// modifications.
386 ///
387 /// If `fix_broken` is set to [`true`], the library will try to repair
388 /// broken dependencies of installed packages.
389 ///
390 /// Returns [`Err`] if there was an error reaching dependency resolution.
391 #[allow(clippy::result_unit_err)]
392 pub fn resolverust-analyzer cargo rust-apt 0.8.0 cache/impl#[Cache]resolve().(&self, fix_broken: bool) -> Resultrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#<(), AptErrorsrust-analyzer cargo rust-apt 0.8.0 error/AptErrors#> {
393 Okrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Ok#(self
394 .resolverrust-analyzer cargo rust-apt 0.8.0 cache/impl#[Cache]resolver().()
395 .resolverust-analyzer cargo rust-apt 0.8.0 pkgmanager/raw/impl#[ProblemResolver]resolve().(fix_broken, OperationProgressrust-analyzer cargo rust-apt 0.8.0 progress/OperationProgress#::quietrust-analyzer cargo rust-apt 0.8.0 progress/impl#[`OperationProgress<'a>`]quiet().().pinrust-analyzer cargo rust-apt 0.8.0 progress/impl#[`OperationProgress<'a>`]pin().().as_mutrust-analyzer cargo core https://github.com/rust-lang/rust/library/core pin/impl#[`Pin<Ptr>`]as_mut().())?rust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`][Try]branch().)
396 }
397
398 /// Autoinstall every broken package and run the problem resolver
399 /// Returns false if the problem resolver fails.
400 ///
401 /// # Example:
402 ///
403 /// ```
404 /// use rust_apt::new_cache;
405 ///
406 /// let cache = new_cache!().unwrap();
407 ///
408 /// cache.fix_broken();
409 ///
410 /// for pkg in cache.get_changes(false) {
411 /// println!("Pkg Name: {}", pkg.name())
412 /// }
413 /// ```
414 pub fn fix_brokenrust-analyzer cargo rust-apt 0.8.0 cache/impl#[Cache]fix_broken().(&self) -> bool { self.depcacherust-analyzer cargo rust-apt 0.8.0 cache/impl#[Cache]depcache().().fix_brokenrust-analyzer cargo rust-apt 0.8.0 depcache/raw/impl#[PkgDepCache]fix_broken().() }
415
416 /// Fetch any archives needed to complete the transaction.
417 ///
418 /// # Returns:
419 /// * A [`Result`] enum: the [`Ok`] variant if fetching succeeded, and
420 /// [`Err`] if there was an issue.
421 ///
422 /// # Example:
423 /// ```
424 /// use rust_apt::new_cache;
425 /// use rust_apt::progress::AcquireProgress;
426 ///
427 /// let cache = new_cache!().unwrap();
428 /// let pkg = cache.get("neovim").unwrap();
429 /// let mut progress = AcquireProgress::apt();
430 ///
431 /// pkg.mark_install(true, true);
432 /// pkg.protect();
433 /// cache.resolve(true).unwrap();
434 ///
435 /// cache.get_archives(&mut progress).unwrap();
436 /// ```
437 /// # Known Errors:
438 /// * W:Problem unlinking the file
439 /// /var/cache/apt/archives/partial/neofetch_7.1.0-4_all.deb -
440 /// PrepareFiles (13: Permission denied)
441 /// * W:Problem unlinking the file
442 /// /var/cache/apt/archives/partial/neofetch_7.1.0-4_all.deb -
443 /// PrepareFiles (13: Permission denied)
444 /// * W:Problem unlinking the file
445 /// /var/cache/apt/archives/partial/neofetch_7.1.0-4_all.deb -
446 /// PrepareFiles (13: Permission denied)
447 /// * W:Problem unlinking the file
448 /// /var/cache/apt/archives/partial/neofetch_7.1.0-4_all.deb -
449 /// PrepareFiles (13: Permission denied)
450 /// * W:Problem unlinking the file
451 /// /var/cache/apt/archives/partial/neofetch_7.1.0-4_all.deb -
452 /// PrepareFiles (13: Permission denied)
453 /// * W:Problem unlinking the file /var/log/apt/eipp.log.xz - FileFd::Open
454 /// (13: Permission denied)
455 /// * W:Could not open file /var/log/apt/eipp.log.xz - open (17: File
456 /// exists)
457 /// * W:Could not open file '/var/log/apt/eipp.log.xz' - EIPP::OrderInstall
458 /// (17: File exists)
459 /// * E:Internal Error, ordering was unable to handle the media swap"
460 pub fn get_archivesrust-analyzer cargo rust-apt 0.8.0 cache/impl#[Cache]get_archives().(&self, progress: &mut AcquireProgressrust-analyzer cargo rust-apt 0.8.0 progress/AcquireProgress#) -> Resultrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#<(), Exceptionrust-analyzer cargo cxx 1.0.199 exception/Exception#> {
461 self.pkg_managerrust-analyzer cargo rust-apt 0.8.0 cache/impl#[Cache]pkg_manager().()
462 .get_archivesrust-analyzer cargo rust-apt 0.8.0 pkgmanager/raw/impl#[PackageManager]get_archives().(&self.ptrrust-analyzer cargo rust-apt 0.8.0 cache/Cache#ptr., self.recordsrust-analyzer cargo rust-apt 0.8.0 cache/impl#[Cache]records().(), progress.mut_statusrust-analyzer cargo rust-apt 0.8.0 progress/impl#[`AcquireProgress<'a>`]mut_status().())
463 }
464
465 /// Install, remove, and do any other actions requested by the cache.
466 ///
467 /// # Returns:
468 /// * A [`Result`] enum: the [`Ok`] variant if transaction was successful,
469 /// and [`Err`] if there was an issue.
470 ///
471 /// # Example:
472 /// ```
473 /// use rust_apt::new_cache;
474 /// use rust_apt::progress::{AcquireProgress, InstallProgress};
475 ///
476 /// let cache = new_cache!().unwrap();
477 /// let pkg = cache.get("neovim").unwrap();
478 /// let mut acquire_progress = AcquireProgress::apt();
479 /// let mut install_progress = InstallProgress::apt();
480 ///
481 /// pkg.mark_install(true, true);
482 /// pkg.protect();
483 /// cache.resolve(true).unwrap();
484 ///
485 /// // These need root
486 /// // cache.get_archives(&mut acquire_progress).unwrap();
487 /// // cache.do_install(&mut install_progress).unwrap();
488 /// ```
489 ///
490 /// # Known Errors:
491 /// * W:Problem unlinking the file /var/log/apt/eipp.log.xz - FileFd::Open
492 /// (13: Permission denied)
493 /// * W:Could not open file /var/log/apt/eipp.log.xz - open (17: File
494 /// exists)
495 /// * W:Could not open file '/var/log/apt/eipp.log.xz' - EIPP::OrderInstall
496 /// (17: File exists)
497 /// * E:Could not create temporary file for /var/lib/apt/extended_states -
498 /// mkstemp (13: Permission denied)
499 /// * E:Failed to write temporary StateFile /var/lib/apt/extended_states
500 /// * W:Could not open file '/var/log/apt/term.log' - OpenLog (13:
501 /// Permission denied)
502 /// * E:Sub-process /usr/bin/dpkg returned an error code (2)
503 /// * W:Problem unlinking the file /var/cache/apt/pkgcache.bin -
504 /// pkgDPkgPM::Go (13: Permission denied)
505 pub fn do_installrust-analyzer cargo rust-apt 0.8.0 cache/impl#[Cache]do_install().(self, progress: &mut InstallProgressrust-analyzer cargo rust-apt 0.8.0 progress/InstallProgress#) -> Resultrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#<(), AptErrorsrust-analyzer cargo rust-apt 0.8.0 error/AptErrors#> {
506 Okrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Ok#(self.pkg_managerrust-analyzer cargo rust-apt 0.8.0 cache/impl#[Cache]pkg_manager().().do_installrust-analyzer cargo rust-apt 0.8.0 pkgmanager/raw/impl#[PackageManager]do_install().(progress.pinrust-analyzer cargo rust-apt 0.8.0 progress/impl#[`InstallProgress<'a>`]pin().().as_mutrust-analyzer cargo core https://github.com/rust-lang/rust/library/core pin/impl#[`Pin<Ptr>`]as_mut().())?rust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`][Try]branch().)
507 }
508
509 /// Handle get_archives and do_install in an easy wrapper.
510 ///
511 /// # Returns:
512 /// * A [`Result`]: the [`Ok`] variant if transaction was successful, and
513 /// [`Err`] if there was an issue.
514 /// # Example:
515 /// ```
516 /// use rust_apt::new_cache;
517 /// use rust_apt::progress::{AcquireProgress, InstallProgress};
518 ///
519 /// let cache = new_cache!().unwrap();
520 /// let pkg = cache.get("neovim").unwrap();
521 /// let mut acquire_progress = AcquireProgress::apt();
522 /// let mut install_progress = InstallProgress::apt();
523 ///
524 /// pkg.mark_install(true, true);
525 /// pkg.protect();
526 /// cache.resolve(true).unwrap();
527 ///
528 /// // This needs root
529 /// // cache.commit(&mut acquire_progress, &mut install_progress).unwrap();
530 /// ```
531 pub fn commitrust-analyzer cargo rust-apt 0.8.0 cache/impl#[Cache]commit().(
532 self,
533 progress: &mut AcquireProgressrust-analyzer cargo rust-apt 0.8.0 progress/AcquireProgress#,
534 install_progress: &mut InstallProgressrust-analyzer cargo rust-apt 0.8.0 progress/InstallProgress#,
535 ) -> Resultrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#<(), AptErrorsrust-analyzer cargo rust-apt 0.8.0 error/AptErrors#> {
536 // Lock the whole thing so as to prevent tamper
537 apt_lockrust-analyzer cargo rust-apt 0.8.0 util/apt_lock().()?rust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`][Try]branch().;
538
539 let config = Configrust-analyzer cargo rust-apt 0.8.0 config/Config#::newrust-analyzer cargo rust-apt 0.8.0 config/impl#[Config]new().();
540 let archive_dir = config.dirrust-analyzer cargo rust-apt 0.8.0 config/impl#[Config]dir().("Dir::Cache::Archives", "/var/cache/apt/archives/");
541
542 // Copy local debs into archives dir
543 for deb in &self.local_debsrust-analyzer cargo rust-apt 0.8.0 cache/Cache#local_debs. {
544 // If it reaches this point it really will be a valid filename, allegedly
545 if let Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(filename) = Pathrust-analyzer cargo std https://github.com/rust-lang/rust/library/std path/Path#::newrust-analyzer cargo std https://github.com/rust-lang/rust/library/std path/impl#[Path]new().(deb).file_namerust-analyzer cargo std https://github.com/rust-lang/rust/library/std path/impl#[Path]file_name().() {
546 // Append the file name onto the archive dir
547 fsrust-analyzer cargo std https://github.com/rust-lang/rust/library/std fs/::copyrust-analyzer cargo std https://github.com/rust-lang/rust/library/std fs/copy().(deb, archive_dir.to_stringrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/impl#[T][ToString]to_string().() rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/Add#add().+rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/Add#add(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/Add#add().&filename.to_string_lossyrust-analyzer cargo std https://github.com/rust-lang/rust/library/std ffi/os_str/impl#[OsStr]to_string_lossy().())?rust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`][Try]branch().;
548 }
549 }
550
551 // The archives can be grabbed during the apt lock.
552 self.get_archivesrust-analyzer cargo rust-apt 0.8.0 cache/impl#[Cache]get_archives().(progress)?rust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`][Try]branch().;
553
554 // If the system is locked we will want to unlock the dpkg files.
555 // This way when dpkg is running it can access its files.
556 apt_unlock_innerrust-analyzer cargo rust-apt 0.8.0 util/apt_unlock_inner().();
557
558 // Perform the operation.
559 self.do_installrust-analyzer cargo rust-apt 0.8.0 cache/impl#[Cache]do_install().(install_progress)?rust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`][Try]branch().;
560
561 // Finally Unlock the whole thing.
562 apt_unlockrust-analyzer cargo rust-apt 0.8.0 util/apt_unlock().();
563 Okrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Ok#(())
564 }
565
566 /// Get a single package.
567 ///
568 /// `cache.get("apt")` Returns a Package object for the native arch.
569 ///
570 /// `cache.get("apt:i386")` Returns a Package object for the i386 arch
571 pub fn getrust-analyzer cargo rust-apt 0.8.0 cache/impl#[Cache]get().(&self, name: &str) -> Optionrust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#<Packagerust-analyzer cargo rust-apt 0.8.0 iterators/package/Package#> {
572 Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(Packagerust-analyzer cargo rust-apt 0.8.0 iterators/package/Package#::newrust-analyzer cargo rust-apt 0.8.0 iterators/package/impl#[`Package<'a>`]new().(self, unsafe {
573 self.find_pkgrust-analyzer cargo rust-apt 0.8.0 cache/raw/impl#[PkgCacheFile]find_pkg().(name).make_saferust-analyzer cargo rust-apt 0.8.0 raw/impl#[`UniquePtr<PkgIterator>`][IntoRawIter]make_safe().()?rust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/impl#[`Option<T>`][Try]branch().
574 }))
575 }
576
577 /// An iterator over the packages
578 /// that will be altered when `cache.commit()` is called.
579 ///
580 /// # sort_name:
581 /// * [`true`] = Packages will be in alphabetical order
582 /// * [`false`] = Packages will not be sorted by name
583 pub fn get_changesrust-analyzer cargo rust-apt 0.8.0 cache/impl#[Cache]get_changes().(&self, sort_name: bool) -> impl Iteratorrust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/traits/iterator/Iterator#<Itemrust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/traits/iterator/Iterator#Item# = Packagerust-analyzer cargo rust-apt 0.8.0 iterators/package/Package#> {
584 let mut changed = Vecrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/Vec#::newrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/impl#[`Vec<T>`]new().();
585 let depcache = self.depcacherust-analyzer cargo rust-apt 0.8.0 cache/impl#[Cache]depcache().();
586
587 for pkg in self.raw_pkgsrust-analyzer cargo rust-apt 0.8.0 cache/impl#[Cache]raw_pkgs().() {
588 if depcache.marked_installrust-analyzer cargo rust-apt 0.8.0 depcache/raw/impl#[PkgDepCache]marked_install().(&pkg)
589 || depcache.marked_deleterust-analyzer cargo rust-apt 0.8.0 depcache/raw/impl#[PkgDepCache]marked_delete().(&pkg)
590 || depcache.marked_upgraderust-analyzer cargo rust-apt 0.8.0 depcache/raw/impl#[PkgDepCache]marked_upgrade().(&pkg)
591 || depcache.marked_downgraderust-analyzer cargo rust-apt 0.8.0 depcache/raw/impl#[PkgDepCache]marked_downgrade().(&pkg)
592 || depcache.marked_reinstallrust-analyzer cargo rust-apt 0.8.0 depcache/raw/impl#[PkgDepCache]marked_reinstall().(&pkg)
593 {
594 changed.pushrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/impl#[`Vec<T, A>`]push().(pkg);
595 }
596 }
597
598 if sort_name {
599 // Sort by cached key seems to be the fastest for what we're doing.
600 // Maybe consider impl ord or something for these.
601 changed.sort_by_cached_keyrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc slice/impl#[`[T]`]sort_by_cached_key().(|pkg| pkg.namerust-analyzer cargo rust-apt 0.8.0 iterators/package/raw/impl#[PkgIterator]name().().to_stringrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/impl#[T][ToString]to_string().());
602 }
603
604 changed
605 .into_iterrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/impl#[`Vec<T, A>`][IntoIterator]into_iter().()
606 .maprust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/traits/iterator/Iterator#map().(|pkg_ptr| Packagerust-analyzer cargo rust-apt 0.8.0 iterators/package/Package#::newrust-analyzer cargo rust-apt 0.8.0 iterators/package/impl#[`Package<'a>`]new().(self, pkg_ptr))
607 }
608 }
609
610 /// Iterator Implementation for the Cache.
611 pub struct CacheIterrust-analyzer cargo rust-apt 0.8.0 cache/CacheIter#<'a> {
612 pkgsrust-analyzer cargo rust-apt 0.8.0 cache/CacheIter#pkgs.: IterPkgIteratorrust-analyzer cargo rust-apt 0.8.0 raw/IterPkgIterator#,
613 cacherust-analyzer cargo rust-apt 0.8.0 cache/CacheIter#cache.: &'a Cacherust-analyzer cargo rust-apt 0.8.0 cache/Cache#,
614 }
615
616 impl<'a> Iteratorrust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/traits/iterator/Iterator# for CacheIterrust-analyzer cargo rust-apt 0.8.0 cache/CacheIter#<'a> {
617 type Itemrust-analyzer cargo rust-apt 0.8.0 cache/impl#[`CacheIter<'a>`][Iterator]Item# = Packagerust-analyzer cargo rust-apt 0.8.0 iterators/package/Package#<'a>;
618
619 fn nextrust-analyzer cargo rust-apt 0.8.0 cache/impl#[`CacheIter<'a>`][Iterator]next().(&mut self) -> Optionrust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#<Selfrust-analyzer cargo rust-apt 0.8.0 cache/impl#[`CacheIter<'a>`][Iterator]::Itemrust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/traits/iterator/Iterator#Item#> { Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(Packagerust-analyzer cargo rust-apt 0.8.0 iterators/package/Package#::newrust-analyzer cargo rust-apt 0.8.0 iterators/package/impl#[`Package<'a>`]new().(self.cacherust-analyzer cargo rust-apt 0.8.0 cache/CacheIter#cache., self.pkgsrust-analyzer cargo rust-apt 0.8.0 cache/CacheIter#pkgs..nextrust-analyzer cargo rust-apt 0.8.0 raw/impl#[IterPkgIterator][Iterator]next().()?rust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/impl#[`Option<T>`][Try]branch().)) }
620 }
621
622 #[cxxrust-analyzer cargo cxx 1.0.199 crate/::bridgerust-analyzer cargo cxxbridge-macro 1.0.199 bridge:]
623 pub(craterust-analyzer cargo rust-apt 0.8.0 crate/) mod rawrust-analyzer cargo rust-apt 0.8.0 cache/raw/ {
624 impl UniquePtr<PkgRecordsrust-analyzer cargo rust-apt 0.8.0 cache/raw/PkgRecords#> {}
625
626 unsafe extern "C++" {
627 includerust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/include!!("rust-apt/apt-pkg-c/cache.h");
628 type PkgCacheFilerust-analyzer cargo rust-apt 0.8.0 cache/raw/PkgCacheFile#;
629
630 type PkgIteratorrust-analyzer cargo rust-apt 0.8.0 cache/raw/PkgIterator# = craterust-analyzer cargo rust-apt 0.8.0 crate/::rawrust-analyzer cargo rust-apt 0.8.0 raw/::PkgIteratorrust-analyzer cargo rust-apt 0.8.0 iterators/package/raw/PkgIterator#;
631 type VerIteratorrust-analyzer cargo rust-apt 0.8.0 cache/raw/VerIterator# = craterust-analyzer cargo rust-apt 0.8.0 crate/::rawrust-analyzer cargo rust-apt 0.8.0 raw/::VerIteratorrust-analyzer cargo rust-apt 0.8.0 iterators/version/raw/VerIterator#;
632 type PkgFileIteratorrust-analyzer cargo rust-apt 0.8.0 cache/raw/PkgFileIterator# = craterust-analyzer cargo rust-apt 0.8.0 crate/::rawrust-analyzer cargo rust-apt 0.8.0 raw/::PkgFileIteratorrust-analyzer cargo rust-apt 0.8.0 iterators/files/raw/PkgFileIterator#;
633 type PkgRecordsrust-analyzer cargo rust-apt 0.8.0 cache/raw/PkgRecords# = craterust-analyzer cargo rust-apt 0.8.0 crate/::recordsrust-analyzer cargo rust-apt 0.8.0 records/::rawrust-analyzer cargo rust-apt 0.8.0 records/raw/::PkgRecordsrust-analyzer cargo rust-apt 0.8.0 records/raw/PkgRecords#;
634 type IndexFilerust-analyzer cargo rust-apt 0.8.0 cache/raw/IndexFile# = craterust-analyzer cargo rust-apt 0.8.0 crate/::recordsrust-analyzer cargo rust-apt 0.8.0 records/::rawrust-analyzer cargo rust-apt 0.8.0 records/raw/::IndexFilerust-analyzer cargo rust-apt 0.8.0 records/raw/IndexFile#;
635 type PkgDepCacherust-analyzer cargo rust-apt 0.8.0 cache/raw/PkgDepCache# = craterust-analyzer cargo rust-apt 0.8.0 crate/::depcacherust-analyzer cargo rust-apt 0.8.0 depcache/::rawrust-analyzer cargo rust-apt 0.8.0 depcache/raw/::PkgDepCacherust-analyzer cargo rust-apt 0.8.0 depcache/raw/PkgDepCache#;
636 type AcqTextStatusrust-analyzer cargo rust-apt 0.8.0 cache/raw/AcqTextStatus# = craterust-analyzer cargo rust-apt 0.8.0 crate/::acquirerust-analyzer cargo rust-apt 0.8.0 acquire/::rawrust-analyzer cargo rust-apt 0.8.0 acquire/raw/::AcqTextStatusrust-analyzer cargo rust-apt 0.8.0 acquire/raw/AcqTextStatus#;
637 type PkgAcquirerust-analyzer cargo rust-apt 0.8.0 cache/raw/PkgAcquire# = craterust-analyzer cargo rust-apt 0.8.0 crate/::acquirerust-analyzer cargo rust-apt 0.8.0 acquire/::rawrust-analyzer cargo rust-apt 0.8.0 acquire/raw/::PkgAcquirerust-analyzer cargo rust-apt 0.8.0 acquire/raw/PkgAcquire#;
638
639 /// Create the CacheFile.
640 pub fn create_cacherust-analyzer cargo rust-apt 0.8.0 cache/raw/create_cache().(volatile_files: &[&str]) -> Resultrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#<UniquePtrrust-analyzer cargo cxx 1.0.199 unique_ptr/UniquePtr#<PkgCacheFilerust-analyzer cargo rust-apt 0.8.0 cache/raw/PkgCacheFile#>>;
641
642 /// Update the package lists, handle errors and return a Result.
643 pub fn updaterust-analyzer cargo rust-apt 0.8.0 cache/raw/impl#[PkgCacheFile]update().(self: &PkgCacheFilerust-analyzer cargo rust-apt 0.8.0 cache/raw/PkgCacheFile#, progress: Pinrust-analyzer cargo core https://github.com/rust-lang/rust/library/core pin/Pin#<&mut AcqTextStatusrust-analyzer cargo rust-apt 0.8.0 cache/raw/AcqTextStatus#>) -> Resultrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#<()>;
644
645 /// Loads the index files into PkgAcquire.
646 ///
647 /// Used to get to source list uris.
648 ///
649 /// It's not clear if this returning a bool is useful.
650 pub fn get_indexesrust-analyzer cargo rust-apt 0.8.0 cache/raw/impl#[PkgCacheFile]get_indexes().(self: &PkgCacheFilerust-analyzer cargo rust-apt 0.8.0 cache/raw/PkgCacheFile#, fetcher: &PkgAcquirerust-analyzer cargo rust-apt 0.8.0 cache/raw/PkgAcquire#) -> bool;
651
652 /// Return a pointer to PkgDepcache.
653 ///
654 /// # Safety
655 ///
656 /// The returned UniquePtr cannot outlive the cache.
657 unsafe fn create_depcacherust-analyzer cargo rust-apt 0.8.0 cache/raw/impl#[PkgCacheFile]create_depcache().(self: &PkgCacheFilerust-analyzer cargo rust-apt 0.8.0 cache/raw/PkgCacheFile#) -> UniquePtrrust-analyzer cargo cxx 1.0.199 unique_ptr/UniquePtr#<PkgDepCacherust-analyzer cargo rust-apt 0.8.0 cache/raw/PkgDepCache#>;
658
659 /// Return a pointer to PkgRecords.
660 ///
661 /// # Safety
662 ///
663 /// The returned UniquePtr cannot outlive the cache.
664 unsafe fn create_recordsrust-analyzer cargo rust-apt 0.8.0 cache/raw/impl#[PkgCacheFile]create_records().(self: &PkgCacheFilerust-analyzer cargo rust-apt 0.8.0 cache/raw/PkgCacheFile#) -> UniquePtrrust-analyzer cargo cxx 1.0.199 unique_ptr/UniquePtr#<PkgRecordsrust-analyzer cargo rust-apt 0.8.0 cache/raw/PkgRecords#>;
665
666 /// The priority of the Version as shown in `apt policy`.
667 pub fn priorityrust-analyzer cargo rust-apt 0.8.0 cache/raw/impl#[PkgCacheFile]priority().(self: &PkgCacheFilerust-analyzer cargo rust-apt 0.8.0 cache/raw/PkgCacheFile#, version: &VerIteratorrust-analyzer cargo rust-apt 0.8.0 cache/raw/VerIterator#) -> i32;
668
669 /// Lookup the IndexFile of the Package file
670 ///
671 /// # Safety
672 ///
673 /// The IndexFile can not outlive PkgCacheFile.
674 ///
675 /// The returned UniquePtr cannot outlive the cache.
676 unsafe fn find_indexrust-analyzer cargo rust-apt 0.8.0 cache/raw/impl#[PkgCacheFile]find_index().(self: &PkgCacheFilerust-analyzer cargo rust-apt 0.8.0 cache/raw/PkgCacheFile#, file: &PkgFileIteratorrust-analyzer cargo rust-apt 0.8.0 cache/raw/PkgFileIterator#) -> UniquePtrrust-analyzer cargo cxx 1.0.199 unique_ptr/UniquePtr#<IndexFilerust-analyzer cargo rust-apt 0.8.0 cache/raw/IndexFile#>;
677
678 /// Return a package by name and optionally architecture.
679 ///
680 /// # Safety
681 ///
682 /// If the Internal Pkg Pointer is NULL, operations can segfault.
683 /// You should call `make_safe()` asap to convert it to an Option.
684 ///
685 /// The returned UniquePtr cannot outlive the cache.
686 unsafe fn find_pkgrust-analyzer cargo rust-apt 0.8.0 cache/raw/impl#[PkgCacheFile]find_pkg().(self: &PkgCacheFilerust-analyzer cargo rust-apt 0.8.0 cache/raw/PkgCacheFile#, name: &str) -> UniquePtrrust-analyzer cargo cxx 1.0.199 unique_ptr/UniquePtr#<PkgIteratorrust-analyzer cargo rust-apt 0.8.0 cache/raw/PkgIterator#>;
687
688 /// Return the pointer to the start of the PkgIterator.
689 ///
690 /// # Safety
691 ///
692 /// If the Internal Pkg Pointer is NULL, operations can segfault.
693 /// You should call `raw_iter()` asap.
694 ///
695 /// The returned UniquePtr cannot outlive the cache.
696 unsafe fn beginrust-analyzer cargo rust-apt 0.8.0 cache/raw/impl#[PkgCacheFile]begin().(self: &PkgCacheFilerust-analyzer cargo rust-apt 0.8.0 cache/raw/PkgCacheFile#) -> UniquePtrrust-analyzer cargo cxx 1.0.199 unique_ptr/UniquePtr#<PkgIteratorrust-analyzer cargo rust-apt 0.8.0 cache/raw/PkgIterator#>;
697 }
698 }