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-personality.h"
00043 #include "sbuild-util.h"
00044 
00045 namespace sbuild
00046 {
00047 
00055   class chroot
00056   {
00057   public:
00059     enum setup_type
00060       {
00061         SETUP_START,   
00062         SETUP_RECOVER, 
00063         SETUP_STOP,    
00064         EXEC_START,    
00065         EXEC_STOP      
00066       };
00067 
00069     enum session_flags
00070       {
00071         SESSION_CREATE = 1 << 0 
00072       };
00073 
00075     typedef runtime_error_custom<chroot> error;
00076 
00078     typedef std::tr1::shared_ptr<chroot> ptr;
00079 
00080   protected:
00082     chroot ();
00083 
00084   public:
00086     virtual ~chroot ();
00087 
00094     static ptr
00095     create (std::string const& type);
00096 
00102     virtual ptr
00103     clone () const = 0;
00104 
00110     std::string const&
00111     get_name () const;
00112 
00118     void
00119     set_name (std::string const& name);
00120 
00126     std::string const&
00127     get_description () const;
00128 
00134     void
00135     set_description (std::string const& description);
00136 
00142     virtual std::string const&
00143     get_mount_location () const;
00144 
00150     void
00151     set_mount_location (std::string const& location);
00152 
00160     virtual std::string const&
00161     get_location () const;
00162 
00163   protected:
00171     virtual void
00172     set_location (std::string const& location);
00173 
00174   public:
00183     virtual std::string
00184     get_path () const;
00185 
00191     virtual std::string const&
00192     get_mount_device () const;
00193 
00199     void
00200     set_mount_device (std::string const& device);
00201 
00208     unsigned int
00209     get_priority () const;
00210 
00220     void
00221     set_priority (unsigned int priority);
00222 
00228     string_list const&
00229     get_groups () const;
00230 
00236     void
00237     set_groups (string_list const& groups);
00238 
00246     string_list const&
00247     get_root_groups () const;
00248 
00256     void
00257     set_root_groups (string_list const& groups);
00258 
00265     string_list const&
00266     get_aliases () const;
00267 
00274     void
00275     set_aliases (string_list const& aliases);
00276 
00282     bool
00283     get_active () const;
00284 
00290     void
00291     set_active (bool active);
00292 
00298     bool
00299     get_run_setup_scripts () const;
00300 
00307     void
00308     set_run_setup_scripts (bool run_setup_scripts);
00309 
00315     bool
00316     get_run_exec_scripts () const;
00317 
00324     void
00325     set_run_exec_scripts (bool run_exec_scripts);
00326 
00333     string_list const&
00334     get_command_prefix () const;
00335 
00342     void
00343     set_command_prefix (string_list const& command_prefix);
00344 
00350     personality const&
00351     get_persona () const;
00352 
00358     void
00359     set_persona (personality const& persona);
00360 
00366     virtual std::string const&
00367     get_chroot_type () const = 0;
00368 
00375     virtual void
00376     setup_env (environment& env);
00377 
00389     void
00390     lock (setup_type type);
00391 
00405     void
00406     unlock (setup_type type,
00407             int        status);
00408 
00409   protected:
00415     virtual void
00416     setup_session_info (bool start);
00417 
00432     virtual void
00433     setup_lock(setup_type type,
00434                bool       lock,
00435                int        status) = 0;
00436 
00437   public:
00444     virtual session_flags
00445     get_session_flags () const = 0;
00446 
00456     friend std::ostream&
00457     operator << (std::ostream& stream,
00458                  ptr const&    rhs)
00459     {
00460       rhs->print_details(stream);
00461       return stream;
00462     }
00463 
00467     friend
00468     keyfile const&
00469     operator >> (keyfile const& keyfile,
00470                  ptr&           rhs)
00471     {
00472       rhs->set_keyfile(keyfile);
00473       return keyfile;
00474     }
00475 
00479     friend
00480     keyfile&
00481     operator << (keyfile&   keyfile,
00482                  ptr const& rhs)
00483     {
00484       rhs->get_keyfile(keyfile);
00485       return keyfile;
00486     }
00487 
00488 
00489   protected:
00497     virtual void
00498     print_details (std::ostream& stream) const;
00499 
00507     virtual void
00508     get_keyfile (keyfile& keyfile) const;
00509 
00517     virtual void
00518     set_keyfile (keyfile const& keyfile);
00519 
00520   private:
00522     std::string   name;
00524     std::string   description;
00526     unsigned int  priority;
00528     string_list   groups;
00530     string_list   root_groups;
00532     string_list   aliases;
00534     std::string   mount_location;
00536     std::string   location;
00538     std::string   mount_device;
00540     bool          active;
00542     bool          run_setup_scripts;
00544     bool          run_exec_scripts;
00546     string_list   command_prefix;
00548     personality   persona;
00549   };
00550 
00551 }
00552 
00553 #endif /* SBUILD_CHROOT_H */
00554 
00555 /*
00556  * Local Variables:
00557  * mode:C++
00558  * End:
00559  */

Generated on Sat Jun 17 14:41:22 2006 for schroot by  doxygen 1.4.6