summaryrefslogtreecommitdiff
path: root/src/cmdline/cmdline_action.h
blob: 663dd05aef0f46ad9dfa0ed2bd57c868815eb63e (plain)
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
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
// cmdline_action.h                                   -*-c++-*-
//
// Copyright (C) 2004, 2010 Daniel Burrows
//
// This program is free software; you can redistribute it and/or
// modify it under the terms of the GNU General Public License as
// published by the Free Software Foundation; either version 2 of the
// License, or (at your option) any later version.
//
// This program is distributed in the hope that it will be useful, but
// WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
// General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with this program; see the file COPYING.  If not, write to
// the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
// Boston, MA 02111-1307, USA.

#ifndef CMDLINE_ACTION_H
#define CMDLINE_ACTION_H

// Local includes:
#include "cmdline_common.h"


// System includes:
#include <boost/shared_ptr.hpp>


/** \file cmdline_action.h
 */

class pkgPolicy;

namespace aptitude
{
  namespace cmdline
  {
    class terminal_metrics;
  }
}

/// \todo The command-line state should probably be encapsulated
/// as an object.

/// \todo allow_auto in cmdline_applyaction() is a hack.  We should
/// use action-groups to suppress auto-installation (not currently
/// done but makes sense) and tidy up afterwards?

/** \brief Apply the given command-line action to the given package,
 *  updating the command-line state appropriately.
 *
 *  \param action The action to apply to the package.
 *
 *  \param pkg The package whose state is to be modified.
 *
 *  \param seen_virtual_packages The set of pure virtual packages that
 *         have already been "seen".  If pkg is a pure virtual package
 *         in this set, it will not be ignored even if a provider is
 *         already installed or going to be installed.  If only one
 *         package provides pkg, that package will be targeted by the
 *         action; otherwise cmdline_applyaction will fail but not
 *         print the usual error message.  The purpose of this option
 *         is to improve the error messages that are printed on the
 *         second pass, but more importantly to ensure that the
 *         dependencies of virtual packages are installed. (bug #475006)
 *
 *  \param to_install The set of packages that are currently marked
 *  to-be-installed; will be updated in accordance with the selected
 *  action.
 *
 *  \param to_hold The set of packages that are currently marked
 *  to-be-held; will be updated in accordance with the selected
 *  action.
 *
 *  \param to_remove The set of packages that are currently marked
 *  to-be-removed; will be updated in accordance with the selected
 *  action.
 *
 *  \param to_purge The set of packages that are currently marked
 *  to-be-purged; will be updated in accordance with the selected
 *  action.
 *
 *  \param verbose The verbosity level at which this command should
 *  operate.
 *
 *  \param source The version-source to be used for this package.
 *
 *  \param sourcestr The string associated with the version source, or
 *  "" if there is no associated string.
 *
 *  \param policy A current policy object (passed as a parameter to
 *  avoid creating a separate one for each action).
 *
 *  \param arch_only If \b true, when packages' build-depends are
 *  satisfied, only architecture-dependent build depends are used;
 *  Build-Depends-Indep and Build-Conflicts-Indep lines are ignored.
 *
 *  \param allow_auto If \b false, auto-installation of dependencies
 *  will be disabled regardless of the value of Auto-Install.
 */
bool cmdline_applyaction(cmdline_pkgaction_type action,
			 pkgCache::PkgIterator pkg,
			 pkgset &seen_virtual_packages,
			 pkgset &to_install, pkgset &to_hold,
			 pkgset &to_remove, pkgset &to_purge,
			 int verbose,
			 cmdline_version_source source,
			 const string &sourcestr,
			 pkgPolicy &policy,
			 bool arch_only,
			 bool allow_auto,
                         const boost::shared_ptr<aptitude::cmdline::terminal_metrics> &term);

