~ubuntu-branches/ubuntu/breezy/apt/breezy

« back to all changes in this revision

Viewing changes to apt-inst/deb/debfile.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: debfile.cc,v 1.2 2001/02/20 07:03:17 jgg Exp $
 
3
// $Id: debfile.cc,v 1.3.2.1 2004/01/16 18:58:50 mdz Exp $
4
4
/* ######################################################################
5
5
 
6
6
   Debian Archive File (.deb)
27
27
 
28
28
#include <sys/stat.h>
29
29
#include <unistd.h>
 
30
#include <apti18n.h>
30
31
                                                                        /*}}}*/
31
32
 
32
33
// DebFile::debDebFile - Constructor                                    /*{{{*/
36
37
{
37
38
   if (_error->PendingError() == true)
38
39
      return;
39
 
   
40
 
   // Check the members for validity
41
 
   if (CheckMember("debian-binary") == false ||
42
 
       CheckMember("control.tar.gz") == false ||
43
 
       CheckMember("data.tar.gz") == false)
44
 
      return;
 
40
 
 
41
   if (!CheckMember("debian-binary")) {
 
42
      _error->Error(_("This is not a valid DEB archive, missing '%s' member"), "debian-binary");
 
43
      return;
 
44
   }
 
45
 
 
46
   if (!CheckMember("control.tar.gz")) {
 
47
      _error->Error(_("This is not a valid DEB archive, missing '%s' member"), "control.tar.gz");
 
48
      return;
 
49
   }
 
50
 
 
51
   if (!CheckMember("data.tar.gz") && !CheckMember("data.tar.bz2")) {
 
52
      _error->Error(_("This is not a valid DEB archive, it has no '%s' or '%s' member"), "data.tar.gz", "data.tar.bz2");
 
53
      return;
 
54
   }
45
55
}
46
56
                                                                        /*}}}*/
47
57
// DebFile::CheckMember - Check if a named member is in the archive     /*{{{*/
51
61
bool debDebFile::CheckMember(const char *Name)
52
62
{
53
63
   if (AR.FindMember(Name) == 0)
54
 
      return _error->Error("This is not a valid DEB archive, missing '%s' member",Name);
 
64
      return false;
55
65
   return true;
56
66
}
57
67
                                                                        /*}}}*/
68
78
   const ARArchive::Member *Member = AR.FindMember(Name);
69
79
   if (Member == 0)
70
80
   {
71
 
      _error->Error("Internal Error, could not locate member %s",Name);
72
81
      return 0;
73
82
   }
74
83
   if (File.Seek(Member->Start) == false)
90
99
      
91
100
   // Prepare Tar
92
101
   ControlExtract Extract;
93
 
   ExtractTar Tar(File,Member->Size);
 
102
   ExtractTar Tar(File,Member->Size,"gzip");
94
103
   if (_error->PendingError() == true)
95
104
      return false;
96
105
   
100
109
   if (DB.GetMetaTmp(Tmp) == false)
101
110
      return false;
102
111
   if (chdir(Tmp.c_str()) != 0)
103
 
      return _error->Errno("chdir","Couldn't change to %s",Tmp.c_str());
 
112
      return _error->Errno("chdir",_("Couldn't change to %s"),Tmp.c_str());
104
113
   
105
114
   // Do extraction
106
115
   if (Tar.Go(Extract) == false)
120
129
{
121
130
   // Get the archive member and positition the file 
122
131
   const ARArchive::Member *Member = AR.FindMember("data.tar.gz");
 
132
   const char *Compressor = "gzip";
 
133
   if (Member == 0) {
 
134
      Member = AR.FindMember("data.tar.bz2");
 
135
      Compressor = "bzip2";
 
136
   }
123
137
   if (Member == 0)
124
 
      return _error->Error("Internal Error, could not locate member");   
 
138
      return _error->Error(_("Internal error, could not locate member"));   
125
139
   if (File.Seek(Member->Start) == false)
126
140
      return false;
127
141
      
128
142
   // Prepare Tar
129
 
   ExtractTar Tar(File,Member->Size);
 
143
   ExtractTar Tar(File,Member->Size,Compressor);
130
144
   if (_error->PendingError() == true)
131
145
      return false;
132
146
   return Tar.Go(Stream);
154
168
      return pkgCache::VerIterator(DB.GetCache());
155
169
   
156
170
   if (Ver.end() == true)
157
 
      _error->Error("Failed to locate a valid control file");
 
171
      _error->Error(_("Failed to locate a valid control file"));
158
172
   return Ver;
159
173
}
160
174
                                                                        /*}}}*/
229
243
      return false;
230
244
 
231
245
   // Extract it.
232
 
   ExtractTar Tar(Deb.GetFile(),Member->Size);
 
246
   ExtractTar Tar(Deb.GetFile(),Member->Size,"gzip");
233
247
   if (Tar.Go(*this) == false)
234
248
      return false;
235
249
 
239
253
   Control[Length] = '\n';
240
254
   Control[Length+1] = '\n';
241
255
   if (Section.Scan(Control,Length+2) == false)
242
 
      return _error->Error("Unparsible control file");
 
256
      return _error->Error(_("Unparsable control file"));
243
257
   return true;
244
258
}
245
259
                                                                        /*}}}*/