~jr/ubuntu/oneiric/apt/bzr-get-rename

« back to all changes in this revision

Viewing changes to cmdline/apt-extracttemplates.cc

  • Committer: Bazaar Package Importer
  • Author(s): Matt Zimmerman
  • Date: 2005-03-07 20:08:33 UTC
  • Revision ID: james.westby@ubuntu.com-20050307200833-0lxdgg2cb4oculdv
Tags: 0.6.35
* Merge apt--mvo--0 (incorporates 0.6.34ubuntu1):
  - Implement MaxSize and MaxAge in apt.cron.daily, to prevent the cache
    from growing too large (Ubuntu #6761)
  - some comments about the pkgAcqMetaSig::Custom600Headers() added
  - use gpg --with-colons
  - commented the ftp no_proxy unseting in methods/ftp.cc
  - added support for "Acquire::gpgv::options" in methods/gpgv.cc
* Merge bubulle@debian.org--2005/apt--main--0
  - Make capitalization more consistent
  - Un-fuzzy translations resulting from capitalization changes
  - Italian translation update

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
1
// -*- mode: cpp; mode: fold -*-
2
2
// Description                                                          /*{{{*/
3
 
// $Id: apt-extracttemplates.cc,v 1.7 2001/04/29 05:40:36 jgg Exp $
 
3
// $Id: apt-extracttemplates.cc,v 1.15 2003/07/26 00:00:11 mdz Exp $
4
4
/* ######################################################################
5
5
   
6
6
   APT Extract Templates - Program to extract debconf config and template
35
35
#include <unistd.h>
36
36
#include <fstream>
37
37
 
 
38
#include <locale.h>
38
39
#include <config.h>
39
40
#include <apti18n.h>
40
41
#include "apt-extracttemplates.h"
41
42
                                                                        /*}}}*/
42
43
 
 
44
using namespace std;
 
45
 
43
46
#define TMPDIR          "/tmp"
44
47
 
45
48
pkgCache *DebFile::Cache = 0;
96
99
        
97
100
        if (File.Seek(Member->Start) == false)
98
101
                return false;
99
 
        ExtractTar Tar(File, Member->Size);
 
102
        ExtractTar Tar(File, Member->Size,"gzip");
100
103
        return Tar.Go(*this);
101
104
}
102
105
                                                                        /*}}}*/
235
238
                "  -h   This help text\n"
236
239
                "  -t   Set the temp dir\n"
237
240
                "  -c=? Read this configuration file\n"
238
 
                "  -o=? Set an arbitary configuration option, eg -o dir::cache=/tmp\n");
 
241
                "  -o=? Set an arbitrary configuration option, eg -o dir::cache=/tmp\n");
239
242
        return 0;
240
243
}
241
244
                                                                        /*}}}*/
242
245
// WriteFile - write the contents of the passed string to a file        /*{{{*/
243
246
// ---------------------------------------------------------------------
244
247
/* */
245
 
string WriteFile(const char *prefix, const char *data)
 
248
string WriteFile(const char *package, const char *prefix, const char *data)
246
249
{
247
250
        char fn[512];
248
251
        static int i;
249
 
        snprintf(fn, sizeof(fn), "%s/%s.%u%d", _config->Find("APT::ExtractTemplates::TempDir", TMPDIR).c_str(), prefix, getpid(), i++);
 
252
        char *tempdir = NULL;
 
253
 
 
254
        tempdir = getenv("TMPDIR");
 
255
        if (tempdir == NULL)
 
256
             tempdir = TMPDIR;
 
257
 
 
258
        snprintf(fn, sizeof(fn), "%s/%s.%s.%u%d",
 
259
                 _config->Find("APT::ExtractTemplates::TempDir", tempdir).c_str(),
 
260
                 package, prefix, getpid(), i++);
250
261
        FileFd f;
251
262
        if (data == NULL)
252
263
                data = "";
267
278
/* */
268
279
void WriteConfig(const DebFile &file)
269
280
{
270
 
        string templatefile = WriteFile("template", file.Template);
271
 
        string configscript = WriteFile("config", file.Config);
 
281
        string templatefile = WriteFile(file.Package.c_str(), "template", file.Template);
 
282
        string configscript = WriteFile(file.Package.c_str(), "config", file.Config);
272
283
 
273
284
        if (templatefile.empty() == true || configscript.empty() == true)
274
285
                return;
287
298
        List.ReadMainList();
288
299
        OpProgress Prog;
289
300
        pkgMakeStatusCache(List,Prog,&Map,true);
 
301
        if (Map == 0)
 
302
           return false;
290
303
        DebFile::Cache = new pkgCache(Map);
291
304
        if (_error->PendingError() == true)
292
305
                return false;
302
315
                // Will pick up the errors later..
303
316
                DebFile file(CmdL.FileList[I]);
304
317
                if (file.Go() == false)
305
 
                        continue; 
306
 
                
 
318
                {
 
319
                        _error->Error("Prior errors apply to %s",CmdL.FileList[I]);
 
320
                        continue;
 
321
                }
 
322
 
307
323
                // Does the package have templates?
308
324
                if (file.Template != 0 && file.ParseInfo() == true)
309
325
                {
310
326
                        // Check to make sure debconf dependencies are
311
327
                        // satisfied
312
 
                        cout << "Check " << file.DepVer << ',' << debconfver << endl;
 
328
                        // cout << "Check " << file.DepVer << ',' << debconfver << endl;
313
329
                        if (file.DepVer != "" &&
314
330
                            DebFile::Cache->VS->CheckDep(debconfver.c_str(),
315
331
                                        file.DepOp,file.DepVer.c_str()
342
358
                {'c',"config-file",0,CommandLine::ConfigFile},
343
359
                {'o',"option",0,CommandLine::ArbItem},
344
360
                {0,0,0,0}};
345
 
        
 
361
 
 
362
        // Set up gettext support
 
363
        setlocale(LC_ALL,"");
 
364
        textdomain(PACKAGE);
 
365
 
346
366
        // Parse the command line and initialize the package library
347
367
        CommandLine CmdL(Args,_config);
348
368
        if (pkgInitConfig(*_config) == false ||