1 /* -*- Mode: C++; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 4 -*- */
4 * Copyright (C) 2005 SUSE Linux Products GmbH
6 * This program is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU General Public License,
8 * version 2, as published by the Free Software Foundation.
10 * This program is distributed in the hope that it will be useful, but
11 * WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 * General Public License for more details.
15 * You should have received a copy of the GNU General Public License
16 * along with this program; if not, write to the Free Software
17 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
22 stolen from PMPackageManager_update.cc
23 original author Michael Andres <ma@suse.de>
24 zypp port by Klaus Kaempf <kkaempf@suse.de>
28 #ifndef ZYPP_UPGRADESTATISTICS_H
29 #define ZYPP_UPGRADESTATISTICS_H
35 /////////////////////////////////////////////////////////////////////////
37 { ///////////////////////////////////////////////////////////////////////
39 ///////////////////////////////////////////////////////////////////
41 // CLASS NAME : UpgradeOptions
43 * @short Struct for update options
45 class UpgradeOptions {
49 ///////////////////////////////////////////////////////////////////
51 ///////////////////////////////////////////////////////////////////
54 * If true, dropped SuSE Packages will be preselected to delete
56 bool delete_unmaintained;
59 * If true, version downgrades are silently performed. Assuming the
60 * installation media contains a consistent sytem, and we target
61 * this well defined state.
63 bool silent_downgrades;
66 * If false, the upgrade algorithm will tag all installed patches to
67 * be deleted. Note, that this will not delete any packages. Just the
68 * patch metadata are removed.
70 bool keep_installed_patches;
75 : delete_unmaintained ( false )
76 , silent_downgrades ( false )
77 , keep_installed_patches( true )
83 ///////////////////////////////////////////////////////////////////
85 ///////////////////////////////////////////////////////////////////
87 // CLASS NAME : UpgradeStatistics
89 * @short Struct for update options, statistics, and result lists.
91 class UpgradeStatistics : public UpgradeOptions {
93 virtual std::ostream & dumpOn( std::ostream & str ) const;
94 friend std::ostream & operator<<( std::ostream & str, const UpgradeStatistics & obj )
95 { return obj.dumpOn (str); }
99 ///////////////////////////////////////////////////////////////////
101 ///////////////////////////////////////////////////////////////////
104 * initial status: packages already tagged to delete
108 * initial status: packages without candidate (foreign, replaced or dropped)
112 * initial status: packages with candidate (available for update)
118 * update checks: total number of packages checked (should be number of installed packages)
120 unsigned chk_installed_total;
123 * update checks: packages already tagged to delete (should be pre_todel)
125 unsigned chk_already_todel;
128 * update checks: packages skipped due to taboo (foreign)
130 unsigned chk_is_taboo;
133 * update checks: with candidate: packages already tagged to install
135 unsigned chk_already_toins;
138 * update checks: with candidate: packages updated to new version
140 unsigned chk_to_update;
143 * update checks: with candidate: packages downgraded
145 * Installed and candidate package have vendor SuSE and candidates buildtime
148 unsigned chk_to_downgrade;
151 * update checks: with candidate: packages untouched (foreign package downgrade)
153 unsigned chk_to_keep_downgrade;
156 * update checks: with candidate: packages untouched (uptodate)
158 unsigned chk_to_keep_installed;
161 * update checks: without candidate: installed package has not vendor SuSE
165 unsigned chk_keep_foreign;
168 * update checks: without candidate: packages dropped (or SuSE internal)
170 * There's no available candidate providing it.
172 unsigned chk_dropped;
175 * update checks: without candidate: packages replaced
177 * There's exactly one available candidate providing it.
179 unsigned chk_replaced;
182 * update checks: without candidate: packages added by splitprovides
184 * Only packages not selected by one of the above checks are counted.
186 unsigned chk_add_split;
189 * update checks: without candidate: package replaced (but not uniqe, thus guessed)
191 * There are multiple available candidates providing it. If at the end
192 * at least one out of these candidates was set to install by one of the
193 * above checks, it's ok. Otherwise we have to guess one.
195 unsigned chk_replaced_guessed;
199 UpgradeStatistics() {
205 chk_installed_total = 0;
206 chk_already_todel = 0;
208 // packages with candidate
209 chk_already_toins = 0;
211 chk_to_downgrade = 0;
212 chk_to_keep_downgrade = 0;
213 chk_to_keep_installed = 0;
214 // packages without candidate
215 chk_keep_foreign = 0;
218 chk_replaced_guessed = 0;
221 virtual ~UpgradeStatistics();
224 * total number of packages that will be installed
226 unsigned totalToInstall() const
228 return chk_already_toins
229 + chk_to_update + chk_to_downgrade
230 + chk_replaced + chk_replaced_guessed + chk_add_split;
234 * total number of packages that will be finaly deleted
235 * (does not count the replaced packages)
237 unsigned totalToDelete() const
239 unsigned ret = chk_already_todel;
240 if ( delete_unmaintained )
246 * total number of packages that remain untouched
248 unsigned totalToKeep() const
250 unsigned ret = chk_is_taboo + chk_to_keep_downgrade + chk_to_keep_installed + chk_keep_foreign;
251 if ( !delete_unmaintained )
257 ///////////////////////////////////////////////////////////////////
258 ///////////////////////////////////////////////////////////////////////
260 /////////////////////////////////////////////////////////////////////////
263 #endif // ZYPP_UPGRADESTATISTICS_H