summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJulian Andres Klode <jak@debian.org>2016-08-23 19:41:58 +0200
committerJulian Andres Klode <jak@debian.org>2016-08-26 22:17:54 +0200
commit8757a0fdeee00ea6a7cc717188a0e129ad8a553c (patch)
treecd13473faa06c189bfd915b835af065e6a2abf11
parentdd7758b9245275a31fde70218db9a531c5859c26 (diff)
Make directory paths configurable
This allows other vendors to use different paths, or to build your own APT in /opt for testing. Note that this uses + 1 in some places, as the paths we receive are absolute, but we need to strip of the initial /.
-rw-r--r--CMake/config.h.in9
-rw-r--r--CMakeLists.txt27
-rw-r--r--apt-pkg/acquire-item.cc2
-rw-r--r--apt-pkg/contrib/gpgv.cc2
-rw-r--r--apt-pkg/deb/debsystem.cc8
-rw-r--r--apt-pkg/init.cc12
-rw-r--r--test/integration/framework5
-rwxr-xr-xtest/integration/test-apt-config2
8 files changed, 45 insertions, 22 deletions
diff --git a/CMake/config.h.in b/CMake/config.h.in
index f32f15b8a..c23254929 100644
--- a/CMake/config.h.in
+++ b/CMake/config.h.in
@@ -55,6 +55,15 @@
/* The mail address to reach upstream */
#define PACKAGE_MAIL "${PACKAGE_MAIL}"
+/* Various directories */
+#cmakedefine CMAKE_INSTALL_FULL_BINDIR "${CMAKE_INSTALL_FULL_BINDIR}"
+#cmakedefine STATE_DIR "${STATE_DIR}"
+#cmakedefine CACHE_DIR "${CACHE_DIR}"
+#cmakedefine LOG_DIR "${LOG_DIR}"
+#cmakedefine CONF_DIR "${CONF_DIR}"
+#cmakedefine LIBEXEC_DIR "${LIBEXEC_DIR}"
+#cmakedefine BIN_DIR "${BIN_DIR}"
+
#define APT_8_CLEANER_HEADERS
#define APT_9_CLEANER_HEADERS
#define APT_10_CLEANER_HEADERS
diff --git a/CMakeLists.txt b/CMakeLists.txt
index 189a8d570..916090866 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -171,6 +171,15 @@ if (NOT DEFINED COMMON_ARCH)
OUTPUT_VARIABLE COMMON_ARCH OUTPUT_STRIP_TRAILING_WHITESPACE)
endif()
+# Set various directories
+set(STATE_DIR "${CMAKE_INSTALL_FULL_LOCALSTATEDIR}/lib/apt" CACHE PATH "Your /var/lib/apt")
+set(CACHE_DIR "${CMAKE_INSTALL_FULL_LOCALSTATEDIR}/cache/apt" CACHE PATH "Your /var/cache/apt")
+set(LOG_DIR "${CMAKE_INSTALL_FULL_LOCALSTATEDIR}/log/apt" CACHE PATH "Your /var/log/apt")
+set(CONF_DIR "${CMAKE_INSTALL_FULL_SYSCONFDIR}/apt" CACHE PATH "Your /etc/apt")
+set(LIBEXEC_DIR "${CMAKE_INSTALL_FULL_LIBEXECDIR}/apt" CACHE PATH "Your /usr/libexec/apt")
+set(BIN_DIR "${CMAKE_INSTALL_FULL_BINDIR}")
+
+
# Configure our configuration headers (config.h and apti18n.h)
configure_file(CMake/config.h.in ${PROJECT_BINARY_DIR}/include/config.h)
configure_file(CMake/apti18n.h.in ${PROJECT_BINARY_DIR}/include/apti18n.h)
@@ -197,13 +206,13 @@ endif()
# Create our directories.
install_empty_directories(
- ${CMAKE_INSTALL_FULL_SYSCONFDIR}/apt/apt.conf.d
- ${CMAKE_INSTALL_FULL_SYSCONFDIR}/apt/preferences.d
- ${CMAKE_INSTALL_FULL_SYSCONFDIR}/apt/sources.list.d
- ${CMAKE_INSTALL_FULL_SYSCONFDIR}/apt/trusted.gpg.d
- ${CMAKE_INSTALL_FULL_LOCALSTATEDIR}/cache/apt/archives/partial
- ${CMAKE_INSTALL_FULL_LOCALSTATEDIR}/lib/apt/lists/partial
- ${CMAKE_INSTALL_FULL_LOCALSTATEDIR}/lib/apt/mirrors/partial
- ${CMAKE_INSTALL_FULL_LOCALSTATEDIR}/lib/apt/periodic
- ${CMAKE_INSTALL_FULL_LOCALSTATEDIR}/log/apt
+ ${CONF_DIR}/apt.conf.d
+ ${CONF_DIR}/preferences.d
+ ${CONF_DIR}/sources.list.d
+ ${CONF_DIR}/trusted.gpg.d
+ ${CACHE_DIR}/archives/partial
+ ${STATE_DIR}/lists/partial
+ ${STATE_DIR}/mirrors/partial
+ ${STATE_DIR}/periodic
+ ${LOG_DIR}
)
diff --git a/apt-pkg/acquire-item.cc b/apt-pkg/acquire-item.cc
index d72e62725..7238d692e 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;
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/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/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/test/integration/framework b/test/integration/framework
index 1e356ffaf..9589ca84c 100644
--- a/test/integration/framework
+++ b/test/integration/framework
@@ -352,6 +352,11 @@ setupenvironment() {
ln -s "${TMPWORKINGDIRECTORY}/keys/joesixpack.pub" rootdir/etc/apt/trusted.gpg.d/joesixpack.gpg
echo "Dir \"${TMPWORKINGDIRECTORY}/rootdir\";" >> aptconfig.conf
+ echo "Dir::Etc \"etc\";" >> aptconfig.conf
+ echo "Dir::State \"var/lib/apt\";" >> aptconfig.conf
+ echo "Dir::Cache \"var/cache/apt\";" >> aptconfig.conf
+ echo "Dir::Etc \"etc/apt\";" >> aptconfig.conf
+ echo "Dir::Log \"var/log/apt\";" >> aptconfig.conf
echo "APT::Get::Show-User-Simulation-Note \"false\";" >> aptconfig.conf
echo "Dir::Bin::Methods \"${TMPWORKINGDIRECTORY}/rootdir/usr/lib/apt/methods\";" >> aptconfig.conf
# either store apt-key were we can access it, even if we run it as a different user
diff --git a/test/integration/test-apt-config b/test/integration/test-apt-config
index abae83ee6..f2068b789 100755
--- a/test/integration/test-apt-config
+++ b/test/integration/test-apt-config
@@ -24,7 +24,7 @@ testsuccessequal "ARCH='amd64'" aptconfig shell ARCH APT::Architecture
ROOTDIR="$(readlink -f rootdir)"
testsuccessequal "CONFIG='apt.conf'" aptconfig shell CONFIG Dir::Etc::main
testsuccessequal "CONFIG='${ROOTDIR}/etc/apt/apt.conf'" aptconfig shell CONFIG Dir::Etc::main/f
-testsuccessequal "CONFIG='etc/apt/'" aptconfig shell CONFIG Dir::Etc
+testsuccessequal "CONFIG='etc/apt'" aptconfig shell CONFIG Dir::Etc
testsuccessequal "CONFIG='${ROOTDIR}/etc/apt/'" aptconfig shell CONFIG Dir::Etc/ # old style
testsuccessequal "CONFIG='${ROOTDIR}/etc/apt/'" aptconfig shell CONFIG Dir::Etc/d