00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020 #ifndef PALUDIS_GUARD_PALUDIS_MERGER_HH
00021 #define PALUDIS_GUARD_PALUDIS_MERGER_HH 1
00022
00023 #include <paludis/merger-fwd.hh>
00024 #include <paludis/util/fs_entry.hh>
00025 #include <paludis/util/exception.hh>
00026 #include <paludis/util/options.hh>
00027 #include <paludis/util/named_value.hh>
00028 #include <paludis/merger_entry_type.hh>
00029 #include <iosfwd>
00030 #include <sys/stat.h>
00031 #include <sys/types.h>
00032
00033
00034
00035
00036
00037
00038
00039
00040
00041
00042
00043
00044 namespace paludis
00045 {
00046 class Environment;
00047 class Hook;
00048
00049 namespace n
00050 {
00051 struct environment;
00052 struct get_new_ids_or_minus_one;
00053 struct image;
00054 struct install_under;
00055 struct no_chown;
00056 struct options;
00057 struct root;
00058 }
00059
00060
00061
00062
00063
00064
00065
00066
00067
00068 struct MergerParams
00069 {
00070 NamedValue<n::environment, Environment *> environment;
00071 NamedValue<n::get_new_ids_or_minus_one, std::tr1::function<std::pair<uid_t, gid_t> (const FSEntry &)> > get_new_ids_or_minus_one;
00072 NamedValue<n::image, FSEntry> image;
00073 NamedValue<n::install_under, FSEntry> install_under;
00074 NamedValue<n::no_chown, bool> no_chown;
00075 NamedValue<n::options, MergerOptions> options;
00076 NamedValue<n::root, FSEntry> root;
00077 };
00078
00079
00080
00081
00082
00083
00084
00085
00086 class PALUDIS_VISIBLE MergerError :
00087 public Exception
00088 {
00089 public:
00090
00091
00092
00093 MergerError(const std::string & msg) throw ();
00094
00095
00096 };
00097
00098
00099
00100
00101
00102
00103
00104
00105 class PALUDIS_VISIBLE Merger :
00106 private PrivateImplementationPattern<Merger>
00107 {
00108 private:
00109 void record_renamed_dir_recursive(const FSEntry &);
00110 void relabel_dir_recursive(const FSEntry &, const FSEntry &);
00111 void rewrite_symlink_as_needed(const FSEntry &, const FSEntry &);
00112 void try_to_copy_xattrs(const FSEntry &, int, MergeStatusFlags &);
00113 bool symlink_needs_rewriting(const FSEntry &);
00114 void do_ownership_fixes_recursive(const FSEntry &);
00115
00116 protected:
00117
00118
00119
00120 Merger(const MergerParams &);
00121
00122
00123
00124
00125
00126
00127 void make_check_fail();
00128
00129
00130
00131
00132 virtual Hook extend_hook(const Hook &);
00133
00134
00135
00136
00137 virtual EntryType entry_type(const FSEntry &);
00138
00139
00140
00141
00142 virtual void do_dir_recursive(bool is_check, const FSEntry &, const FSEntry &);
00143
00144
00145
00146
00147 virtual void on_enter_dir(bool is_check, const FSEntry);
00148
00149
00150
00151
00152 virtual void on_leave_dir(bool is_check, const FSEntry);
00153
00154
00155
00156
00157 virtual void on_file(bool is_check, const FSEntry &, const FSEntry &);
00158 virtual void on_file_over_nothing(bool is_check, const FSEntry &, const FSEntry &);
00159 virtual void on_file_over_file(bool is_check, const FSEntry &, const FSEntry &);
00160 virtual void on_file_over_dir(bool is_check, const FSEntry &, const FSEntry &);
00161 virtual void on_file_over_sym(bool is_check, const FSEntry &, const FSEntry &);
00162 virtual void on_file_over_misc(bool is_check, const FSEntry &, const FSEntry &);
00163
00164 virtual MergeStatusFlags install_file(const FSEntry &, const FSEntry &, const std::string &) PALUDIS_ATTRIBUTE((warn_unused_result));
00165 virtual void unlink_file(FSEntry);
00166 virtual void record_install_file(const FSEntry &, const FSEntry &, const std::string &, const MergeStatusFlags &) = 0;
00167
00168 virtual void on_dir(bool is_check, const FSEntry &, const FSEntry &);
00169 virtual void on_dir_over_nothing(bool is_check, const FSEntry &, const FSEntry &);
00170 virtual void on_dir_over_file(bool is_check, const FSEntry &, const FSEntry &);
00171 virtual void on_dir_over_dir(bool is_check, const FSEntry &, const FSEntry &);
00172 virtual void on_dir_over_sym(bool is_check, const FSEntry &, const FSEntry &);
00173 virtual void on_dir_over_misc(bool is_check, const FSEntry &, const FSEntry &);
00174
00175 virtual MergeStatusFlags install_dir(const FSEntry &, const FSEntry &) PALUDIS_ATTRIBUTE((warn_unused_result));
00176 virtual void unlink_dir(FSEntry);
00177 virtual void record_install_dir(const FSEntry &, const FSEntry &, const MergeStatusFlags &) = 0;
00178 virtual void record_install_under_dir(const FSEntry &, const MergeStatusFlags &) = 0;
00179
00180 virtual void on_sym(bool is_check, const FSEntry &, const FSEntry &);
00181 virtual void on_sym_over_nothing(bool is_check, const FSEntry &, const FSEntry &);
00182 virtual void on_sym_over_file(bool is_check, const FSEntry &, const FSEntry &);
00183 virtual void on_sym_over_dir(bool is_check, const FSEntry &, const FSEntry &);
00184 virtual void on_sym_over_sym(bool is_check, const FSEntry &, const FSEntry &);
00185 virtual void on_sym_over_misc(bool is_check, const FSEntry &, const FSEntry &);
00186
00187 virtual MergeStatusFlags install_sym(const FSEntry &, const FSEntry &) PALUDIS_ATTRIBUTE((warn_unused_result));
00188 virtual void unlink_sym(FSEntry);
00189 virtual void record_install_sym(const FSEntry &, const FSEntry &, const MergeStatusFlags &) = 0;
00190
00191 virtual void unlink_misc(FSEntry);
00192 virtual void on_misc(bool is_check, const FSEntry &, const FSEntry &);
00193
00194
00195
00196
00197
00198
00199 virtual void on_error(bool is_check, const std::string &) = 0;
00200
00201
00202
00203
00204 virtual void on_warn(bool is_check, const std::string &) = 0;
00205
00206 virtual void display_override(const std::string &) const = 0;
00207
00208
00209
00210
00211 virtual bool config_protected(const FSEntry &, const FSEntry &) = 0;
00212 virtual std::string make_config_protect_name(const FSEntry &, const FSEntry &) = 0;
00213
00214
00215
00216 public:
00217
00218
00219
00220 virtual ~Merger();
00221
00222
00223
00224
00225
00226
00227 virtual bool check() PALUDIS_ATTRIBUTE((warn_unused_result));
00228
00229
00230
00231
00232 virtual void merge();
00233 };
00234
00235 }
00236
00237 #endif