1
/* Copyright © 2005-2006 Roger Leigh <rleigh@debian.org>
3
* schroot is free software; you can redistribute it and/or modify it
4
* under the terms of the GNU General Public License as published by
5
* the Free Software Foundation; either version 2 of the License, or
6
* (at your option) any later version.
8
* schroot is distributed in the hope that it will be useful, but
9
* WITHOUT ANY WARRANTY; without even the implied warranty of
10
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
11
* General Public License for more details.
13
* You should have received a copy of the GNU General Public License
14
* along with this program; if not, write to the Free Software
15
* Foundation, Inc., 59 Temple Place, Suite 330, Boston,
18
*********************************************************************/
22
#include "dchroot-main.h"
23
#include "dchroot-chroot-config.h"
24
#include "dchroot-session.h"
30
#include <sys/types.h>
35
#include <boost/format.hpp>
41
using schroot::options_base;
42
using namespace dchroot;
44
main_base::main_base (std::string const& program_name,
45
std::string const& program_usage,
46
schroot::options_base::ptr& options):
47
schroot::main_base(program_name, program_usage, options),
48
use_dchroot_conf(false)
52
main_base::~main_base ()
57
main_base::action_config ()
60
<< format(_("schroot configuration generated by %1% %2% on %3%"))
61
% this->program_name % VERSION % sbuild::date(time(0))
63
if (this->use_dchroot_conf)
65
// Help text at head of new config.
66
std::cout << "# " << endl
68
<< _("To allow users access to the chroots, use the users or groups keys.") << endl;
70
<< _("To allow passwordless root access, use the root-users or root-groups keys.") << endl;
72
<< format(_("Remove '%1%' to use the new configuration."))
77
this->config->print_chroot_config(this->chroots, std::cout);
81
main_base::action_list ()
83
this->config->print_chroot_list_simple(std::cout);
87
main_base::compat_check ()
89
if (this->options->verbose)
92
<< format(_("Running schroot in %1% compatibility mode"))
96
<< _("Run 'schroot' for full capabilities")
102
main_base::check_dchroot_conf ()
104
this->use_dchroot_conf = false;
106
if (stat(DCHROOT_CONF, &statbuf) == 0 && !S_ISDIR(statbuf.st_mode))
108
this->use_dchroot_conf = true;
110
if (this->options->verbose)
112
sbuild::log_warning()
113
<< format(_("Using %1% configuration file: "))
118
<< format(_("Run '%1%'"))
119
% "dchroot --config >> " SCHROOT_CONF
122
<< _("to migrate to a schroot configuration.")
125
<< format(_("Edit '%1%' to add appropriate group access."))
129
<< format(_("Remove '%1%' to use the new configuration."))