### Install Example Configuration Files Source: https://github.com/apt-team/apt/blob/main/doc/examples/CMakeLists.txt Installs example configuration files like apt.conf, configure-index, and preferences to the documentation directory. ```cmake install(FILES apt.conf configure-index preferences DESTINATION ${CMAKE_INSTALL_DOCDIR}/examples) ``` -------------------------------- ### Install Example APT Utilities Configuration Files Source: https://github.com/apt-team/apt/blob/main/doc/examples/CMakeLists.txt Installs example configuration files for apt-utils, such as apt-ftparchive.conf and ftp-archive.conf, to a specific documentation path. ```cmake install(FILES apt-ftparchive.conf ftp-archive.conf DESTINATION ${CMAKE_INSTALL_DATAROOTDIR}/doc/apt-utils/examples) ``` -------------------------------- ### APT media-change Example Source: https://github.com/apt-team/apt/blob/main/doc/progress-reporting.md Demonstrates the format for media change requests, specifying the medium, drive, and a human-readable string prompting the user to insert a specific disc. This is used when APT requires a new installation medium. ```text media-change: Ubuntu 5.10 _Breezy Badger_ - Alpha i386 (20050830):/cdrom/:Please insert the disc labeled: 'Ubuntu 5.10 _Breezy Badger_ - Alpha i386 (20050830)' in the drive '/cdrom/' and press enter. ``` -------------------------------- ### APT Install Pre-Hook Example Source: https://github.com/apt-team/apt/blob/main/doc/json-hooks-protocol.md This JSON object represents a pre-installation hook call for the 'purge' command, detailing package information and versions. ```json { "jsonrpc": "2.0", "method": "org.debian.apt.hooks.install.pre", "params": { "command": "purge", "search-terms": [ "petname-", "lxd+" ], "packages": [ { "id": 1500, "name": "ebtables", "architecture": "amd64", "mode": "install", "automatic": 1, "versions": { "candidate": { "id": 376, "version": "2.0.10.4-3.5ubuntu2", "architecture": "amd64", "pin": 990 }, "install": { "id": 376, "version": "2.0.10.4-3.5ubuntu2", "architecture": "amd64", "pin": 990 } } } ] } } ``` -------------------------------- ### APT pmstatus Example Source: https://github.com/apt-team/apt/blob/main/doc/progress-reporting.md Shows the format of package manager status reports, including package name, total percentage, and action description. This is sent when packages are installed or removed. ```bash # ./apt-get install -o APT::Status-Fd=2 3dchess >/dev/null pmstatus:3dchess:20:Preparing 3dchess pmstatus:3dchess:40:Unpacking 3dchess pmstatus:3dchess:60:Preparing to configure 3dchess pmstatus:3dchess:80:Configuring 3dchess pmstatus:3dchess:100:Installed 3dchess ``` -------------------------------- ### Install Library and Headers Source: https://github.com/apt-team/apt/blob/main/apt-private/CMakeLists.txt Installs the 'apt-private' shared library to the system's library directory and skips the NAMELINK for the library. It also installs the header files to a specified include directory. ```cmake install(TARGETS apt-private LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR} NAMELINK_SKIP) flatify(${PROJECT_BINARY_DIR}/include/apt-private/ "${headers}") ``` -------------------------------- ### Install Empty Directories Source: https://github.com/apt-team/apt/blob/main/CMakeLists.txt Ensures that various APT-related directories are created during the installation process. ```cmake install_empty_directories( ${CONF_DIR}/apt.conf.d ${CONF_DIR}/auth.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} ) ``` -------------------------------- ### Install dselect method description files Source: https://github.com/apt-team/apt/blob/main/dselect/CMakeLists.txt Installs description files for dselect methods to the specified destination. ```cmake install(FILES desc.apt names DESTINATION ${CMAKE_INSTALL_LIBEXECDIR}/dpkg/methods/apt) ``` -------------------------------- ### APT Hello Handshake Example Source: https://github.com/apt-team/apt/blob/main/doc/json-hooks-protocol.md APT initiates the connection by calling the 'org.debian.apt.hooks.hello' method, providing supported protocol versions and configuration options. The hook responds with the chosen version. ```json {"jsonrpc":"2.0","method":"org.debian.apt.hooks.hello","id":0,"params":{"versions":["0.1", "0.2"], "options": [{"name": "APT::Architecture", "value": "amd64"}]}} ``` -------------------------------- ### Install APT Method Libraries Source: https://github.com/apt-team/apt/blob/main/methods/CMakeLists.txt Installs the 'file', 'copy', 'store', 'cdrom', 'gpgv', 'http', and 'rred' executables to the APT methods runtime directory. This makes these executables available for use by APT. ```cmake install(TARGETS file copy store cdrom gpgv http rred mirror RUNTIME DESTINATION ${CMAKE_INSTALL_LIBEXECDIR}/apt/methods) ``` -------------------------------- ### Set APT Directories Source: https://github.com/apt-team/apt/blob/main/CMakeLists.txt Defines the installation paths for APT's state, cache, log, configuration, and binary files. ```cmake 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}") ``` -------------------------------- ### Install APT Executables Source: https://github.com/apt-team/apt/blob/main/cmdline/CMakeLists.txt Installs the built APT executables to their designated locations within the installation prefix. Different executables are installed to different directories based on their function. ```cmake install(TARGETS apt apt-cache apt-get apt-config apt-cdrom apt-mark apt-sortpkgs RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR}) install(TARGETS apt-helper apt-extracttemplates 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) ``` -------------------------------- ### Using FileBegin() for PkgFileIterator Source: https://github.com/apt-team/apt/blob/main/doc/libapt-pkg2_to_3.txt The legacy ability to create a PkgFileIterator starting at Begin is removed. All iterators should now be started using FileBegin(). ```c++ FileBegin(); ``` -------------------------------- ### Install Executable Source: https://github.com/apt-team/apt/blob/main/ftparchive/CMakeLists.txt This snippet defines how the 'apt-ftparchive' executable should be installed. It specifies that the executable should be placed in the runtime destination directory defined by CMAKE_INSTALL_BINDIR. ```cmake install(TARGETS apt-ftparchive RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR}) ``` -------------------------------- ### Installing apt.conf Snippets Source: https://github.com/apt-team/apt/blob/main/vendor/CMakeLists.txt This snippet finds all apt.conf files prefixed with 'apt.conf-' within the vendor directory and installs them into the apt.conf.d directory. It renames the files to remove the prefix during installation. ```cmake # 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() ``` -------------------------------- ### APT dlstatus Example Source: https://github.com/apt-team/apt/blob/main/doc/progress-reporting.md Shows the format for download status reports, including the number of already downloaded packages, total progress percentage, and a human-readable description of the download action. This is used during the package download phase. ```text dlstatus:1:9.05654:Downloading file 1 of 3 (4m40s remaining) dlstatus:1:9.46357:Downloading file 1 of 3 (4m39s remaining) dlstatus:1:9.61022:Downloading file 1 of 3 (4m38s remaining) ``` -------------------------------- ### Handling sources.list Example Source: https://github.com/apt-team/apt/blob/main/vendor/CMakeLists.txt This snippet conditionally processes the sources.list example file based on WITH_DOC or WITH_DOC_EXAMPLES flags. It determines the input and output filenames for the sources list and adds it as a vendor file with specific variables. ```cmake # Handle sources.list example if (WITH_DOC OR WITH_DOC_EXAMPLES) if (EXISTS "${CMAKE_CURRENT_SOURCE_DIR}/${CURRENT_VENDOR}/${CURRENT_VENDOR}.sources.in") set(sources_in "${CURRENT_VENDOR}/${CURRENT_VENDOR}.sources.in") set(sources_out "${CURRENT_VENDOR}.sources") else() set(sources_in "${CURRENT_VENDOR}/sources.list.in") set(sources_out "sources.list") endif() add_vendor_file(OUTPUT ${sources_out} INPUT "${sources_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_out} DESTINATION ${CMAKE_INSTALL_DOCDIR}/examples) endif() ``` -------------------------------- ### APT Option List Representation Example Source: https://github.com/apt-team/apt/blob/main/doc/json-hooks-protocol.md Illustrates how APT represents configuration options that are lists, such as 'APT::Architectures', within the JSON protocol. This format requires specific parsing logic. ```json [ {"name": "APT::Architectures", "value": "unused"}, {"name": "APT::Architectures::first", "amd64"}, {"name": "APT::Architectures::", ""} ] ``` -------------------------------- ### Install dselect methods Source: https://github.com/apt-team/apt/blob/main/dselect/CMakeLists.txt Installs executable programs for dselect methods to the specified destination. ```cmake install(PROGRAMS install setup update DESTINATION ${CMAKE_INSTALL_LIBEXECDIR}/dpkg/methods/apt) ``` -------------------------------- ### Build APT in Source Tree with CMake Source: https://github.com/apt-team/apt/blob/main/README.md A specific example of using CMake to build APT directly within the source directory. ```bash cmake . ``` -------------------------------- ### Install Bash Completion Script Source: https://github.com/apt-team/apt/blob/main/completions/CMakeLists.txt Installs the 'apt' bash completion script to the directory specified by BASH_COMPLETION_DIR. This makes the completion script available to the bash shell. ```cmake install(FILES bash/apt DESTINATION ${BASH_COMPLETION_DIR}) ``` -------------------------------- ### APT pmerror Example Source: https://github.com/apt-team/apt/blob/main/doc/progress-reporting.md Illustrates the format for package manager error reports, including the deb file path, percentage, and the error string. This is used for reporting errors during package operations. ```text pmerror: /var/cache/apt/archives/krecipes_0.8.1-0ubuntu1_i386.deb : 75% : trying to overwrite `/usr/share/doc/kde/HTML/en/krecipes/krectip.png', which is also in package krecipes-data ``` -------------------------------- ### Get Translation-en Filenames Source: https://github.com/apt-team/apt/blob/main/doc/acquire-additional-files.md Use apt-get indextargets with a custom format to retrieve specific filenames. This example filters for 'Identifier: Translations' and 'Language: en' to get all Translation-en files. ```bash apt-get indextargets --format '$(FILENAME)' "Identifier: Translations" "Language: en" ``` -------------------------------- ### Hook Hello Response Example Source: https://github.com/apt-team/apt/blob/main/doc/json-hooks-protocol.md The hook acknowledges the hello handshake by responding with the selected protocol version. ```json {"jsonrpc":"2.0","id":0,"result":{"version":"0.1"}} ``` -------------------------------- ### Enable Debug Output for Auto Installation Decisions Source: https://github.com/apt-team/apt/blob/main/README.md Enable debug logging to see which packages APT decides to install automatically to satisfy dependencies during the resolution process. ```aptconf Debug::pkgDepCache::AutoInstall "true"; ``` -------------------------------- ### Add Links for APT Methods Source: https://github.com/apt-team/apt/blob/main/methods/CMakeLists.txt Adds symbolic links for various APT methods, including 'mirror', 'mirror+http', 'mirror+https', 'mirror+file', and 'mirror+copy', pointing to the installed mirror executable. This allows APT to invoke different mirror configurations. ```cmake add_links(${CMAKE_INSTALL_LIBEXECDIR}/apt/methods mirror mirror+http mirror+https mirror+file mirror+copy) ``` -------------------------------- ### Run Manual APT Build Source: https://github.com/apt-team/apt/blob/main/README.md Execute manually built APT binaries. CMake's rpath ensures binaries find correct libraries. Ensure the correct install prefix is set during CMake invocation or configure runtime locations. ```bash -DCMAKE_INSTALL_PREFIX=/usr ``` -------------------------------- ### Enable Debug Output for Package Dependency Marker Source: https://github.com/apt-team/apt/blob/main/README.md Activate debug logging for the initial stage of APT's dependency resolution, where packages are visited and marked for installation, keeping, or removal. ```aptconf Debug::pkgDepCache::Marker "true"; ``` -------------------------------- ### Enable Debug Output for Package Problem Resolver Source: https://github.com/apt-team/apt/blob/main/README.md Activate detailed debug logging for the pkgProblemResolver, which handles conflicts and makes decisions when multiple packages contend for installation. ```aptconf Debug::pkgProblemResolver "true"; ``` -------------------------------- ### Add Links for HTTP and HTTPS Methods Source: https://github.com/apt-team/apt/blob/main/methods/CMakeLists.txt Adds symbolic links for 'http' and 'https' methods, pointing to the installed 'http' executable. This enables APT to use the 'http' executable for both HTTP and HTTPS transport protocols. ```cmake add_links(${CMAKE_INSTALL_LIBEXECDIR}/apt/methods http https) ``` -------------------------------- ### Define Bash Completion Directory Variable Source: https://github.com/apt-team/apt/blob/main/completions/CMakeLists.txt Sets a CMake cache variable for the installation directory of bash completion scripts. This allows users to customize the installation path. ```cmake set(BASH_COMPLETION_DIR "${CMAKE_INSTALL_DATAROOTDIR}/bash-completion/completions" CACHE PATH "Path to the bash-completion completions directory") ``` -------------------------------- ### Create Conditional Executable Target for SQV Source: https://github.com/apt-team/apt/blob/main/methods/CMakeLists.txt Conditionally creates the 'sqv' executable if the 'SQV_EXECUTABLE' variable is true. It also specifies the runtime installation destination for the 'sqv' executable. ```cmake if (SQV_EXECUTABLE) add_executable(sqv sqv.cc) install(TARGETS sqv RUNTIME DESTINATION ${CMAKE_INSTALL_LIBEXECDIR}/apt/methods) endif() ``` -------------------------------- ### Two-Stage Initialization with APT_COMPATIBILITY Source: https://github.com/apt-team/apt/blob/main/doc/libapt-pkg2_to_3.txt Initialization is now a two-stage process. pkgInitConfig is called before command-line parsing, and pkgInitSystem is called after, allowing configuration overrides. ```c++ // First stage: pkgInitConfig called before commandline parsing // Second stage: pkgInitSystem called after commandline parsing ``` -------------------------------- ### Build APT with CMake Source: https://github.com/apt-team/apt/blob/main/README.md Use CMake to configure the build process for APT. Specify the source directory to begin. ```bash cmake ``` -------------------------------- ### APT pmconffile Format Source: https://github.com/apt-team/apt/blob/main/doc/progress-reporting.md Defines the format for configuration file prompts, including conffile path, percentage, current and new conffile names, and flags for user or distribution edits. This is used when handling configuration file conflicts. ```text pmconffile:conffile:percent:'current-conffile' 'new-conffile' useredited distedited ``` -------------------------------- ### APT Acquire Index Target Configuration Source: https://github.com/apt-team/apt/blob/main/doc/acquire-additional-files.md Defines the configuration for downloading the Packages index file within a deb repository. This snippet illustrates the use of MetaKey, ShortDescription, Description, flatMetaKey, flatDescription, and Optional directives. ```apt.conf Acquire::IndexTargets::deb::Packages { MetaKey "$(COMPONENT)/binary-$(ARCHITECTURE)/Packages"; ShortDescription "Packages"; Description "$(RELEASE)/$(COMPONENT) $(ARCHITECTURE) Packages"; flatMetaKey "Packages"; flatDescription "$(RELEASE) Packages"; Optional "no"; }; ``` -------------------------------- ### Build APT with Ninja Generator Source: https://github.com/apt-team/apt/blob/main/README.md Configure APT build using CMake with the Ninja generator for potentially faster builds. Use 'ninja' instead of 'make' to build. ```bash -G Ninja ``` -------------------------------- ### Create Executable Targets Source: https://github.com/apt-team/apt/blob/main/methods/CMakeLists.txt Defines several executable targets for APT methods, including 'file', 'copy', 'store', and 'gpgv'. These are built from their respective source files. ```cmake add_executable(file file.cc) add_executable(copy copy.cc) add_executable(store store.cc) add_executable(gpgv gpgv.cc) ``` -------------------------------- ### Run APT Integration Tests Source: https://github.com/apt-team/apt/blob/main/README.md Execute the comprehensive integration test suite for APT. Consider using quiet modes (-q, -qq) or parallel execution (-j X) for noisy or lengthy test runs. ```bash ./test/integration/run-tests ``` -------------------------------- ### APT Acquire Index Targets Configuration Source: https://github.com/apt-team/apt/blob/main/doc/acquire-additional-files.md This stanza defines configurations for `deb::Translations` and `deb-src::Sources` files, specifying metadata keys and descriptions for different release components and languages. It's used to manage how APT fetches translation and source index files. ```apt Acquire::IndexTargets { deb::Translations { MetaKey "$(COMPONENT)/i18n/Translation-$(LANGUAGE)"; ShortDescription "Translation-$(LANGUAGE)"; Description "$(RELEASE)/$(COMPONENT) Translation-$(LANGUAGE)"; flatMetaKey "$(LANGUAGE)"; flatDescription "$(RELEASE) Translation-$(LANGUAGE)"; }; deb-src::Sources { MetaKey "$(COMPONENT)/source/Sources"; ShortDescription "Sources"; Description "$(RELEASE)/$(COMPONENT) Sources"; flatMetaKey "Sources"; flatDescription "$(RELEASE) Sources"; Optional "no"; }; }; ``` -------------------------------- ### Configure Header Files Source: https://github.com/apt-team/apt/blob/main/CMakeLists.txt Generates the config.h and apti18n.h configuration header files from their respective template files. ```cmake configure_file(CMake/config.h.in ${PROJECT_BINARY_DIR}/include/config.h) configure_file(CMake/apti18n.h.in ${PROJECT_BINARY_DIR}/include/apti18n.h) ``` -------------------------------- ### Add Subdirectories for APT Components Source: https://github.com/apt-team/apt/blob/main/CMakeLists.txt Includes build configurations for various APT subdirectories like vendor, apt-pkg, apt-private, cmdline, etc. ```cmake add_subdirectory(vendor) if (NOT USE_SYSTEM_APTPKG) add_subdirectory(apt-pkg) add_subdirectory(apt-private) endif() add_subdirectory(cmdline) add_subdirectory(completions) add_subdirectory(doc) add_subdirectory(dselect) add_subdirectory(ftparchive) add_subdirectory(methods) add_subdirectory(test) ``` -------------------------------- ### Run APT Unit Tests with CTest Source: https://github.com/apt-team/apt/blob/main/README.md Execute APT's unit tests using CTest. For more detailed output, especially on failures, run with the --verbose flag. ```bash make test ``` ```bash ctest --verbose ``` -------------------------------- ### Enable Debug Output for HTTP Acquire Source: https://github.com/apt-team/apt/blob/main/README.md Activate debug logging specifically for the HTTP protocol used by the Acquire system to download files. Useful for diagnosing download issues. ```aptconf Debug::Acquire::http "true"; ``` -------------------------------- ### Configure APT Architecture Source: https://github.com/apt-team/apt/blob/main/README.md Set a specific architecture for APT operations using a configuration file. This is useful when dealing with multi-architecture systems or specific build environments. ```aptconf APT::Architecture "arch1"; #clear APT::Architectures; APT:: Architectures { "arch1"; "arch2"; } ``` -------------------------------- ### Python Helper for Parsing APT Options Source: https://github.com/apt-team/apt/blob/main/doc/json-hooks-protocol.md A Python function to help parse APT configuration options, specifically when they represent lists. This is useful for interpreting the 'options' array in the hello handshake. ```python def get_list(options, key): """key includes trailing ::""" return [value for name, value in options if name.startswith(key) and "::" not in name[len(key):]] ``` -------------------------------- ### Link Libraries and Set SONAME Source: https://github.com/apt-team/apt/blob/main/apt-private/CMakeLists.txt Links the 'apt-private' library with 'apt-pkg' and sets the VERSION and SOVERSION properties. CXX_VISIBILITY_PRESET is set to 'hidden' to control symbol visibility. ```cmake 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}) set_target_properties(apt-private PROPERTIES CXX_VISIBILITY_PRESET hidden) ``` -------------------------------- ### Conditional Re-introduction of Global Version Compare Functions Source: https://github.com/apt-team/apt/blob/main/doc/libapt-pkg2_to_3.txt If the APT_COMPATIBILITY macro is defined as 1, global version compare functions will be re-introduced. Otherwise, code should reference versioning system compare functions via Cache or _system structures. ```c++ #define APT_COMPATIBILITY 1 ``` -------------------------------- ### Downloading Index Files with SourceList::GetIndexes Source: https://github.com/apt-team/apt/blob/main/doc/libapt-pkg2_to_3.txt The method for downloading 'Package' and 'Source' index files has changed. Use the GetIndexes call within SourceList. ```c++ SourceList::GetIndexes(); ``` -------------------------------- ### Add Links for Solver/Planner Binaries Source: https://github.com/apt-team/apt/blob/main/cmdline/CMakeLists.txt Creates symbolic links for solver and planner binaries. This is often used to provide convenient access or to link against specific versions or configurations. ```cmake add_links(${CMAKE_INSTALL_LIBEXECDIR}/apt/planners ../solvers/dump planners/dump) add_links(${CMAKE_INSTALL_LIBEXECDIR}/apt/solvers apt solver3) ``` -------------------------------- ### Create Executable Target for Mirror Source: https://github.com/apt-team/apt/blob/main/methods/CMakeLists.txt Defines the 'mirror' executable target, built from 'mirror.cc'. ```cmake add_executable(mirror mirror.cc) ``` -------------------------------- ### Argument Change: pkgTagFile Constructor Source: https://github.com/apt-team/apt/blob/main/doc/libapt-pkg2_to_3.txt The pkgTagFile constructor signature has changed. It now takes a FileFd pointer. ```c++ // Old: pkgTagFile(FileFd &F,unsigned long Size = 32*1024); // New: pkgTagFile(FileFd *F,unsigned long Size = 32*1024); ``` -------------------------------- ### Enable Debug Output for Acquire Worker Source: https://github.com/apt-team/apt/blob/main/README.md Enable debug logging for the Acquire system's worker processes, showing messages exchanged with download methods. ```aptconf Debug::pkgAcquire::Worker "true"; ``` -------------------------------- ### Create Shared Library Source: https://github.com/apt-team/apt/blob/main/apt-private/CMakeLists.txt Creates a shared library named 'apt-private' using the C++ source files found by GLOB_RECURSE. ```cmake add_library(apt-private SHARED ${library}) ``` -------------------------------- ### Argument Change: pkgSimulate Source: https://github.com/apt-team/apt/blob/main/doc/libapt-pkg2_to_3.txt The pkgSimulate function signature has changed from taking a reference to a pointer. ```c++ // Old: pkgSimulate(pkgDepCache &Cache); // New: pkgSimulate(pkgDepCache *Cache); ``` -------------------------------- ### Set Target Properties for Solver/Planner Binaries Source: https://github.com/apt-team/apt/blob/main/cmdline/CMakeLists.txt Configures specific properties for solver and planner executables, including their runtime output directory and runtime name. This helps organize the build output. ```cmake 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) ``` -------------------------------- ### Link Libraries to Executable Source: https://github.com/apt-team/apt/blob/main/ftparchive/CMakeLists.txt This command links the 'apt-ftparchive' executable against specified libraries: 'apt-pkg', 'apt-private', and 'BERKELEY_LIBRARIES'. This ensures that the executable has access to the necessary functions and symbols from these libraries. ```cmake target_link_libraries(apt-ftparchive apt-pkg apt-private ${BERKELEY_LIBRARIES}) ``` -------------------------------- ### Link Executables Against Libraries Source: https://github.com/apt-team/apt/blob/main/cmdline/CMakeLists.txt Links the defined executable targets against the core APT libraries (apt-pkg and apt-private). This step is crucial for providing the necessary functionality to the executables. ```cmake 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-private) target_link_libraries(apt-internal-solver apt-pkg apt-private) target_link_libraries(apt-dump-solver apt-pkg apt-private) target_link_libraries(apt-internal-planner apt-pkg apt-private) ``` -------------------------------- ### Define Executable Target Source: https://github.com/apt-team/apt/blob/main/ftparchive/CMakeLists.txt This command defines the 'apt-ftparchive' executable and links it with the discovered source files. This is a standard way to create an executable target in CMake. ```cmake add_executable(apt-ftparchive ${source}) ``` -------------------------------- ### Add NLS Subdirectory if Enabled Source: https://github.com/apt-team/apt/blob/main/CMakeLists.txt Includes the 'po' subdirectory for Native Language Support (NLS) if the USE_NLS option is enabled. ```cmake if (USE_NLS) add_subdirectory(po) endif() ``` -------------------------------- ### pkgMakeStatusCache Functionality Source: https://github.com/apt-team/apt/blob/main/doc/libapt-pkg2_to_3.txt pkgMakeStatusCache now performs the same function as the removed pkgMakeOnlyStatusCache if the AllowMem flag is set. The used map can be copied to avoid remapping. ```c++ pkgMakeStatusCache(AllowMem); ``` -------------------------------- ### Define Executable Targets Source: https://github.com/apt-team/apt/blob/main/cmdline/CMakeLists.txt Defines the executable targets for various APT command-line tools. Each executable is built from its corresponding C++ source file. ```cmake 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) ``` -------------------------------- ### Run Specific APT Integration Test Source: https://github.com/apt-team/apt/blob/main/README.md Execute individual integration tests within the APT test suite. The tests are designed to be run in isolation or as part of the full suite. ```bash ./test/integration/run-tests ``` -------------------------------- ### Argument Change: pkgOrderList Source: https://github.com/apt-team/apt/blob/main/doc/libapt-pkg2_to_3.txt The pkgOrderList function signature has changed from taking a reference to a pointer. ```c++ // Old: pkgOrderList(pkgDepCache &Cache); // New: pkgOrderList(pkgDepCache *Cache); ``` -------------------------------- ### Determine Host Architecture Source: https://github.com/apt-team/apt/blob/main/CMakeLists.txt Uses 'dpkg-architecture' to determine the host's Debian architecture if not already defined. ```cmake if (NOT DEFINED COMMON_ARCH) execute_process(COMMAND dpkg-architecture -qDEB_HOST_ARCH OUTPUT_VARIABLE COMMON_ARCH OUTPUT_STRIP_TRAILING_WHITESPACE COMMAND_ERROR_IS_FATAL ANY) endif() ``` -------------------------------- ### Argument Change: pkgCache Constructor Source: https://github.com/apt-team/apt/blob/main/doc/libapt-pkg2_to_3.txt The pkgCache constructor signature has changed. It now takes an MMap pointer. ```c++ // Old: pkgCache(MMap &Map,bool DoMap = true); // New: pkgCache(MMap *Map,bool DoMap = true); ``` -------------------------------- ### Set Package Information Source: https://github.com/apt-team/apt/blob/main/CMakeLists.txt Sets variables for the package name, maintainer email, and version. ```cmake set(PACKAGE ${PROJECT_NAME}) set(PACKAGE_MAIL "APT Development Team ") set(PACKAGE_VERSION "3.3.1") string(REGEX MATCH "^[0-9.]+" PROJECT_VERSION ${PACKAGE_VERSION}) ``` -------------------------------- ### Create Connect Library Target Source: https://github.com/apt-team/apt/blob/main/methods/CMakeLists.txt Defines an OBJECT library named 'connectlib' from 'connect.cc' and 'rfc2553emu.cc'. OBJECT libraries are useful for creating pre-compiled object files that can be linked into multiple targets. ```cmake add_library(connectlib OBJECT connect.cc rfc2553emu.cc) ``` -------------------------------- ### Create Executable Target for CDROM Source: https://github.com/apt-team/apt/blob/main/methods/CMakeLists.txt Defines the 'cdrom' executable target, built from 'cdrom.cc'. ```cmake add_executable(cdrom cdrom.cc) ``` -------------------------------- ### Create Executable Target for HTTP Method Source: https://github.com/apt-team/apt/blob/main/methods/CMakeLists.txt Defines the 'http' executable target, built from 'http.cc', 'basehttp.cc', and the pre-compiled 'connectlib' object library. This target is used for HTTP and HTTPS APT methods. ```cmake add_executable(http http.cc basehttp.cc $) ``` -------------------------------- ### Set Pager and Environment Variables Source: https://github.com/apt-team/apt/blob/main/CMakeLists.txt Configures the default pager and the environment variables to be passed to the pager. ```cmake set(DEFAULT_PAGER "pager" CACHE STRING "The default pager to use for commands that support it.") set(PAGER_ENV "LESS=FRSXMK\nMORE=FRX\nLV=-c" CACHE STRING "Environment to pass to the pager. One variable per line, with escaped newlines") ``` -------------------------------- ### Adding Vendor Subdirectory Source: https://github.com/apt-team/apt/blob/main/vendor/CMakeLists.txt This snippet checks for the existence of a CMakeLists.txt file within the vendor directory and, if found, adds that directory as a sub-build. This allows for vendor-specific build configurations. ```cmake if (EXISTS "${CURRENT_VENDOR}/CMakeLists.txt") add_subdirectory(${CURRENT_VENDOR}) endif() ``` -------------------------------- ### Creating a Shared Library in CMake Source: https://github.com/apt-team/apt/blob/main/test/interactive-helper/CMakeLists.txt Defines a shared library named 'noprofile' from a C source file and links it with the dynamic loading libraries. ```cmake add_library(noprofile SHARED libnoprofile.c) target_link_libraries(noprofile ${CMAKE_DL_LIBS}) ``` -------------------------------- ### Argument Change: pkgDepCache Constructor Source: https://github.com/apt-team/apt/blob/main/doc/libapt-pkg2_to_3.txt The pkgDepCache constructor signature has changed. It now takes a pkgCache pointer instead of an MMap. ```c++ // Old: pkgDepCache(MMap &Map,Policy *Plcy = 0); // New: pkgDepCache(pkgCache *Cache,Policy *Plcy = 0); ``` -------------------------------- ### Set Target Include Directories Source: https://github.com/apt-team/apt/blob/main/ftparchive/CMakeLists.txt This snippet sets the include directories for the 'apt-ftparchive' target. The PRIVATE keyword means these include directories are only used for compiling the target itself and not for targets that link to it. ```cmake target_include_directories(apt-ftparchive PRIVATE ${BERKELEY_INCLUDE_DIRS}) ``` -------------------------------- ### Compile Definitions and Include Directories for Connectlib Source: https://github.com/apt-team/apt/blob/main/methods/CMakeLists.txt Sets private compile definitions and include directories for the 'connectlib' target, specifically for OpenSSL. This ensures that OpenSSL headers and definitions are available during compilation. ```cmake target_compile_definitions(connectlib PRIVATE ${OPENSSL_DEFINITIONS}) target_include_directories(connectlib PRIVATE ${OPENSSL_INCLUDE_DIR}) ``` -------------------------------- ### Argument Change: pkgCacheGenerator Constructor Source: https://github.com/apt-team/apt/blob/main/doc/libapt-pkg2_to_3.txt The pkgCacheGenerator constructor signature has changed. It now takes DynamicMMap and OpProgress pointers. ```c++ // Old: pkgCacheGenerator(DynamicMMap &Map,OpProgress &Progress); // New: pkgCacheGenerator(DynamicMMap *Map,OpProgress *Progress); ``` -------------------------------- ### Define FreeBSD Specific Macro Source: https://github.com/apt-team/apt/blob/main/CMakeLists.txt Adds a definition for FreeBSD systems to enable specific features like getline. ```cmake add_definitions(-D_WITH_GETLINE=1) ``` -------------------------------- ### Vim Editor Settings for APT Coding Style Source: https://github.com/apt-team/apt/blob/main/README.md Configure Vim editor settings to adhere to APT's 3-space indent and 8-space tab convention. These settings help maintain consistent code style. ```vim setlocal shiftwidth=3 noexpandtab tabstop=8 ``` -------------------------------- ### Link Libraries for HTTP Method Source: https://github.com/apt-team/apt/blob/main/methods/CMakeLists.txt Links OpenSSL SSL library and conditionally links systemd libraries to the 'http' target. This ensures that the HTTP method can utilize SSL/TLS encryption and systemd features. ```cmake target_link_libraries(http OpenSSL::SSL $:${SYSTEMD_LIBRARIES}) ``` -------------------------------- ### Add Version Script Source: https://github.com/apt-team/apt/blob/main/apt-private/CMakeLists.txt Generates a version script for the 'apt-private' library. This is typically used on Linux systems to control exported symbols. ```cmake add_version_script(apt-private) ``` -------------------------------- ### Argument Change: pkgProblemResolver Source: https://github.com/apt-team/apt/blob/main/doc/libapt-pkg2_to_3.txt The pkgProblemResolver function signature has changed from taking a reference to a pointer. ```c++ // Old: pkgProblemResolver(pkgDepCache &Cache); // New: pkgProblemResolver(pkgDepCache *Cache); ``` -------------------------------- ### Argument Change: pkgPackageManager Source: https://github.com/apt-team/apt/blob/main/doc/libapt-pkg2_to_3.txt The pkgPackageManager function signature has changed from taking a reference to a pointer. ```c++ // Old: pkgPackageManager(pkgDepCache &Cache); // New: pkgPackageManager(pkgDepCache *Cache); ``` -------------------------------- ### Include Directories for HTTP with Systemd Source: https://github.com/apt-team/apt/blob/main/methods/CMakeLists.txt Conditionally adds systemd include directories to the 'http' target if systemd is found. This is necessary for using systemd-related functionalities in the HTTP method. ```cmake target_include_directories(http PRIVATE $:${SYSTEMD_INCLUDE_DIRS}) ``` -------------------------------- ### Conditional Library Linking in CMake Source: https://github.com/apt-team/apt/blob/main/test/interactive-helper/CMakeLists.txt Configures the linking of apt-pkg and apt-private libraries based on the USE_SYSTEM_APTPKG flag. Sets library paths and include directories accordingly. ```cmake if(USE_SYSTEM_APTPKG) find_library(aptpkg NAMES apt-pkg NO_PACKAGE_ROOT_PATH REQUIRED) set(APTPKG_LIB "${aptpkg}") # it isn't easy to link against -private, but that is by design set(APTPRIVATE_LIB "/usr/lib/${CMAKE_LIBRARY_ARCHITECTURE}/libapt-private.so.0.0") set(APTPRIVATE_INCLUDE_DIRS "${PROJECT_SOURCE_DIR}") else() set(APTPKG_LIB "apt-pkg") set(APTPRIVATE_LIB "apt-private") set(APTPRIVATE_INCLUDE_DIRS "") endif() ``` -------------------------------- ### Check for resolv Function Source: https://github.com/apt-team/apt/blob/main/CMakeLists.txt Determines if the resolv library is available by checking for the res_ninit function. ```cmake check_function_exists(res_ninit HAVE_LIBC_RESOLV) if(HAVE_LIBC_RESOLV) set(RESOLV_LIBRARIES) else() set(RESOLV_LIBRARIES -lresolv) endif() ``` -------------------------------- ### Linking apt-pkg to Executables in CMake Source: https://github.com/apt-team/apt/blob/main/test/interactive-helper/CMakeLists.txt Defines and links the apt-pkg library to various executable targets within the CMake build system. ```cmake add_executable(mthdcat mthdcat.cc) target_link_libraries(mthdcat ${APTPKG_LIB}) ``` ```cmake add_executable(testdeb testdeb.cc) target_link_libraries(testdeb ${APTPKG_LIB}) ``` ```cmake add_executable(testkeep testkeep.cc) target_link_libraries(testkeep ${APTPKG_LIB}) ``` ```cmake add_executable(extract-control extract-control.cc) target_link_libraries(extract-control ${APTPKG_LIB}) ``` ```cmake add_executable(aptwebserver aptwebserver.cc) target_link_libraries(aptwebserver ${APTPKG_LIB} ${CMAKE_THREAD_LIBS_INIT}) ``` ```cmake add_executable(aptdropprivs aptdropprivs.cc) target_link_libraries(aptdropprivs ${APTPKG_LIB}) ``` ```cmake add_executable(test_fileutl test_fileutl.cc) target_link_libraries(test_fileutl ${APTPKG_LIB}) ``` ```cmake add_executable(createdeb-cve-2020-27350 createdeb-cve-2020-27350.cc) ``` ```cmake add_executable(longest-dependency-chain longest-dependency-chain.cc) target_link_libraries(longest-dependency-chain ${APTPKG_LIB} ${APTPRIVATE_LIB}) target_include_directories(longest-dependency-chain PRIVATE ${APTPRIVATE_INCLUDE_DIRS}) ```