]>
git.saurik.com Git - apt.git/blob - apt-pkg/deb/debsrcrecords.cc
1 // -*- mode: cpp; mode: fold -*-
3 // $Id: debsrcrecords.cc,v 1.5 2001/11/04 17:09:18 tausq Exp $
4 /* ######################################################################
6 Debian Source Package Records - Parser implementation for Debian style
9 ##################################################################### */
11 // Include Files /*{{{*/
13 #pragma implementation "apt-pkg/debsrcrecords.h"
16 #include <apt-pkg/deblistparser.h>
17 #include <apt-pkg/debsrcrecords.h>
18 #include <apt-pkg/error.h>
19 #include <apt-pkg/strutl.h>
20 #include <apt-pkg/configuration.h>
23 // SrcRecordParser::Binaries - Return the binaries field /*{{{*/
24 // ---------------------------------------------------------------------
25 /* This member parses the binaries field into a pair of class arrays and
26 returns a list of strings representing all of the components of the
27 binaries field. The returned array need not be freed and will be
28 reused by the next Binaries function call. This function is commonly
29 used during scanning to find the right package */
30 const char **debSrcRecordParser::Binaries()
32 // This should use Start/Stop too, it is supposed to be efficient after all.
33 string Bins
= Sect
.FindS("Binary");
34 if (Bins
.empty() == true || Bins
.length() >= sizeof(Buffer
))
37 strcpy(Buffer
,Bins
.c_str());
38 if (TokSplitString(',',Buffer
,StaticBinList
,
39 sizeof(StaticBinList
)/sizeof(StaticBinList
[0])) == false)
41 return (const char **)StaticBinList
;
44 // SrcRecordParser::BuildDepends - Return the Build-Depends information /*{{{*/
45 // ---------------------------------------------------------------------
46 /* This member parses the build-depends information and returns a list of
47 package/version records representing the build dependency. The returned
48 array need not be freed and will be reused by the next call to this
50 bool debSrcRecordParser::BuildDepends(vector
<pkgSrcRecords::Parser::BuildDepRec
> &BuildDeps
, bool ArchOnly
)
53 const char *Start
, *Stop
;
55 const char *fields
[] = {"Build-Depends",
56 "Build-Depends-Indep",
58 "Build-Conflicts-Indep"};
62 for (I
= 0; I
< 4; I
++)
64 if (ArchOnly
&& (I
== 1 || I
== 3))
67 if (Sect
.Find(fields
[I
], Start
, Stop
) == false)
72 Start
= debListParser::ParseDepends(Start
, Stop
,
73 rec
.Package
,rec
.Version
,rec
.Op
,true);
76 return _error
->Error("Problem parsing dependency: %s", fields
[I
]);
79 if (rec
.Package
!= "")
80 BuildDeps
.push_back(rec
);
90 // SrcRecordParser::Files - Return a list of files for this source /*{{{*/
91 // ---------------------------------------------------------------------
92 /* This parses the list of files and returns it, each file is required to have
93 a complete source package */
94 bool debSrcRecordParser::Files(vector
<pkgSrcRecords::File
> &List
)
96 List
.erase(List
.begin(),List
.end());
98 string Files
= Sect
.FindS("Files");
99 if (Files
.empty() == true)
102 // Stash the / terminated directory prefix
103 string Base
= Sect
.FindS("Directory");
104 if (Base
.empty() == false && Base
[Base
.length()-1] != '/')
107 // Iterate over the entire list grabbing each triplet
108 const char *C
= Files
.c_str();
111 pkgSrcRecords::File F
;
114 // Parse each of the elements
115 if (ParseQuoteWord(C
,F
.MD5Hash
) == false ||
116 ParseQuoteWord(C
,Size
) == false ||
117 ParseQuoteWord(C
,F
.Path
) == false)
118 return _error
->Error("Error parsing file record");
120 // Parse the size and append the directory
121 F
.Size
= atoi(Size
.c_str());
122 F
.Path
= Base
+ F
.Path
;
124 // Try to guess what sort of file it is we are getting.
125 string::size_type Pos
= F
.Path
.length()-1;
128 string::size_type Tmp
= F
.Path
.rfind('.',Pos
);
129 if (Tmp
== string::npos
)
131 F
.Type
= string(F
.Path
,Tmp
+1,Pos
-Tmp
);
133 if (F
.Type
== "gz" || F
.Type
== "bz2")