summaryrefslogtreecommitdiff
path: root/apt-pkg
diff options
context:
space:
mode:
authorJulian Andres Klode <jak@debian.org>2016-08-27 00:31:03 +0200
committerJulian Andres Klode <jak@debian.org>2016-08-27 00:31:03 +0200
commit6a68315e938eb2611806658828ecea86805822e7 (patch)
tree5ff552cf0e6bac9a35bedaf544cb19332663fa70 /apt-pkg
parent75d238ba66576c04f257e9d7c0a6995721f1441d (diff)
parent01d207a5076b6fc37a064645b13f2c6550f58b94 (diff)
Merge branch 'portability/freebsd'
Diffstat (limited to 'apt-pkg')
-rw-r--r--apt-pkg/CMakeLists.txt11
-rw-r--r--apt-pkg/acquire-item.cc9
-rw-r--r--apt-pkg/acquire-worker.cc4
-rw-r--r--apt-pkg/acquire.cc6
-rw-r--r--apt-pkg/contrib/gpgv.cc2
-rw-r--r--apt-pkg/contrib/strutl.cc5
-rw-r--r--apt-pkg/deb/debindexfile.cc1
-rw-r--r--apt-pkg/deb/debsystem.cc8
-rw-r--r--apt-pkg/deb/dpkgpm.cc2
-rw-r--r--apt-pkg/edsp/edsplistparser.cc2
-rw-r--r--apt-pkg/indexcopy.cc6
-rw-r--r--apt-pkg/init.cc12
-rw-r--r--apt-pkg/install-progress.cc4
13 files changed, 42 insertions, 30 deletions
diff --git a/apt-pkg/CMakeLists.txt b/apt-pkg/CMakeLists.txt
index a90bb1d8c..34930c8e9 100644
--- a/apt-pkg/CMakeLists.txt
+++ b/apt-pkg/CMakeLists.txt
@@ -28,14 +28,19 @@ target_include_directories(apt-pkg
PRIVATE ${ZLIB_INCLUDE_DIRS}
${BZIP2_INCLUDE_DIR}
${LZMA_INCLUDE_DIRS}
- ${LZ4_INCLUDE_DIRS})
+ ${LZ4_INCLUDE_DIRS}
+ ${ICONV_DIRECTORIES}
+)
+
target_link_libraries(apt-pkg
- PRIVATE -lutil -ldl -lresolv
+ PRIVATE -lutil ${CMAKE_DL_LIBS} ${RESOLV_LIBRARIES}
${CMAKE_THREAD_LIBS_INIT}
${ZLIB_LIBRARIES}
${BZIP2_LIBRARIES}
${LZMA_LIBRARIES}
- ${LZ4_LIBRARIES})
+ ${LZ4_LIBRARIES}
+ ${ICONV_LIBRARIES}
+)
set_target_properties(apt-pkg PROPERTIES VERSION ${MAJOR}.${MINOR})
set_target_properties(apt-pkg PROPERTIES SOVERSION ${MAJOR})
add_version_script(apt-pkg)
diff --git a/apt-pkg/acquire-item.cc b/apt-pkg/acquire-item.cc
index 7fbbf08f8..91d7a3eae 100644
--- a/apt-pkg/acquire-item.cc
+++ b/apt-pkg/acquire-item.cc
@@ -145,7 +145,7 @@ static void ReportMirrorFailureToCentral(pkgAcquire::Item const &I, std::string
<< FailCode << std::endl;
#endif
string const report = _config->Find("Methods::Mirror::ProblemReporting",
- "/usr/lib/apt/apt-report-mirror-failure");
+ LIBEXEC_DIR "/apt-report-mirror-failure");
if(!FileExists(report))
return;
@@ -2047,7 +2047,7 @@ bool pkgAcqDiffIndex::ParseDiffIndex(string const &IndexDiffFile) /*{{{*/
HashStringList ServerHashes;
unsigned long long ServerSize = 0;
- auto const &posix = std::locale("C.UTF-8");
+ auto const &posix = std::locale::classic();
for (char const * const * type = HashString::SupportedHashes(); *type != NULL; ++type)
{
std::string tagname = *type;
@@ -3439,7 +3439,7 @@ void pkgAcqChangelog::Init(std::string const &DestDir, std::string const &DestFi
TemporaryDirectory = tmpname;
ChangeOwnerAndPermissionOfFile("Item::QueueURI", TemporaryDirectory.c_str(),
- SandboxUser.c_str(), "root", 0700);
+ SandboxUser.c_str(), ROOT_GROUP, 0700);
DestFile = flCombine(TemporaryDirectory, DestFileName);
if (DestDir.empty() == false)
@@ -3487,7 +3487,8 @@ std::string pkgAcqChangelog::URI(pkgCache::VerIterator const &Ver) /*{{{*/
pkgCache::PkgIterator const Pkg = Ver.ParentPkg();
if (Pkg->CurrentVer != 0 && Pkg.CurrentVer() == Ver)
{
- std::string const basename = std::string("/usr/share/doc/") + Pkg.Name() + "/changelog";
+ std::string const root = _config->FindDir("Dir");
+ std::string const basename = root + std::string("usr/share/doc/") + Pkg.Name() + "/changelog";
std::string const debianname = basename + ".Debian";
if (FileExists(debianname))
return "copy://" + debianname;
diff --git a/apt-pkg/acquire-worker.cc b/apt-pkg/acquire-worker.cc
index 5b6634db8..7d6e6f79c 100644
--- a/apt-pkg/acquire-worker.cc
+++ b/apt-pkg/acquire-worker.cc
@@ -692,7 +692,7 @@ bool pkgAcquire::Worker::QueueItem(pkgAcquire::Queue::QItem *Item)
{
std::string const SandboxUser = _config->Find("APT::Sandbox::User");
ChangeOwnerAndPermissionOfFile("Item::QueueURI", Item->Owner->DestFile.c_str(),
- SandboxUser.c_str(), "root", 0600);
+ SandboxUser.c_str(), ROOT_GROUP, 0600);
}
if (Debug == true)
@@ -788,7 +788,7 @@ void pkgAcquire::Worker::PrepareFiles(char const * const caller, pkgAcquire::Que
{
if (RealFileExists(Itm->Owner->DestFile))
{
- ChangeOwnerAndPermissionOfFile(caller, Itm->Owner->DestFile.c_str(), "root", "root", 0644);
+ ChangeOwnerAndPermissionOfFile(caller, Itm->Owner->DestFile.c_str(), "root", ROOT_GROUP, 0644);
std::string const filename = Itm->Owner->DestFile;
for (pkgAcquire::Queue::QItem::owner_iterator O = Itm->Owners.begin(); O != Itm->Owners.end(); ++O)
{
diff --git a/apt-pkg/acquire.cc b/apt-pkg/acquire.cc
index e588b0306..b4d1b5959 100644
--- a/apt-pkg/acquire.cc
+++ b/apt-pkg/acquire.cc
@@ -80,7 +80,7 @@ void pkgAcquire::Initialize()
if (getuid() == 0 && SandboxUser.empty() == false && SandboxUser != "root") // if we aren't root, we can't chown, so don't try it
{
struct passwd const * const pw = getpwnam(SandboxUser.c_str());
- struct group const * const gr = getgrnam("root");
+ struct group const * const gr = getgrnam(ROOT_GROUP);
if (pw != NULL && gr != NULL)
{
std::string const AuthConf = _config->FindFile("Dir::Etc::netrc");
@@ -106,7 +106,7 @@ static bool SetupAPTPartialDirectory(std::string const &grand, std::string const
if (getuid() == 0 && SandboxUser.empty() == false && SandboxUser != "root") // if we aren't root, we can't chown, so don't try it
{
struct passwd const * const pw = getpwnam(SandboxUser.c_str());
- struct group const * const gr = getgrnam("root");
+ struct group const * const gr = getgrnam(ROOT_GROUP);
if (pw != NULL && gr != NULL)
{
// chown the partial dir
@@ -1312,7 +1312,7 @@ bool pkgAcquireStatus::Pulse(pkgAcquire *Owner)
// build the status str
std::ostringstream str;
- str.imbue(std::locale("C.UTF-8"));
+ str.imbue(std::locale::classic());
str.precision(4);
str << "dlstatus" << ':' << std::fixed << i << ':' << Percent << ':' << msg << '\n';
auto const dlstatus = str.str();
diff --git a/apt-pkg/contrib/gpgv.cc b/apt-pkg/contrib/gpgv.cc
index 8796195b8..941f901e8 100644
--- a/apt-pkg/contrib/gpgv.cc
+++ b/apt-pkg/contrib/gpgv.cc
@@ -48,7 +48,7 @@ void ExecGPGV(std::string const &File, std::string const &FileGPG,
int const &statusfd, int fd[2], std::string const &key)
{
#define EINTERNAL 111
- std::string const aptkey = _config->Find("Dir::Bin::apt-key", "/usr/bin/apt-key");
+ std::string const aptkey = _config->Find("Dir::Bin::apt-key", CMAKE_INSTALL_FULL_BINDIR "/apt-key");
bool const Debug = _config->FindB("Debug::Acquire::gpgv", false);
struct exiter {
diff --git a/apt-pkg/contrib/strutl.cc b/apt-pkg/contrib/strutl.cc
index 6c72859d4..66b0078dc 100644
--- a/apt-pkg/contrib/strutl.cc
+++ b/apt-pkg/contrib/strutl.cc
@@ -21,6 +21,7 @@
#include <apt-pkg/fileutl.h>
#include <apt-pkg/error.h>
+#include <array>
#include <algorithm>
#include <iomanip>
#include <locale>
@@ -758,7 +759,7 @@ string TimeRFC1123(time_t Date, bool const NumericTimezone)
if (gmtime_r(&Date, &Conv) == NULL)
return "";
- auto const posix = std::locale("C.UTF-8");
+ auto const posix = std::locale::classic();
std::ostringstream datestr;
datestr.imbue(posix);
APT::StringView const fmt("%a, %d %b %Y %H:%M:%S");
@@ -945,7 +946,7 @@ bool RFC1123StrToTime(const char* const str,time_t &time)
signed int year = 0; // yes, Y23K problem – we gonna worry then…
std::string weekday, month, datespec, timespec, zone;
std::istringstream ss(str);
- auto const &posix = std::locale("C.UTF-8");
+ auto const &posix = std::locale::classic();
ss.imbue(posix);
ss >> weekday;
// we only superficially check weekday, mostly to avoid accepting localized
diff --git a/apt-pkg/deb/debindexfile.cc b/apt-pkg/deb/debindexfile.cc
index 65bd3e6ee..c55847305 100644
--- a/apt-pkg/deb/debindexfile.cc
+++ b/apt-pkg/deb/debindexfile.cc
@@ -30,6 +30,7 @@
#include <sstream>
#include <sys/stat.h>
+#include <unistd.h>
/*}}}*/
// Sources Index /*{{{*/
diff --git a/apt-pkg/deb/debsystem.cc b/apt-pkg/deb/debsystem.cc
index f7968ec47..899f7328b 100644
--- a/apt-pkg/deb/debsystem.cc
+++ b/apt-pkg/deb/debsystem.cc
@@ -188,7 +188,7 @@ static std::string getDpkgStatusLocation(Configuration const &Cnf) {
Configuration PathCnf;
PathCnf.Set("Dir", Cnf.Find("Dir", "/"));
PathCnf.Set("Dir::State::status", "status");
- auto const cnfstatedir = Cnf.Find("Dir::State", "var/lib/apt/");
+ auto const cnfstatedir = Cnf.Find("Dir::State", STATE_DIR + 1);
// if the state dir ends in apt, replace it with dpkg -
// for the default this gives us the same as the fallback below.
// This can't be a ../dpkg as that would play bad with symlinks
@@ -211,7 +211,7 @@ bool debSystem::Initialize(Configuration &Cnf)
Cnf.CndSet("Dir::State::extended_states", "extended_states");
if (Cnf.Exists("Dir::State::status") == false)
Cnf.Set("Dir::State::status", getDpkgStatusLocation(Cnf));
- Cnf.CndSet("Dir::Bin::dpkg","/usr/bin/dpkg");
+ Cnf.CndSet("Dir::Bin::dpkg",BIN_DIR"/dpkg");
if (d->StatusFile) {
delete d->StatusFile;
@@ -239,9 +239,9 @@ APT_PURE bool debSystem::ArchiveSupported(const char *Type)
signed debSystem::Score(Configuration const &Cnf)
{
signed Score = 0;
- if (FileExists(Cnf.FindFile("Dir::State::status","/var/lib/dpkg/status")) == true)
+ if (FileExists(Cnf.FindFile("Dir::State::status",getDpkgStatusLocation(Cnf).c_str())) == true)
Score += 10;
- if (FileExists(Cnf.Find("Dir::Bin::dpkg","/usr/bin/dpkg")) == true)
+ if (FileExists(Cnf.Find("Dir::Bin::dpkg",BIN_DIR"/dpkg")) == true)
Score += 10;
if (FileExists("/etc/debian_version") == true)
Score += 10;
diff --git a/apt-pkg/deb/dpkgpm.cc b/apt-pkg/deb/dpkgpm.cc
index 9c871d477..9d1739d68 100644
--- a/apt-pkg/deb/dpkgpm.cc
+++ b/apt-pkg/deb/dpkgpm.cc
@@ -61,6 +61,8 @@
#include <apti18n.h>
/*}}}*/
+extern char **environ;
+
using namespace std;
APT_PURE static string AptHistoryRequestingUser() /*{{{*/
diff --git a/apt-pkg/edsp/edsplistparser.cc b/apt-pkg/edsp/edsplistparser.cc
index dd8890f0e..c6fd528da 100644
--- a/apt-pkg/edsp/edsplistparser.cc
+++ b/apt-pkg/edsp/edsplistparser.cc
@@ -21,6 +21,8 @@
#include <apt-pkg/fileutl.h>
#include <apt-pkg/pkgsystem.h>
+#include <array>
+
/*}}}*/
// ListParser::edspListParser - Constructor /*{{{*/
diff --git a/apt-pkg/indexcopy.cc b/apt-pkg/indexcopy.cc
index 4a35e3847..ca5c42cb7 100644
--- a/apt-pkg/indexcopy.cc
+++ b/apt-pkg/indexcopy.cc
@@ -207,7 +207,7 @@ bool IndexCopy::CopyPackages(string CDROM,string Name,vector<string> &List,
FinalF += URItoFileName(S);
if (rename(TargetF.c_str(),FinalF.c_str()) != 0)
return _error->Errno("rename","Failed to rename");
- ChangeOwnerAndPermissionOfFile("CopyPackages", FinalF.c_str(), "root", "root", 0644);
+ ChangeOwnerAndPermissionOfFile("CopyPackages", FinalF.c_str(), "root", ROOT_GROUP, 0644);
}
/* Mangle the source to be in the proper notation with
@@ -531,7 +531,7 @@ bool SigVerify::CopyMetaIndex(string CDROM, string CDName, /*{{{*/
Rel.Open(prefix + file,FileFd::ReadOnly);
if (CopyFile(Rel,Target) == false || Target.Close() == false)
return _error->Error("Copying of '%s' for '%s' from '%s' failed", file.c_str(), CDName.c_str(), prefix.c_str());
- ChangeOwnerAndPermissionOfFile("CopyPackages", TargetF.c_str(), "root", "root", 0644);
+ ChangeOwnerAndPermissionOfFile("CopyPackages", TargetF.c_str(), "root", ROOT_GROUP, 0644);
return true;
}
@@ -738,7 +738,7 @@ bool TranslationsCopy::CopyTranslations(string CDROM,string Name, /*{{{*/
FinalF += URItoFileName(S);
if (rename(TargetF.c_str(),FinalF.c_str()) != 0)
return _error->Errno("rename","Failed to rename");
- ChangeOwnerAndPermissionOfFile("CopyTranslations", FinalF.c_str(), "root", "root", 0644);
+ ChangeOwnerAndPermissionOfFile("CopyTranslations", FinalF.c_str(), "root", ROOT_GROUP, 0644);
}
CurrentSize += FileSize;
diff --git a/apt-pkg/init.cc b/apt-pkg/init.cc
index fa679e6c6..282c0daf0 100644
--- a/apt-pkg/init.cc
+++ b/apt-pkg/init.cc
@@ -47,19 +47,19 @@ bool pkgInitConfig(Configuration &Cnf)
Cnf.CndSet("Dir","/");
// State
- Cnf.CndSet("Dir::State","var/lib/apt/");
+ Cnf.CndSet("Dir::State", STATE_DIR + 1);
Cnf.CndSet("Dir::State::lists","lists/");
Cnf.CndSet("Dir::State::cdroms","cdroms.list");
Cnf.CndSet("Dir::State::mirrors","mirrors/");
// Cache
- Cnf.CndSet("Dir::Cache","var/cache/apt/");
+ Cnf.CndSet("Dir::Cache", CACHE_DIR + 1);
Cnf.CndSet("Dir::Cache::archives","archives/");
Cnf.CndSet("Dir::Cache::srcpkgcache","srcpkgcache.bin");
Cnf.CndSet("Dir::Cache::pkgcache","pkgcache.bin");
// Configuration
- Cnf.CndSet("Dir::Etc","etc/apt/");
+ Cnf.CndSet("Dir::Etc", CONF_DIR + 1);
Cnf.CndSet("Dir::Etc::sourcelist","sources.list");
Cnf.CndSet("Dir::Etc::sourceparts","sources.list.d");
Cnf.CndSet("Dir::Etc::main","apt.conf");
@@ -69,12 +69,12 @@ bool pkgInitConfig(Configuration &Cnf)
Cnf.CndSet("Dir::Etc::preferencesparts","preferences.d");
Cnf.CndSet("Dir::Etc::trusted", "trusted.gpg");
Cnf.CndSet("Dir::Etc::trustedparts","trusted.gpg.d");
- Cnf.CndSet("Dir::Bin::methods","/usr/lib/apt/methods");
- Cnf.CndSet("Dir::Bin::solvers::","/usr/lib/apt/solvers");
+ Cnf.CndSet("Dir::Bin::methods", LIBEXEC_DIR "/methods");
+ Cnf.CndSet("Dir::Bin::solvers::",LIBEXEC_DIR "/apt/solvers");
Cnf.CndSet("Dir::Media::MountPath","/media/apt");
// State
- Cnf.CndSet("Dir::Log","var/log/apt");
+ Cnf.CndSet("Dir::Log", LOG_DIR + 1);
Cnf.CndSet("Dir::Log::Terminal","term.log");
Cnf.CndSet("Dir::Log::History","history.log");
Cnf.CndSet("Dir::Log::Planner","eipp.log.xz");
diff --git a/apt-pkg/install-progress.cc b/apt-pkg/install-progress.cc
index 256495420..6c3e51b2c 100644
--- a/apt-pkg/install-progress.cc
+++ b/apt-pkg/install-progress.cc
@@ -84,7 +84,7 @@ static std::string GetProgressFdString(char const * const status,
{
float const progress{Done / static_cast<float>(Total) * 100};
std::ostringstream str;
- str.imbue(std::locale("C.UTF-8"));
+ str.imbue(std::locale::classic());
str.precision(4);
str << status << ':' << pkg << ':' << std::fixed << progress << ':' << msg << '\n';
return str.str();
@@ -165,7 +165,7 @@ static std::string GetProgressDeb822String(char const * const status,
{
float const progress{Done / static_cast<float>(Total) * 100};
std::ostringstream str;
- str.imbue(std::locale("C.UTF-8"));
+ str.imbue(std::locale::classic());
str.precision(4);
str << "Status: " << status << '\n';
if (pkg != nullptr)