paludis Version 3.0.2
The one true package mangler
merger.hh
1/* vim: set sw=4 sts=4 et foldmethod=syntax : */
2
3/*
4 * Copyright (c) 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_MERGER_HH
21#define PALUDIS_GUARD_PALUDIS_MERGER_HH 1
22
23#include <paludis/merger-fwd.hh>
24#include <paludis/util/named_value.hh>
26#include <paludis/util/timestamp.hh>
27#include <paludis/util/fs_path.hh>
28#include <paludis/hook-fwd.hh>
31#include <paludis/output_manager-fwd.hh>
32
33namespace paludis
34{
35 namespace n
36 {
37 typedef Name<struct name_environment> environment;
38 typedef Name<struct name_fix_mtimes_before> fix_mtimes_before;
39 typedef Name<struct name_get_new_ids_or_minus_one> get_new_ids_or_minus_one;
40 typedef Name<struct name_image> image;
41 typedef Name<struct name_install_under> install_under;
42 typedef Name<struct name_maybe_output_manager> maybe_output_manager;
43 typedef Name<struct name_merged_entries> merged_entries;
44 typedef Name<struct name_no_chown> no_chown;
45 typedef Name<struct name_options> options;
46 typedef Name<struct name_permit_destination> permit_destination;
47 typedef Name<struct name_root> root;
48 }
49
50 /**
51 * Parameters for a basic Merger.
52 *
53 * \see Merger
54 * \ingroup g_repository
55 * \nosubgrouping
56 * \since 0.30
57 */
75
76 class PALUDIS_VISIBLE MergerError :
77 public Exception
78 {
79 public:
80 MergerError(const std::string &) noexcept;
81 };
82
83 class PALUDIS_VISIBLE Merger
84 {
85 private:
86 Pimp<Merger> _imp;
87
88 protected:
89 bool symlink_needs_rewriting(const FSPath &);
90 void rewrite_symlink_as_needed(const FSPath &, const FSPath &);
91 void set_skipped_dir(const bool);
92 void do_ownership_fixes_recursive(const FSPath &);
93 bool fixed_ownership_for(const FSPath &);
94
95 /**
96 * Allows subclasses to extend hook calls.
97 */
98 virtual Hook extend_hook(const Hook &);
99
100 /**
101 * Allows subclasses to perform behaviour before anything has been
102 * merged, after initialization.
103 */
104 virtual void on_begin_merge();
105
106 /**
107 * When called, makes check()'s result a failure.
108 */
110
111 /**
112 * Handle a directory, recursively.
113 */
114 virtual void do_dir_recursive(bool is_check, const FSPath &, const FSPath &);
115
116 /**
117 * Determine the entry type of a filesystem entry.
118 */
119 virtual EntryType entry_type(const FSPath &);
120
121 /**
122 * Allows subclasses to perform behaviour when entering a directory.
123 */
124 virtual void on_enter_dir(bool is_check, const FSPath);
125
126 /**
127 * Allows subclasses to perform behaviour when leaving a directory.
128 */
129 virtual void on_leave_dir(bool is_check, const FSPath);
130
131 /**
132 * Allows subclasses to perform behaviour when everything has been
133 * merged, before any cleanup.
134 */
135 virtual void on_done_merge();
136
137 /**
138 * What to do when an error occurs.
139 */
140 virtual void on_error(bool is_check, const std::string &) = 0;
141
142 /**
143 * What to do when a warning occurs.
144 */
145 virtual void on_warn(bool is_check, const std::string &) = 0;
146
147 virtual void display_override(const std::string &) const = 0;
148
149 virtual void on_misc(bool is_check, const FSPath &, const FSPath &);
150 virtual void on_file(bool is_check, const FSPath &, const FSPath &);
151 virtual void on_dir(bool is_check, const FSPath &, const FSPath &);
152 virtual void on_sym(bool is_check, const FSPath &, const FSPath &);
153
154 virtual void on_file_main(bool is_check, const FSPath &, const FSPath &) = 0;
155 virtual void on_dir_main(bool is_check, const FSPath &, const FSPath &) = 0;
156 virtual void on_sym_main(bool is_check, const FSPath &, const FSPath &) = 0;
157
158 virtual void prepare_install_under() = 0;
159
160 virtual FSPath canonicalise_root_path(const FSPath &) = 0;
161
162 public:
163 explicit Merger(const MergerParams &);
164 ~Merger();
165
166 Merger(const Merger &) = delete;
167 Merger & operator= (const Merger &) = delete;
168
169 /**
170 * Check a merge, return whether no errors were encountered.
171 */
172 virtual bool check() PALUDIS_ATTRIBUTE((warn_unused_result));
173
174 /**
175 * Perform the merge.
176 */
177 virtual void merge();
178 };
179}
180
181#endif
Definition fs_path.hh:34
Definition hook.hh:75
virtual void on_warn(bool is_check, const std::string &)=0
virtual EntryType entry_type(const FSPath &)
void make_check_fail()
virtual void do_dir_recursive(bool is_check, const FSPath &, const FSPath &)
virtual void on_done_merge()
virtual void on_enter_dir(bool is_check, const FSPath)
virtual void merge()
virtual void on_begin_merge()
virtual void on_leave_dir(bool is_check, const FSPath)
virtual Hook extend_hook(const Hook &)
virtual bool check() PALUDIS_ATTRIBUTE((warn_unused_result))
virtual void on_error(bool is_check, const std::string &)=0
Definition named_value.hh:51
Definition pimp.hh:52
#define PALUDIS_ATTRIBUTE(x)
Definition attributes.hh:53
#define PALUDIS_VISIBLE
Definition attributes.hh:59
Definition about_metadata-fwd.hh:24
Definition merger.hh:59
NamedValue< n::permit_destination, PermitDestinationFn > permit_destination
Definition merger.hh:71