dchroot-main-base.cc

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

Generated on Sun Jul 8 21:23:55 2007 for schroot by  doxygen 1.5.2