aboutsummaryrefslogtreecommitdiff
path: root/src/output/console_install_task.hh
blob: 90ee086f7312415fde11165f4b49943578f996ab (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
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
/* 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_SRC_CONSOLE_INSTALL_TASK_HH
#define PALUDIS_GUARD_SRC_CONSOLE_INSTALL_TASK_HH 1

#include <paludis/install_task.hh>
#include <paludis/util/set.hh>
#include <src/output/console_task.hh>
#include <iosfwd>
#include <map>
#include <list>

namespace paludis
{
    class ConsoleInstallTask;

    class PALUDIS_VISIBLE DepTagSummaryDisplayer
    {
        private:
            ConsoleInstallTask * _task;

        public:
            DepTagSummaryDisplayer(ConsoleInstallTask *) PALUDIS_ATTRIBUTE((nonnull(1)));
            virtual ~DepTagSummaryDisplayer();

            void visit(const GLSADepTag &);
            void visit(const DependencyDepTag &);
            void visit(const GeneralSetDepTag &);
            void visit(const TargetDepTag &);

            ConsoleInstallTask * task()
            {
                return _task;
            }
    };

    class PALUDIS_VISIBLE EntryDepTagDisplayer
    {
        private:
            std::string _text;

        public:
            EntryDepTagDisplayer();
            virtual ~EntryDepTagDisplayer();

            void visit(const GLSADepTag & tag);
            void visit(const DependencyDepTag &);
            void visit(const GeneralSetDepTag & tag);
            void visit(const TargetDepTag &);

            std::string & text()
            {
                return _text;
            }
    };

    class PALUDIS_VISIBLE ConsoleInstallTask :
        public InstallTask,
        public ConsoleTask
    {
        public:
            enum Count
            {
                max_count,
                new_count,
                upgrade_count,
                downgrade_count,
                new_slot_count,
                rebuild_count,
                error_count,
                suggested_count,
                last_count
            };

            enum DisplayMode
            {
                normal_entry,
                unimportant_entry,
                error_entry,
                suggested_entry
            };

            typedef std::map<ChoiceNameWithPrefix, std::list<std::tr1::shared_ptr<const PackageID> > > ChoiceValueDescriptions;
            typedef std::map<std::string, ChoiceValueDescriptions> ChoiceDescriptions;

        private:
            int _counts[last_count];
            unsigned long _download_size;
            bool _download_size_overflow;
            std::tr1::shared_ptr<Set<DepTagEntry, DepTagEntryComparator> > _all_tags;
            std::tr1::shared_ptr<Set<FSEntry> > _already_downloaded;
            ChoiceDescriptions _choice_descriptions;

            bool _resolution_finished;

            std::tr1::shared_ptr<NotifierCallbackID> _notifier_callback;

            void _notifier_callback_fn(const NotifierCallbackEvent &);

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

        public:
            virtual void execute();
            int exit_status() const;

            bool try_to_set_targets_from_user_specs(const std::tr1::shared_ptr<const Sequence<std::string> > &)
                PALUDIS_ATTRIBUTE((warn_unused_result));

            virtual std::string make_x_of_y(const int x, const int y, const int s, const int f);

            virtual void on_build_deplist_pre();
            virtual void on_build_deplist_post();

            virtual void on_display_merge_list_pre();
            virtual void on_display_merge_list_post();
            virtual void on_not_continuing_due_to_errors();
            virtual void on_display_merge_list_entry(const DepListEntry &);

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

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

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

            virtual void on_skip_unsatisfied(const DepListEntry &, const PackageDepSpec &,
                    const int x, const int y, const int s, const int f);
            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);
            virtual void on_skip_already_done(const DepListEntry &, const int, const int, const int, const int);

            virtual void on_clean_pre(const DepListEntry &,
                    const PackageID &, const int x, const int y, const int s, const int f);
            virtual void on_clean_post(const DepListEntry &,
                    const PackageID &, const int x, const int y, const int s, const int f);
            virtual void on_clean_fail(const DepListEntry &,
                    const PackageID &, const int x, const int y, const int s, const int f);

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

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

            virtual void on_install_action_error(const std::tr1::shared_ptr<OutputManager> &, const ActionError &);
            virtual void on_fetch_action_error(const std::tr1::shared_ptr<OutputManager> &, const FetchActionError &);

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

            virtual void on_phase_skip(const std::tr1::shared_ptr<OutputManager> & output_manager, const std::string & phase);
            virtual void on_phase_abort(const std::tr1::shared_ptr<OutputManager> & output_manager, const std::string & phase);
            virtual void on_phase_skip_until(const std::tr1::shared_ptr<OutputManager> & output_manager, const std::string & phase);
            virtual void on_phase_proceed_conditionally(const std::tr1::shared_ptr<OutputManager> & output_manager, const std::string & phase);
            virtual void on_phase_proceed_unconditionally(const std::tr1::shared_ptr<OutputManager> & output_manager, const std::string & phase);

            ///\name More granular display routines
            ///\{

            virtual void display_merge_list_post_counts();
            virtual void display_merge_list_post_tags();
            virtual void display_merge_list_post_use_descriptions();

            virtual void display_merge_list_entry_start(const DepListEntry &, const DisplayMode);
            virtual void display_merge_list_entry_package_name(const DepListEntry &, const DisplayMode);
            virtual void display_merge_list_entry_repository(const DepListEntry &, const DisplayMode);
            virtual void display_merge_list_entry_slot(const DepListEntry &, const DisplayMode);
            virtual void display_merge_list_entry_for(const PackageID &, const DisplayMode);
            virtual void display_merge_list_entry_status_and_update_counts(const DepListEntry &,
                    const std::tr1::shared_ptr<const PackageIDSequence> &,
                    const std::tr1::shared_ptr<const PackageIDSequence> &, const DisplayMode);
            virtual void display_merge_list_entry_description(const DepListEntry &,
                    const std::tr1::shared_ptr<const PackageIDSequence> &,
                    const std::tr1::shared_ptr<const PackageIDSequence> &, const DisplayMode);
            virtual void display_merge_list_entry_choices(const DepListEntry &, const DisplayMode,
                    const std::tr1::shared_ptr<const PackageIDSequence> & existing_repo,
                    const std::tr1::shared_ptr<const PackageIDSequence> & existing_slot_repo);
            virtual void display_merge_list_entry_distsize(const DepListEntry &, const DisplayMode);
            virtual void display_merge_list_entry_non_package_tags(const DepListEntry &, const DisplayMode);
            virtual void display_merge_list_entry_package_tags(const DepListEntry &, const DisplayMode);
            virtual void display_merge_list_entry_end(const DepListEntry &, const DisplayMode);

            virtual void display_merge_list_entry_mask_reasons(const DepListEntry &);

            virtual void display_tag_summary_start();
            virtual void display_tag_summary_tag_title(const DepTagCategory &);
            virtual void display_tag_summary_tag_pre_text(const DepTagCategory &);
            virtual void display_tag_summary_tag(const std::tr1::shared_ptr<const DepTag> &);
            virtual void display_tag_summary_tag_post_text(const DepTagCategory &);
            virtual void display_tag_summary_end();

            virtual void display_use_summary_start();
            virtual void display_use_summary_start_choice(const ChoiceDescriptions::const_iterator &);
            virtual void display_use_summary_entry(const ChoiceValueDescriptions::const_iterator &);
            virtual void display_use_summary_end_choice(const ChoiceDescriptions::const_iterator &);
            virtual void display_use_summary_end();

            virtual void show_resume_command() const;
            void show_resume_command(const std::string &) const;
            virtual std::string make_resume_command(const bool undo_failures) const = 0;
            virtual void on_installed_paludis();
            virtual HookResult perform_hook(const Hook &) const;

            ///\}

            ///\name Data
            ///\{

            template <Count count_>
            int count() const
            {
                return _counts[count_];
            }

            template <Count count_>
            void set_count(const int value)
            {
                _counts[count_] = value;
            }

            long get_download_size() const
            {
                return _download_size;
            }

            std::tr1::shared_ptr<Set<DepTagEntry, DepTagEntryComparator> > all_tags()
            {
                return _all_tags;
            }

            ///\}

            ///\name Options
            ///\{

            virtual bool want_full_install_reasons() const = 0;
            virtual bool want_install_reasons() const = 0;
            virtual bool want_tags_summary() const = 0;

            virtual bool want_use_summary() const = 0;
            virtual bool want_unchanged_use_flags() const = 0;
            virtual bool want_changed_use_flags() const = 0;
            virtual bool want_new_use_flags() const = 0;

            virtual bool want_new_descriptions() const = 0;
            virtual bool want_existing_descriptions() const = 0;

            virtual bool want_compact() const = 0;
            virtual bool want_suggestions() const = 0;

            ///\}

            ///\name Makers
            ///\{

            std::tr1::shared_ptr<DepTagSummaryDisplayer> make_dep_tag_summary_displayer();
            std::tr1::shared_ptr<EntryDepTagDisplayer> make_entry_dep_tag_displayer();

            ///\}
    };
}

#endif