sbuild-chroot.h

Go to the documentation of this file.
00001 /* Copyright © 2005-2006  Roger Leigh <rleigh@debian.org>
00002  *
00003  * schroot is free software; you can redistribute it and/or modify it
00004  * under the terms of the GNU General Public License as published by
00005  * the Free Software Foundation; either version 2 of the License, or
00006  * (at your option) any later version.
00007  *
00008  * schroot is distributed in the hope that it will be useful, but
00009  * WITHOUT ANY WARRANTY; without even the implied warranty of
00010  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00011  * General Public License for more details.
00012  *
00013  * You should have received a copy of the GNU General Public License
00014  * along with this program; if not, write to the Free Software
00015  * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
00016  * MA  02111-1307  USA
00017  *
00018  *********************************************************************/
00019 
00020 #ifndef SBUILD_CHROOT_H
00021 #define SBUILD_CHROOT_H
00022 
00023 #include "sbuild-config.h"
00024 
00025 #include <iomanip>
00026 #include <ostream>
00027 #include <string>
00028 #include <vector>
00029 
00030 #ifdef HAVE_TR1_MEMORY
00031 #include <tr1/memory>
00032 #elif HAVE_BOOST_SHARED_PTR_HPP
00033 #include <boost/shared_ptr.hpp>
00034 namespace std { namespace tr1 { using boost::shared_ptr; } }
00035 #else
00036 #error A shared_ptr implementation is not available
00037 #endif
00038 
00039 #include "sbuild-error.h"
00040 #include "sbuild-environment.h"
00041 #include "sbuild-keyfile.h"
00042 #include "sbuild-util.h"
00043 
00044 namespace sbuild
00045 {
00046 
00054   class chroot
00055   {
00056   public:
00058     enum setup_type
00059       {
00060         SETUP_START,   
00061         SETUP_RECOVER, 
00062         SETUP_STOP,    
00063         EXEC_START,     
00064         EXEC_STOP       
00065       };
00066 
00068     enum session_flags
00069       {
00070         SESSION_CREATE = 1 << 0 
00071       };
00072 
00074     typedef runtime_error_custom<chroot> error;
00075 
00077     typedef std::tr1::shared_ptr<chroot> ptr;
00078 
00079   protected:
00081     chroot ();
00082 
00083   public:
00085     virtual ~chroot ();
00086 
00093     static ptr
00094     create (std::string const& type);
00095 
00101     virtual ptr
00102     clone () const = 0;
00103 
00109     std::string const&
00110     get_name () const;
00111 
00117     void
00118     set_name (std::string const& name);
00119 
00125     std::string const&
00126     get_description () const;
00127 
00133     void
00134     set_description (std::string const& description);
00135 
00141     virtual std::string const&
00142     get_mount_location () const;
00143 
00149     void
00150     set_mount_location (std::string const& location);
00151 
00159     virtual std::string const&
00160     get_location () const;
00161 
00162   protected:
00170     virtual void
00171     set_location (std::string const& location);
00172 
00173   public:
00182     virtual std::string
00183     get_path () const;
00184 
00190     virtual std::string const&
00191     get_mount_device () const;
00192 
00198     void
00199     set_mount_device (std::string const& device);
00200 
00207     unsigned int
00208     get_priority () const;
00209 
00219     void
00220     set_priority (unsigned int priority);
00221 
00227     string_list const&
00228     get_groups () const;
00229 
00235     void
00236     set_groups (string_list const& groups);
00237 
00245     string_list const&
00246     get_root_groups () const;
00247 
00255     void
00256     set_root_groups (string_list const& groups);
00257 
00264     string_list const&
00265     get_aliases () const;
00266 
00273     void
00274     set_aliases (string_list const& aliases);
00275 
00281     bool
00282     get_active () const;
00283 
00289     void
00290     set_active (bool active);
00291 
00297     bool
00298     get_run_setup_scripts () const;
00299 
00306     void
00307     set_run_setup_scripts (bool run_setup_scripts);
00308 
00314     bool
00315     get_run_exec_scripts () const;
00316 
00323     void
00324     set_run_exec_scripts (bool run_exec_scripts);
00325 
00332     string_list const&
00333     get_command_prefix () const;
00334 
00341     void
00342     set_command_prefix (string_list const& command_prefix);
00343 
00349     virtual std::string const&
00350     get_chroot_type () const = 0;
00351 
00358     virtual void
00359     setup_env (environment& env);
00360 
00373     virtual void
00374     setup_lock (setup_type type,
00375                 bool       lock) = 0;
00376 
00377   protected:
00383     virtual void
00384     setup_session_info (bool start);
00385 
00386   public:
00393     virtual session_flags
00394     get_session_flags () const = 0;
00395 
00405     friend std::ostream&
00406     operator << (std::ostream& stream,
00407                  ptr const&    rhs)
00408     {
00409       rhs->print_details(stream);
00410       return stream;
00411     }
00412 
00416     friend
00417     keyfile const&
00418     operator >> (keyfile const& keyfile,
00419                  ptr&           rhs)
00420     {
00421       rhs->set_keyfile(keyfile);
00422       return keyfile;
00423     }
00424 
00428     friend
00429     keyfile&
00430     operator << (keyfile&   keyfile,
00431                  ptr const& rhs)
00432     {
00433       rhs->get_keyfile(keyfile);
00434       return keyfile;
00435     }
00436 
00437 
00438   protected:
00446     virtual void
00447     print_details (std::ostream& stream) const;
00448 
00456     virtual void
00457     get_keyfile (keyfile& keyfile) const;
00458 
00466     virtual void
00467     set_keyfile (keyfile const& keyfile);
00468 
00469   private:
00471     std::string   name;
00473     std::string   description;
00475     unsigned int  priority;
00477     string_list   groups;
00479     string_list   root_groups;
00481     string_list   aliases;
00483     std::string   mount_location;
00485     std::string   location;
00487     std::string   mount_device;
00489     bool          active;
00491     bool          run_setup_scripts;
00493     bool          run_exec_scripts;
00495     string_list   command_prefix;
00496   };
00497 
00498 }
00499 
00500 #endif /* SBUILD_CHROOT_H */
00501 
00502 /*
00503  * Local Variables:
00504  * mode:C++
00505  * End:
00506  */

Generated on Sun Apr 30 14:07:01 2006 for schroot by  doxygen 1.4.6