~ubuntu-branches/ubuntu/intrepid/schroot/intrepid

« back to all changes in this revision

Viewing changes to dchroot/dchroot-main-base.cc

  • Committer: Bazaar Package Importer
  • Author(s): Reinhard Tartler
  • Date: 2006-07-08 18:33:28 UTC
  • mfrom: (1.1.4 upstream)
  • Revision ID: james.westby@ubuntu.com-20060708183328-rlo4mpldmyoda55q
Tags: 0.99.2-2ubuntu1
* remerge ubuntu changes:
  + debian/control: libpam-dev (>> 0.79-3ubuntu6)

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/* Copyright © 2005-2006  Roger Leigh <rleigh@debian.org>
 
2
 *
 
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.
 
7
 *
 
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.
 
12
 *
 
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,
 
16
 * MA  02111-1307  USA
 
17
 *
 
18
 *********************************************************************/
 
19
 
 
20
#include <config.h>
 
21
 
 
22
#include "dchroot-main.h"
 
23
#include "dchroot-chroot-config.h"
 
24
#include "dchroot-session.h"
 
25
 
 
26
#include <cstdlib>
 
27
#include <iostream>
 
28
#include <locale>
 
29
 
 
30
#include <sys/types.h>
 
31
#include <sys/stat.h>
 
32
#include <termios.h>
 
33
#include <unistd.h>
 
34
 
 
35
#include <boost/format.hpp>
 
36
 
 
37
#include <syslog.h>
 
38
 
 
39
using std::endl;
 
40
using boost::format;
 
41
using schroot::options_base;
 
42
using namespace dchroot;
 
43
 
 
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)
 
49
{
 
50
}
 
51
 
 
52
main_base::~main_base ()
 
53
{
 
54
}
 
55
 
 
56
void
 
57
main_base::action_config ()
 
58
{
 
59
  std::cout << "# "
 
60
            << format(_("schroot configuration generated by %1% %2% on %3%"))
 
61
    % this->program_name % VERSION % sbuild::date(time(0))
 
62
            << endl;
 
63
  if (this->use_dchroot_conf)
 
64
    {
 
65
      // Help text at head of new config.
 
66
      std::cout << "# " << endl
 
67
                << "# "
 
68
                << _("To allow users access to the chroots, use the users or groups keys.") << endl;
 
69
      std::cout << "# "
 
70
                << _("To allow passwordless root access, use the root-users or root-groups keys.") << endl;
 
71
      std::cout << "# "
 
72
                << format(_("Remove '%1%' to use the new configuration."))
 
73
        % DCHROOT_CONF
 
74
                << endl;
 
75
    }
 
76
  std::cout << endl;
 
77
  this->config->print_chroot_config(this->chroots, std::cout);
 
78
}
 
79
 
 
80
void
 
81
main_base::action_list ()
 
82
{
 
83
  this->config->print_chroot_list_simple(std::cout);
 
84
}
 
85
 
 
86
void
 
87
main_base::compat_check ()
 
88
{
 
89
  if (this->options->verbose)
 
90
    {
 
91
      sbuild::log_warning()
 
92
        << format(_("Running schroot in %1% compatibility mode"))
 
93
        % this->program_name
 
94
        << endl;
 
95
      sbuild::log_info()
 
96
        << _("Run 'schroot' for full capabilities")
 
97
        << endl;
 
98
    }
 
99
}
 
100
 
 
101
void
 
102
main_base::check_dchroot_conf ()
 
103
{
 
104
  this->use_dchroot_conf = false;
 
105
  struct stat statbuf;
 
106
  if (stat(DCHROOT_CONF, &statbuf) == 0 && !S_ISDIR(statbuf.st_mode))
 
107
    {
 
108
      this->use_dchroot_conf = true;
 
109
 
 
110
      if (this->options->verbose)
 
111
        {
 
112
          sbuild::log_warning()
 
113
            << format(_("Using %1% configuration file: "))
 
114
            % this->program_name
 
115
            << DCHROOT_CONF
 
116
            << endl;
 
117
          sbuild::log_info()
 
118
            << format(_("Run '%1%'"))
 
119
            % "dchroot --config >> " SCHROOT_CONF
 
120
            << endl;
 
121
          sbuild::log_info()
 
122
            << _("to migrate to a schroot configuration.")
 
123
            << endl;
 
124
          sbuild::log_info()
 
125
            << format(_("Edit '%1%' to add appropriate group access."))
 
126
            % SCHROOT_CONF
 
127
            << endl;
 
128
          sbuild::log_info()
 
129
            << format(_("Remove '%1%' to use the new configuration."))
 
130
            % DCHROOT_CONF
 
131
            << endl;
 
132
        }
 
133
    }
 
134
}