dchroot-main.cc

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 #include <config.h>
00021 
00022 #include "dchroot-main.h"
00023 #include "dchroot-chroot-config.h"
00024 #include "dchroot-session.h"
00025 
00026 #include <cstdlib>
00027 #include <iostream>
00028 #include <locale>
00029 
00030 #include <sys/types.h>
00031 #include <sys/stat.h>
00032 #include <termios.h>
00033 #include <unistd.h>
00034 
00035 #include <boost/format.hpp>
00036 
00037 using std::endl;
00038 using boost::format;
00039 using schroot::options_base;
00040 using namespace dchroot;
00041 
00042 main::main (schroot::options_base::ptr& options):
00043   main_base("dchroot",
00044             // TRANSLATORS: '...' is an ellipsis e.g. U+2026, and '-'
00045             // is an em-dash.
00046             N_("[OPTION...] [COMMAND] - run command or shell in a chroot"),
00047             options)
00048 {
00049 }
00050 
00051 main::~main ()
00052 {
00053 }
00054 
00055 void
00056 main::action_location ()
00057 {
00058   sbuild::string_list chroot;
00059   chroot.push_back(this->options->chroot_path);
00060   this->config->print_chroot_location(chroot, std::cout);
00061 }
00062 
00063 void
00064 main::load_config ()
00065 {
00066   check_dchroot_conf();
00067 
00068   if (this->use_dchroot_conf)
00069     {
00070       this->config = sbuild::chroot_config::ptr(new dchroot::chroot_config);
00071       if (this->options->load_chroots == true)
00072         this->config->add(DCHROOT_CONF, false);
00073     }
00074   else
00075     {
00076       schroot::main_base::load_config();
00077     }
00078 }
00079 
00080 void
00081 main::create_session (sbuild::session::operation sess_op)
00082 {
00083   sbuild::log_debug(sbuild::DEBUG_INFO) << "Creating dchroot session" << endl;
00084 
00085   // Using dchroot.conf implies using dchroot_session_base, which does
00086   // not require user or group access.
00087   this->session = sbuild::session::ptr
00088     (new dchroot::session("schroot",
00089                           this->config,
00090                           sess_op,
00091                           this->chroots,
00092                           this->use_dchroot_conf));
00093 }

Generated on Sat Jan 27 16:11:03 2007 for schroot by  doxygen 1.5.1