dchroot-main-base.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 #include <syslog.h>
00038 
00039 using std::endl;
00040 using boost::format;
00041 using schroot::options_base;
00042 using namespace dchroot;
00043 
00044 main_base::main_base (std::string const& program_name,
00045                       std::string const& program_usage,
00046                       schroot::options_base::ptr& options):
00047   schroot::main_base(program_name, program_usage, options),
00048   use_dchroot_conf(false)
00049 {
00050 }
00051 
00052 main_base::~main_base ()
00053 {
00054 }
00055 
00056 void
00057 main_base::action_config ()
00058 {
00059   std::cout << "# "
00060     // TRANSLATORS: %1% = program name
00061     // TRANSLATORS: %2% = program version
00062     // TRANSLATORS: %3% = current date
00063             << format(_("schroot configuration generated by %1% %2% on %3%"))
00064     % this->program_name % VERSION % sbuild::date(time(0))
00065             << endl;
00066   if (this->use_dchroot_conf)
00067     {
00068       // Help text at head of new config.
00069       std::cout << "# " << endl
00070                 << "# "
00071                 // TODO: Quote "users" and "groups".
00072                 // TRANSLATORS: Do not translate "users" and "groups";
00073                 // these are keywords used in the configuration file.
00074                 << _("To allow users access to the chroots, use the users or groups keys.") << endl;
00075       std::cout << "# "
00076                 // TODO: Quote "root-users" and "root-groups".
00077                 // TRANSLATORS: Do not translate "root-users" and
00078                 // "root-groups"; these are keywords used in the
00079                 // configuration file.
00080                 << _("To allow password-less root access, use the root-users or root-groups keys.") << endl;
00081       std::cout << "# "
00082         // TRANSLATORS: %1% = file
00083                 << format(_("Remove '%1%' to use the new configuration."))
00084         % DCHROOT_CONF
00085                 << endl;
00086     }
00087   std::cout << endl;
00088   this->config->print_chroot_config(this->chroots, std::cout);
00089 }
00090 
00091 void
00092 main_base::action_list ()
00093 {
00094   this->config->print_chroot_list_simple(std::cout);
00095 }
00096 
00097 void
00098 main_base::compat_check ()
00099 {
00100   if (this->options->verbose)
00101     {
00102       sbuild::log_warning()
00103         // TRANSLATORS: %1% = program name
00104         << format(_("Running schroot in %1% compatibility mode"))
00105         % this->program_name
00106         << endl;
00107       sbuild::log_info()
00108         // TRANSLATORS: "full capabilities" in this context means "all
00109         // features"
00110         << _("Run \"schroot\" for full capabilities")
00111         << endl;
00112     }
00113 }
00114 
00115 void
00116 main_base::check_dchroot_conf ()
00117 {
00118   this->use_dchroot_conf = false;
00119   struct stat statbuf;
00120   if (stat(DCHROOT_CONF, &statbuf) == 0 && !S_ISDIR(statbuf.st_mode))
00121     {
00122       this->use_dchroot_conf = true;
00123 
00124       if (this->options->verbose)
00125         {
00126           sbuild::log_warning()
00127             // TRANSLATORS: %1% = program name
00128             // TRANSLATORS: %2% = configuration file
00129             << format(_("Using %1% configuration file: '%2%'"))
00130             % this->program_name % DCHROOT_CONF
00131             << endl;
00132           sbuild::log_info()
00133             << format(_("Run \"%1%\""))
00134             % "dchroot --config >> " SCHROOT_CONF
00135             << endl;
00136           sbuild::log_info()
00137             << _("to migrate to a schroot configuration.")
00138             << endl;
00139           sbuild::log_info()
00140             << format(_("Edit '%1%' to add appropriate user and/or group access."))
00141             % SCHROOT_CONF
00142             << endl;
00143           sbuild::log_info()
00144             << format(_("Remove '%1%' to use the new configuration."))
00145             % DCHROOT_CONF
00146             << endl;
00147         }
00148     }
00149 }

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