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/fileutl.h>
22 #include <apt-pkg/crc-16.h>
23 #include <apt-pkg/md5.h>
24 #include <apt-pkg/mmap.h>
25 #include <apt-pkg/pkgcache.h>
26 #include <apt-pkg/cacheiterators.h>
27 #include <apt-pkg/tagfile.h>
28 #include <apt-pkg/macros.h>
40 static debListParser::WordList PrioList
[] = {
41 {"required",pkgCache::State::Required
},
42 {"important",pkgCache::State::Important
},
43 {"standard",pkgCache::State::Standard
},
44 {"optional",pkgCache::State::Optional
},
45 {"extra",pkgCache::State::Extra
},
48 // ListParser::debListParser - Constructor /*{{{*/
49 // ---------------------------------------------------------------------
50 /* Provide an architecture and only this one and "all" will be accepted
51 in Step(), if no Architecture is given we will accept every arch
52 we would accept in general with checkArchitecture() */
53 debListParser::debListParser(FileFd
*File
) :
54 pkgCacheListParser(), d(NULL
), Tags(File
)
58 // ListParser::Package - Return the package name /*{{{*/
59 // ---------------------------------------------------------------------
60 /* This is to return the name of the package this section describes */
61 string
debListParser::Package() {
62 string
const Result
= Section
.FindS("Package");
63 if(unlikely(Result
.empty() == true))
64 _error
->Error("Encountered a section with no Package: header");
68 // ListParser::Architecture - Return the package arch /*{{{*/
69 // ---------------------------------------------------------------------
70 /* This will return the Architecture of the package this section describes */
71 string
debListParser::Architecture() {
72 return Section
.FindS("Architecture");
75 // ListParser::ArchitectureAll /*{{{*/
76 // ---------------------------------------------------------------------
78 bool debListParser::ArchitectureAll() {
79 return Section
.FindS("Architecture") == "all";
82 // ListParser::Version - Return the version string /*{{{*/
83 // ---------------------------------------------------------------------
84 /* This is to return the string describing the version in debian form,
85 epoch:upstream-release. If this returns the blank string then the
86 entry is assumed to only describe package properties */
87 string
debListParser::Version()
89 return Section
.FindS("Version");
92 unsigned char debListParser::ParseMultiArch(bool const showErrors
) /*{{{*/
95 string
const MultiArch
= Section
.FindS("Multi-Arch");
96 if (MultiArch
.empty() == true || MultiArch
== "no")
97 MA
= pkgCache::Version::None
;
98 else if (MultiArch
== "same") {
99 if (ArchitectureAll() == true)
101 if (showErrors
== true)
102 _error
->Warning("Architecture: all package '%s' can't be Multi-Arch: same",
103 Section
.FindS("Package").c_str());
104 MA
= pkgCache::Version::None
;
107 MA
= pkgCache::Version::Same
;
109 else if (MultiArch
== "foreign")
110 MA
= pkgCache::Version::Foreign
;
111 else if (MultiArch
== "allowed")
112 MA
= pkgCache::Version::Allowed
;
115 if (showErrors
== true)
116 _error
->Warning("Unknown Multi-Arch type '%s' for package '%s'",
117 MultiArch
.c_str(), Section
.FindS("Package").c_str());
118 MA
= pkgCache::Version::None
;
121 if (ArchitectureAll() == true)
122 MA
|= pkgCache::Version::All
;
127 // ListParser::NewVersion - Fill in the version structure /*{{{*/
128 // ---------------------------------------------------------------------
130 bool debListParser::NewVersion(pkgCache::VerIterator
&Ver
)
136 if (Section
.Find("Section",Start
,Stop
) == true)
138 map_stringitem_t
const idx
= StoreString(pkgCacheGenerator::SECTION
, Start
, Stop
- Start
);
141 // Parse the source package name
142 pkgCache::GrpIterator
const G
= Ver
.ParentPkg().Group();
143 Ver
->SourcePkgName
= G
->Name
;
144 Ver
->SourceVerStr
= Ver
->VerStr
;
145 if (Section
.Find("Source",Start
,Stop
) == true)
147 const char * const Space
= (const char * const) memchr(Start
, ' ', Stop
- Start
);
148 pkgCache::VerIterator V
;
153 const char * const Open
= (const char * const) memchr(Space
, '(', Stop
- Space
);
154 if (likely(Open
!= NULL
))
156 const char * const Close
= (const char * const) memchr(Open
, ')', Stop
- Open
);
157 if (likely(Close
!= NULL
))
159 std::string
const version(Open
+ 1, (Close
- Open
) - 1);
160 if (version
!= Ver
.VerStr())
162 map_stringitem_t
const idx
= StoreString(pkgCacheGenerator::VERSIONNUMBER
, version
);
163 Ver
->SourceVerStr
= idx
;
169 std::string
const pkgname(Start
, Stop
- Start
);
170 if (pkgname
!= G
.Name())
172 for (pkgCache::PkgIterator P
= G
.PackageList(); P
.end() == false; P
= G
.NextPkg(P
))
174 for (V
= P
.VersionList(); V
.end() == false; ++V
)
176 if (pkgname
== V
.SourcePkgName())
178 Ver
->SourcePkgName
= V
->SourcePkgName
;
182 if (V
.end() == false)
187 map_stringitem_t
const idx
= StoreString(pkgCacheGenerator::PKGNAME
, pkgname
);
188 Ver
->SourcePkgName
= idx
;
193 Ver
->MultiArch
= ParseMultiArch(true);
195 Ver
->Size
= Section
.FindULL("Size");
196 // Unpacked Size (in K)
197 Ver
->InstalledSize
= Section
.FindULL("Installed-Size");
198 Ver
->InstalledSize
*= 1024;
201 if (Section
.Find("Priority",Start
,Stop
) == true)
203 if (GrabWord(string(Start
,Stop
-Start
),PrioList
,Ver
->Priority
) == false)
204 Ver
->Priority
= pkgCache::State::Extra
;
207 if (ParseDepends(Ver
,"Pre-Depends",pkgCache::Dep::PreDepends
) == false)
209 if (ParseDepends(Ver
,"Depends",pkgCache::Dep::Depends
) == false)
211 if (ParseDepends(Ver
,"Conflicts",pkgCache::Dep::Conflicts
) == false)
213 if (ParseDepends(Ver
,"Breaks",pkgCache::Dep::DpkgBreaks
) == false)
215 if (ParseDepends(Ver
,"Recommends",pkgCache::Dep::Recommends
) == false)
217 if (ParseDepends(Ver
,"Suggests",pkgCache::Dep::Suggests
) == false)
219 if (ParseDepends(Ver
,"Replaces",pkgCache::Dep::Replaces
) == false)
221 if (ParseDepends(Ver
,"Enhances",pkgCache::Dep::Enhances
) == false)
224 if (ParseDepends(Ver
,"Optional",pkgCache::Dep::Suggests
) == false)
227 if (ParseProvides(Ver
) == false)
233 // ListParser::Description - Return the description string /*{{{*/
234 // ---------------------------------------------------------------------
235 /* This is to return the string describing the package in debian
236 form. If this returns the blank string then the entry is assumed to
237 only describe package properties */
238 string
debListParser::Description(std::string
const &lang
)
241 return Section
.FindS("Description");
243 return Section
.FindS(string("Description-").append(lang
).c_str());
246 // ListParser::AvailableDescriptionLanguages /*{{{*/
247 std::vector
<std::string
> debListParser::AvailableDescriptionLanguages()
249 std::vector
<std::string
> const understood
= APT::Configuration::getLanguages();
250 std::vector
<std::string
> avail
;
251 if (Section
.Exists("Description") == true)
253 for (std::vector
<std::string
>::const_iterator lang
= understood
.begin(); lang
!= understood
.end(); ++lang
)
255 std::string
const tagname
= "Description-" + *lang
;
256 if (Section
.Exists(tagname
.c_str()) == true)
257 avail
.push_back(*lang
);
262 // ListParser::Description_md5 - Return the description_md5 MD5SumValue /*{{{*/
263 // ---------------------------------------------------------------------
264 /* This is to return the md5 string to allow the check if it is the right
265 description. If no Description-md5 is found in the section it will be
268 MD5SumValue
debListParser::Description_md5()
270 string
const value
= Section
.FindS("Description-md5");
271 if (value
.empty() == true)
273 std::string
const desc
= Description("") + "\n";
275 return MD5SumValue();
278 md5
.Add(desc
.c_str());
281 else if (likely(value
.size() == 32))
283 if (likely(value
.find_first_not_of("0123456789abcdefABCDEF") == string::npos
))
284 return MD5SumValue(value
);
285 _error
->Error("Malformed Description-md5 line; includes invalid character '%s'", value
.c_str());
286 return MD5SumValue();
288 _error
->Error("Malformed Description-md5 line; doesn't have the required length (32 != %d) '%s'", (int)value
.size(), value
.c_str());
289 return MD5SumValue();
292 // ListParser::UsePackage - Update a package structure /*{{{*/
293 // ---------------------------------------------------------------------
294 /* This is called to update the package with any new information
295 that might be found in the section */
296 bool debListParser::UsePackage(pkgCache::PkgIterator
&Pkg
,
297 pkgCache::VerIterator
&Ver
)
299 string
const static myArch
= _config
->Find("APT::Architecture");
300 // Possible values are: "all", "native", "installed" and "none"
301 // The "installed" mode is handled by ParseStatus(), See #544481 and friends.
302 string
const static essential
= _config
->Find("pkgCacheGen::Essential", "all");
303 if (essential
== "all" ||
304 (essential
== "native" && Pkg
->Arch
!= 0 && myArch
== Pkg
.Arch()))
305 if (Section
.FindFlag("Essential",Pkg
->Flags
,pkgCache::Flag::Essential
) == false)
307 if (Section
.FindFlag("Important",Pkg
->Flags
,pkgCache::Flag::Important
) == false)
310 if (strcmp(Pkg
.Name(),"apt") == 0)
312 if ((essential
== "native" && Pkg
->Arch
!= 0 && myArch
== Pkg
.Arch()) ||
314 Pkg
->Flags
|= pkgCache::Flag::Essential
| pkgCache::Flag::Important
;
316 Pkg
->Flags
|= pkgCache::Flag::Important
;
319 if (ParseStatus(Pkg
,Ver
) == false)
324 // ListParser::VersionHash - Compute a unique hash for this version /*{{{*/
325 // ---------------------------------------------------------------------
327 unsigned short debListParser::VersionHash()
329 const char *Sections
[] ={"Installed-Size",
337 unsigned long Result
= INIT_FCS
;
339 for (const char * const *I
= Sections
; *I
!= 0; ++I
)
343 if (Section
.Find(*I
,Start
,End
) == false || End
- Start
>= (signed)sizeof(S
))
346 /* Strip out any spaces from the text, this undoes dpkgs reformatting
347 of certain fields. dpkg also has the rather interesting notion of
348 reformatting depends operators < -> <= */
350 for (; Start
!= End
; ++Start
)
352 if (isspace(*Start
) != 0)
354 *J
++ = tolower_ascii(*Start
);
356 if ((*Start
== '<' || *Start
== '>') && Start
[1] != *Start
&& Start
[1] != '=')
360 Result
= AddCRC16(Result
,S
,J
- S
);
366 // ListParser::ParseStatus - Parse the status field /*{{{*/
367 // ---------------------------------------------------------------------
368 /* Status lines are of the form,
369 Status: want flag status
370 want = unknown, install, hold, deinstall, purge
372 status = not-installed, config-files, half-installed, unpacked,
373 half-configured, triggers-awaited, triggers-pending, installed
375 bool debListParser::ParseStatus(pkgCache::PkgIterator
&Pkg
,
376 pkgCache::VerIterator
&Ver
)
380 if (Section
.Find("Status",Start
,Stop
) == false)
383 // UsePackage() is responsible for setting the flag in the default case
384 bool const static essential
= _config
->Find("pkgCacheGen::Essential", "") == "installed";
385 if (essential
== true &&
386 Section
.FindFlag("Essential",Pkg
->Flags
,pkgCache::Flag::Essential
) == false)
389 // Isolate the first word
390 const char *I
= Start
;
391 for(; I
< Stop
&& *I
!= ' '; I
++);
392 if (I
>= Stop
|| *I
!= ' ')
393 return _error
->Error("Malformed Status line");
395 // Process the want field
396 WordList WantList
[] = {{"unknown",pkgCache::State::Unknown
},
397 {"install",pkgCache::State::Install
},
398 {"hold",pkgCache::State::Hold
},
399 {"deinstall",pkgCache::State::DeInstall
},
400 {"purge",pkgCache::State::Purge
},
402 if (GrabWord(string(Start
,I
-Start
),WantList
,Pkg
->SelectedState
) == false)
403 return _error
->Error("Malformed 1st word in the Status line");
405 // Isloate the next word
408 for(; I
< Stop
&& *I
!= ' '; I
++);
409 if (I
>= Stop
|| *I
!= ' ')
410 return _error
->Error("Malformed status line, no 2nd word");
412 // Process the flag field
413 WordList FlagList
[] = {{"ok",pkgCache::State::Ok
},
414 {"reinstreq",pkgCache::State::ReInstReq
},
415 {"hold",pkgCache::State::HoldInst
},
416 {"hold-reinstreq",pkgCache::State::HoldReInstReq
},
418 if (GrabWord(string(Start
,I
-Start
),FlagList
,Pkg
->InstState
) == false)
419 return _error
->Error("Malformed 2nd word in the Status line");
421 // Isloate the last word
424 for(; I
< Stop
&& *I
!= ' '; I
++);
426 return _error
->Error("Malformed Status line, no 3rd word");
428 // Process the flag field
429 WordList StatusList
[] = {{"not-installed",pkgCache::State::NotInstalled
},
430 {"config-files",pkgCache::State::ConfigFiles
},
431 {"half-installed",pkgCache::State::HalfInstalled
},
432 {"unpacked",pkgCache::State::UnPacked
},
433 {"half-configured",pkgCache::State::HalfConfigured
},
434 {"triggers-awaited",pkgCache::State::TriggersAwaited
},
435 {"triggers-pending",pkgCache::State::TriggersPending
},
436 {"installed",pkgCache::State::Installed
},
438 if (GrabWord(string(Start
,I
-Start
),StatusList
,Pkg
->CurrentState
) == false)
439 return _error
->Error("Malformed 3rd word in the Status line");
441 /* A Status line marks the package as indicating the current
442 version as well. Only if it is actually installed.. Otherwise
443 the interesting dpkg handling of the status file creates bogus
445 if (!(Pkg
->CurrentState
== pkgCache::State::NotInstalled
||
446 Pkg
->CurrentState
== pkgCache::State::ConfigFiles
))
448 if (Ver
.end() == true)
449 _error
->Warning("Encountered status field in a non-version description");
451 Pkg
->CurrentVer
= Ver
.Index();
457 const char *debListParser::ConvertRelation(const char *I
,unsigned int &Op
)
459 // Determine the operator
467 Op
= pkgCache::Dep::LessEq
;
474 Op
= pkgCache::Dep::Less
;
478 // < is the same as <= and << is really Cs < for some reason
479 Op
= pkgCache::Dep::LessEq
;
487 Op
= pkgCache::Dep::GreaterEq
;
494 Op
= pkgCache::Dep::Greater
;
498 // > is the same as >= and >> is really Cs > for some reason
499 Op
= pkgCache::Dep::GreaterEq
;
503 Op
= pkgCache::Dep::Equals
;
507 // HACK around bad package definitions
509 Op
= pkgCache::Dep::Equals
;
515 // ListParser::ParseDepends - Parse a dependency element /*{{{*/
516 // ---------------------------------------------------------------------
517 /* This parses the dependency elements out of a standard string in place,
519 const char *debListParser::ParseDepends(const char *Start
,const char *Stop
,
520 std::string
&Package
,std::string
&Ver
,unsigned int &Op
)
521 { return ParseDepends(Start
, Stop
, Package
, Ver
, Op
, false, true, false); }
522 const char *debListParser::ParseDepends(const char *Start
,const char *Stop
,
523 std::string
&Package
,std::string
&Ver
,unsigned int &Op
,
524 bool const &ParseArchFlags
)
525 { return ParseDepends(Start
, Stop
, Package
, Ver
, Op
, ParseArchFlags
, true, false); }
526 const char *debListParser::ParseDepends(const char *Start
,const char *Stop
,
527 std::string
&Package
,std::string
&Ver
,unsigned int &Op
,
528 bool const &ParseArchFlags
, bool const &StripMultiArch
)
529 { return ParseDepends(Start
, Stop
, Package
, Ver
, Op
, ParseArchFlags
, StripMultiArch
, false); }
530 const char *debListParser::ParseDepends(const char *Start
,const char *Stop
,
531 string
&Package
,string
&Ver
,
532 unsigned int &Op
, bool const &ParseArchFlags
,
533 bool const &StripMultiArch
,
534 bool const &ParseRestrictionsList
)
536 // Strip off leading space
537 for (;Start
!= Stop
&& isspace(*Start
) != 0; ++Start
);
539 // Parse off the package name
540 const char *I
= Start
;
541 for (;I
!= Stop
&& isspace(*I
) == 0 && *I
!= '(' && *I
!= ')' &&
542 *I
!= ',' && *I
!= '|' && *I
!= '[' && *I
!= ']' &&
543 *I
!= '<' && *I
!= '>'; ++I
);
546 if (I
!= Stop
&& *I
== ')')
552 // Stash the package name
553 Package
.assign(Start
,I
- Start
);
555 // We don't want to confuse library users which can't handle MultiArch
556 string
const arch
= _config
->Find("APT::Architecture");
557 if (StripMultiArch
== true) {
558 size_t const found
= Package
.rfind(':');
559 if (found
!= string::npos
&&
560 (strcmp(Package
.c_str() + found
, ":any") == 0 ||
561 strcmp(Package
.c_str() + found
, ":native") == 0 ||
562 strcmp(Package
.c_str() + found
+ 1, arch
.c_str()) == 0))
563 Package
= Package
.substr(0,found
);
566 // Skip white space to the '('
567 for (;I
!= Stop
&& isspace(*I
) != 0 ; I
++);
570 if (I
!= Stop
&& *I
== '(')
573 for (I
++; I
!= Stop
&& isspace(*I
) != 0 ; I
++);
576 I
= ConvertRelation(I
,Op
);
579 for (;I
!= Stop
&& isspace(*I
) != 0; I
++);
581 I
= (const char*) memchr(I
, ')', Stop
- I
);
582 if (I
== NULL
|| Start
== I
)
585 // Skip trailing whitespace
587 for (; End
> Start
&& isspace(End
[-1]); End
--);
589 Ver
.assign(Start
,End
-Start
);
595 Op
= pkgCache::Dep::NoOp
;
599 for (;I
!= Stop
&& isspace(*I
) != 0; I
++);
601 if (ParseArchFlags
== true)
603 APT::CacheFilter::PackageArchitectureMatchesSpecification
matchesArch(arch
, false);
605 // Parse an architecture
606 if (I
!= Stop
&& *I
== '[')
610 if (unlikely(I
== Stop
))
615 bool NegArch
= false;
618 // look for whitespace or ending ']'
619 for (;End
!= Stop
&& !isspace(*End
) && *End
!= ']'; ++End
);
621 if (unlikely(End
== Stop
))
630 std::string
arch(I
, End
);
631 if (arch
.empty() == false && matchesArch(arch
.c_str()) == true)
636 // we found a match, so fast-forward to the end of the wildcards
637 for (; End
!= Stop
&& *End
!= ']'; ++End
);
646 for (;I
!= Stop
&& isspace(*I
) != 0; I
++);
653 Package
= ""; /* not for this arch */
657 for (;I
!= Stop
&& isspace(*I
) != 0; I
++);
660 if (ParseRestrictionsList
== true)
662 // Parse a restrictions formula which is in disjunctive normal form:
663 // (foo AND bar) OR (blub AND bla)
665 std::vector
<string
> const profiles
= APT::Configuration::getBuildProfiles();
667 // if the next character is a restriction list, then by default the
668 // dependency does not apply and the conditions have to be checked
669 // if the next character is not a restriction list, then by default the
670 // dependency applies
671 bool applies1
= (*I
!= '<');
679 if (unlikely(I
== Stop
))
684 // if of the prior restriction list is already fulfilled, then
685 // we can just skip to the end of the current list
687 for (;End
!= Stop
&& *End
!= '>'; ++End
);
690 for (;I
!= Stop
&& isspace(*I
) != 0; I
++);
692 bool applies2
= true;
693 // all the conditions inside a restriction list have to be
694 // met so once we find one that is not met, we can skip to
695 // the end of this list
698 // look for whitespace or ending '>'
699 // End now points to the character after the current term
700 for (;End
!= Stop
&& !isspace(*End
) && *End
!= '>'; ++End
);
702 if (unlikely(End
== Stop
))
705 bool NegRestriction
= false;
708 NegRestriction
= true;
712 std::string
restriction(I
, End
);
714 if (restriction
.empty() == false && profiles
.empty() == false &&
715 std::find(profiles
.begin(), profiles
.end(), restriction
) != profiles
.end())
717 if (NegRestriction
) {
719 // since one of the terms does not apply we don't have to check the others
720 for (; End
!= Stop
&& *End
!= '>'; ++End
);
723 if (!NegRestriction
) {
725 // since one of the terms does not apply we don't have to check the others
726 for (; End
!= Stop
&& *End
!= '>'; ++End
);
733 for (;I
!= Stop
&& isspace(*I
) != 0; I
++);
739 for (;I
!= Stop
&& isspace(*I
) != 0; I
++);
747 if (applies1
== false) {
748 Package
= ""; //not for this restriction
752 if (I
!= Stop
&& *I
== '|')
753 Op
|= pkgCache::Dep::Or
;
755 if (I
== Stop
|| *I
== ',' || *I
== '|')
758 for (I
++; I
!= Stop
&& isspace(*I
) != 0; I
++);
765 // ListParser::ParseDepends - Parse a dependency list /*{{{*/
766 // ---------------------------------------------------------------------
767 /* This is the higher level depends parser. It takes a tag and generates
768 a complete depends tree for the given version. */
769 bool debListParser::ParseDepends(pkgCache::VerIterator
&Ver
,
770 const char *Tag
,unsigned int Type
)
774 if (Section
.Find(Tag
,Start
,Stop
) == false)
777 string
const pkgArch
= Ver
.Arch();
785 Start
= ParseDepends(Start
, Stop
, Package
, Version
, Op
, false, false, false);
787 return _error
->Error("Problem parsing dependency %s",Tag
);
788 size_t const found
= Package
.rfind(':');
790 if (found
== string::npos
|| strcmp(Package
.c_str() + found
, ":any") == 0)
792 if (NewDepends(Ver
,Package
,pkgArch
,Version
,Op
,Type
) == false)
797 string Arch
= Package
.substr(found
+1, string::npos
);
798 Package
= Package
.substr(0, found
);
799 // Such dependencies are not supposed to be accepted …
800 // … but this is probably the best thing to do anyway
801 if (Arch
== "native")
802 Arch
= _config
->Find("APT::Architecture");
803 if (NewDepends(Ver
,Package
,Arch
,Version
,Op
| pkgCache::Dep::ArchSpecific
,Type
) == false)
813 // ListParser::ParseProvides - Parse the provides list /*{{{*/
814 // ---------------------------------------------------------------------
816 bool debListParser::ParseProvides(pkgCache::VerIterator
&Ver
)
820 if (Section
.Find("Provides",Start
,Stop
) == true)
824 string
const Arch
= Ver
.Arch();
829 Start
= ParseDepends(Start
,Stop
,Package
,Version
,Op
);
830 const size_t archfound
= Package
.rfind(':');
832 return _error
->Error("Problem parsing Provides line");
833 if (Op
!= pkgCache::Dep::NoOp
&& Op
!= pkgCache::Dep::Equals
) {
834 _error
->Warning("Ignoring Provides line with non-equal DepCompareOp for package %s", Package
.c_str());
835 } else if (archfound
!= string::npos
) {
836 string OtherArch
= Package
.substr(archfound
+1, string::npos
);
837 Package
= Package
.substr(0, archfound
);
838 if (NewProvides(Ver
, Package
, OtherArch
, Version
, pkgCache::Flag::ArchSpecific
) == false)
840 } else if ((Ver
->MultiArch
& pkgCache::Version::Foreign
) == pkgCache::Version::Foreign
) {
841 if (NewProvidesAllArch(Ver
, Package
, Version
, 0) == false)
844 if (NewProvides(Ver
, Package
, Arch
, Version
, 0) == false)
853 if ((Ver
->MultiArch
& pkgCache::Version::Allowed
) == pkgCache::Version::Allowed
)
855 string
const Package
= string(Ver
.ParentPkg().Name()).append(":").append("any");
856 return NewProvidesAllArch(Ver
, Package
, Ver
.VerStr(), pkgCache::Flag::MultiArchImplicit
);
858 else if ((Ver
->MultiArch
& pkgCache::Version::Foreign
) == pkgCache::Version::Foreign
)
859 return NewProvidesAllArch(Ver
, Ver
.ParentPkg().Name(), Ver
.VerStr(), pkgCache::Flag::MultiArchImplicit
);
864 // ListParser::GrabWord - Matches a word and returns /*{{{*/
865 // ---------------------------------------------------------------------
866 /* Looks for a word in a list of words - for ParseStatus */
867 bool debListParser::GrabWord(string Word
,WordList
*List
,unsigned char &Out
)
869 for (unsigned int C
= 0; List
[C
].Str
!= 0; C
++)
871 if (strcasecmp(Word
.c_str(),List
[C
].Str
) == 0)
880 // ListParser::Step - Move to the next section in the file /*{{{*/
881 // ---------------------------------------------------------------------
882 /* This has to be careful to only process the correct architecture */
883 bool debListParser::Step()
885 iOffset
= Tags
.Offset();
886 return Tags
.Step(Section
);
889 // ListParser::GetPrio - Convert the priority from a string /*{{{*/
890 // ---------------------------------------------------------------------
892 unsigned char debListParser::GetPrio(string Str
)
895 if (GrabWord(Str
,PrioList
,Out
) == false)
896 Out
= pkgCache::State::Extra
;
901 bool debListParser::SameVersion(unsigned short const Hash
, /*{{{*/
902 pkgCache::VerIterator
const &Ver
)
904 if (pkgCacheListParser::SameVersion(Hash
, Ver
) == false)
906 // status file has no (Download)Size, but all others are fair game
907 // status file is parsed last, so the first version we encounter is
908 // probably also the version we have downloaded
909 unsigned long long const Size
= Section
.FindULL("Size");
910 if (Size
!= 0 && Size
!= Ver
->Size
)
912 // available everywhere, but easier to check here than to include in VersionHash
913 unsigned char MultiArch
= ParseMultiArch(false);
914 if (MultiArch
!= Ver
->MultiArch
)
916 // for all practical proposes (we can check): same version
921 debDebFileParser::debDebFileParser(FileFd
*File
, std::string
const &DebFile
)
922 : debListParser(File
), DebFile(DebFile
)
926 bool debDebFileParser::UsePackage(pkgCache::PkgIterator
&Pkg
,
927 pkgCache::VerIterator
&Ver
)
929 bool res
= debListParser::UsePackage(Pkg
, Ver
);
930 // we use the full file path as a provides so that the file is found
932 if(NewProvides(Ver
, DebFile
, Pkg
.Cache()->NativeArch(), Ver
.VerStr(), 0) == false)
937 debListParser::~debListParser() {}