- return true;
-}
- /*}}}*/
-// DoSource - Fetch a source archive /*{{{*/
-// ---------------------------------------------------------------------
-/* Fetch souce packages */
-struct DscFile
-{
- string Package;
- string Version;
- string Dsc;
-};
-
-static bool DoSource(CommandLine &CmdL)
-{
- CacheFile Cache;
- if (Cache.Open(false) == false)
- return false;
-
- if (CmdL.FileSize() <= 1)
- return _error->Error(_("Must specify at least one package to fetch source for"));
-
- // Read the source list
- if (Cache.BuildSourceList() == false)
- return false;
- pkgSourceList *List = Cache.GetSourceList();
-
- // Create the text record parsers
- pkgSrcRecords SrcRecs(*List);
- if (_error->PendingError() == true)
- return false;
-
- // Create the download object
- AcqTextStatus Stat(std::cout, ScreenWidth,_config->FindI("quiet",0));
- pkgAcquire Fetcher(&Stat);
-
- SPtrArray<DscFile> Dsc = new DscFile[CmdL.FileSize()];
-
- // insert all downloaded uris into this set to avoid downloading them
- // twice
- set<string> queued;
-
- // Diff only mode only fetches .diff files
- bool const diffOnly = _config->FindB("APT::Get::Diff-Only", false);
- // Tar only mode only fetches .tar files
- bool const tarOnly = _config->FindB("APT::Get::Tar-Only", false);
- // Dsc only mode only fetches .dsc files
- bool const dscOnly = _config->FindB("APT::Get::Dsc-Only", false);
-
- // Load the requestd sources into the fetcher
- unsigned J = 0;
- std::vector<std::string> UntrustedList;
- for (const char **I = CmdL.FileList + 1; *I != 0; I++, J++)
- {
- string Src;
- pkgSrcRecords::Parser *Last = FindSrc(*I,SrcRecs,Src,Cache);
- if (Last == 0) {
- return _error->Error(_("Unable to find a source package for %s"),Src.c_str());
- }
-
- if (Last->Index().IsTrusted() == false)
- UntrustedList.push_back(Src);
-
- string srec = Last->AsStr();
- string::size_type pos = srec.find("\nVcs-");
- while (pos != string::npos)
- {
- pos += strlen("\nVcs-");
- string vcs = srec.substr(pos,srec.find(":",pos)-pos);
- if(vcs == "Browser")
- {
- pos = srec.find("\nVcs-", pos);
- continue;
- }
- pos += vcs.length()+2;
- string::size_type epos = srec.find("\n", pos);
- string uri = srec.substr(pos,epos-pos).c_str();
- ioprintf(c1out, _("NOTICE: '%s' packaging is maintained in "
- "the '%s' version control system at:\n"
- "%s\n"),
- Src.c_str(), vcs.c_str(), uri.c_str());
- if(vcs == "Bzr")
- ioprintf(c1out,_("Please use:\n"
- "bzr branch %s\n"
- "to retrieve the latest (possibly unreleased) "
- "updates to the package.\n"),
- uri.c_str());
- break;
- }
-
- // Back track
- vector<pkgSrcRecords::File2> Lst;
- if (Last->Files2(Lst) == false) {
- return false;
- }
-
- // Load them into the fetcher
- for (vector<pkgSrcRecords::File2>::const_iterator I = Lst.begin();
- I != Lst.end(); ++I)
- {
- // Try to guess what sort of file it is we are getting.
- if (I->Type == "dsc")
- {
- Dsc[J].Package = Last->Package();
- Dsc[J].Version = Last->Version();
- Dsc[J].Dsc = flNotDir(I->Path);
- }
-
- // Handle the only options so that multiple can be used at once
- if (diffOnly == true || tarOnly == true || dscOnly == true)
- {
- if ((diffOnly == true && I->Type == "diff") ||
- (tarOnly == true && I->Type == "tar") ||
- (dscOnly == true && I->Type == "dsc"))
- ; // Fine, we want this file downloaded
- else
- continue;
- }
-
- // don't download the same uri twice (should this be moved to
- // the fetcher interface itself?)
- if(queued.find(Last->Index().ArchiveURI(I->Path)) != queued.end())
- continue;
- queued.insert(Last->Index().ArchiveURI(I->Path));
-
- // check if we have a file with that md5 sum already localy
- std::string localFile = flNotDir(I->Path);
- if (FileExists(localFile) == true)
- if(I->Hashes.VerifyFile(localFile) == true)
- {
- ioprintf(c1out,_("Skipping already downloaded file '%s'\n"),
- localFile.c_str());
- continue;
- }
-
- // see if we have a hash (Acquire::ForceHash is the only way to have none)
- if (I->Hashes.usable() == false && _config->FindB("APT::Get::AllowUnauthenticated",false) == false)
- {
- ioprintf(c1out, "Skipping download of file '%s' as requested hashsum is not available for authentication\n",
- localFile.c_str());
- continue;
- }
-
- new pkgAcqFile(&Fetcher,Last->Index().ArchiveURI(I->Path),
- I->Hashes, I->FileSize, Last->Index().SourceInfo(*Last,*I), Src);
- }
- }
-
- // Display statistics
- unsigned long long FetchBytes = Fetcher.FetchNeeded();
- unsigned long long FetchPBytes = Fetcher.PartialPresent();
- unsigned long long DebBytes = Fetcher.TotalNeeded();
-
- if (CheckFreeSpaceBeforeDownload(".", (FetchBytes - FetchPBytes)) == false)
- return false;
-
- // Number of bytes
- if (DebBytes != FetchBytes)
- //TRANSLATOR: The required space between number and unit is already included
- // in the replacement strings, so %sB will be correctly translate in e.g. 1,5 MB
- ioprintf(c1out,_("Need to get %sB/%sB of source archives.\n"),
- SizeToStr(FetchBytes).c_str(),SizeToStr(DebBytes).c_str());
- else
- //TRANSLATOR: The required space between number and unit is already included
- // in the replacement string, so %sB will be correctly translate in e.g. 1,5 MB
- ioprintf(c1out,_("Need to get %sB of source archives.\n"),
- SizeToStr(DebBytes).c_str());
-
- if (_config->FindB("APT::Get::Simulate",false) == true)
- {
- for (unsigned I = 0; I != J; I++)
- ioprintf(cout,_("Fetch source %s\n"),Dsc[I].Package.c_str());
- return true;
- }
-
- // Just print out the uris an exit if the --print-uris flag was used
- if (_config->FindB("APT::Get::Print-URIs") == true)
- {
- pkgAcquire::UriIterator I = Fetcher.UriBegin();
- for (; I != Fetcher.UriEnd(); ++I)
- cout << '\'' << I->URI << "' " << flNotDir(I->Owner->DestFile) << ' ' <<
- I->Owner->FileSize << ' ' << I->Owner->HashSum() << endl;
- return true;
- }
-
- // Disable drop-privs if "_apt" can not write to the target dir
- CheckDropPrivsMustBeDisabled(Fetcher);
-
- // check authentication status of the source as well
- if (UntrustedList.empty() == false && AuthPrompt(UntrustedList, false) == false)
- return false;
-
- // Run it
- bool Failed = false;
- if (AcquireRun(Fetcher, 0, &Failed, NULL) == false || Failed == true)
- {
- return _error->Error(_("Failed to fetch some archives."));
- }
-
- if (_config->FindB("APT::Get::Download-only",false) == true)
- {
- c1out << _("Download complete and in download only mode") << endl;
- return true;
- }
-
- // Unpack the sources
- pid_t Process = ExecFork();
-
- if (Process == 0)
- {
- bool const fixBroken = _config->FindB("APT::Get::Fix-Broken", false);
- for (unsigned I = 0; I != J; ++I)
- {
- string Dir = Dsc[I].Package + '-' + Cache->VS().UpstreamVersion(Dsc[I].Version.c_str());
-
- // Diff only mode only fetches .diff files
- if (_config->FindB("APT::Get::Diff-Only",false) == true ||
- _config->FindB("APT::Get::Tar-Only",false) == true ||
- Dsc[I].Dsc.empty() == true)
- continue;
-
- // See if the package is already unpacked
- struct stat Stat;
- if (fixBroken == false && stat(Dir.c_str(),&Stat) == 0 &&
- S_ISDIR(Stat.st_mode) != 0)
- {
- ioprintf(c0out ,_("Skipping unpack of already unpacked source in %s\n"),
- Dir.c_str());
- }
- else
- {
- // Call dpkg-source
- std::string const sourceopts = _config->Find("DPkg::Source-Options", "-x");
- std::string S;
- strprintf(S, "%s %s %s",
- _config->Find("Dir::Bin::dpkg-source","dpkg-source").c_str(),
- sourceopts.c_str(), Dsc[I].Dsc.c_str());
- if (system(S.c_str()) != 0)
- {
- fprintf(stderr, _("Unpack command '%s' failed.\n"), S.c_str());
- fprintf(stderr, _("Check if the 'dpkg-dev' package is installed.\n"));
- _exit(1);
- }
- }
-
- // Try to compile it with dpkg-buildpackage
- if (_config->FindB("APT::Get::Compile",false) == true)
- {
- string buildopts = _config->Find("APT::Get::Host-Architecture");
- if (buildopts.empty() == false)
- buildopts = "-a" + buildopts + " ";
-
- // get all active build profiles
- std::string const profiles = APT::Configuration::getBuildProfilesString();
- if (profiles.empty() == false)
- buildopts.append(" -P").append(profiles).append(" ");
-
- buildopts.append(_config->Find("DPkg::Build-Options","-b -uc"));
-
- // Call dpkg-buildpackage
- std::string S;
- strprintf(S, "cd %s && %s %s",
- Dir.c_str(),
- _config->Find("Dir::Bin::dpkg-buildpackage","dpkg-buildpackage").c_str(),
- buildopts.c_str());
-
- if (system(S.c_str()) != 0)
- {
- fprintf(stderr, _("Build command '%s' failed.\n"), S.c_str());
- _exit(1);
- }
- }
- }
-
- _exit(0);
- }
-
- // Wait for the subprocess
- int Status = 0;
- while (waitpid(Process,&Status,0) != Process)
- {
- if (errno == EINTR)
- continue;
- return _error->Errno("waitpid","Couldn't wait for subprocess");
- }
-
- if (WIFEXITED(Status) == 0 || WEXITSTATUS(Status) != 0)
- return _error->Error(_("Child process failed"));
-
- return true;
-}
- /*}}}*/
-// DoBuildDep - Install/removes packages to satisfy build dependencies /*{{{*/
-// ---------------------------------------------------------------------
-/* This function will look at the build depends list of the given source
- package and install the necessary packages to make it true, or fail. */
-static bool DoBuildDep(CommandLine &CmdL)
-{
- CacheFile Cache;
-
- _config->Set("APT::Install-Recommends", false);
-
- if (Cache.Open(true) == false)
- return false;
-
- if (CmdL.FileSize() <= 1)
- return _error->Error(_("Must specify at least one package to check builddeps for"));
-
- // Read the source list
- if (Cache.BuildSourceList() == false)
- return false;
- pkgSourceList *List = Cache.GetSourceList();
-
- // Create the text record parsers
- pkgSrcRecords SrcRecs(*List);
- if (_error->PendingError() == true)
- return false;
-
- bool StripMultiArch;
- string hostArch = _config->Find("APT::Get::Host-Architecture");
- if (hostArch.empty() == false)
- {
- std::vector<std::string> archs = APT::Configuration::getArchitectures();
- if (std::find(archs.begin(), archs.end(), hostArch) == archs.end())
- return _error->Error(_("No architecture information available for %s. See apt.conf(5) APT::Architectures for setup"), hostArch.c_str());
- StripMultiArch = false;
- }
- else
- StripMultiArch = true;
-
- unsigned J = 0;
- for (const char **I = CmdL.FileList + 1; *I != 0; I++, J++)
- {
- string Src;
- pkgSrcRecords::Parser *Last = 0;
- std::unique_ptr<pkgSrcRecords::Parser> LastOwner;
-
- // an unpacked debian source tree
- using APT::String::Startswith;
- if ((Startswith(*I, "./") || Startswith(*I, "/")) &&
- DirectoryExists(*I))
- {
- ioprintf(c1out, _("Note, using directory '%s' to get the build dependencies\n"), *I);
- // FIXME: how can we make this more elegant?
- std::string TypeName = "Debian control file";
- pkgIndexFile::Type *Type = pkgIndexFile::Type::GetType(TypeName.c_str());
- if(Type != NULL)
- LastOwner.reset(Last = Type->CreateSrcPkgParser(*I));
- }
- // if its a local file (e.g. .dsc) use this
- else if (FileExists(*I))
- {
- ioprintf(c1out, _("Note, using file '%s' to get the build dependencies\n"), *I);
-
- // see if we can get a parser for this pkgIndexFile type
- string TypeName = "Debian " + flExtension(*I) + " file";
- pkgIndexFile::Type *Type = pkgIndexFile::Type::GetType(TypeName.c_str());
- if(Type != NULL)
- LastOwner.reset(Last = Type->CreateSrcPkgParser(*I));
- } else {
- // normal case, search the cache for the source file
- Last = FindSrc(*I,SrcRecs,Src,Cache);
- }
-
- if (Last == 0)
- return _error->Error(_("Unable to find a source package for %s"),Src.c_str());
-
- // Process the build-dependencies
- vector<pkgSrcRecords::Parser::BuildDepRec> BuildDeps;
- // FIXME: Can't specify architecture to use for [wildcard] matching, so switch default arch temporary
- if (hostArch.empty() == false)
- {
- std::string nativeArch = _config->Find("APT::Architecture");
- _config->Set("APT::Architecture", hostArch);
- bool Success = Last->BuildDepends(BuildDeps, _config->FindB("APT::Get::Arch-Only", false), StripMultiArch);
- _config->Set("APT::Architecture", nativeArch);
- if (Success == false)
- return _error->Error(_("Unable to get build-dependency information for %s"),Src.c_str());
- }
- else if (Last->BuildDepends(BuildDeps, _config->FindB("APT::Get::Arch-Only", false), StripMultiArch) == false)
- return _error->Error(_("Unable to get build-dependency information for %s"),Src.c_str());
-
- // Also ensure that build-essential packages are present
- Configuration::Item const *Opts = _config->Tree("APT::Build-Essential");
- if (Opts)
- Opts = Opts->Child;
- for (; Opts; Opts = Opts->Next)
- {
- if (Opts->Value.empty() == true)
- continue;
-
- pkgSrcRecords::Parser::BuildDepRec rec;
- rec.Package = Opts->Value;
- rec.Type = pkgSrcRecords::Parser::BuildDependIndep;
- rec.Op = 0;
- BuildDeps.push_back(rec);
- }
-
- if (BuildDeps.empty() == true)
- {
- ioprintf(c1out,_("%s has no build depends.\n"),Src.c_str());
- continue;
- }
-
- // Install the requested packages
- vector <pkgSrcRecords::Parser::BuildDepRec>::iterator D;
- pkgProblemResolver Fix(Cache);
- bool skipAlternatives = false; // skip remaining alternatives in an or group
- for (D = BuildDeps.begin(); D != BuildDeps.end(); ++D)
- {
- bool hasAlternatives = (((*D).Op & pkgCache::Dep::Or) == pkgCache::Dep::Or);
-
- if (skipAlternatives == true)
- {
- /*
- * if there are alternatives, we've already picked one, so skip
- * the rest
- *
- * TODO: this means that if there's a build-dep on A|B and B is
- * installed, we'll still try to install A; more importantly,
- * if A is currently broken, we cannot go back and try B. To fix
- * this would require we do a Resolve cycle for each package we
- * add to the install list. Ugh
- */
- if (!hasAlternatives)
- skipAlternatives = false; // end of or group
- continue;
- }
-
- if ((*D).Type == pkgSrcRecords::Parser::BuildConflict ||
- (*D).Type == pkgSrcRecords::Parser::BuildConflictIndep)
- {
- pkgCache::GrpIterator Grp = Cache->FindGrp((*D).Package);
- // Build-conflicts on unknown packages are silently ignored
- if (Grp.end() == true)
- continue;
-
- for (pkgCache::PkgIterator Pkg = Grp.PackageList(); Pkg.end() == false; Pkg = Grp.NextPkg(Pkg))
- {
- pkgCache::VerIterator IV = (*Cache)[Pkg].InstVerIter(*Cache);
- /*
- * Remove if we have an installed version that satisfies the
- * version criteria
- */
- if (IV.end() == false &&
- Cache->VS().CheckDep(IV.VerStr(),(*D).Op,(*D).Version.c_str()) == true)
- TryToInstallBuildDep(Pkg,Cache,Fix,true,false);
- }
- }
- else // BuildDep || BuildDepIndep
- {
- if (_config->FindB("Debug::BuildDeps",false) == true)
- cout << "Looking for " << (*D).Package << "...\n";
-
- pkgCache::PkgIterator Pkg;
-
- // Cross-Building?
- if (StripMultiArch == false && D->Type != pkgSrcRecords::Parser::BuildDependIndep)
- {
- size_t const colon = D->Package.find(":");
- if (colon != string::npos)
- {
- if (strcmp(D->Package.c_str() + colon, ":any") == 0 || strcmp(D->Package.c_str() + colon, ":native") == 0)
- Pkg = Cache->FindPkg(D->Package.substr(0,colon));
- else
- Pkg = Cache->FindPkg(D->Package);
- }
- else
- Pkg = Cache->FindPkg(D->Package, hostArch);
-
- // a bad version either is invalid or doesn't satify dependency
- #define BADVER(Ver) (Ver.end() == true || \
- (D->Version.empty() == false && \
- Cache->VS().CheckDep(Ver.VerStr(),D->Op,D->Version.c_str()) == false))
-
- APT::VersionList verlist;
- if (Pkg.end() == false)
- {
- pkgCache::VerIterator Ver = (*Cache)[Pkg].InstVerIter(*Cache);
- if (BADVER(Ver) == false)
- verlist.insert(Ver);
- Ver = (*Cache)[Pkg].CandidateVerIter(*Cache);
- if (BADVER(Ver) == false)
- verlist.insert(Ver);
- }
- if (verlist.empty() == true)
- {
- pkgCache::PkgIterator BuildPkg = Cache->FindPkg(D->Package, "native");
- if (BuildPkg.end() == false && Pkg != BuildPkg)
- {
- pkgCache::VerIterator Ver = (*Cache)[BuildPkg].InstVerIter(*Cache);
- if (BADVER(Ver) == false)
- verlist.insert(Ver);
- Ver = (*Cache)[BuildPkg].CandidateVerIter(*Cache);
- if (BADVER(Ver) == false)
- verlist.insert(Ver);
- }
- }
- #undef BADVER
-
- string forbidden;
- // We need to decide if host or build arch, so find a version we can look at
- APT::VersionList::const_iterator Ver = verlist.begin();
- for (; Ver != verlist.end(); ++Ver)
- {
- forbidden.clear();
- if (Ver->MultiArch == pkgCache::Version::No || Ver->MultiArch == pkgCache::Version::All)
- {
- if (colon == string::npos)
- Pkg = Ver.ParentPkg().Group().FindPkg(hostArch);
- else if (strcmp(D->Package.c_str() + colon, ":any") == 0)
- forbidden = "Multi-Arch: no";
- else if (strcmp(D->Package.c_str() + colon, ":native") == 0)
- Pkg = Ver.ParentPkg().Group().FindPkg("native");
- }
- else if (Ver->MultiArch == pkgCache::Version::Same)
- {
- if (colon == string::npos)
- Pkg = Ver.ParentPkg().Group().FindPkg(hostArch);
- else if (strcmp(D->Package.c_str() + colon, ":any") == 0)
- forbidden = "Multi-Arch: same";
- else if (strcmp(D->Package.c_str() + colon, ":native") == 0)
- Pkg = Ver.ParentPkg().Group().FindPkg("native");
- }
- else if ((Ver->MultiArch & pkgCache::Version::Foreign) == pkgCache::Version::Foreign)
- {
- if (colon == string::npos)
- Pkg = Ver.ParentPkg().Group().FindPkg("native");
- else if (strcmp(D->Package.c_str() + colon, ":any") == 0 ||
- strcmp(D->Package.c_str() + colon, ":native") == 0)
- forbidden = "Multi-Arch: foreign";
- }
- else if ((Ver->MultiArch & pkgCache::Version::Allowed) == pkgCache::Version::Allowed)
- {
- if (colon == string::npos)
- Pkg = Ver.ParentPkg().Group().FindPkg(hostArch);
- else if (strcmp(D->Package.c_str() + colon, ":any") == 0)
- {
- // prefer any installed over preferred non-installed architectures
- pkgCache::GrpIterator Grp = Ver.ParentPkg().Group();
- // we don't check for version here as we are better of with upgrading than remove and install
- for (Pkg = Grp.PackageList(); Pkg.end() == false; Pkg = Grp.NextPkg(Pkg))
- if (Pkg.CurrentVer().end() == false)
- break;
- if (Pkg.end() == true)
- Pkg = Grp.FindPreferredPkg(true);
- }
- else if (strcmp(D->Package.c_str() + colon, ":native") == 0)
- Pkg = Ver.ParentPkg().Group().FindPkg("native");
- }
-
- if (forbidden.empty() == false)
- {
- if (_config->FindB("Debug::BuildDeps",false) == true)
- cout << D->Package.substr(colon, string::npos) << " is not allowed from " << forbidden << " package " << (*D).Package << " (" << Ver.VerStr() << ")" << endl;
- continue;
- }
-
- //we found a good version
- break;
- }
- if (Ver == verlist.end())
- {
- if (_config->FindB("Debug::BuildDeps",false) == true)
- cout << " No multiarch info as we have no satisfying installed nor candidate for " << D->Package << " on build or host arch" << endl;
-
- if (forbidden.empty() == false)
- {
- if (hasAlternatives)
- continue;
- return _error->Error(_("%s dependency for %s can't be satisfied "
- "because %s is not allowed on '%s' packages"),
- Last->BuildDepType(D->Type), Src.c_str(),
- D->Package.c_str(), forbidden.c_str());
- }
- }
- }
- else
- Pkg = Cache->FindPkg(D->Package);
-
- if (Pkg.end() == true || (Pkg->VersionList == 0 && Pkg->ProvidesList == 0))
- {
- if (_config->FindB("Debug::BuildDeps",false) == true)
- cout << " (not found)" << (*D).Package << endl;
-
- if (hasAlternatives)
- continue;
-
- return _error->Error(_("%s dependency for %s cannot be satisfied "
- "because the package %s cannot be found"),
- Last->BuildDepType((*D).Type),Src.c_str(),
- (*D).Package.c_str());
- }
-
- pkgCache::VerIterator IV = (*Cache)[Pkg].InstVerIter(*Cache);
- if (IV.end() == false)
- {
- if (_config->FindB("Debug::BuildDeps",false) == true)
- cout << " Is installed\n";
-
- if (D->Version.empty() == true ||
- Cache->VS().CheckDep(IV.VerStr(),(*D).Op,(*D).Version.c_str()) == true)
- {
- skipAlternatives = hasAlternatives;
- continue;
- }
-
- if (_config->FindB("Debug::BuildDeps",false) == true)
- cout << " ...but the installed version doesn't meet the version requirement\n";
-
- if (((*D).Op & pkgCache::Dep::LessEq) == pkgCache::Dep::LessEq)
- return _error->Error(_("Failed to satisfy %s dependency for %s: Installed package %s is too new"),
- Last->BuildDepType((*D).Type), Src.c_str(), Pkg.FullName(true).c_str());
- }
-
- // Only consider virtual packages if there is no versioned dependency
- if ((*D).Version.empty() == true)
- {
- /*
- * If this is a virtual package, we need to check the list of
- * packages that provide it and see if any of those are
- * installed
- */
- pkgCache::PrvIterator Prv = Pkg.ProvidesList();
- for (; Prv.end() != true; ++Prv)
- {
- if (_config->FindB("Debug::BuildDeps",false) == true)
- cout << " Checking provider " << Prv.OwnerPkg().FullName() << endl;
-
- if ((*Cache)[Prv.OwnerPkg()].InstVerIter(*Cache).end() == false)
- break;
- }
-
- if (Prv.end() == false)
- {
- if (_config->FindB("Debug::BuildDeps",false) == true)
- cout << " Is provided by installed package " << Prv.OwnerPkg().FullName() << endl;
- skipAlternatives = hasAlternatives;
- continue;
- }
- }
- else // versioned dependency
- {
- pkgCache::VerIterator CV = (*Cache)[Pkg].CandidateVerIter(*Cache);
- if (CV.end() == true ||
- Cache->VS().CheckDep(CV.VerStr(),(*D).Op,(*D).Version.c_str()) == false)
- {
- if (hasAlternatives)
- continue;
- else if (CV.end() == false)
- return _error->Error(_("%s dependency for %s cannot be satisfied "
- "because candidate version of package %s "
- "can't satisfy version requirements"),
- Last->BuildDepType(D->Type), Src.c_str(),
- D->Package.c_str());
- else
- return _error->Error(_("%s dependency for %s cannot be satisfied "
- "because package %s has no candidate version"),
- Last->BuildDepType(D->Type), Src.c_str(),
- D->Package.c_str());
- }
- }
-
- if (TryToInstallBuildDep(Pkg,Cache,Fix,false,false,false) == true)
- {
- // We successfully installed something; skip remaining alternatives
- skipAlternatives = hasAlternatives;
- if(_config->FindB("APT::Get::Build-Dep-Automatic", false) == true)
- Cache->MarkAuto(Pkg, true);
- continue;
- }
- else if (hasAlternatives)
- {
- if (_config->FindB("Debug::BuildDeps",false) == true)
- cout << " Unsatisfiable, trying alternatives\n";
- continue;
- }
- else
- {
- return _error->Error(_("Failed to satisfy %s dependency for %s: %s"),
- Last->BuildDepType((*D).Type),
- Src.c_str(),
- (*D).Package.c_str());
- }
- }
- }
-
- if (Fix.Resolve(true) == false)
- _error->Discard();
-
- // Now we check the state of the packages,
- if (Cache->BrokenCount() != 0)
- {
- ShowBroken(cout, Cache, false);
- return _error->Error(_("Build-dependencies for %s could not be satisfied."),*I);
- }
- }
-
- if (InstallPackages(Cache, false, true) == false)
- return _error->Error(_("Failed to process build dependencies"));
- return true;
-}
- /*}}}*/
-// DoChangelog - Get changelog from the command line /*{{{*/
-static bool DoChangelog(CommandLine &CmdL)
-{
- CacheFile Cache;
- if (Cache.ReadOnlyOpen() == false)
- return false;
-
- APT::CacheSetHelper helper;
- APT::VersionList verset = APT::VersionList::FromCommandLine(Cache,
- CmdL.FileList + 1, APT::CacheSetHelper::CANDIDATE, helper);
- if (verset.empty() == true)
- return false;
- pkgAcquire Fetcher;
- AcqTextStatus Stat(std::cout, ScreenWidth,_config->FindI("quiet",0));
- Fetcher.SetLog(&Stat);
-
- bool const downOnly = _config->FindB("APT::Get::Download-Only", false);
- bool const printOnly = _config->FindB("APT::Get::Print-URIs", false);
-
- for (APT::VersionList::const_iterator Ver = verset.begin();
- Ver != verset.end();
- ++Ver)
- {
- if (printOnly)
- new pkgAcqChangelog(&Fetcher, Ver, "/dev/null");
- else if (downOnly)
- new pkgAcqChangelog(&Fetcher, Ver, ".");
- else
- new pkgAcqChangelog(&Fetcher, Ver);
- }
-
- if (printOnly == false)
- {
- // Disable drop-privs if "_apt" can not write to the target dir
- CheckDropPrivsMustBeDisabled(Fetcher);
- if (_error->PendingError() == true)
- return false;
-
- bool Failed = false;
- if (AcquireRun(Fetcher, 0, &Failed, NULL) == false || Failed == true)
- return false;
- }
-
- if (downOnly == false || printOnly == true)
- {
- bool Failed = false;
- for (pkgAcquire::ItemIterator I = Fetcher.ItemsBegin(); I != Fetcher.ItemsEnd(); ++I)
- {
- if (printOnly)
- {
- if ((*I)->ErrorText.empty() == false)
- {
- Failed = true;
- _error->Error("%s", (*I)->ErrorText.c_str());
- }
- else
- cout << '\'' << (*I)->DescURI() << "' " << flNotDir((*I)->DestFile) << std::endl;
- }
- else
- DisplayFileInPager((*I)->DestFile);
- }
- return Failed == false;
- }
-