aboutsummaryrefslogtreecommitdiff
path: root/paludis/install_task.hh
blob: 51a1100d091f499e2d80e85b3fd1108935676026 (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
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
/* vim: set sw=4 sts=4 et foldmethod=syntax : */

/*
 * Copyright (c) 2006, 2007, 2008, 2009 Ciaran McCreesh
 *
 * This file is part of the Paludis package manager. Paludis is free software;
 * you can redistribute it and/or modify it under the terms of the GNU General
 * Public License version 2, as published by the Free Software Foundation.
 *
 * Paludis 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; if not, write to the Free Software Foundation, Inc., 59 Temple
 * Place, Suite 330, Boston, MA  02111-1307  USA
 */

#ifndef PALUDIS_GUARD_PALUDIS_INSTALL_TASK_HH
#define PALUDIS_GUARD_PALUDIS_INSTALL_TASK_HH 1

#include <paludis/util/instantiation_policy.hh>
#include <paludis/util/private_implementation_pattern.hh>
#include <paludis/util/wrapped_forward_iterator-fwd.hh>
#include <paludis/dep_list.hh>
#include <paludis/dep_list_exceptions.hh>
#include <paludis/tasks_exceptions.hh>
#include <paludis/repository-fwd.hh>
#include <paludis/action-fwd.hh>
#include <paludis/package_database-fwd.hh>

/** \file
 * Declarations for InstallTask.
 *
 * \ingroup g_tasks
 *
 * \section Examples
 *
 * - None at this time.
 */

namespace paludis
{
    class Environment;

#include <paludis/install_task-se.hh>

    /**
     * Task used to install one or more targets.
     *
     * \ingroup g_tasks
     * \nosubgrouping
     */
    class PALUDIS_VISIBLE InstallTask :
        PrivateImplementationPattern<InstallTask>,
        InstantiationPolicy<InstallTask, instantiation_method::NonCopyableTag>
    {
        private:
            void _execute();
            void _build_dep_list();
            void _display_task_list();
            bool _pretend();
            void _main_actions();
            void _one(const DepList::Iterator, const int, const int, const int, const int, const bool is_first, const bool is_last);
            void _display_failure_summary();

            void _add_target(const std::string &);
            void _add_package_id(const std::tr1::shared_ptr<const PackageID> &);

            std::tr1::shared_ptr<const PackageDepSpec> _unsatisfied(const DepListEntry &) const;
            std::tr1::shared_ptr<const PackageID> _dependent(const DepListEntry &) const;

        protected:
            ///\name Basic operations
            ///\{

            InstallTask(Environment * const env, const DepListOptions & options,
                    const std::tr1::shared_ptr<const DestinationsSet> & destinations);

            ///\}

            bool already_done(const DepListEntry &) const PALUDIS_ATTRIBUTE((warn_unused_result));
            FetchActionOptions & fetch_action_options() PALUDIS_ATTRIBUTE((warn_unused_result));

        public:
            ///\name Basic operations
            ///\{

            virtual ~InstallTask();

            ///\}

            ///\name DepList and Install behaviour options
            ///\{

            void set_fetch_only(const bool value);
            void set_pretend(const bool value);
            void set_preserve_world(const bool value);
            void set_add_to_world_spec(const std::string &);
            void set_safe_resume(const bool);
            void set_continue_on_failure(const InstallTaskContinueOnFailure);
            void set_skip_phases(const std::tr1::shared_ptr<const Set<std::string> > &);
            void set_skip_until_phases(const std::tr1::shared_ptr<const Set<std::string> > &);
            void set_abort_at_phases(const std::tr1::shared_ptr<const Set<std::string> > &);
            void set_phase_options_apply_to_first(const bool);
            void set_phase_options_apply_to_last(const bool);
            void set_phase_options_apply_to_all(const bool);

            ///\}

            ///\name Targets
            ///\{

            void set_targets_from_user_specs(const std::tr1::shared_ptr<const Sequence<std::string> > &);
            void set_targets_from_exact_packages(const std::tr1::shared_ptr<const PackageIDSequence> &);
            void set_targets_from_serialisation(const std::string &, const std::tr1::shared_ptr<const Sequence<std::string> > &);

            void clear();
            void override_target_type(const DepListTargetType);

            struct TargetsConstIteratorTag;
            typedef WrappedForwardIterator<TargetsConstIteratorTag, const std::string> TargetsConstIterator;
            TargetsConstIterator begin_targets() const PALUDIS_ATTRIBUTE((warn_unused_result));
            TargetsConstIterator end_targets() const PALUDIS_ATTRIBUTE((warn_unused_result));

            ///\}

            ///\name Event callbacks
            ///\{

            virtual void on_build_deplist_pre() = 0;
            virtual void on_build_deplist_post() = 0;

            virtual void on_build_cleanlist_pre(const DepListEntry &) = 0;
            virtual void on_build_cleanlist_post(const DepListEntry &) = 0;

            virtual void on_display_merge_list_pre() = 0;
            virtual void on_display_merge_list_post() = 0;
            virtual void on_display_merge_list_entry(const DepListEntry &) = 0;

            virtual void on_display_failure_summary_pre() = 0;
            virtual void on_display_failure_summary_success(const DepListEntry &) = 0;
            virtual void on_display_failure_summary_failure(const DepListEntry &) = 0;
            virtual void on_display_failure_summary_skipped_unsatisfied(const DepListEntry &, const PackageDepSpec &) = 0;
            virtual void on_display_failure_summary_skipped_dependent(const DepListEntry &, const std::tr1::shared_ptr<const PackageID> &) = 0;
            virtual void on_display_failure_summary_totals(const int, const int, const int, const int, const int) = 0;
            virtual void on_display_failure_summary_post() = 0;

            virtual void on_not_continuing_due_to_errors() = 0;

            virtual void on_pretend_all_pre() = 0;
            virtual void on_pretend_pre(const DepListEntry &) = 0;
            virtual void on_pretend_post(const DepListEntry &) = 0;
            virtual void on_pretend_all_post() = 0;

            virtual void on_fetch_all_pre() = 0;
            virtual void on_fetch_pre(const DepListEntry &, const int x, const int y, const int s, const int f) = 0;
            virtual void on_fetch_post(const DepListEntry &, const int x, const int y, const int s, const int f) = 0;
            virtual void on_fetch_all_post() = 0;

            virtual void on_install_all_pre() = 0;
            virtual void on_install_pre(const DepListEntry &, const int x, const int y, const int s, const int f) = 0;
            virtual void on_install_post(const DepListEntry &, const int x, const int y, const int s, const int f) = 0;
            virtual void on_install_fail(const DepListEntry &, const int x, const int y, const int s, const int f) = 0;
            virtual void on_install_all_post() = 0;

            virtual void on_skip_unsatisfied(const DepListEntry &, const PackageDepSpec &,
                    const int x, const int y, const int s, const int f) = 0;
            virtual void on_skip_dependent(const DepListEntry &, const std::tr1::shared_ptr<const PackageID> &,
                    const int x, const int y, const int s, const int f) = 0;
            virtual void on_skip_already_done(const DepListEntry &, const int, const int, const int, const int) = 0;

            virtual void on_no_clean_needed(const DepListEntry &) = 0;
            virtual void on_clean_all_pre(const DepListEntry &,
                    const PackageIDSequence &) = 0;
            virtual void on_clean_pre(const DepListEntry &,
                    const PackageID &,
                    const int x, const int y, const int s, const int f) = 0;
            virtual void on_clean_post(const DepListEntry &,
                    const PackageID &,
                    const int x, const int y, const int s, const int f) = 0;
            virtual void on_clean_fail(const DepListEntry &,
                    const PackageID &,
                    const int x, const int y, const int s, const int f) = 0;
            virtual void on_clean_all_post(const DepListEntry &,
                    const PackageIDSequence &) = 0;

            virtual void on_update_world_pre() = 0;
            virtual void on_update_world(const PackageDepSpec &) = 0;
            virtual void on_update_world(const SetName &) = 0;
            virtual void on_update_world_skip(const PackageDepSpec &, const std::string &) = 0;
            virtual void on_update_world_skip(const SetName &, const std::string &) = 0;
            virtual void on_update_world_post() = 0;
            virtual void on_preserve_world() = 0;

            virtual void on_installed_paludis();

            virtual void on_ambiguous_package_name_error(const AmbiguousPackageNameError &) = 0;
            virtual void on_no_such_package_error(const NoSuchPackageError &) = 0;
            virtual void on_all_masked_error(const AllMaskedError &) = 0;
            virtual void on_additional_requirements_not_met_error(const AdditionalRequirementsNotMetError &) = 0;
            virtual void on_dep_list_error(const DepListError &) = 0;
            virtual void on_had_both_package_and_set_targets_error(const HadBothPackageAndSetTargets &) = 0;
            virtual void on_multiple_set_targets_specified(const MultipleSetTargetsSpecified &) = 0;

            virtual void on_install_action_error(const InstallActionError &) = 0;
            virtual void on_fetch_action_error(const FetchActionError &) = 0;

            virtual void on_phase_skip(const std::string & phase) = 0;
            virtual void on_phase_abort(const std::string & phase) = 0;
            virtual void on_phase_skip_until(const std::string & phase) = 0;
            virtual void on_phase_proceed_conditionally(const std::string & phase) = 0;
            virtual void on_phase_proceed_unconditionally(const std::string & phase) = 0;

            ///\}

            ///\name Logic
            ///\{

            virtual void world_update_set(const SetName &);
            virtual void world_update_packages(const std::tr1::shared_ptr<const SetSpecTree> &);

            ///\}

            /**
             * Run the task.
             */
            virtual void execute();

            /**
             * Fetch our deplist.
             */
            const DepList & dep_list() const PALUDIS_ATTRIBUTE((warn_unused_result));

            /**
             * Fetch our environment.
             */
            Environment * environment() PALUDIS_ATTRIBUTE((warn_unused_result));

            /**
             * Fetch our environment.
             */
            const Environment * environment() const PALUDIS_ATTRIBUTE((warn_unused_result));

            /**
             * Perform a hook. By default, delegates to environment.
             */
            virtual HookResult perform_hook(const Hook &) const
                PALUDIS_ATTRIBUTE((warn_unused_result));

            /**
             * Have we had any resolution failures?
             */
            virtual bool had_resolution_failures() const PALUDIS_ATTRIBUTE((warn_unused_result));

            /**
             * Have we had any action failures?
             */
            virtual bool had_action_failures() const PALUDIS_ATTRIBUTE((warn_unused_result));

            /**
             * Serialise the task.
             */
            std::string serialise(const bool undo_failures) const PALUDIS_ATTRIBUTE((warn_unused_result));

            /**
             * The format for serialisation.
             */
            std::string serialised_format() const PALUDIS_ATTRIBUTE((warn_unused_result));
    };
}

#endif