summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--CMake/FindBerkeleyDB.cmake48
-rw-r--r--CMake/Misc.cmake65
-rw-r--r--CMake/apti18n.h.in30
-rw-r--r--CMake/config.h.in54
-rw-r--r--CMakeLists.txt132
-rw-r--r--README.cmake36
-rw-r--r--apt-inst/CMakeLists.txt26
-rw-r--r--apt-pkg/CMakeLists.txt46
-rw-r--r--apt-private/CMakeLists.txt23
-rw-r--r--cmdline/CMakeLists.txt59
-rw-r--r--dselect/CMakeLists.txt4
-rw-r--r--ftparchive/CMakeLists.txt10
-rw-r--r--methods/CMakeLists.txt35
-rw-r--r--vendor/CMakeLists.txt33
14 files changed, 601 insertions, 0 deletions
diff --git a/CMake/FindBerkeleyDB.cmake b/CMake/FindBerkeleyDB.cmake
new file mode 100644
index 000000000..44cfd3ddb
--- /dev/null
+++ b/CMake/FindBerkeleyDB.cmake
@@ -0,0 +1,48 @@
+# - Try to find Berkeley DB
+# Once done this will define
+#
+# BERKELEY_DB_FOUND - system has Berkeley DB
+# BERKELEY_DB_INCLUDE_DIRS - the Berkeley DB include directory
+# BERKELEY_DB_LIBRARIES - Link these to use Berkeley DB
+# BERKELEY_DB_DEFINITIONS - Compiler switches required for using Berkeley DB
+
+# Copyright (c) 2006, Alexander Dymo, <adymo@kdevelop.org>
+# Copyright (c) 2016, Julian Andres Klode <jak@debian.org>
+#
+# Redistribution and use in source and binary forms, with or without
+# modification, are permitted provided that the following conditions
+# are met:
+#
+# 1. Redistributions of source code must retain the copyright
+# notice, this list of conditions and the following disclaimer.
+# 2. Redistributions in binary form must reproduce the copyright
+# notice, this list of conditions and the following disclaimer in the
+# documentation and/or other materials provided with the distribution.
+# 3. The name of the author may not be used to endorse or promote products
+# derived from this software without specific prior written permission.
+#
+# THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
+# IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
+# OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
+# IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
+# INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
+# NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+# THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
+# THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+
+
+find_path(BERKELEY_DB_INCLUDE_DIRS db.h
+ /usr/include/db5
+ /usr/local/include/db5
+ /usr/include/db4
+ /usr/local/include/db4
+)
+
+find_library(BERKELEY_DB_LIBRARIES NAMES db )
+
+include(FindPackageHandleStandardArgs)
+find_package_handle_standard_args(Berkeley "Could not find Berkeley DB >= 4.1" BERKELEY_DB_INCLUDE_DIRS BERKELEY_DB_LIBRARIES)
+# show the BERKELEY_DB_INCLUDE_DIRS and BERKELEY_DB_LIBRARIES variables only in the advanced view
+mark_as_advanced(BERKELEY_DB_INCLUDE_DIRS BERKELEY_DB_LIBRARIES)
diff --git a/CMake/Misc.cmake b/CMake/Misc.cmake
new file mode 100644
index 000000000..584a4da2a
--- /dev/null
+++ b/CMake/Misc.cmake
@@ -0,0 +1,65 @@
+include(CheckCXXCompilerFlag)
+
+# Flatten our header structure
+function(flatify target headers)
+ foreach(header ${headers})
+ get_filename_component(tgt ${header} NAME)
+ configure_file(${header} ${target}/${tgt} @ONLY)
+ endforeach(header ${headers})
+endfunction()
+
+
+function(add_optional_compile_options flags)
+ foreach(flag ${flags})
+ check_cxx_compiler_flag(-${flag} have-compiler-flag:-${flag})
+ if (have-compiler-flag:-${flag})
+ add_compile_options("-${flag}")
+ endif()
+ endforeach()
+endfunction()
+
+# Substitute vendor references in a file
+function(add_vendor_file)
+ set(options)
+ set(oneValueArgs OUTPUT INPUT MODE)
+ set(multiValueArgs VARIABLES)
+ cmake_parse_arguments(AVF "${options}" "${oneValueArgs}" "${multiValueArgs}" ${ARGN})
+ message(STATUS "Configuring vendor file ${AVF_OUTPUT}")
+
+ FILE(READ ${CMAKE_CURRENT_SOURCE_DIR}/${AVF_INPUT} input)
+ foreach(variable ${AVF_VARIABLES})
+ execute_process(COMMAND ../vendor/getinfo ${variable} OUTPUT_VARIABLE value OUTPUT_STRIP_TRAILING_WHITESPACE)
+ string(REPLACE "&${variable};" "${value}" input "${input}")
+ endforeach()
+ file(WRITE ${CMAKE_CURRENT_BINARY_DIR}/${AVF_OUTPUT} "${input}")
+
+ execute_process(COMMAND chmod ${AVF_MODE} ${CMAKE_CURRENT_BINARY_DIR}/${AVF_OUTPUT})
+endfunction()
+
+# Add symbolic links to a file
+function(add_slaves destination master)
+ set(slaves "")
+ foreach(slave ${ARGN})
+ add_custom_command(OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/${slave}
+ COMMAND ${CMAKE_COMMAND} -E create_symlink ${master} ${CMAKE_CURRENT_BINARY_DIR}/${slave})
+ list(APPEND slaves ${CMAKE_CURRENT_BINARY_DIR}/${slave})
+ endforeach()
+
+ STRING(REPLACE "/" "-" master "${master}")
+ add_custom_target(${master}-slaves ALL DEPENDS ${slaves})
+ install(FILES ${slaves} DESTINATION ${destination})
+endfunction()
+
+# Generates a simple version script versioning everything with current SOVERSION
+function(add_version_script target)
+ get_target_property(soversion ${target} SOVERSION)
+ set(script "${CMAKE_CURRENT_BINARY_DIR}/${target}.versionscript")
+ string(REPLACE "-" "" name "${target}_${soversion}")
+ string(TOUPPER "${name}" name)
+ add_custom_command(OUTPUT "${script}"
+ COMMAND echo "${name} {global: *; };" > "${script}"
+ VERBATIM )
+ add_custom_target(${target}-versionscript DEPENDS "${script}")
+ target_link_libraries(${target} PRIVATE -Wl,-version-script="${script}")
+ add_dependencies(${target} ${target}-versionscript)
+endfunction()
diff --git a/CMake/apti18n.h.in b/CMake/apti18n.h.in
new file mode 100644
index 000000000..9c843b037
--- /dev/null
+++ b/CMake/apti18n.h.in
@@ -0,0 +1,30 @@
+// -*- mode: cpp; mode: fold -*-
+// $Id: apti18n.h.in,v 1.6 2003/01/11 07:18:18 jgg Exp $
+/* Internationalization macros for apt. This header should be included last
+ in each C file. */
+
+// Set by autoconf
+#cmakedefine USE_NLS
+
+#ifdef USE_NLS
+// apt will use the gettext implementation of the C library
+#include <libintl.h>
+#include <locale.h>
+# ifdef APT_DOMAIN
+# define _(x) dgettext(APT_DOMAIN,x)
+# define P_(msg,plural,n) dngettext(APT_DOMAIN,msg,plural,n)
+# else
+# define _(x) gettext(x)
+# define P_(msg,plural,n) ngettext(msg,plural,n)
+# endif
+# define N_(x) x
+#else
+// apt will not use any gettext
+# define setlocale(a, b)
+# define textdomain(a)
+# define bindtextdomain(a, b)
+# define _(x) x
+# define P_(msg,plural,n) (n == 1 ? msg : plural)
+# define N_(x) x
+# define dgettext(d, m) m
+#endif
diff --git a/CMake/config.h.in b/CMake/config.h.in
new file mode 100644
index 000000000..7515fc9a6
--- /dev/null
+++ b/CMake/config.h.in
@@ -0,0 +1,54 @@
+/* Define if your processor stores words with the most significant
+ byte first (like Motorola and SPARC, unlike Intel and VAX). */
+#cmakedefine WORDS_BIGENDIAN
+
+/* Define if we have the timegm() function */
+#cmakedefine HAVE_TIMEGM
+
+/* Define if we have the zlib library for gzip */
+#cmakedefine HAVE_ZLIB
+
+/* Define if we have the bz2 library for bzip2 */
+#cmakedefine HAVE_BZ2
+
+/* Define if we have the lzma library for lzma/xz */
+#cmakedefine HAVE_LZMA
+
+/* Define if we have the lz4 library for lz4 */
+#cmakedefine HAVE_LZ4
+
+/* These two are used by the statvfs shim for glibc2.0 and bsd */
+/* Define if we have sys/vfs.h */
+#cmakedefine HAVE_VFS_H
+#cmakedefine HAVE_STRUCT_STATFS_F_TYPE
+
+/* Define if we have sys/mount.h */
+#cmakedefine HAVE_MOUNT_H
+
+/* Define if we have enabled pthread support */
+#cmakedefine HAVE_PTHREAD
+
+/* Check for getresuid() function and similar ones */
+#cmakedefine HAVE_GETRESUID
+#cmakedefine HAVE_GETRESGID
+#cmakedefine HAVE_SETRESUID
+#cmakedefine HAVE_SETRESGID
+
+/* Define the arch name string */
+#define COMMON_ARCH "${COMMON_ARCH}"
+
+/* The package name string */
+#define PACKAGE "${PACKAGE}"
+
+/* The version number string */
+#define PACKAGE_VERSION "${PACKAGE_VERSION}"
+
+/* The mail address to reach upstream */
+#define PACKAGE_MAIL "deity@lists.debian.org"
+
+#define APT_8_CLEANER_HEADERS
+#define APT_9_CLEANER_HEADERS
+#define APT_10_CLEANER_HEADERS
+
+/* unrolling is faster combined with an optimizing compiler */
+#define SHA2_UNROLL_TRANSFORM
diff --git a/CMakeLists.txt b/CMakeLists.txt
new file mode 100644
index 000000000..90e5272c9
--- /dev/null
+++ b/CMakeLists.txt
@@ -0,0 +1,132 @@
+# Copyright (C) 2009, 2016 Julian Andres Klode <jak@debian.org>.
+# Licensed under the same terms as APT; i.e. GPL 2 or later.
+
+# set minimum version
+project(apt)
+cmake_minimum_required(VERSION 3.3.0)
+
+option(WITH_DOC "Build documentation." OFF)
+option(USE_NLS "Localisation support." ON)
+
+set(CMAKE_MODULE_PATH "${PROJECT_SOURCE_DIR}/CMake")
+
+# Work around bug in GNUInstallDirs
+if (EXISTS "/etc/debian_version")
+ set(CMAKE_INSTALL_LIBEXECDIR "lib")
+endif()
+
+# Include stuff
+include(Misc)
+include(CheckIncludeFiles)
+include(CheckFunctionExists)
+include(CheckStructHasMember)
+include(GNUInstallDirs)
+include(TestBigEndian)
+find_package(Threads)
+find_package(PkgConfig)
+
+# Set compiler flags
+set(CMAKE_CXX_STANDARD 11)
+set(CMAKE_CXX_STANDARD_REQUIRED ON)
+set(CMAKE_VISIBILITY_INLINES_HIDDEN 1)
+
+add_optional_compile_options(Wall)
+add_optional_compile_options(Wextra)
+add_optional_compile_options(Wcast-align)
+add_optional_compile_options(Wlogical-op)
+add_optional_compile_options(Wredundant-decls)
+add_optional_compile_options(Wmissing-declarations)
+add_optional_compile_options(Wunsafe-loop-optimizations)
+add_optional_compile_options(Wctor-dtor-privacy)
+add_optional_compile_options(Wdisabled-optimization)
+add_optional_compile_options(Winit-self)
+add_optional_compile_options(Wmissing-include-dirs)
+add_optional_compile_options(Wnoexcept)
+add_optional_compile_options(Wsign-promo)
+add_optional_compile_options(Wundef)
+
+# apt-ftparchive dependencies
+find_package(BerkeleyDB REQUIRED)
+if (BERKELEY_DB_FOUND)
+ set(HAVE_BDB 1)
+endif()
+
+
+# apt-transport-https dependencies
+pkg_check_modules(CURL libcurl REQUIRED)
+if (CURL_FOUND)
+ set(HAVE_CURL 1)
+endif()
+
+# (De)Compressor libraries
+find_package(ZLIB REQUIRED)
+if (ZLIB_FOUND)
+ set(HAVE_ZLIB 1)
+endif()
+
+
+find_package(BZip2)
+if (BZIP2_FOUND)
+ set(HAVE_BZ2 1)
+endif()
+
+pkg_check_modules(LZMA liblzma)
+if (LZMA_FOUND)
+ set(HAVE_LZMA 1)
+endif()
+
+pkg_check_modules(LZ4 liblz4)
+if (LZ4_FOUND)
+ set(HAVE_LZ4 1)
+endif()
+
+# Mount()ing and stat()ing and friends
+
+check_function_exists(statvfs HAVE_STATVFS)
+if (NOT HAVE_STATVFS)
+ check_symbol_exists(statfs sys/vfs.h HAVE_VFS_H)
+ check_symbol_exists(statfs sys/mount.h HAVE_MOUNT_H)
+ if (NOT HAVE_VFS_H AND NOT HAVE_MOUNT_H)
+ message(FATAL_ERROR "Can find neither statvfs() nor statfs()")
+ endif()
+ configure_file(buildlib/statvfs.h.in ${PROJECT_BINARY_DIR}/include/statvfs.h @ONLY)
+endif()
+
+CHECK_STRUCT_HAS_MEMBER("struct statfs" f_type sys/vfs.h HAVE_STRUCT_STATFS_F_TYPE)
+
+# Other checks
+check_function_exists(getresuid HAVE_GETRESUID)
+check_function_exists(getresgid HAVE_GETRESGID)
+check_function_exists(setresuid HAVE_SETRESUID)
+check_function_exists(setresgid HAVE_SETRESGID)
+check_function_exists(timegm HAVE_TIMEGM)
+test_big_endian(WORDS_BIGENDIAN)
+
+if (CMAKE_USE_PTHREADS_INIT)
+ set(HAVE_PTHREAD 1)
+endif()
+
+# Configure some variables like package, version and architecture.
+set(PACKAGE "apt")
+
+execute_process(COMMAND dpkg-parsechangelog -SVersion -l${PROJECT_SOURCE_DIR}/debian/changelog
+ OUTPUT_VARIABLE PACKAGE_VERSION OUTPUT_STRIP_TRAILING_WHITESPACE)
+execute_process(COMMAND dpkg-architecture -qDEB_HOST_ARCH
+ OUTPUT_VARIABLE COMMON_ARCH OUTPUT_STRIP_TRAILING_WHITESPACE)
+
+# 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)
+
+# Generic header locations
+include_directories(${PROJECT_BINARY_DIR}/include)
+
+# Add our subdirectories
+add_subdirectory(vendor)
+add_subdirectory(apt-pkg)
+add_subdirectory(apt-private)
+add_subdirectory(apt-inst)
+add_subdirectory(cmdline)
+add_subdirectory(dselect)
+add_subdirectory(ftparchive)
+add_subdirectory(methods)
diff --git a/README.cmake b/README.cmake
new file mode 100644
index 000000000..c9347a057
--- /dev/null
+++ b/README.cmake
@@ -0,0 +1,36 @@
+The Make System
+================
+
+To compile this program using cmake you require cmake 3.3 or newer.
+
+Building
+--------
+The recommended way is to generate a build directory and build in it, e.g.
+
+ mkdir build
+ cd build
+ cmake .. OR cmake -G Ninja ..
+ make -j4 OR ninja
+
+You can use either the make or the ninja generator; the ninja stuff is faster,
+though. You can also build in-tree:
+
+ cmake -G Ninja
+ ninja
+
+To build a subdirectory; for example, apt-pkg, use one of:
+
+ ninja apt-pkg/all
+ make -C apt-pkg -j4 (or cd apt-pkg && make -j4)
+
+Ninja automatically parallelizes, make needs an explicit -j switch. The travis
+system uses the make generator, the packaging as well.
+
+TODO
+----
+
+The following features have not been implemented yet:
+
+ - documentation
+ - translation
+ - unit tests
diff --git a/apt-inst/CMakeLists.txt b/apt-inst/CMakeLists.txt
new file mode 100644
index 000000000..f7578231a
--- /dev/null
+++ b/apt-inst/CMakeLists.txt
@@ -0,0 +1,26 @@
+# Include apt-pkg directly, as some files have #include <system.h>
+include_directories(${PROJECT_BINARY_DIR}/include/apt-pkg)
+
+# Set the version of the library
+set(MAJOR 2.0)
+set(MINOR 0)
+set(APT_INST_MAJOR ${MAJOR} PARENT_SCOPE)
+
+# Definition of the C++ files used to build the library
+file(GLOB_RECURSE library "*.cc")
+file(GLOB_RECURSE headers "*.h")
+
+# Create a library using the C++ files
+add_library(apt-inst SHARED ${library})
+
+# Link the library and set the SONAME
+target_link_libraries(apt-inst PUBLIC apt-pkg ${CMAKE_THREAD_LIBS_INIT})
+target_link_libraries(apt-inst PRIVATE ${CMAKE_THREAD_LIBS_INIT})
+set_target_properties(apt-inst PROPERTIES VERSION ${MAJOR}.${MINOR})
+set_target_properties(apt-inst PROPERTIES SOVERSION ${MAJOR})
+add_version_script(apt-inst)
+
+# Install the library and the headers
+install(TARGETS apt-inst LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR})
+install(FILES ${headers} DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/apt-pkg)
+flatify(${PROJECT_BINARY_DIR}/include/apt-pkg/ "${headers}")
diff --git a/apt-pkg/CMakeLists.txt b/apt-pkg/CMakeLists.txt
new file mode 100644
index 000000000..ec78f49c4
--- /dev/null
+++ b/apt-pkg/CMakeLists.txt
@@ -0,0 +1,46 @@
+# Include apt-pkg directly, as some files have #include <system.h>
+include_directories(${PROJECT_BINARY_DIR}/include/apt-pkg)
+
+add_definitions("-DAPT_PKG_EXPOSE_STRING_VIEW")
+
+# Set the version of the library
+execute_process(COMMAND awk -v ORS=. "/^\#define APT_PKG_M/ {print \$3}"
+ COMMAND sed "s/\\.\$//"
+ INPUT_FILE ${CMAKE_CURRENT_SOURCE_DIR}/contrib/macros.h
+ OUTPUT_VARIABLE MAJOR OUTPUT_STRIP_TRAILING_WHITESPACE)
+execute_process(COMMAND grep "^#define APT_PKG_RELEASE"
+ COMMAND cut -d " " -f 3
+ INPUT_FILE ${CMAKE_CURRENT_SOURCE_DIR}/contrib/macros.h
+ OUTPUT_VARIABLE MINOR OUTPUT_STRIP_TRAILING_WHITESPACE)
+
+message(STATUS "Building libapt-pkg ${MAJOR} (release ${MINOR})")
+set(APT_PKG_MAJOR ${MAJOR} PARENT_SCOPE) # exporting for methods/CMakeLists.txt
+
+# Definition of the C++ files used to build the library
+file(GLOB_RECURSE library "*.cc")
+file(GLOB_RECURSE headers "*.h")
+
+# Create a library using the C++ files
+add_library(apt-pkg SHARED ${library})
+add_dependencies(apt-pkg apt-pkg-versionscript)
+# Link the library and set the SONAME
+target_include_directories(apt-pkg
+ PRIVATE ${ZLIB_INCLUDE_DIRS}
+ ${BZIP2_INCLUDE_DIRS}
+ ${LZMA_INCLUDE_DIRS}
+ ${LZ4_INCLUDE_DIRS})
+target_link_libraries(apt-pkg
+ PRIVATE -lutil -ldl -lresolv
+ ${CMAKE_THREAD_LIBS_INIT}
+ ${ZLIB_LIBRARIES}
+ ${BZIP2_LIBRARIES}
+ ${LZMA_LIBRARIES}
+ ${LZ4_LIBRARIES})
+set_target_properties(apt-pkg PROPERTIES VERSION ${MAJOR}.${MINOR})
+set_target_properties(apt-pkg PROPERTIES SOVERSION ${MAJOR})
+add_version_script(apt-pkg)
+
+# Install the library and the header files
+install(TARGETS apt-pkg LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR})
+install(FILES ${headers} DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/apt-pkg)
+flatify(${PROJECT_BINARY_DIR}/include/apt-pkg/ "${headers}")
diff --git a/apt-private/CMakeLists.txt b/apt-private/CMakeLists.txt
new file mode 100644
index 000000000..6de9e0281
--- /dev/null
+++ b/apt-private/CMakeLists.txt
@@ -0,0 +1,23 @@
+# Set the version of the library
+set(MAJOR 0.0)
+set(MINOR 0)
+
+# Definition of the C++ files used to build the library
+file(GLOB_RECURSE library "*.cc")
+file(GLOB_RECURSE headers "*.h")
+
+# Create a library using the C++ files
+add_library(apt-private SHARED ${library})
+
+# Link the library and set the SONAME
+target_link_libraries(apt-private PUBLIC apt-pkg)
+set_target_properties(apt-private PROPERTIES VERSION ${MAJOR}.${MINOR})
+set_target_properties(apt-private PROPERTIES SOVERSION ${MAJOR})
+add_version_script(apt-private)
+
+# Install the library and the headers
+install(TARGETS apt-private
+ LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR}
+ NAMELINK_SKIP)
+
+flatify(${PROJECT_BINARY_DIR}/include/apt-private/ "${headers}")
diff --git a/cmdline/CMakeLists.txt b/cmdline/CMakeLists.txt
new file mode 100644
index 000000000..8977b45d1
--- /dev/null
+++ b/cmdline/CMakeLists.txt
@@ -0,0 +1,59 @@
+# Create the executable tasks
+add_executable(apt apt.cc)
+add_executable(apt-cache apt-cache.cc)
+add_executable(apt-get apt-get.cc)
+add_executable(apt-mark apt-mark.cc)
+add_executable(apt-config apt-config.cc)
+add_executable(apt-cdrom apt-cdrom.cc)
+add_executable(apt-helper apt-helper.cc)
+add_executable(apt-sortpkgs apt-sortpkgs.cc)
+add_executable(apt-extracttemplates apt-extracttemplates.cc)
+add_executable(apt-internal-solver apt-internal-solver.cc)
+add_executable(apt-dump-solver apt-dump-solver.cc)
+add_executable(apt-internal-planner apt-internal-planner.cc)
+add_vendor_file(OUTPUT apt-key
+ INPUT apt-key.in
+ MODE 755
+ VARIABLES keyring-filename
+ keyring-removed-filename
+ keyring-master-filename
+ keyring-uri keyring-package)
+
+
+# Link the executables against the libraries
+target_link_libraries(apt apt-pkg apt-private)
+target_link_libraries(apt-cache apt-pkg apt-private)
+target_link_libraries(apt-get apt-pkg apt-private)
+target_link_libraries(apt-config apt-pkg apt-private)
+target_link_libraries(apt-cdrom apt-pkg apt-private)
+target_link_libraries(apt-helper apt-pkg apt-private)
+target_link_libraries(apt-mark apt-pkg apt-private)
+target_link_libraries(apt-sortpkgs apt-pkg apt-private)
+target_link_libraries(apt-extracttemplates apt-pkg apt-inst apt-private)
+target_link_libraries(apt-internal-solver apt-pkg apt-inst apt-private)
+target_link_libraries(apt-dump-solver apt-pkg apt-inst apt-private)
+target_link_libraries(apt-internal-planner apt-pkg apt-inst apt-private)
+
+set_target_properties(apt-dump-solver
+ PROPERTIES RUNTIME_OUTPUT_DIRECTORY solvers
+ RUNTIME_OUTPUT_NAME dump)
+set_target_properties(apt-internal-solver
+ PROPERTIES RUNTIME_OUTPUT_DIRECTORY solvers
+ RUNTIME_OUTPUT_NAME apt)
+set_target_properties(apt-internal-planner
+ PROPERTIES RUNTIME_OUTPUT_DIRECTORY planners
+ RUNTIME_OUTPUT_NAME apt)
+
+# Install the executables
+install(TARGETS apt apt-cache apt-get apt-config apt-cdrom apt-mark apt-sortpkgs
+ apt-extracttemplates
+ RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR})
+
+install(TARGETS apt-helper RUNTIME DESTINATION ${CMAKE_INSTALL_LIBEXECDIR}/apt/)
+install(TARGETS apt-dump-solver apt-internal-solver RUNTIME DESTINATION ${CMAKE_INSTALL_LIBEXECDIR}/apt/solvers)
+install(TARGETS apt-internal-planner RUNTIME DESTINATION ${CMAKE_INSTALL_LIBEXECDIR}/apt/planners)
+
+add_slaves(${CMAKE_INSTALL_LIBEXECDIR}/apt/planners ../solvers/dump planners/dump)
+
+# Install the not-to-be-compiled programs
+INSTALL(PROGRAMS ${CMAKE_CURRENT_BINARY_DIR}/apt-key DESTINATION ${CMAKE_INSTALL_BINDIR})
diff --git a/dselect/CMakeLists.txt b/dselect/CMakeLists.txt
new file mode 100644
index 000000000..804306e72
--- /dev/null
+++ b/dselect/CMakeLists.txt
@@ -0,0 +1,4 @@
+install(PROGRAMS install setup update
+ DESTINATION ${CMAKE_INSTALL_LIBEXECDIR}/dpkg/methods/apt)
+install(FILES desc.apt names
+ DESTINATION ${CMAKE_INSTALL_LIBEXECDIR}/dpkg/methods/apt)
diff --git a/ftparchive/CMakeLists.txt b/ftparchive/CMakeLists.txt
new file mode 100644
index 000000000..1e1dc36ca
--- /dev/null
+++ b/ftparchive/CMakeLists.txt
@@ -0,0 +1,10 @@
+# Create the executable tasks
+file(GLOB_RECURSE source "*.cc")
+add_executable(apt-ftparchive ${source})
+
+# Link the executables against the libraries
+target_include_directories(apt-ftparchive PRIVATE ${BERKELEY_DB_INCLUDE_DIRS})
+target_link_libraries(apt-ftparchive apt-inst apt-pkg apt-private ${BERKELEY_DB_LIBRARIES})
+
+# Install the executables
+install(TARGETS apt-ftparchive RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR})
diff --git a/methods/CMakeLists.txt b/methods/CMakeLists.txt
new file mode 100644
index 000000000..2417c4dc1
--- /dev/null
+++ b/methods/CMakeLists.txt
@@ -0,0 +1,35 @@
+# Create the executable targets
+add_executable(file file.cc)
+add_executable(copy copy.cc)
+add_executable(store store.cc)
+add_executable(gpgv gpgv.cc)
+add_executable(cdrom cdrom.cc)
+add_executable(http http.cc http_main.cc rfc2553emu.cc connect.cc server.cc)
+add_executable(mirror mirror.cc http.cc rfc2553emu.cc connect.cc server.cc)
+add_executable(https https.cc server.cc)
+add_executable(ftp ftp.cc rfc2553emu.cc connect.cc)
+add_executable(rred rred.cc)
+add_executable(rsh rsh.cc)
+
+# Add target-specific header directories
+target_include_directories(https PRIVATE ${CURL_INCLUDE_DIRS})
+
+# Link the executables against the libraries
+target_link_libraries(file apt-pkg)
+target_link_libraries(copy apt-pkg)
+target_link_libraries(store apt-pkg)
+target_link_libraries(gpgv apt-pkg)
+target_link_libraries(cdrom apt-pkg)
+target_link_libraries(http apt-pkg)
+target_link_libraries(mirror apt-pkg -lresolv)
+target_link_libraries(https apt-pkg ${CURL_LIBRARIES})
+target_link_libraries(ftp apt-pkg)
+target_link_libraries(rred apt-pkg)
+target_link_libraries(rsh apt-pkg)
+
+# Install the library
+install(TARGETS file copy store gpgv cdrom http https ftp rred rsh mirror
+ RUNTIME DESTINATION ${CMAKE_INSTALL_LIBEXECDIR}/apt/methods)
+
+add_slaves(${CMAKE_INSTALL_LIBEXECDIR}/apt/methods store gzip lzma bzip2 xz)
+add_slaves(${CMAKE_INSTALL_LIBEXECDIR}/apt/methods rsh ssh)
diff --git a/vendor/CMakeLists.txt b/vendor/CMakeLists.txt
new file mode 100644
index 000000000..72aad49e1
--- /dev/null
+++ b/vendor/CMakeLists.txt
@@ -0,0 +1,33 @@
+# Determine the current vendor, export to CURRENT_VENDOR
+execute_process(COMMAND ${CMAKE_CURRENT_SOURCE_DIR}/getinfo current
+ OUTPUT_VARIABLE CURRENT_VENDOR OUTPUT_STRIP_TRAILING_WHITESPACE)
+set(CURRENT_VENDOR ${CURRENT_VENDOR} PARENT_SCOPE)
+
+message(STATUS "Detected vendor: ${CURRENT_VENDOR}")
+
+# Handle sources.list example
+add_vendor_file(OUTPUT sources.list
+ INPUT "${CURRENT_VENDOR}/sources.list.in"
+ MODE 644
+ VARIABLES sourceslist-list-format
+ debian-stable-codename
+ debian-oldstable-codename
+ debian-testing-codename
+ ubuntu-codename
+ current-codename)
+install(FILES ${CMAKE_CURRENT_BINARY_DIR}/sources.list
+ DESTINATION ${CMAKE_INSTALL_DOCDIR}/examples)
+
+# Handle apt.conf snippets
+file(GLOB conffiles ${CURRENT_VENDOR}/apt.conf-*)
+foreach(file ${conffiles})
+ file(RELATIVE_PATH confname ${CMAKE_CURRENT_SOURCE_DIR}/${CURRENT_VENDOR}/ ${file})
+ string(REPLACE "apt.conf-" "" confname "${confname}")
+ install(FILES "${file}"
+ DESTINATION "${CMAKE_INSTALL_SYSCONFDIR}/apt/apt.conf.d/"
+ RENAME "${confname}")
+endforeach()
+
+if (EXISTS "${CURRENT_VENDOR}/CMakeLists.txt")
+ add_subdirectory(${CURRENT_VENDOR})
+endif()