We are calling system() in this code paths, so all we do here is having
a single child performing the action while the parent waits for it to
finish… with the added strangeness of not having our usual error message
collection and giving up after first failure even if told to act on
multiple packages.
if (_error->PendingError() == true)
return false;
if (_error->PendingError() == true)
return false;
- std::unique_ptr<DscFile[]> Dsc(new DscFile[CmdL.FileSize()]);
+ std::vector<DscFile> Dsc;
+ Dsc.reserve(CmdL.FileSize());
// insert all downloaded uris into this set to avoid downloading them
// twice
// insert all downloaded uris into this set to avoid downloading them
// twice
// Load the requestd sources into the fetcher
aptAcquireWithTextStatus Fetcher;
// Load the requestd sources into the fetcher
aptAcquireWithTextStatus Fetcher;
std::vector<std::string> UntrustedList;
std::vector<std::string> UntrustedList;
- for (const char **I = CmdL.FileList + 1; *I != 0; I++, J++)
+ for (const char **I = CmdL.FileList + 1; *I != 0; I++)
{
std::string Src;
pkgSrcRecords::Parser *Last = FindSrc(*I,SrcRecs,Src,Cache);
{
std::string Src;
pkgSrcRecords::Parser *Last = FindSrc(*I,SrcRecs,Src,Cache);
// Load them into the fetcher
for (std::vector<pkgSrcRecords::File2>::const_iterator I = Lst.begin();
I != Lst.end(); ++I)
// Load them into the fetcher
for (std::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")
{
// 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);
+ curDsc.Package = Last->Package();
+ curDsc.Version = Last->Version();
+ curDsc.Dsc = flNotDir(I->Path);
}
// Handle the only options so that multiple can be used at once
}
// Handle the only options so that multiple can be used at once
{
ioprintf(c1out, "Skipping download of file '%s' as requested hashsum is not available for authentication\n",
localFile.c_str());
{
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);
}
continue;
}
new pkgAcqFile(&Fetcher,Last->Index().ArchiveURI(I->Path),
I->Hashes, I->FileSize, Last->Index().SourceInfo(*Last,*I), Src);
}
+ Dsc.push_back(std::move(curDsc));
if (_config->FindB("APT::Get::Simulate",false) == true)
{
if (_config->FindB("APT::Get::Simulate",false) == true)
{
- for (unsigned I = 0; I != J; I++)
- ioprintf(std::cout,_("Fetch source %s\n"),Dsc[I].Package.c_str());
+ for (auto const &D: Dsc)
+ ioprintf(std::cout, _("Fetch source %s\n"), D.Package.c_str());
// Run it
bool Failed = false;
if (AcquireRun(Fetcher, 0, &Failed, NULL) == false || Failed == true)
// Run it
bool Failed = false;
if (AcquireRun(Fetcher, 0, &Failed, NULL) == false || Failed == true)
return _error->Error(_("Failed to fetch some archives."));
return _error->Error(_("Failed to fetch some archives."));
if (diffOnly || tarOnly || dscOnly || _config->FindB("APT::Get::Download-only",false) == true)
{
if (diffOnly || tarOnly || dscOnly || _config->FindB("APT::Get::Download-only",false) == true)
{
- // Unpack the sources
- pid_t Process = ExecFork();
-
- if (Process == 0)
+ bool const fixBroken = _config->FindB("APT::Get::Fix-Broken", false);
+ bool SaidCheckIfDpkgDev = false;
+ for (auto const &D: Dsc)
- bool const fixBroken = _config->FindB("APT::Get::Fix-Broken", false);
- for (unsigned I = 0; I != J; ++I)
+ if (unlikely(D.Dsc.empty() == true))
+ continue;
+ std::string const Dir = D.Package + '-' + Cache.GetPkgCache()->VS->UpstreamVersion(D.Version.c_str());
+
+ // 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)
- if (unlikely(Dsc[I].Dsc.empty() == true))
- continue;
- std::string const Dir = Dsc[I].Package + '-' + Cache.GetPkgCache()->VS->UpstreamVersion(Dsc[I].Version.c_str());
-
- // 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
+ 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(), D.Dsc.c_str());
+ if (system(S.c_str()) != 0)
- // 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)
+ _error->Error(_("Unpack command '%s' failed.\n"), S.c_str());
+ if (SaidCheckIfDpkgDev == false)
- fprintf(stderr, _("Unpack command '%s' failed.\n"), S.c_str());
- fprintf(stderr, _("Check if the 'dpkg-dev' package is installed.\n"));
- _exit(1);
+ _error->Notice(_("Check if the 'dpkg-dev' package is installed.\n"));
+ SaidCheckIfDpkgDev = true;
- // Try to compile it with dpkg-buildpackage
- if (_config->FindB("APT::Get::Compile",false) == true)
- {
- std::string buildopts = _config->Find("APT::Get::Host-Architecture");
- if (buildopts.empty() == false)
- buildopts = "-a" + buildopts + " ";
+ // Try to compile it with dpkg-buildpackage
+ if (_config->FindB("APT::Get::Compile",false) == true)
+ {
+ std::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(" ");
+ // 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"));
+ 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());
+ // 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);
- }
+ if (system(S.c_str()) != 0)
+ {
+ _error->Error(_("Build command '%s' failed.\n"), S.c_str());
+ continue;
-
- return ExecWait(Process, "dpkg-source");
}
/*}}}*/
// DoBuildDep - Install/removes packages to satisfy build dependencies /*{{{*/
}
/*}}}*/
// DoBuildDep - Install/removes packages to satisfy build dependencies /*{{{*/