1 // -*- mode: cpp; mode: fold -*-
3 // $Id: deblistparser.cc,v 1.29.2.5 2004/01/06 01:43:44 mdz Exp $
4 /* ######################################################################
6 Package Cache Generator - Generator for the cache structure.
8 This builds the cache structure from the abstract package list parser.
10 ##################################################################### */
12 // Include Files /*{{{*/
15 #include <apt-pkg/deblistparser.h>
16 #include <apt-pkg/error.h>
17 #include <apt-pkg/configuration.h>
18 #include <apt-pkg/cachefilter.h>
19 #include <apt-pkg/aptconfiguration.h>
20 #include <apt-pkg/strutl.h>
21 #include <apt-pkg/crc-16.h>
22 #include <apt-pkg/md5.h>
23 #include <apt-pkg/pkgcache.h>
24 #include <apt-pkg/cacheiterators.h>
25 #include <apt-pkg/tagfile.h>
26 #include <apt-pkg/macros.h>
38 static debListParser::WordList PrioList
[] = {
39 {"required",pkgCache::State::Required
},
40 {"important",pkgCache::State::Important
},
41 {"standard",pkgCache::State::Standard
},
42 {"optional",pkgCache::State::Optional
},
43 {"extra",pkgCache::State::Extra
},
46 // ListParser::debListParser - Constructor /*{{{*/
47 // ---------------------------------------------------------------------
48 /* Provide an architecture and only this one and "all" will be accepted
49 in Step(), if no Architecture is given we will accept every arch
50 we would accept in general with checkArchitecture() */
51 debListParser::debListParser(FileFd
*File
) :
52 pkgCacheListParser(), d(NULL
), Tags(File
)
56 // ListParser::Package - Return the package name /*{{{*/
57 // ---------------------------------------------------------------------
58 /* This is to return the name of the package this section describes */
59 string
debListParser::Package() {
60 string
const Result
= Section
.FindS("Package");
61 if(unlikely(Result
.empty() == true))
62 _error
->Error("Encountered a section with no Package: header");
66 // ListParser::Architecture - Return the package arch /*{{{*/
67 // ---------------------------------------------------------------------
68 /* This will return the Architecture of the package this section describes */
69 string
debListParser::Architecture() {
70 std::string
const Arch
= Section
.FindS("Architecture");
71 return Arch
.empty() ? "none" : Arch
;
74 // ListParser::ArchitectureAll /*{{{*/
75 // ---------------------------------------------------------------------
77 bool debListParser::ArchitectureAll() {
78 return Section
.FindS("Architecture") == "all";
81 // ListParser::Version - Return the version string /*{{{*/
82 // ---------------------------------------------------------------------
83 /* This is to return the string describing the version in debian form,
84 epoch:upstream-release. If this returns the blank string then the
85 entry is assumed to only describe package properties */
86 string
debListParser::Version()
88 return Section
.FindS("Version");
91 unsigned char debListParser::ParseMultiArch(bool const showErrors
) /*{{{*/
94 string
const MultiArch
= Section
.FindS("Multi-Arch");
95 if (MultiArch
.empty() == true || MultiArch
== "no")
96 MA
= pkgCache::Version::No
;
97 else if (MultiArch
== "same") {
98 if (ArchitectureAll() == true)
100 if (showErrors
== true)
101 _error
->Warning("Architecture: all package '%s' can't be Multi-Arch: same",
102 Section
.FindS("Package").c_str());
103 MA
= pkgCache::Version::No
;
106 MA
= pkgCache::Version::Same
;
108 else if (MultiArch
== "foreign")
109 MA
= pkgCache::Version::Foreign
;
110 else if (MultiArch
== "allowed")
111 MA
= pkgCache::Version::Allowed
;
114 if (showErrors
== true)
115 _error
->Warning("Unknown Multi-Arch type '%s' for package '%s'",
116 MultiArch
.c_str(), Section
.FindS("Package").c_str());
117 MA
= pkgCache::Version::No
;
120 if (ArchitectureAll() == true)
121 MA
|= pkgCache::Version::All
;
126 // ListParser::NewVersion - Fill in the version structure /*{{{*/
127 // ---------------------------------------------------------------------
129 bool debListParser::NewVersion(pkgCache::VerIterator
&Ver
)
135 if (Section
.Find("Section",Start
,Stop
) == true)
137 map_stringitem_t
const idx
= StoreString(pkgCacheGenerator::SECTION
, Start
, Stop
- Start
);
140 // Parse the source package name
141 pkgCache::GrpIterator
const G
= Ver
.ParentPkg().Group();
142 Ver
->SourcePkgName
= G
->Name
;
143 Ver
->SourceVerStr
= Ver
->VerStr
;
144 if (Section
.Find("Source",Start
,Stop
) == true)
146 const char * const Space
= (const char * const) memchr(Start
, ' ', Stop
- Start
);
147 pkgCache::VerIterator V
;
152 const char * const Open
= (const char * const) memchr(Space
, '(', Stop
- Space
);
153 if (likely(Open
!= NULL
))
155 const char * const Close
= (const char * const) memchr(Open
, ')', Stop
- Open
);
156 if (likely(Close
!= NULL
))
158 std::string
const version(Open
+ 1, (Close
- Open
) - 1);
159 if (version
!= Ver
.VerStr())
161 map_stringitem_t
const idx
= StoreString(pkgCacheGenerator::VERSIONNUMBER
, version
);
162 Ver
->SourceVerStr
= idx
;
168 std::string
const pkgname(Start
, Stop
- Start
);
169 if (pkgname
!= G
.Name())
171 for (pkgCache::PkgIterator P
= G
.PackageList(); P
.end() == false; P
= G
.NextPkg(P
))
173 for (V
= P
.VersionList(); V
.end() == false; ++V
)
175 if (pkgname
== V
.SourcePkgName())
177 Ver
->SourcePkgName
= V
->SourcePkgName
;
181 if (V
.end() == false)
186 map_stringitem_t
const idx
= StoreString(pkgCacheGenerator::PKGNAME
, pkgname
);
187 Ver
->SourcePkgName
= idx
;
192 Ver
->MultiArch
= ParseMultiArch(true);
194 Ver
->Size
= Section
.FindULL("Size");
195 // Unpacked Size (in K)
196 Ver
->InstalledSize
= Section
.FindULL("Installed-Size");
197 Ver
->InstalledSize
*= 1024;
200 if (Section
.Find("Priority",Start
,Stop
) == true)
202 if (GrabWord(string(Start
,Stop
-Start
),PrioList
,Ver
->Priority
) == false)
203 Ver
->Priority
= pkgCache::State::Extra
;
206 if (ParseDepends(Ver
,"Pre-Depends",pkgCache::Dep::PreDepends
) == false)
208 if (ParseDepends(Ver
,"Depends",pkgCache::Dep::Depends
) == false)
210 if (ParseDepends(Ver
,"Conflicts",pkgCache::Dep::Conflicts
) == false)
212 if (ParseDepends(Ver
,"Breaks",pkgCache::Dep::DpkgBreaks
) == false)
214 if (ParseDepends(Ver
,"Recommends",pkgCache::Dep::Recommends
) == false)
216 if (ParseDepends(Ver
,"Suggests",pkgCache::Dep::Suggests
) == false)
218 if (ParseDepends(Ver
,"Replaces",pkgCache::Dep::Replaces
) == false)
220 if (ParseDepends(Ver
,"Enhances",pkgCache::Dep::Enhances
) == false)
223 if (ParseDepends(Ver
,"Optional",pkgCache::Dep::Suggests
) == false)
226 if (ParseProvides(Ver
) == false)
232 // ListParser::Description - Return the description string /*{{{*/
233 // ---------------------------------------------------------------------
234 /* This is to return the string describing the package in debian
235 form. If this returns the blank string then the entry is assumed to
236 only describe package properties */
237 string
debListParser::Description(std::string
const &lang
)
240 return Section
.FindS("Description");
242 return Section
.FindS(string("Description-").append(lang
).c_str());
245 // ListParser::AvailableDescriptionLanguages /*{{{*/
246 std::vector
<std::string
> debListParser::AvailableDescriptionLanguages()
248 std::vector
<std::string
> const understood
= APT::Configuration::getLanguages();
249 std::vector
<std::string
> avail
;
250 if (Section
.Exists("Description") == true)
252 for (std::vector
<std::string
>::const_iterator lang
= understood
.begin(); lang
!= understood
.end(); ++lang
)
254 std::string
const tagname
= "Description-" + *lang
;
255 if (Section
.Exists(tagname
.c_str()) == true)
256 avail
.push_back(*lang
);
261 // ListParser::Description_md5 - Return the description_md5 MD5SumValue /*{{{*/
262 // ---------------------------------------------------------------------
263 /* This is to return the md5 string to allow the check if it is the right
264 description. If no Description-md5 is found in the section it will be
267 MD5SumValue
debListParser::Description_md5()
269 string
const value
= Section
.FindS("Description-md5");
270 if (value
.empty() == true)
272 std::string
const desc
= Description("") + "\n";
274 return MD5SumValue();
277 md5
.Add(desc
.c_str());
280 else if (likely(value
.size() == 32))
282 if (likely(value
.find_first_not_of("0123456789abcdefABCDEF") == string::npos
))
283 return MD5SumValue(value
);
284 _error
->Error("Malformed Description-md5 line; includes invalid character '%s'", value
.c_str());
285 return MD5SumValue();
287 _error
->Error("Malformed Description-md5 line; doesn't have the required length (32 != %d) '%s'", (int)value
.size(), value
.c_str());
288 return MD5SumValue();
291 // ListParser::UsePackage - Update a package structure /*{{{*/
292 // ---------------------------------------------------------------------
293 /* This is called to update the package with any new information
294 that might be found in the section */
295 bool debListParser::UsePackage(pkgCache::PkgIterator
&Pkg
,
296 pkgCache::VerIterator
&Ver
)
298 string
const static myArch
= _config
->Find("APT::Architecture");
299 // Possible values are: "all", "native", "installed" and "none"
300 // The "installed" mode is handled by ParseStatus(), See #544481 and friends.
301 string
const static essential
= _config
->Find("pkgCacheGen::Essential", "all");
302 if (essential
== "all" ||
303 (essential
== "native" && Pkg
->Arch
!= 0 && myArch
== Pkg
.Arch()))
304 if (Section
.FindFlag("Essential",Pkg
->Flags
,pkgCache::Flag::Essential
) == false)
306 if (Section
.FindFlag("Important",Pkg
->Flags
,pkgCache::Flag::Important
) == false)
309 if (strcmp(Pkg
.Name(),"apt") == 0)
311 if ((essential
== "native" && Pkg
->Arch
!= 0 && myArch
== Pkg
.Arch()) ||
313 Pkg
->Flags
|= pkgCache::Flag::Essential
| pkgCache::Flag::Important
;
315 Pkg
->Flags
|= pkgCache::Flag::Important
;
318 if (ParseStatus(Pkg
,Ver
) == false)
323 // ListParser::VersionHash - Compute a unique hash for this version /*{{{*/
324 // ---------------------------------------------------------------------
326 unsigned short debListParser::VersionHash()
328 const char *Sections
[] ={"Installed-Size",
336 unsigned long Result
= INIT_FCS
;
338 for (const char * const *I
= Sections
; *I
!= 0; ++I
)
342 if (Section
.Find(*I
,Start
,End
) == false || End
- Start
>= (signed)sizeof(S
))
345 /* Strip out any spaces from the text, this undoes dpkgs reformatting
346 of certain fields. dpkg also has the rather interesting notion of
347 reformatting depends operators < -> <= */
349 for (; Start
!= End
; ++Start
)
351 if (isspace(*Start
) != 0)
353 *J
++ = tolower_ascii(*Start
);
355 if ((*Start
== '<' || *Start
== '>') && Start
[1] != *Start
&& Start
[1] != '=')
359 Result
= AddCRC16(Result
,S
,J
- S
);
365 // ListParser::ParseStatus - Parse the status field /*{{{*/
366 // ---------------------------------------------------------------------
367 /* Status lines are of the form,
368 Status: want flag status
369 want = unknown, install, hold, deinstall, purge
371 status = not-installed, config-files, half-installed, unpacked,
372 half-configured, triggers-awaited, triggers-pending, installed
374 bool debListParser::ParseStatus(pkgCache::PkgIterator
&Pkg
,
375 pkgCache::VerIterator
&Ver
)
379 if (Section
.Find("Status",Start
,Stop
) == false)
382 // UsePackage() is responsible for setting the flag in the default case
383 bool const static essential
= _config
->Find("pkgCacheGen::Essential", "") == "installed";
384 if (essential
== true &&
385 Section
.FindFlag("Essential",Pkg
->Flags
,pkgCache::Flag::Essential
) == false)
388 // Isolate the first word
389 const char *I
= Start
;
390 for(; I
< Stop
&& *I
!= ' '; I
++);
391 if (I
>= Stop
|| *I
!= ' ')
392 return _error
->Error("Malformed Status line");
394 // Process the want field
395 WordList WantList
[] = {{"unknown",pkgCache::State::Unknown
},
396 {"install",pkgCache::State::Install
},
397 {"hold",pkgCache::State::Hold
},
398 {"deinstall",pkgCache::State::DeInstall
},
399 {"purge",pkgCache::State::Purge
},
401 if (GrabWord(string(Start
,I
-Start
),WantList
,Pkg
->SelectedState
) == false)
402 return _error
->Error("Malformed 1st word in the Status line");
404 // Isloate the next word
407 for(; I
< Stop
&& *I
!= ' '; I
++);
408 if (I
>= Stop
|| *I
!= ' ')
409 return _error
->Error("Malformed status line, no 2nd word");
411 // Process the flag field
412 WordList FlagList
[] = {{"ok",pkgCache::State::Ok
},
413 {"reinstreq",pkgCache::State::ReInstReq
},
414 {"hold",pkgCache::State::HoldInst
},
415 {"hold-reinstreq",pkgCache::State::HoldReInstReq
},
417 if (GrabWord(string(Start
,I
-Start
),FlagList
,Pkg
->InstState
) == false)
418 return _error
->Error("Malformed 2nd word in the Status line");
420 // Isloate the last word
423 for(; I
< Stop
&& *I
!= ' '; I
++);
425 return _error
->Error("Malformed Status line, no 3rd word");
427 // Process the flag field
428 WordList StatusList
[] = {{"not-installed",pkgCache::State::NotInstalled
},
429 {"config-files",pkgCache::State::ConfigFiles
},
430 {"half-installed",pkgCache::State::HalfInstalled
},
431 {"unpacked",pkgCache::State::UnPacked
},
432 {"half-configured",pkgCache::State::HalfConfigured
},
433 {"triggers-awaited",pkgCache::State::TriggersAwaited
},
434 {"triggers-pending",pkgCache::State::TriggersPending
},
435 {"installed",pkgCache::State::Installed
},
437 if (GrabWord(string(Start
,I
-Start
),StatusList
,Pkg
->CurrentState
) == false)
438 return _error
->Error("Malformed 3rd word in the Status line");
440 /* A Status line marks the package as indicating the current
441 version as well. Only if it is actually installed.. Otherwise
442 the interesting dpkg handling of the status file creates bogus
444 if (!(Pkg
->CurrentState
== pkgCache::State::NotInstalled
||
445 Pkg
->CurrentState
== pkgCache::State::ConfigFiles
))
447 if (Ver
.end() == true)
448 _error
->Warning("Encountered status field in a non-version description");
450 Pkg
->CurrentVer
= Ver
.Index();
456 const char *debListParser::ConvertRelation(const char *I
,unsigned int &Op
)
458 // Determine the operator
466 Op
= pkgCache::Dep::LessEq
;
473 Op
= pkgCache::Dep::Less
;
477 // < is the same as <= and << is really Cs < for some reason
478 Op
= pkgCache::Dep::LessEq
;
486 Op
= pkgCache::Dep::GreaterEq
;
493 Op
= pkgCache::Dep::Greater
;
497 // > is the same as >= and >> is really Cs > for some reason
498 Op
= pkgCache::Dep::GreaterEq
;
502 Op
= pkgCache::Dep::Equals
;
506 // HACK around bad package definitions
508 Op
= pkgCache::Dep::Equals
;
514 // ListParser::ParseDepends - Parse a dependency element /*{{{*/
515 // ---------------------------------------------------------------------
516 /* This parses the dependency elements out of a standard string in place,
518 const char *debListParser::ParseDepends(const char *Start
,const char *Stop
,
519 std::string
&Package
,std::string
&Ver
,unsigned int &Op
)
520 { return ParseDepends(Start
, Stop
, Package
, Ver
, Op
, false, true, false); }
521 const char *debListParser::ParseDepends(const char *Start
,const char *Stop
,
522 std::string
&Package
,std::string
&Ver
,unsigned int &Op
,
523 bool const &ParseArchFlags
)
524 { return ParseDepends(Start
, Stop
, Package
, Ver
, Op
, ParseArchFlags
, true, false); }
525 const char *debListParser::ParseDepends(const char *Start
,const char *Stop
,
526 std::string
&Package
,std::string
&Ver
,unsigned int &Op
,
527 bool const &ParseArchFlags
, bool const &StripMultiArch
)
528 { return ParseDepends(Start
, Stop
, Package
, Ver
, Op
, ParseArchFlags
, StripMultiArch
, false); }
529 const char *debListParser::ParseDepends(const char *Start
,const char *Stop
,
530 string
&Package
,string
&Ver
,
531 unsigned int &Op
, bool const &ParseArchFlags
,
532 bool const &StripMultiArch
,
533 bool const &ParseRestrictionsList
)
535 // Strip off leading space
536 for (;Start
!= Stop
&& isspace(*Start
) != 0; ++Start
);
538 // Parse off the package name
539 const char *I
= Start
;
540 for (;I
!= Stop
&& isspace(*I
) == 0 && *I
!= '(' && *I
!= ')' &&
541 *I
!= ',' && *I
!= '|' && *I
!= '[' && *I
!= ']' &&
542 *I
!= '<' && *I
!= '>'; ++I
);
545 if (I
!= Stop
&& *I
== ')')
551 // Stash the package name
552 Package
.assign(Start
,I
- Start
);
554 // We don't want to confuse library users which can't handle MultiArch
555 string
const arch
= _config
->Find("APT::Architecture");
556 if (StripMultiArch
== true) {
557 size_t const found
= Package
.rfind(':');
558 if (found
!= string::npos
&&
559 (strcmp(Package
.c_str() + found
, ":any") == 0 ||
560 strcmp(Package
.c_str() + found
, ":native") == 0 ||
561 strcmp(Package
.c_str() + found
+ 1, arch
.c_str()) == 0))
562 Package
= Package
.substr(0,found
);
565 // Skip white space to the '('
566 for (;I
!= Stop
&& isspace(*I
) != 0 ; I
++);
569 if (I
!= Stop
&& *I
== '(')
572 for (I
++; I
!= Stop
&& isspace(*I
) != 0 ; I
++);
575 I
= ConvertRelation(I
,Op
);
578 for (;I
!= Stop
&& isspace(*I
) != 0; I
++);
580 I
= (const char*) memchr(I
, ')', Stop
- I
);
581 if (I
== NULL
|| Start
== I
)
584 // Skip trailing whitespace
586 for (; End
> Start
&& isspace(End
[-1]); End
--);
588 Ver
.assign(Start
,End
-Start
);
594 Op
= pkgCache::Dep::NoOp
;
598 for (;I
!= Stop
&& isspace(*I
) != 0; I
++);
600 if (ParseArchFlags
== true)
602 APT::CacheFilter::PackageArchitectureMatchesSpecification
matchesArch(arch
, false);
604 // Parse an architecture
605 if (I
!= Stop
&& *I
== '[')
609 if (unlikely(I
== Stop
))
614 bool NegArch
= false;
617 // look for whitespace or ending ']'
618 for (;End
!= Stop
&& !isspace(*End
) && *End
!= ']'; ++End
);
620 if (unlikely(End
== Stop
))
629 std::string
arch(I
, End
);
630 if (arch
.empty() == false && matchesArch(arch
.c_str()) == true)
635 // we found a match, so fast-forward to the end of the wildcards
636 for (; End
!= Stop
&& *End
!= ']'; ++End
);
645 for (;I
!= Stop
&& isspace(*I
) != 0; I
++);
652 Package
= ""; /* not for this arch */
656 for (;I
!= Stop
&& isspace(*I
) != 0; I
++);
659 if (ParseRestrictionsList
== true)
661 // Parse a restrictions formula which is in disjunctive normal form:
662 // (foo AND bar) OR (blub AND bla)
664 std::vector
<string
> const profiles
= APT::Configuration::getBuildProfiles();
666 // if the next character is a restriction list, then by default the
667 // dependency does not apply and the conditions have to be checked
668 // if the next character is not a restriction list, then by default the
669 // dependency applies
670 bool applies1
= (*I
!= '<');
678 if (unlikely(I
== Stop
))
683 // if of the prior restriction list is already fulfilled, then
684 // we can just skip to the end of the current list
686 for (;End
!= Stop
&& *End
!= '>'; ++End
);
689 for (;I
!= Stop
&& isspace(*I
) != 0; I
++);
691 bool applies2
= true;
692 // all the conditions inside a restriction list have to be
693 // met so once we find one that is not met, we can skip to
694 // the end of this list
697 // look for whitespace or ending '>'
698 // End now points to the character after the current term
699 for (;End
!= Stop
&& !isspace(*End
) && *End
!= '>'; ++End
);
701 if (unlikely(End
== Stop
))
704 bool NegRestriction
= false;
707 NegRestriction
= true;
711 std::string
restriction(I
, End
);
713 if (restriction
.empty() == false && profiles
.empty() == false &&
714 std::find(profiles
.begin(), profiles
.end(), restriction
) != profiles
.end())
716 if (NegRestriction
) {
718 // since one of the terms does not apply we don't have to check the others
719 for (; End
!= Stop
&& *End
!= '>'; ++End
);
722 if (!NegRestriction
) {
724 // since one of the terms does not apply we don't have to check the others
725 for (; End
!= Stop
&& *End
!= '>'; ++End
);
732 for (;I
!= Stop
&& isspace(*I
) != 0; I
++);
738 for (;I
!= Stop
&& isspace(*I
) != 0; I
++);
746 if (applies1
== false) {
747 Package
= ""; //not for this restriction
751 if (I
!= Stop
&& *I
== '|')
752 Op
|= pkgCache::Dep::Or
;
754 if (I
== Stop
|| *I
== ',' || *I
== '|')
757 for (I
++; I
!= Stop
&& isspace(*I
) != 0; I
++);
764 // ListParser::ParseDepends - Parse a dependency list /*{{{*/
765 // ---------------------------------------------------------------------
766 /* This is the higher level depends parser. It takes a tag and generates
767 a complete depends tree for the given version. */
768 bool debListParser::ParseDepends(pkgCache::VerIterator
&Ver
,
769 const char *Tag
,unsigned int Type
)
773 if (Section
.Find(Tag
,Start
,Stop
) == false)
776 string
const pkgArch
= Ver
.Arch();
784 Start
= ParseDepends(Start
, Stop
, Package
, Version
, Op
, false, false, false);
786 return _error
->Error("Problem parsing dependency %s",Tag
);
787 size_t const found
= Package
.rfind(':');
789 if (found
== string::npos
|| strcmp(Package
.c_str() + found
, ":any") == 0)
791 if (NewDepends(Ver
,Package
,pkgArch
,Version
,Op
,Type
) == false)
796 string Arch
= Package
.substr(found
+1, string::npos
);
797 Package
= Package
.substr(0, found
);
798 // Such dependencies are not supposed to be accepted …
799 // … but this is probably the best thing to do anyway
800 if (Arch
== "native")
801 Arch
= _config
->Find("APT::Architecture");
802 if (NewDepends(Ver
,Package
,Arch
,Version
,Op
| pkgCache::Dep::ArchSpecific
,Type
) == false)
812 // ListParser::ParseProvides - Parse the provides list /*{{{*/
813 // ---------------------------------------------------------------------
815 bool debListParser::ParseProvides(pkgCache::VerIterator
&Ver
)
819 if (Section
.Find("Provides",Start
,Stop
) == true)
823 string
const Arch
= Ver
.Arch();
828 Start
= ParseDepends(Start
,Stop
,Package
,Version
,Op
);
829 const size_t archfound
= Package
.rfind(':');
831 return _error
->Error("Problem parsing Provides line");
832 if (Op
!= pkgCache::Dep::NoOp
&& Op
!= pkgCache::Dep::Equals
) {
833 _error
->Warning("Ignoring Provides line with non-equal DepCompareOp for package %s", Package
.c_str());
834 } else if (archfound
!= string::npos
) {
835 string OtherArch
= Package
.substr(archfound
+1, string::npos
);
836 Package
= Package
.substr(0, archfound
);
837 if (NewProvides(Ver
, Package
, OtherArch
, Version
, pkgCache::Flag::ArchSpecific
) == false)
839 } else if ((Ver
->MultiArch
& pkgCache::Version::Foreign
) == pkgCache::Version::Foreign
) {
840 if (NewProvidesAllArch(Ver
, Package
, Version
, 0) == false)
843 if (NewProvides(Ver
, Package
, Arch
, Version
, 0) == false)
852 if ((Ver
->MultiArch
& pkgCache::Version::Allowed
) == pkgCache::Version::Allowed
)
854 string
const Package
= string(Ver
.ParentPkg().Name()).append(":").append("any");
855 return NewProvidesAllArch(Ver
, Package
, Ver
.VerStr(), pkgCache::Flag::MultiArchImplicit
);
857 else if ((Ver
->MultiArch
& pkgCache::Version::Foreign
) == pkgCache::Version::Foreign
)
858 return NewProvidesAllArch(Ver
, Ver
.ParentPkg().Name(), Ver
.VerStr(), pkgCache::Flag::MultiArchImplicit
);
863 // ListParser::GrabWord - Matches a word and returns /*{{{*/
864 // ---------------------------------------------------------------------
865 /* Looks for a word in a list of words - for ParseStatus */
866 bool debListParser::GrabWord(string Word
,WordList
*List
,unsigned char &Out
)
868 for (unsigned int C
= 0; List
[C
].Str
!= 0; C
++)
870 if (strcasecmp(Word
.c_str(),List
[C
].Str
) == 0)
879 // ListParser::Step - Move to the next section in the file /*{{{*/
880 // ---------------------------------------------------------------------
881 /* This has to be careful to only process the correct architecture */
882 bool debListParser::Step()
884 iOffset
= Tags
.Offset();
885 return Tags
.Step(Section
);
888 // ListParser::GetPrio - Convert the priority from a string /*{{{*/
889 // ---------------------------------------------------------------------
891 unsigned char debListParser::GetPrio(string Str
)
894 if (GrabWord(Str
,PrioList
,Out
) == false)
895 Out
= pkgCache::State::Extra
;
900 bool debListParser::SameVersion(unsigned short const Hash
, /*{{{*/
901 pkgCache::VerIterator
const &Ver
)
903 if (pkgCacheListParser::SameVersion(Hash
, Ver
) == false)
905 // status file has no (Download)Size, but all others are fair game
906 // status file is parsed last, so the first version we encounter is
907 // probably also the version we have downloaded
908 unsigned long long const Size
= Section
.FindULL("Size");
909 if (Size
!= 0 && Size
!= Ver
->Size
)
911 // available everywhere, but easier to check here than to include in VersionHash
912 unsigned char MultiArch
= ParseMultiArch(false);
913 if (MultiArch
!= Ver
->MultiArch
)
915 // for all practical proposes (we can check): same version
920 debDebFileParser::debDebFileParser(FileFd
*File
, std::string
const &DebFile
)
921 : debListParser(File
), DebFile(DebFile
)
925 bool debDebFileParser::UsePackage(pkgCache::PkgIterator
&Pkg
,
926 pkgCache::VerIterator
&Ver
)
928 bool res
= debListParser::UsePackage(Pkg
, Ver
);
929 // we use the full file path as a provides so that the file is found
931 if(NewProvides(Ver
, DebFile
, Pkg
.Cache()->NativeArch(), Ver
.VerStr(), 0) == false)
936 debListParser::~debListParser() {}