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 FILE_NOTREG,
00060 FILE_OPEN,
00061 FILE_OWNER,
00062 FILE_PERMS,
00063 FILE_STAT
00064 };
00065
00067 typedef custom_error<error_code> error;
00068
00070 typedef std::tr1::shared_ptr<chroot_config> ptr;
00071
00073 chroot_config ();
00074
00083 chroot_config (std::string const& file,
00084 bool active);
00085
00087 virtual ~chroot_config ();
00088
00098 void
00099 add (std::string const& location,
00100 bool active);
00101
00102 private:
00111 void
00112 add_config_file (std::string const& file,
00113 bool active);
00114
00123 void
00124 add_config_directory (std::string const& dir,
00125 bool active);
00126
00127 protected:
00138 void
00139 add (chroot::ptr& chroot,
00140 keyfile const& kconfig);
00141
00142 public:
00149 chroot_list
00150 get_chroots () const;
00151
00158 const chroot::ptr
00159 find_chroot (std::string const& name) const;
00160
00167 const chroot::ptr
00168 find_alias (std::string const& name) const;
00169
00177 string_list
00178 get_chroot_list () const;
00179
00185 void
00186 print_chroot_list (std::ostream& stream) const;
00187
00194 void
00195 print_chroot_list_simple (std::ostream& stream) const;
00196
00204 void
00205 print_chroot_info (string_list const& chroots,
00206 std::ostream& stream) const;
00207
00215 void
00216 print_chroot_location (string_list const& chroots,
00217 std::ostream& stream) const;
00218
00226 void
00227 print_chroot_config (string_list const& chroots,
00228 std::ostream& stream) const;
00229
00237 string_list
00238 validate_chroots (string_list const& chroots) const;
00239
00240 private:
00250 void
00251 load_data (std::string const& file,
00252 bool active);
00253
00254 protected:
00263 virtual void
00264 parse_data (std::istream& stream,
00265 bool active);
00266
00275 virtual void
00276 load_keyfile (keyfile& kconfig,
00277 bool active);
00278
00280 chroot_map chroots;
00282 string_map aliases;
00283 };
00284
00285 }
00286
00287 #endif
00288
00289
00290
00291
00292
00293