summaryrefslogtreecommitdiff
path: root/apt-private
diff options
context:
space:
mode:
Diffstat (limited to 'apt-private')
-rw-r--r--apt-private/CMakeLists.txt4
-rw-r--r--apt-private/private-cachefile.cc5
-rw-r--r--apt-private/private-cmndline.cc20
-rw-r--r--apt-private/private-download.cc2
-rw-r--r--apt-private/private-install.cc19
-rw-r--r--apt-private/private-moo.cc45
-rw-r--r--apt-private/private-moo.h4
-rw-r--r--apt-private/private-output.cc6
-rw-r--r--apt-private/private-source.cc151
-rw-r--r--apt-private/private-update.cc14
-rw-r--r--apt-private/private-utils.cc22
-rw-r--r--apt-private/private-utils.h1
12 files changed, 162 insertions, 131 deletions
diff --git a/apt-private/CMakeLists.txt b/apt-private/CMakeLists.txt
index 6de9e0281..5dda36c92 100644
--- a/apt-private/CMakeLists.txt
+++ b/apt-private/CMakeLists.txt
@@ -2,7 +2,9 @@
set(MAJOR 0.0)
set(MINOR 0)
-# Definition of the C++ files used to build the library
+# Definition of the C++ files used to build the library - note that this
+# is expanded at CMake time, so you have to rerun cmake if you add or remove
+# a file (you can just run cmake . in the build directory)
file(GLOB_RECURSE library "*.cc")
file(GLOB_RECURSE headers "*.h")
diff --git a/apt-private/private-cachefile.cc b/apt-private/private-cachefile.cc
index 32cad1c33..77090f8eb 100644
--- a/apt-private/private-cachefile.cc
+++ b/apt-private/private-cachefile.cc
@@ -108,10 +108,9 @@ bool CacheFile::CheckDeps(bool AllowBroken)
}
else
{
- c1out << _("You might want to run 'apt-get -f install' to correct these.") << endl;
+ c1out << _("You might want to run 'apt --fix-broken install' to correct these.") << endl;
ShowBroken(c1out,*this,true);
-
- return _error->Error(_("Unmet dependencies. Try using -f."));
+ return _error->Error(_("Unmet dependencies. Try 'apt --fix-broken install' with no packages (or specify a solution)."));
}
return true;
diff --git a/apt-private/private-cmndline.cc b/apt-private/private-cmndline.cc
index d0cda08a6..de3992a00 100644
--- a/apt-private/private-cmndline.cc
+++ b/apt-private/private-cmndline.cc
@@ -220,6 +220,8 @@ static bool addArgumentsAPTGet(std::vector<CommandLine::Args> &Args, char const
addArg('P', "build-profiles", "APT::Build-Profiles", CommandLine::HasArg);
addArg(0, "purge", "APT::Get::Purge", 0);
addArg(0, "solver", "APT::Solver", CommandLine::HasArg);
+ addArg(0,"arch-only","APT::Get::Arch-Only",0);
+ addArg(0,"indep-only","APT::Get::Indep-Only",0);
// this has no effect *but* sbuild is using it (see LP: #1255806)
// once sbuild is fixed, this option can be removed
addArg('f', "fix-broken", "APT::Get::Fix-Broken", 0);
@@ -270,7 +272,6 @@ static bool addArgumentsAPTGet(std::vector<CommandLine::Args> &Args, char const
addArg(0,"trivial-only","APT::Get::Trivial-Only",0);
addArg(0,"remove","APT::Get::Remove",0);
addArg(0,"only-source","APT::Get::Only-Source",0);
- addArg(0,"arch-only","APT::Get::Arch-Only",0);
addArg(0,"allow-unauthenticated","APT::Get::AllowUnauthenticated",0);
addArg(0,"allow-insecure-repositories","Acquire::AllowInsecureRepositories",0);
addArg(0,"allow-weak-repositories","Acquire::AllowWeakRepositories",0);
@@ -473,6 +474,16 @@ static void BinaryCommandSpecificConfiguration(char const * const Binary, char c
std::string const binary = flNotDir(Binary);
if (binary == "apt-get" && CmdMatches("update"))
_config->CndSet("Binary::apt-get::Acquire::AllowInsecureRepositories", true);
+ if ((binary == "apt" || binary == "apt-get") && CmdMatches("upgrade", "dist-upgrade", "full-upgrade"))
+ {
+ //FIXME: the option is documented to apply only for install/remove, so
+ // we force it false for configuration files where users can be confused if
+ // we support it anyhow, but allow it on the commandline to take effect
+ // even through it isn't documented as a user who doesn't want it wouldn't
+ // ask for it
+ _config->Set("Binary::apt-get::APT::Get::AutomaticRemove", false);
+ _config->Set("Binary::apt::APT::Get::AutomaticRemove", false);
+ }
}
#undef CmdMatches
/*}}}*/
@@ -500,9 +511,6 @@ std::vector<CommandLine::Dispatch> ParseCommandLine(CommandLine &CmdL, APT_CMD c
for (auto const& cmd : CmdsWithHelp)
Cmds.push_back({cmd.Match, cmd.Handler});
- // Args running out of scope invalidates the pointer stored in CmdL,
- // but we don't use the pointer after this function, so we ignore
- // this problem for now and figure something out if we have to.
char const * CmdCalled = nullptr;
if (Cmds.empty() == false && Cmds[0].Handler != nullptr)
CmdCalled = CommandLine::GetCommand(Cmds.data(), argc, argv);
@@ -510,6 +518,10 @@ std::vector<CommandLine::Dispatch> ParseCommandLine(CommandLine &CmdL, APT_CMD c
BinaryCommandSpecificConfiguration(argv[0], CmdCalled);
std::string const conf = "Binary::" + _config->Find("Binary");
_config->MoveSubTree(conf.c_str(), nullptr);
+
+ // Args running out of scope invalidates the pointer stored in CmdL,
+ // but we don't use the pointer after this function, so we ignore
+ // this problem for now and figure something out if we have to.
auto Args = getCommandArgs(Binary, CmdCalled);
CmdL = CommandLine(Args.data(), _config);
diff --git a/apt-private/private-download.cc b/apt-private/private-download.cc
index d0cbbcf50..ee477f4cb 100644
--- a/apt-private/private-download.cc
+++ b/apt-private/private-download.cc
@@ -367,7 +367,7 @@ bool DoAutoClean(CommandLine &)
}
CacheFile Cache;
- if (Cache.Open() == false)
+ if (Cache.Open(false) == false)
return false;
LogCleaner Cleaner;
diff --git a/apt-private/private-install.cc b/apt-private/private-install.cc
index 761e4d175..73a03a828 100644
--- a/apt-private/private-install.cc
+++ b/apt-private/private-install.cc
@@ -136,16 +136,19 @@ bool InstallPackages(CacheFile &Cache,bool ShwKept,bool Ask, bool Safety)
_error->PendingError() == true)
return false;
- if (_config->FindB("APT::Get::Fix-Missing",false) == true &&
- _config->FindB("APT::Get::Download",true) == false)
+ if (_config->FindB("APT::Get::Download",true) == false)
{
bool Missing = false;
RemoveDownloadNeedingItemsFromFetcher(Fetcher, Missing);
if (Missing)
- PM->FixMissing();
+ {
+ if (_config->FindB("APT::Get::Fix-Missing",false))
+ PM->FixMissing();
+ else
+ return _error->Error(_("Unable to fetch some archives, maybe run apt-get update or try with --fix-missing?"));
+ }
Fetcher.Shutdown();
- if (PM->GetArchives(&Fetcher,List,&Recs) == false ||
- _error->PendingError() == true)
+ if (_error->PendingError() == true)
return false;
}
@@ -396,7 +399,7 @@ bool InstallPackages(CacheFile &Cache,bool ShwKept,bool Ask, bool Safety)
/* Remove unused automatic packages */
bool DoAutomaticRemove(CacheFile &Cache)
{
- bool Debug = _config->FindI("Debug::pkgAutoRemove",false);
+ bool Debug = _config->FindB("Debug::pkgAutoRemove",false);
bool doAutoRemove = _config->FindB("APT::Get::AutomaticRemove", false);
bool hideAutoRemove = _config->FindB("APT::Get::HideAutoRemove");
@@ -657,9 +660,9 @@ bool DoCacheManipulationFromCommandLine(CommandLine &CmdL, std::vector<std::stri
packages */
if (BrokenFix == true && Cache->BrokenCount() != 0)
{
- c1out << _("You might want to run 'apt-get -f install' to correct these:") << std::endl;
+ c1out << _("You might want to run 'apt --fix-broken install' to correct these.") << std::endl;
ShowBroken(c1out,Cache,false);
- return _error->Error(_("Unmet dependencies. Try 'apt-get -f install' with no packages (or specify a solution)."));
+ return _error->Error(_("Unmet dependencies. Try 'apt --fix-broken install' with no packages (or specify a solution)."));
}
if (Fix != NULL)
diff --git a/apt-private/private-moo.cc b/apt-private/private-moo.cc
index a87999150..b8ed6efbd 100644
--- a/apt-private/private-moo.cc
+++ b/apt-private/private-moo.cc
@@ -15,6 +15,7 @@
#include <apt-private/private-moo.h>
#include <apt-private/private-output.h>
+#include <apt-private/private-utils.h>
#include <stddef.h>
#include <string.h>
@@ -26,8 +27,8 @@
#include <apti18n.h>
/*}}}*/
-static std::string getMooLine() { /*{{{*/
- time_t const timenow = time(NULL);
+static std::string getMooLine(time_t const timenow) /*{{{*/
+{
struct tm special;
localtime_r(&timenow, &special);
enum { NORMAL, PACKAGEMANAGER, APPRECIATION, AGITATION, AIRBORN } line;
@@ -64,17 +65,18 @@ static std::string getMooLine() { /*{{{*/
return out.str();
}
/*}}}*/
-static bool printMooLine() { /*{{{*/
- std::cerr << getMooLine() << std::endl;
+static bool printMooLine(time_t const timenow) /*{{{*/
+{
+ std::cerr << getMooLine(timenow);
return true;
}
/*}}}*/
-bool DoMoo1(CommandLine &) /*{{{*/
+static bool DoMoo1(time_t const timenow) /*{{{*/
{
// our trustworthy super cow since 2001
if (_config->FindI("quiet") >= 2)
- return printMooLine();
- std::string const moo = getMooLine();
+ return printMooLine(timenow);
+ std::string const moo = getMooLine(timenow);
size_t const depth = moo.length()/4;
c1out <<
OutputInDepth(depth, " ") << " (__) \n" <<
@@ -87,12 +89,12 @@ bool DoMoo1(CommandLine &) /*{{{*/
return true;
}
/*}}}*/
-bool DoMoo2(CommandLine &) /*{{{*/
+static bool DoMoo2(time_t const timenow) /*{{{*/
{
// by Fernando Ribeiro in lp:56125
if (_config->FindI("quiet") >= 2)
- return printMooLine();
- std::string const moo = getMooLine();
+ return printMooLine(timenow);
+ std::string const moo = getMooLine(timenow);
size_t const depth = moo.length()/4;
if (_config->FindB("APT::Moo::Color", false) == false)
c1out <<
@@ -121,12 +123,12 @@ bool DoMoo2(CommandLine &) /*{{{*/
return true;
}
/*}}}*/
-bool DoMoo3(CommandLine &) /*{{{*/
+static bool DoMoo3(time_t const timenow) /*{{{*/
{
// by Robert Millan in deb:134156
if (_config->FindI("quiet") >= 2)
- return printMooLine();
- std::string const moo = getMooLine();
+ return printMooLine(timenow);
+ std::string const moo = getMooLine(timenow);
size_t const depth = moo.length()/16;
c1out <<
OutputInDepth(depth, " ") << " \\_/ \n" <<
@@ -138,7 +140,7 @@ bool DoMoo3(CommandLine &) /*{{{*/
return true;
}
/*}}}*/
-bool DoMooApril(CommandLine &) /*{{{*/
+static bool DoMooApril() /*{{{*/
{
// by Christopher Allan Webber and proposed by Paul Tagliamonte
// in a "Community outreach": https://lists.debian.org/debian-devel/2013/04/msg00045.html
@@ -163,11 +165,12 @@ bool DoMooApril(CommandLine &) /*{{{*/
/*}}}*/
bool DoMoo(CommandLine &CmdL) /*{{{*/
{
- time_t const timenow = time(NULL);
+ time_t const timenow = GetSecondsSinceEpoch();
+
struct tm april;
localtime_r(&timenow, &april);
if (april.tm_mday == 1 && april.tm_mon == 3)
- return DoMooApril(CmdL);
+ return DoMooApril();
signed short SuperCow = 1;
if (CmdL.FileSize() != 0)
@@ -185,11 +188,11 @@ bool DoMoo(CommandLine &CmdL) /*{{{*/
}
switch(SuperCow) {
- case 1: return DoMoo1(CmdL);
- case 2: return DoMoo2(CmdL);
- case 3: return DoMoo3(CmdL);
- case 4: return DoMooApril(CmdL);
- default: return DoMoo1(CmdL);
+ case 1: return DoMoo1(timenow);
+ case 2: return DoMoo2(timenow);
+ case 3: return DoMoo3(timenow);
+ case 4: return DoMooApril();
+ default: return DoMoo1(timenow);
}
return true;
diff --git a/apt-private/private-moo.h b/apt-private/private-moo.h
index bc8b3e7dd..c230ce2e1 100644
--- a/apt-private/private-moo.h
+++ b/apt-private/private-moo.h
@@ -6,9 +6,5 @@
class CommandLine;
APT_PUBLIC bool DoMoo(CommandLine &CmdL);
-bool DoMoo1(CommandLine &CmdL);
-bool DoMoo2(CommandLine &CmdL);
-bool DoMoo3(CommandLine &CmdL);
-bool DoMooApril(CommandLine &CmdL);
#endif
diff --git a/apt-private/private-output.cc b/apt-private/private-output.cc
index 301aa5519..9c25cda6d 100644
--- a/apt-private/private-output.cc
+++ b/apt-private/private-output.cc
@@ -304,14 +304,14 @@ void ListSingleVersion(pkgCacheFile &CacheFile, pkgRecords &records, /*{{{*/
// ShowBroken - Debugging aide /*{{{*/
// ---------------------------------------------------------------------
/* This prints out the names of all the packages that are broken along
- with the name of each each broken dependency and a quite version
+ with the name of each broken dependency and a quite version
description.
-
+
The output looks like:
The following packages have unmet dependencies:
exim: Depends: libc6 (>= 2.1.94) but 2.1.3-10 is to be installed
Depends: libldap2 (>= 2.0.2-2) but it is not going to be installed
- Depends: libsasl7 but it is not going to be installed
+ Depends: libsasl7 but it is not going to be installed
*/
static void ShowBrokenPackage(ostream &out, pkgCacheFile * const Cache, pkgCache::PkgIterator const &Pkg, bool const Now)
{
diff --git a/apt-private/private-source.cc b/apt-private/private-source.cc
index 9e7951ed2..923ea4db1 100644
--- a/apt-private/private-source.cc
+++ b/apt-private/private-source.cc
@@ -306,7 +306,7 @@ static pkgSrcRecords::Parser *FindSrc(const char *Name,
/*}}}*/
// DoSource - Fetch a source archive /*{{{*/
// ---------------------------------------------------------------------
-/* Fetch souce packages */
+/* Fetch source packages */
struct DscFile
{
std::string Package;
@@ -328,7 +328,8 @@ bool DoSource(CommandLine &CmdL)
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
@@ -343,9 +344,8 @@ bool DoSource(CommandLine &CmdL)
// Load the requestd sources into the fetcher
aptAcquireWithTextStatus Fetcher;
- unsigned J = 0;
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);
@@ -394,6 +394,7 @@ bool DoSource(CommandLine &CmdL)
return false;
}
+ DscFile curDsc;
// Load them into the fetcher
for (std::vector<pkgSrcRecords::File2>::const_iterator I = Lst.begin();
I != Lst.end(); ++I)
@@ -401,9 +402,9 @@ bool DoSource(CommandLine &CmdL)
// 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
@@ -438,13 +439,14 @@ bool DoSource(CommandLine &CmdL)
{
ioprintf(c1out, "Skipping download of file '%s' as requested hashsum is not available for authentication\n",
localFile.c_str());
- Dsc[J].Dsc.clear();
+ curDsc.Dsc.clear();
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));
}
// Display statistics
@@ -469,8 +471,8 @@ bool DoSource(CommandLine &CmdL)
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());
return true;
}
@@ -491,89 +493,79 @@ bool DoSource(CommandLine &CmdL)
// 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)
+ if (diffOnly || tarOnly || dscOnly || _config->FindB("APT::Get::Download-only",false) == true)
{
c1out << _("Download complete and in download only mode") << std::endl;
return 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)
{
- std::string Dir = Dsc[I].Package + '-' + Cache.GetPkgCache()->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
+ 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", "--no-check -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 (RunCmd(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 (RunCmd(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;
}
+ continue;
}
+ }
- // 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 (RunCmd(S.c_str()) != 0)
- {
- fprintf(stderr, _("Build command '%s' failed.\n"), S.c_str());
- _exit(1);
- }
+ if (RunCmd(S.c_str()) != 0)
+ {
+ _error->Error(_("Build command '%s' failed.\n"), S.c_str());
+ continue;
}
}
-
- _exit(0);
}
-
- return ExecWait(Process, "dpkg-source");
+ return true;
}
/*}}}*/
// DoBuildDep - Install/removes packages to satisfy build dependencies /*{{{*/
@@ -616,9 +608,14 @@ static void WriteBuildDependencyPackage(std::ostringstream &buildDepsPkgFile,
<< "Architecture: " << Arch << "\n"
<< "Version: 1\n";
+ bool const IndepOnly = _config->FindB("APT::Get::Indep-Only", false);
std::string depends, conflicts;
for (auto const &dep: Dependencies)
{
+ // ArchOnly is handled while parsing the dependencies on input
+ if (IndepOnly && (dep.Type == pkgSrcRecords::Parser::BuildDependArch ||
+ dep.Type == pkgSrcRecords::Parser::BuildConflictArch))
+ continue;
std::string * type;
if (dep.Type == pkgSrcRecords::Parser::BuildConflict ||
dep.Type == pkgSrcRecords::Parser::BuildConflictIndep ||
@@ -671,16 +668,12 @@ bool DoBuildDep(CommandLine &CmdL)
// deal with the build essentials first
{
std::vector<pkgSrcRecords::Parser::BuildDepRec> BuildDeps;
- Configuration::Item const *Opts = _config->Tree("APT::Build-Essential");
- if (Opts)
- Opts = Opts->Child;
- for (; Opts; Opts = Opts->Next)
+ for (auto && opt: _config->FindVector("APT::Build-Essential"))
{
- if (Opts->Value.empty() == true)
+ if (opt.empty())
continue;
-
pkgSrcRecords::Parser::BuildDepRec rec;
- rec.Package = Opts->Value;
+ rec.Package = std::move(opt);
rec.Type = pkgSrcRecords::Parser::BuildDependIndep;
rec.Op = 0;
BuildDeps.push_back(rec);
diff --git a/apt-private/private-update.cc b/apt-private/private-update.cc
index ba953a088..a886c830f 100644
--- a/apt-private/private-update.cc
+++ b/apt-private/private-update.cc
@@ -71,19 +71,19 @@ bool DoUpdate(CommandLine &CmdL)
ListUpdate(Stat, *List);
}
+ if (_config->FindB("pkgCacheFile::Generate", true) == false)
+ return true;
+
// Rebuild the cache.
- if (_config->FindB("pkgCacheFile::Generate", true) == true)
- {
- pkgCacheFile::RemoveCaches();
- if (Cache.BuildCaches() == false)
- return false;
- }
+ pkgCacheFile::RemoveCaches();
+ if (Cache.BuildCaches(false) == false)
+ return false;
// show basic stats (if the user whishes)
if (_config->FindB("APT::Cmd::Show-Update-Stats", false) == true)
{
int upgradable = 0;
- if (Cache.Open() == false)
+ if (Cache.Open(false) == false)
return false;
for (pkgCache::PkgIterator I = Cache->PkgBegin(); I.end() != true; ++I)
{
diff --git a/apt-private/private-utils.cc b/apt-private/private-utils.cc
index 775bf7e79..5863925b9 100644
--- a/apt-private/private-utils.cc
+++ b/apt-private/private-utils.cc
@@ -1,11 +1,13 @@
#include <config.h>
#include <apt-pkg/configuration.h>
+#include <apt-pkg/error.h>
#include <apt-pkg/fileutl.h>
#include <apt-private/private-utils.h>
#include <cstdlib>
+#include <sstream>
#include <unistd.h>
// DisplayFileInPager - Display File with pager /*{{{*/
@@ -74,3 +76,23 @@ bool EditFileInSensibleEditor(std::string const &filename)
return ExecWait(Process, "editor", false);
}
/*}}}*/
+time_t GetSecondsSinceEpoch() /*{{{*/
+{
+ auto const source_date_epoch = getenv("SOURCE_DATE_EPOCH");
+ if (source_date_epoch == nullptr)
+ return time(nullptr);
+
+ time_t epoch;
+ std::stringstream ss(source_date_epoch);
+ ss >> epoch;
+
+ if (ss.fail() || !ss.eof())
+ {
+ _error->Warning("Environment variable SOURCE_DATE_EPOCH was ignored as it has an invalid value: \"%s\"",
+ source_date_epoch);
+ return time(nullptr);
+ }
+
+ return epoch;
+}
+ /*}}}*/
diff --git a/apt-private/private-utils.h b/apt-private/private-utils.h
index b3b249689..4d48bd1ba 100644
--- a/apt-private/private-utils.h
+++ b/apt-private/private-utils.h
@@ -5,5 +5,6 @@
bool DisplayFileInPager(std::string const &filename);
bool EditFileInSensibleEditor(std::string const &filename);
+time_t GetSecondsSinceEpoch();
#endif