Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019 #ifndef SBUILD_CHROOT_CONFIG_H
00020 #define SBUILD_CHROOT_CONFIG_H
00021
00022 #include <sbuild/sbuild-chroot.h>
00023 #include <sbuild/sbuild-custom-error.h>
00024
00025 #include <map>
00026 #include <ostream>
00027 #include <vector>
00028 #include <string>
00029
00030 namespace sbuild
00031 {
00032
00042 class chroot_config
00043 {
00044 public:
00046 typedef std::vector<chroot::ptr> chroot_list;
00048 typedef std::map<std::string, std::string> string_map;
00050 typedef std::map<std::string, chroot::ptr> chroot_map;
00051
00053 enum error_code
00054 {
00055 ALIAS_EXIST,
00056 CHROOT_NOTFOUND,
00057 CHROOT_EXIST,
00058 FILE_NOTREG,
00059 FILE_OPEN,
00060 FILE_OWNER,
00061 FILE_PERMS
00062 };
00063
00065 typedef custom_error<error_code> error;
00066
00068 typedef std::tr1::shared_ptr<chroot_config> ptr;
00069
00071 chroot_config ();
00072
00081 chroot_config (std::string const& file,
00082 bool active);
00083
00085 virtual ~chroot_config ();
00086
00096 void
00097 add (std::string const& location,
00098 bool active);
00099
00100 private:
00109 void
00110 add_config_file (std::string const& file,
00111 bool active);
00112
00121 void
00122 add_config_directory (std::string const& dir,
00123 bool active);
00124
00125 protected:
00136 void
00137 add (chroot::ptr& chroot,
00138 keyfile const& kconfig);
00139
00140 public:
00147 chroot_list
00148 get_chroots () const;
00149
00156 const chroot::ptr
00157 find_chroot (std::string const& name) const;
00158
00165 const chroot::ptr
00166 find_alias (std::string const& name) const;
00167
00175 string_list
00176 get_chroot_list () const;
00177
00183 void
00184 print_chroot_list (std::ostream& stream) const;
00185
00192 void
00193 print_chroot_list_simple (std::ostream& stream) const;
00194
00202 void
00203 print_chroot_info (string_list const& chroots,
00204 std::ostream& stream) const;
00205
00213 void
00214 print_chroot_location (string_list const& chroots,
00215 std::ostream& stream) const;
00216
00224 void
00225 print_chroot_config (string_list const& chroots,
00226 std::ostream& stream) const;
00227
00235 string_list
00236 validate_chroots (string_list const& chroots) const;
00237
00238 private:
00248 void
00249 load_data (std::string const& file,
00250 bool active);
00251
00252 protected:
00261 virtual void
00262 parse_data (std::istream& stream,
00263 bool active);
00264
00273 virtual void
00274 load_keyfile (keyfile& kconfig,
00275 bool active);
00276
00278 chroot_map chroots;
00280 string_map aliases;
00281 };
00282
00283 }
00284
00285 #endif
00286
00287
00288
00289
00290
00291