~ubuntu-branches/ubuntu/trusty/schroot/trusty

« back to all changes in this revision

Viewing changes to bin/csbuild/csbuild-main.cc

  • Committer: Bazaar Package Importer
  • Author(s): Roger Leigh
  • Date: 2009-11-07 10:46:54 UTC
  • mfrom: (1.1.20 upstream) (2.1.6 experimental)
  • Revision ID: james.westby@ubuntu.com-20091107104654-kk1fp1icv8dzfyfi
* New upstream development release.
* schroot:
  - Return success when ending a session and the operation
    succeeded (Closes: #554907).

Show diffs side-by-side

added added

removed removed

Lines of Context:
18
18
 
19
19
#include <config.h>
20
20
 
 
21
#include "sbuild-log.h"
 
22
 
21
23
#include "csbuild-main.h"
22
24
 
23
25
#include <cerrno>
25
27
#include <ctime>
26
28
#include <iostream>
27
29
#include <locale>
 
30
#include <sstream>
28
31
 
29
32
#include <sys/types.h>
30
33
#include <sys/stat.h>
82
85
void
83
86
main::action_build ()
84
87
{
 
88
  sbuild::string_list command;
 
89
  sbuild::environment env(environ);
 
90
 
 
91
  /// @todo Make sbuild binary configurable.
 
92
  command.push_back("/usr/bin/sbuild");
 
93
 
 
94
  /// @todo Handle incrementing debug level.
 
95
  if (sbuild::debug_log_level != sbuild::DEBUG_NONE)
 
96
    command.push_back("--debug");
 
97
 
 
98
  if (opts->nolog)
 
99
    command.push_back("--nolog");
 
100
 
 
101
  if (opts->batch_mode)
 
102
    command.push_back("--batch");
 
103
 
 
104
  for (sbuild::string_list::const_iterator pos = opts->deb_build_options.begin();
 
105
       pos != opts->deb_build_options.end();
 
106
       ++pos)
 
107
    {
 
108
      std::string bopt("--debbuildopt=");
 
109
      bopt += *pos;
 
110
      command.push_back(bopt);
 
111
    }
 
112
 
 
113
  if (!opts->distribution.empty())
 
114
    {
 
115
      std::string dist("--dist=");
 
116
      dist += opts->distribution;
 
117
      command.push_back(dist);
 
118
    }
 
119
 
 
120
  if (!opts->archive.empty())
 
121
    {
 
122
      std::string archive("--archive=");
 
123
      archive += opts->archive;
 
124
      command.push_back(archive);
 
125
    }
 
126
 
 
127
  if (!opts->build_arch.empty())
 
128
    {
 
129
      std::string arch("--arch=");
 
130
      arch += opts->build_arch;
 
131
      command.push_back(arch);
 
132
    }
 
133
 
 
134
  if (opts->build_arch_all)
 
135
      command.push_back("--arch-all");
 
136
 
 
137
  if (opts->build_source)
 
138
      command.push_back("--source");
 
139
 
 
140
  if (opts->force_orig_source)
 
141
      command.push_back("--force-orig-source");
 
142
 
 
143
  if (opts->bin_nmu)
 
144
    {
 
145
      std::string binnmu1("--make-binNMU=");
 
146
      binnmu1 += opts->bin_nmu_changelog;
 
147
      command.push_back(binnmu1);
 
148
 
 
149
      std::ostringstream binnmu2;
 
150
      binnmu2.imbue(std::locale::classic());
 
151
      binnmu2 << "--binNMU=";
 
152
      binnmu2 << opts->bin_nmu_version;
 
153
      command.push_back(binnmu2.str());
 
154
    }
 
155
 
 
156
  if (!opts->append_version.empty())
 
157
    {
 
158
      std::string append("--append-to-version=");
 
159
      append += opts->append_version;
 
160
      command.push_back(append);
 
161
    }
 
162
 
 
163
  if (opts->apt_update)
 
164
    command.push_back("apt-update");
 
165
 
 
166
  if (!opts->chroot.empty())
 
167
    {
 
168
      std::string chroot("--chroot=");
 
169
      chroot += opts->chroot;
 
170
      command.push_back(chroot);
 
171
    }
 
172
 
 
173
  if (!opts->purge_string.empty())
 
174
    {
 
175
      std::string purge("--purge=");
 
176
      purge += opts->purge_string;
 
177
      command.push_back(purge);
 
178
    }
 
179
 
 
180
  if (!opts->purge_deps_string.empty())
 
181
    {
 
182
      std::string purge_deps("--purge-deps=");
 
183
      purge_deps += opts->purge_deps_string;
 
184
      command.push_back(purge_deps);
 
185
    }
 
186
 
 
187
  if (!opts->setup_hook_script.empty())
 
188
    {
 
189
      std::string setup_hook("--setup-hook=");
 
190
      setup_hook += opts->setup_hook_script;
 
191
      command.push_back(setup_hook);
 
192
    }
 
193
 
 
194
  if (!opts->keyid.empty())
 
195
    {
 
196
      std::string keyid("--keyid=");
 
197
      keyid += opts->keyid;
 
198
      command.push_back(keyid);
 
199
    }
 
200
 
 
201
  if (!opts->maintainer.empty())
 
202
    {
 
203
      std::string maintainer("--maintainer=");
 
204
      maintainer += opts->maintainer;
 
205
      command.push_back(maintainer);
 
206
    }
 
207
 
 
208
  if (!opts->uploader.empty())
 
209
    {
 
210
      std::string uploader("--uploader=");
 
211
      uploader += opts->uploader;
 
212
      command.push_back(uploader);
 
213
    }
 
214
 
 
215
  for (sbuild::string_list::const_iterator bd = opts->build_depends.begin();
 
216
       bd != opts->build_depends.end();
 
217
       ++bd)
 
218
    {
 
219
      std::string dep("--add-depends=");
 
220
      dep += *bd;
 
221
      command.push_back(dep);
 
222
    }
 
223
 
 
224
  for (sbuild::string_list::const_iterator bc = opts->build_conflicts.begin();
 
225
       bc != opts->build_conflicts.end();
 
226
       ++bc)
 
227
    {
 
228
      std::string dep("--add-conflicts=");
 
229
      dep += *bc;
 
230
      command.push_back(dep);
 
231
    }
 
232
 
 
233
  for (sbuild::string_list::const_iterator bdi = opts->build_depends_indep.begin();
 
234
       bdi != opts->build_depends_indep.end();
 
235
       ++bdi)
 
236
    {
 
237
      std::string dep("--add-depends=");
 
238
      dep += *bdi;
 
239
      command.push_back(dep);
 
240
    }
 
241
 
 
242
  for (sbuild::string_list::const_iterator bci = opts->build_conflicts_indep.begin();
 
243
       bci != opts->build_conflicts_indep.end();
 
244
       ++bci)
 
245
    {
 
246
      std::string dep("--add-conflicts=");
 
247
      dep += *bci;
 
248
      command.push_back(dep);
 
249
    }
 
250
 
 
251
  if (!opts->depends_algorithm.empty())
 
252
    {
 
253
      std::string algo("check-depends-algorithm=");
 
254
      algo += opts->depends_algorithm;
 
255
      command.push_back(algo);
 
256
    }
 
257
 
 
258
  if (opts->gcc_snapshot)
 
259
    command.push_back("--use-snapshot");
 
260
 
 
261
  std::copy(opts->packages.begin(), opts->packages.end(),
 
262
            std::back_inserter(command));
 
263
 
 
264
  sbuild::log_debug(sbuild::DEBUG_NOTICE)
 
265
    << "command="
 
266
    << sbuild::string_list_to_string(command, ", ")
 
267
    << std::endl;
 
268
 
 
269
  exec(command[0], command, env);
 
270
 
 
271
  // This should never be reached.
 
272
  exit(EXIT_FAILURE);
85
273
}
86
274
 
87
275
int