00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020 #ifndef SBUILD_CHROOT_CONFIG_H
00021 #define SBUILD_CHROOT_CONFIG_H
00022
00023 #include <sbuild/sbuild-chroot.h>
00024 #include <sbuild/sbuild-custom-error.h>
00025
00026 #include <map>
00027 #include <ostream>
00028 #include <vector>
00029 #include <string>
00030
00031 namespace sbuild
00032 {
00033
00043 class chroot_config
00044 {
00045 public:
00047 typedef std::vector<chroot::ptr> chroot_list;
00049 typedef std::map<std::string, std::string> string_map;
00051 typedef std::map<std::string, chroot::ptr> chroot_map;
00052
00054 enum error_code
00055 {
00056 ALIAS_EXIST,
00057 CHROOT_NOTFOUND,
00058 CHROOT_EXIST,
00059 DIR_OPEN,
00060 FILE_NOTREG,
00061 FILE_OPEN,
00062 FILE_OWNER,
00063 FILE_PERMS,
00064 FILE_STAT
00065 };
00066
00068 typedef custom_error<error_code> error;
00069
00071 typedef std::tr1::shared_ptr<chroot_config> ptr;
00072
00074 chroot_config ();
00075
00084 chroot_config (std::string const& file,
00085 bool active);
00086
00088 virtual ~chroot_config ();
00089
00099 void
00100 add (std::string const& location,
00101 bool active);
00102
00103 private:
00112 void
00113 add_config_file (std::string const& file,
00114 bool active);
00115
00124 void
00125 add_config_directory (std::string const& dir,
00126 bool active);
00127
00128 protected:
00139 void
00140 add (chroot::ptr& chroot,
00141 keyfile const& kconfig);
00142
00143 public:
00150 chroot_list
00151 get_chroots () const;
00152
00159 const chroot::ptr
00160 find_chroot (std::string const& name) const;
00161
00168 const chroot::ptr
00169 find_alias (std::string const& name) const;
00170
00178 string_list
00179 get_chroot_list () const;
00180
00186 void
00187 print_chroot_list (std::ostream& stream) const;
00188
00195 void
00196 print_chroot_list_simple (std::ostream& stream) const;
00197
00205 void
00206 print_chroot_info (string_list const& chroots,
00207 std::ostream& stream) const;
00208
00216 void
00217 print_chroot_location (string_list const& chroots,
00218 std::ostream& stream) const;
00219
00227 void
00228 print_chroot_config (string_list const& chroots,
00229 std::ostream& stream) const;
00230
00238 string_list
00239 validate_chroots (string_list const& chroots) const;
00240
00241 private:
00251 void
00252 load_data (std::string const& file,
00253 bool active);
00254
00255 protected:
00264 virtual void
00265 parse_data (std::istream& stream,
00266 bool active);
00267
00276 virtual void
00277 load_keyfile (keyfile& kconfig,
00278 bool active);
00279
00281 chroot_map chroots;
00283 string_map aliases;
00284 };
00285
00286 }
00287
00288 #endif
00289
00290
00291
00292
00293
00294