paludis Version 3.0.2
The one true package mangler
action.hh
Go to the documentation of this file.
1/* vim: set sw=4 sts=4 et foldmethod=syntax : */
2
3/*
4 * Copyright (c) 2007, 2008, 2009, 2010, 2011 Ciaran McCreesh
5 *
6 * This file is part of the Paludis package manager. Paludis is free software;
7 * you can redistribute it and/or modify it under the terms of the GNU General
8 * Public License version 2, as published by the Free Software Foundation.
9 *
10 * Paludis is distributed in the hope that it will be useful, but WITHOUT ANY
11 * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
12 * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
13 * details.
14 *
15 * You should have received a copy of the GNU General Public License along with
16 * this program; if not, write to the Free Software Foundation, Inc., 59 Temple
17 * Place, Suite 330, Boston, MA 02111-1307 USA
18 */
19
20#ifndef PALUDIS_GUARD_PALUDIS_ACTION_HH
21#define PALUDIS_GUARD_PALUDIS_ACTION_HH 1
22
23#include <paludis/action-fwd.hh>
27#include <paludis/output_manager-fwd.hh>
28
30#include <paludis/util/visitor.hh>
32#include <paludis/util/pimp.hh>
34#include <paludis/util/named_value.hh>
35#include <paludis/util/fs_path-fwd.hh>
37#include <paludis/util/type_list.hh>
38
39#include <functional>
40
41/** \file
42 * Declarations for action-related classes.
43 *
44 * \ingroup g_actions
45 *
46 * \section Examples
47 *
48 * - \ref example_action.cc "example_action.cc"
49 */
50
51namespace paludis
52{
53 namespace n
54 {
55 typedef Name<struct name_config_protect> config_protect;
56 typedef Name<struct name_cross_compile_host> cross_compile_host;
57 typedef Name<struct name_destination> destination;
58 typedef Name<struct name_errors> errors;
59 typedef Name<struct name_exclude_unmirrorable> exclude_unmirrorable;
60 typedef Name<struct name_failed_automatic_fetching> failed_automatic_fetching;
61 typedef Name<struct name_failed_integrity_checks> failed_integrity_checks;
62 typedef Name<struct name_fetch_parts> fetch_parts;
63 typedef Name<struct name_if_for_install_id> if_for_install_id;
64 typedef Name<struct name_ignore_for_unmerge> ignore_for_unmerge;
65 typedef Name<struct name_ignore_unfetched> ignore_unfetched;
66 typedef Name<struct name_is_overwrite> is_overwrite;
67 typedef Name<struct name_make_output_manager> make_output_manager;
68 typedef Name<struct name_override_contents> override_contents;
69 typedef Name<struct name_perform_uninstall> perform_uninstall;
70 typedef Name<struct name_replacing> replacing;
71 typedef Name<struct name_requires_manual_fetching> requires_manual_fetching;
72 typedef Name<struct name_safe_resume> safe_resume;
73 typedef Name<struct name_tool_prefix> tool_prefix;
74 typedef Name<struct name_target_file> target_file;
75 typedef Name<struct name_want_phase> want_phase;
76 typedef Name<struct name_ignore_not_in_manifest> ignore_not_in_manifest;
77 }
78
79 /**
80 * Options for a FetchAction.
81 *
82 * \see FetchAction
83 * \ingroup g_actions
84 * \since 0.30
85 */
87 {
89
90 /**
91 * Any errors that occur will be added to this list. Must not be null.
92 *
93 * \since 0.40
94 */
96
97 /**
98 * \since 0.32
99 */
101
102 /**
103 * Which parts to fetch.
104 *
105 * \since 0.43
106 */
108
109 /**
110 * Ignore if a package is or isn't referenced in the Manifest.
111 * It's useful for generating manifests, to avoid getting errors
112 * before generating it.
113 *
114 * \since 0.46
115 */
117
118 /**
119 * Ignore any unfetched packages. Verify digests for anything that's
120 * already there, and if we know for sure manual fetching will be
121 * required, raise the appropriate error.
122 *
123 * \since 0.36
124 */
126
127 /**
128 * This is a function to avoid chicken / egg problems when using
129 * Environment::create_output_manager.
130 *
131 * \since 0.36
132 */
135
137
139
140 /**
141 * \since 0.48
142 */
143 NamedValue<n::want_phase, std::function<WantPhase (const std::string &)> > want_phase;
144 };
145
146 /**
147 * Options for an InstallAction.
148 *
149 * \see InstallAction
150 * \ingroup g_actions
151 * \since 0.30
152 */
154 {
156
157 /**
158 * This is a function to avoid chicken / egg problems when using
159 * Environment::create_output_manager.
160 *
161 * \since 0.36
162 */
165
166 /**
167 * Callback to carry out an uninstall, for replacing.
168 *
169 * Won't necessarily be used. Some repositories have special code paths
170 * for reinstalls, and in some cases (e.g. accounts) an upgrade doesn't
171 * remove the old version at all.
172 *
173 * \since 0.36
174 */
175 NamedValue<n::perform_uninstall, std::function<void (
176 const std::shared_ptr<const PackageID> &,
179
180 /**
181 * We must replace these.
182 *
183 * \since 0.36
184 */
186
187 NamedValue<n::want_phase, std::function<WantPhase (const std::string &)> > want_phase;
188 };
189
190 /**
191 * Options for an UninstallAction.
192 *
193 * \see UninstallAction
194 * \ingroup g_actions
195 * \since 0.30
196 */
198 {
200
201 /**
202 * If we're being uninstalled as part of an install, this is the ID
203 * that's being installed. Otherwise null.
204 *
205 * \since 0.36
206 */
208
209 /**
210 * Sometimes we never want to unmerge certain files.
211 *
212 * \since 0.38
213 * \since 0.55 uses FSPath
214 */
215 NamedValue<n::ignore_for_unmerge, std::function<bool (const FSPath &)> > ignore_for_unmerge;
216
217 /**
218 * Some repositories need to do special handlings for direct overwrites
219 * (foo-1.2 replacing foo-1.2). Clients should set this to false.
220 *
221 * \since 0.36
222 */
224
225 /**
226 * This is a function to avoid chicken / egg problems when using
227 * Environment::create_output_manager.
228 *
229 * \since 0.36
230 */
233
234 /**
235 * Sometimes we need to override the contents of an installed package,
236 * for example when doing 'overwrite' merges for VDB.
237 *
238 * Not all repositories support this, or do what you expect with it. Clients
239 * should always set this to null.
240 *
241 * \since 0.61
242 */
244
245 /**
246 * \since 0.77
247 */
248 NamedValue<n::want_phase, std::function<WantPhase (const std::string &)> > want_phase;
249 };
250
251 /**
252 * A failed fetch action part.
253 *
254 * \see FetchActionError
255 * \ingroup g_actions
256 * \since 0.30
257 */
265
266 /**
267 * An Action represents an action that can be executed by a PackageID via
268 * PackageID::perform_action.
269 *
270 * \since 0.26
271 * \ingroup g_actions
272 * \nosubgrouping
273 */
275 public virtual DeclareAbstractAcceptMethods<Action, MakeTypeList<
276 InstallAction, UninstallAction, PretendAction, ConfigAction, FetchAction,
277 InfoAction, PretendFetchAction>::Type>
278 {
279 public:
280 ///\name Basic operations
281 ///\{
282
283 virtual ~Action() = 0;
284
285 ///\}
286
287 /**
288 * A simple string name (install, uninstall, pretend-fetch etc).
289 *
290 * \since 0.44
291 */
292 virtual const std::string simple_name() const PALUDIS_ATTRIBUTE((warn_unused_result)) = 0;
293 };
294
295 /**
296 * An InstallAction is used by InstallTask to perform a build / install on a
297 * PackageID.
298 *
299 * \since 0.26
300 * \ingroup g_actions
301 * \nosubgrouping
302 */
303 class PALUDIS_VISIBLE InstallAction :
304 public Action,
305 public ImplementAcceptMethods<Action, InstallAction>
306 {
307 private:
309
310 public:
311 ///\name Basic operations
312 ///\{
313
314 InstallAction(const InstallActionOptions &);
315 ~InstallAction() override;
316
317 ///\}
318
319 /// Options for the action.
321
322 const std::string simple_name() const override PALUDIS_ATTRIBUTE((warn_unused_result));
323
324 static const std::string class_simple_name() PALUDIS_ATTRIBUTE((warn_unused_result));
325 };
326
327 /**
328 * A FetchAction can be used to fetch source files for a PackageID using
329 * PackageID::perform_action.
330 *
331 * \since 0.26
332 * \ingroup g_actions
333 * \nosubgrouping
334 */
335 class PALUDIS_VISIBLE FetchAction :
336 public Action,
337 public ImplementAcceptMethods<Action, FetchAction>
338 {
339 private:
341
342 public:
343 ///\name Basic operations
344 ///\{
345
346 FetchAction(const FetchActionOptions &);
347 ~FetchAction() override;
348
349 ///\}
350
351 /// Options for the action.
353
354 const std::string simple_name() const override PALUDIS_ATTRIBUTE((warn_unused_result));
355
356 static const std::string class_simple_name() PALUDIS_ATTRIBUTE((warn_unused_result));
357 static const std::string ignore_unfetched_flag_name() PALUDIS_ATTRIBUTE((warn_unused_result));
358 };
359
360 /**
361 * An UninstallAction is used by UninstallTask to uninstall a PackageID.
362 *
363 * \since 0.26
364 * \ingroup g_actions
365 * \nosubgrouping
366 */
367 class PALUDIS_VISIBLE UninstallAction :
368 public Action,
369 public ImplementAcceptMethods<Action, UninstallAction>
370 {
371 private:
373
374 public:
375 ///\name Basic operations
376 ///\{
377
378 UninstallAction(const UninstallActionOptions &);
379 ~UninstallAction() override;
380
381 ///\}
382
383 /// Options for the action.
385
386 const std::string simple_name() const override PALUDIS_ATTRIBUTE((warn_unused_result));
387
388 static const std::string class_simple_name() PALUDIS_ATTRIBUTE((warn_unused_result));
389 };
390
391 /**
392 * Options for a PretendAction.
393 *
394 * \see PretendAction
395 * \ingroup g_actions
396 * \since 0.36
397 */
399 {
401
402 /**
403 * This is a function to avoid chicken / egg problems when using
404 * Environment::create_output_manager.
405 *
406 * \since 0.36
407 */
410
411 /**
412 * We will replace these.
413 *
414 * \since 0.55
415 */
417 };
418
419 /**
420 * A PretendAction is used by InstallTask to handle install-pretend-phase
421 * checks on a PackageID.
422 *
423 * \since 0.26
424 * \ingroup g_actions
425 * \nosubgrouping
426 */
428 public Action,
429 public ImplementAcceptMethods<Action, PretendAction>
430 {
431 private:
433
434 public:
435 ///\name Basic operations
436 ///\{
437
438 /**
439 * \since 0.36
440 */
442 ~PretendAction() override;
443
444 ///\}
445
446 /// Did our pretend phase fail?
447 bool failed() const PALUDIS_ATTRIBUTE((warn_unused_result));
448
449 /// Mark the action as failed.
451
452 /**
453 * \since 0.36
454 */
456
457 const std::string simple_name() const override PALUDIS_ATTRIBUTE((warn_unused_result));
458
459 static const std::string class_simple_name() PALUDIS_ATTRIBUTE((warn_unused_result));
460 };
461
462 /**
463 * A PretendFetchAction is used to get information about a fetch that will take
464 * place on a PackageID.
465 *
466 * \since 0.26
467 * \ingroup g_actions
468 * \nosubgrouping
469 */
470 class PALUDIS_VISIBLE PretendFetchAction :
471 public Action,
472 public ImplementAcceptMethods<Action, PretendFetchAction>
473 {
474 private:
476
477 public:
478 ///\name Basic operations
479 ///\{
480
481 PretendFetchAction(const FetchActionOptions &);
482 ~PretendFetchAction() override;
483
484 ///\}
485
486 /// Options for the FetchAction we will use.
488
489 /// Signal that we will fetch a particular file.
490 virtual void will_fetch(const FSPath & destination, const unsigned long size_in_bytes) = 0;
491
492 const std::string simple_name() const override PALUDIS_ATTRIBUTE((warn_unused_result));
493
494 static const std::string class_simple_name() PALUDIS_ATTRIBUTE((warn_unused_result));
495 };
496
497 /**
498 * Options for a ConfigAction.
499 *
500 * \see ConfigAction
501 * \ingroup g_actions
502 * \since 0.36
503 */
505 {
506 /**
507 * This is a function to avoid chicken / egg problems when using
508 * Environment::create_output_manager.
509 *
510 * \since 0.36
511 */
514 };
515
516 /**
517 * A ConfigAction is used via PackageID::perform_action to execute
518 * post-install configuration (for example, via 'paludis --config')
519 * on a PackageID.
520 *
521 * \since 0.26
522 * \ingroup g_actions
523 * \nosubgrouping
524 */
526 public Action,
527 public ImplementAcceptMethods<Action, ConfigAction>
528 {
529 private:
531
532 public:
533 ///\name Basic operations
534 ///\{
535
536 /**
537 * \since 0.36
538 */
540 ~ConfigAction() override;
541
542 ///\}
543
544 /**
545 * \since 0.36
546 */
548
549 const std::string simple_name() const override PALUDIS_ATTRIBUTE((warn_unused_result));
550
551 static const std::string class_simple_name() PALUDIS_ATTRIBUTE((warn_unused_result));
552 };
553
554 /**
555 * Options for an InfoAction.
556 *
557 * \see InfoAction
558 * \ingroup g_actions
559 * \since 0.36
560 */
562 {
564
565 /**
566 * This is a function to avoid chicken / egg problems when using
567 * Environment::create_output_manager.
568 *
569 * \since 0.36
570 */
573
575 };
576
577 /**
578 * An InfoAction is used via PackageID::perform_action to execute
579 * additional information (for example, via 'paludis --info')
580 * on a PackageID.
581 *
582 * This action potentially makes sense for both installed and
583 * installable packages. Unlike Ebuild EAPI-0 'pkg_info', this
584 * action is not specifically tied to installed packages.
585 *
586 * \since 0.26
587 * \ingroup g_actions
588 * \nosubgrouping
589 */
591 public Action,
592 public ImplementAcceptMethods<Action, InfoAction>
593 {
594 private:
595 Pimp<InfoAction> _imp;
596
597 public:
598 ///\name Basic operations
599 ///\{
600
601 /**
602 * \since 0.36
603 */
605
606 ~InfoAction() override;
607
608 ///\}
609
610 /**
611 * \since 0.36
612 */
614
615 const std::string simple_name() const override PALUDIS_ATTRIBUTE((warn_unused_result));
616
617 static const std::string class_simple_name() PALUDIS_ATTRIBUTE((warn_unused_result));
618 };
619
620 /**
621 * Base class for SupportsActionTest<>.
622 *
623 * \see SupportsActionTest<>
624 * \since 0.26
625 * \ingroup g_actions
626 * \nosubgrouping
627 */
637
638 /**
639 * Instantiated with an Action subclass as its template parameter,
640 * SupportsActionTest<> is used by PackageID::supports_action and
641 * Repository::some_ids_might_support_action to query whether a
642 * particular action is supported by that PackageID or potentially
643 * supported by some IDs in that Repository.
644 *
645 * Use of a separate class, rather than a mere Action, avoids the
646 * need to create bogus options for the more complicated Action
647 * subclasses.
648 *
649 * \since 0.26
650 * \ingroup g_actions
651 * \nosubgrouping
652 */
653 template <typename A_>
656 public ImplementAcceptMethods<SupportsActionTestBase, SupportsActionTest<A_> >
657 {
658 };
659
660 /**
661 * Thrown if an action fails.
662 *
663 * \ingroup g_actions
664 * \ingroup g_exceptions
665 * \since 0.42
666 */
667 class PALUDIS_VISIBLE ActionFailedError :
668 public Exception
669 {
670 public:
671 ///\name Basic operations
672 ///\{
673
674 ActionFailedError(const std::string & msg) noexcept;
675
676 ///\}
677 };
678
679 /**
680 * Thrown if an action is aborted.
681 *
682 * \ingroup g_actions
683 * \ingroup g_exceptions
684 * \since 0.42
685 */
686 class PALUDIS_VISIBLE ActionAbortedError :
687 public Exception
688 {
689 public:
690 ///\name Basic operations
691 ///\{
692
693 ActionAbortedError(const std::string &) noexcept;
694
695 ///\}
696 };
697
698 extern template class Pimp<FetchAction>;
699 extern template class Pimp<InstallAction>;
700 extern template class Pimp<PretendAction>;
701 extern template class Pimp<PretendFetchAction>;
702 extern template class Pimp<UninstallAction>;
703 extern template class Pimp<InfoAction>;
704 extern template class Pimp<ConfigAction>;
705}
706
707#endif
Definition action.hh:278
virtual const std::string simple_name() const PALUDIS_ATTRIBUTE((warn_unused_result))=0
Definition action.hh:528
const ConfigActionOptions & options
Definition action.hh:547
const std::string simple_name() const override PALUDIS_ATTRIBUTE((warn_unused_result))
ConfigAction(const ConfigActionOptions &)
Definition visitor.hh:326
Definition fs_path.hh:34
Definition action.hh:338
const FetchActionOptions & options
Options for the action.
Definition action.hh:352
const std::string simple_name() const override PALUDIS_ATTRIBUTE((warn_unused_result))
Definition visitor.hh:411
Definition action.hh:593
const InfoActionOptions & options
Definition action.hh:613
const std::string simple_name() const override PALUDIS_ATTRIBUTE((warn_unused_result))
InfoAction(const InfoActionOptions &)
Definition action.hh:306
const InstallActionOptions & options
Options for the action.
Definition action.hh:320
const std::string simple_name() const override PALUDIS_ATTRIBUTE((warn_unused_result))
Definition named_value.hh:51
Definition pimp.hh:52
Definition action.hh:430
PretendAction(const PretendActionOptions &)
const std::string simple_name() const override PALUDIS_ATTRIBUTE((warn_unused_result))
const PretendActionOptions & options
Definition action.hh:455
void set_failed()
Mark the action as failed.
bool failed() const PALUDIS_ATTRIBUTE((warn_unused_result))
Did our pretend phase fail?
Definition action.hh:473
const std::string simple_name() const override PALUDIS_ATTRIBUTE((warn_unused_result))
virtual void will_fetch(const FSPath &destination, const unsigned long size_in_bytes)=0
Signal that we will fetch a particular file.
const FetchActionOptions & options
Options for the FetchAction we will use.
Definition action.hh:487
Definition action.hh:633
Definition action.hh:657
Definition action.hh:370
const UninstallActionOptions & options
Options for the action.
Definition action.hh:384
const std::string simple_name() const override PALUDIS_ATTRIBUTE((warn_unused_result))
#define PALUDIS_ATTRIBUTE(x)
Definition attributes.hh:53
#define PALUDIS_VISIBLE
Definition attributes.hh:59
Definition about_metadata-fwd.hh:24
Definition action.hh:505
NamedValue< n::make_output_manager, std::function< std::shared_ptr< OutputManager >(const ConfigAction &)> > make_output_manager
Definition action.hh:513
Definition action.hh:259
Definition action.hh:87
NamedValue< n::make_output_manager, std::function< std::shared_ptr< OutputManager >(const FetchAction &)> > make_output_manager
Definition action.hh:134
NamedValue< n::exclude_unmirrorable, bool > exclude_unmirrorable
Definition action.hh:100
NamedValue< n::ignore_not_in_manifest, bool > ignore_not_in_manifest
Definition action.hh:116
NamedValue< n::ignore_unfetched, bool > ignore_unfetched
Definition action.hh:125
NamedValue< n::errors, std::shared_ptr< Sequence< FetchActionFailure > > > errors
Definition action.hh:95
NamedValue< n::want_phase, std::function< WantPhase(const std::string &)> > want_phase
Definition action.hh:143
NamedValue< n::fetch_parts, FetchParts > fetch_parts
Definition action.hh:107
Definition action.hh:562
NamedValue< n::make_output_manager, std::function< std::shared_ptr< OutputManager >(const InfoAction &)> > make_output_manager
Definition action.hh:572
Definition action.hh:154
NamedValue< n::replacing, std::shared_ptr< const PackageIDSequence > > replacing
Definition action.hh:185
NamedValue< n::perform_uninstall, std::function< void(const std::shared_ptr< const PackageID > &, const UninstallActionOptions &)> > perform_uninstall
Definition action.hh:178
NamedValue< n::make_output_manager, std::function< std::shared_ptr< OutputManager >(const InstallAction &)> > make_output_manager
Definition action.hh:164
Definition type_list-fwd.hh:31
Definition action.hh:399
NamedValue< n::make_output_manager, std::function< std::shared_ptr< OutputManager >(const PretendAction &)> > make_output_manager
Definition action.hh:409
NamedValue< n::replacing, std::shared_ptr< const PackageIDSequence > > replacing
Definition action.hh:416
Definition action.hh:198
NamedValue< n::is_overwrite, bool > is_overwrite
Definition action.hh:223
NamedValue< n::ignore_for_unmerge, std::function< bool(const FSPath &)> > ignore_for_unmerge
Definition action.hh:215
NamedValue< n::if_for_install_id, std::shared_ptr< const PackageID > > if_for_install_id
Definition action.hh:207
NamedValue< n::override_contents, std::shared_ptr< const Contents > > override_contents
Definition action.hh:243
NamedValue< n::make_output_manager, std::function< std::shared_ptr< OutputManager >(const UninstallAction &)> > make_output_manager
Definition action.hh:232
NamedValue< n::want_phase, std::function< WantPhase(const std::string &)> > want_phase
Definition action.hh:248