/** \brief Apply the given command-line action to the given package,
 *  updating the command-line state appropriately.
 *
 *  \param s The name of the package or the match pattern selecting the
 *           packages whose state is to be modified.
 *
 *  \param action The action to apply to the package.
 *
 *  \param pkg The package whose state is to be modified.
 *
 *  \param seen_virtual_packages The set of pure virtual packages that
 *         have already been "seen".  If a pure virtual package in
 *         this set is encountered, it will not be ignored even if a
 *         provider is already installed or going to be installed.  If
 *         only one package provides it, that package will be targeted
 *         by the action; otherwise cmdline_applyaction will fail but
 *         not print the usual error message.  The purpose of this
 *         option is to improve the error messages that are printed on
 *         the second pass, but more importantly to ensure that the
 *         dependencies of virtual packages are installed. (bug
 *         #475006)
 *
 *  \param to_install The set of packages that are currently marked
 *  to-be-installed; will be updated in accordance with the selected
 *  action.
 *
 *  \param to_hold The set of packages that are currently marked
 *  to-be-held; will be updated in accordance with the selected
 *  action.
 *
 *  \param to_remove The set of packages that are currently marked
 *  to-be-removed; will be updated in accordance with the selected
 *  action.
 *
 *  \param to_purge The set of packages that are currently marked
 *  to-be-purged; will be updated in accordance with the selected
 *  action.
 *
 *  \param verbose The verbosity level at which this command should
 *  operate.
 *
 *  \param policy A current policy object (passed as a parameter to
 *  avoid creating a separate one for each action).
 *
 *  \param arch_only If \b true, when packages' build-depends are
 *  satisfied, only architecture-dependent build depends are used;
 *  Build-Depends-Indep and Build-Conflicts-Indep lines are ignored.
 *
 *  \param allow_auto If \b false, auto-installation of dependencies
 *  will be disabled regardless of the value of Auto-Install.
 */
bool cmdline_applyaction(string s,
			 std::set<pkgCache::PkgIterator> &seen_virtual_packages,
			 cmdline_pkgaction_type action,
			 pkgset &to_install, pkgset &to_hold,
			 pkgset &to_remove, pkgset &to_purge,
			 int verbose,
			 pkgPolicy &policy, bool arch_only,
			 bool allow_auto,
                         const boost::shared_ptr<aptitude::cmdline::terminal_metrics> &term);

/** \brief Parses a list of actions and executes them.
 *
 *  If there is a syntax or other error, all the commands up to the
 *  point of the error will be executed regardless.
 *
 *  \param s The string to be parsed.
 *
 *  \param seen_virtual_packages The set of pure virtual packages that
 *         have already been "seen".  If a pure virtual package in
 *         this set is encountered, it will not be ignored even if a
 *         provider is already installed or going to be installed.  If
 *         only one package provides it, that package will be targeted
 *         by the action; otherwise cmdline_applyaction will fail but
 *         not print the usual error message.  The purpose of this
 *         option is to improve the error messages that are printed on
 *         the second pass, but more importantly to ensure that the
 *         dependencies of virtual packages are installed. (bug
 *         #475006)
 *
 *  \param to_install The set of packages that are currently marked
 *  to-be-installed; will be updated in accordance with the selected
 *  action.
 *
 *  \param to_hold The set of packages that are currently marked
 *  to-be-held; will be updated in accordance with the selected
 *  action.
 *
 *  \param to_remove The set of packages that are currently marked
 *  to-be-removed; will be updated in accordance with the selected
 *  action.
 *
 *  \param to_purge The set of packages that are currently marked
 *  to-be-purged; will be updated in accordance with the selected
 *  action.
 *
 *  \param verbose The verbosity level at which this command should
 *  operate.
 *
 *  \param policy A current policy object (passed as a parameter to
 *  avoid creating a separate one for each action).
 *
 *  \param arch_only If \b true, when packages' build-depends are
 *  satisfied, only architecture-dependent build depends are used;
 *  Build-Depends-Indep and Build-Conflicts-Indep lines are ignored.
 *
 *  \param allow_auto If \b false, auto-installation of dependencies
 *  will be disabled regardless of the value of Auto-Install.
 */
void cmdline_parse_action(string s,
			  std::set<pkgCache::PkgIterator> &seen_virtual_packages,
			  pkgset &to_install, pkgset &to_hold,
			  pkgset &to_remove, pkgset &to_purge,
			  int verbose,
			  pkgPolicy &policy, bool arch_only,
			  bool allow_auto,
                          const boost::shared_ptr<aptitude::cmdline::terminal_metrics> &term);

#endif // CMDLINE_ACTION_H