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 <map>
00024 #include <ostream>
00025 #include <vector>
00026 #include <string>
00027
00028 #include "sbuild-chroot.h"
00029 #include "sbuild-error.h"
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 typedef runtime_error_custom<chroot_config> error;
00055
00057 typedef std::tr1::shared_ptr<chroot_config> ptr;
00058
00060 chroot_config ();
00061
00070 chroot_config (std::string const& file,
00071 bool active);
00072
00074 virtual ~chroot_config ();
00075
00085 void
00086 add (std::string const& location,
00087 bool active);
00088
00089 private:
00098 void
00099 add_config_file (std::string const& file,
00100 bool active);
00101
00110 void
00111 add_config_directory (std::string const& dir,
00112 bool active);
00113
00114 protected:
00124 void
00125 add (chroot::ptr& chroot);
00126
00127 public:
00134 chroot_list
00135 get_chroots () const;
00136
00143 const chroot::ptr
00144 find_chroot (std::string const& name) const;
00145
00152 const chroot::ptr
00153 find_alias (std::string const& name) const;
00154
00162 string_list
00163 get_chroot_list () const;
00164
00170 void
00171 print_chroot_list (std::ostream& stream) const;
00172
00179 void
00180 print_chroot_list_simple (std::ostream& stream) const;
00181
00189 void
00190 print_chroot_info (string_list const& chroots,
00191 std::ostream& stream) const;
00192
00200 void
00201 print_chroot_location (string_list const& chroots,
00202 std::ostream& stream) const;
00203
00211 void
00212 print_chroot_config (string_list const& chroots,
00213 std::ostream& stream) const;
00214
00222 string_list
00223 validate_chroots (string_list const& chroots) const;
00224
00225 private:
00235 void
00236 check_security (int fd) const;
00237
00246 void
00247 load_data (std::string const& file,
00248 bool active);
00249
00258 virtual void
00259 parse_data (std::istream& stream,
00260 bool active);
00261
00263 chroot_map chroots;
00265 string_map aliases;
00266 };
00267
00268 }
00269
00270 #endif
00271
00272
00273
00274
00275
00276