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 CHROOT,
00057 DIR_OPEN,
00058 FILE_NOTREG,
00059 FILE_OPEN,
00060 FILE_OWNER,
00061 FILE_PERMS,
00062 FILE_STAT
00063 };
00064
00066 typedef custom_error<error_code> error;
00067
00069 typedef std::tr1::shared_ptr<chroot_config> ptr;
00070
00072 chroot_config ();
00073
00082 chroot_config (std::string const& file,
00083 bool active);
00084
00086 virtual ~chroot_config ();
00087
00097 void
00098 add (std::string const& location,
00099 bool active);
00100
00101 private:
00110 void
00111 add_config_file (std::string const& file,
00112 bool active);
00113
00122 void
00123 add_config_directory (std::string const& dir,
00124 bool active);
00125
00126 protected:
00136 void
00137 add (chroot::ptr& chroot);
00138
00139 public:
00146 chroot_list
00147 get_chroots () const;
00148
00155 const chroot::ptr
00156 find_chroot (std::string const& name) const;
00157
00164 const chroot::ptr
00165 find_alias (std::string const& name) const;
00166
00174 string_list
00175 get_chroot_list () const;
00176
00182 void
00183 print_chroot_list (std::ostream& stream) const;
00184
00191 void
00192 print_chroot_list_simple (std::ostream& stream) const;
00193
00201 void
00202 print_chroot_info (string_list const& chroots,
00203 std::ostream& stream) const;
00204
00212 void
00213 print_chroot_location (string_list const& chroots,
00214 std::ostream& stream) const;
00215
00223 void
00224 print_chroot_config (string_list const& chroots,
00225 std::ostream& stream) const;
00226
00234 string_list
00235 validate_chroots (string_list const& chroots) const;
00236
00237 private:
00247 void
00248 load_data (std::string const& file,
00249 bool active);
00250
00259 virtual void
00260 parse_data (std::istream& stream,
00261 bool active);
00262
00264 chroot_map chroots;
00266 string_map aliases;
00267 };
00268
00269 }
00270
00271 #endif
00272
00273
00274
00275
00276
00277