Skip to content
This repository has been archived by the owner on May 21, 2024. It is now read-only.

Commit

Permalink
Remove dependency on libdpkg
Browse files Browse the repository at this point in the history
API of libdpkg is unstable and its usage is discouraged
for purposes other than internal.
It also prevents building libaktualizr as a shared library.
As getInstalledPackages() functionality of debian package
manager seems to be unused, we will avoid reimplementing it for now.

Signed-off-by: Eugene Smirnov <evgenii.smirnov@here.com>
  • Loading branch information
Eugene Smirnov committed Jul 26, 2019
1 parent af6c907 commit b5a0d4f
Show file tree
Hide file tree
Showing 9 changed files with 3 additions and 58 deletions.
7 changes: 0 additions & 7 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -119,12 +119,6 @@ else(BUILD_OSTREE)
unset(LIBOSTREE_LIBRARIES CACHE)
endif(BUILD_OSTREE)

if(BUILD_DEB)
pkg_check_modules(LIBDPKG REQUIRED libdpkg)
else(BUILD_DEB)
unset(LIBDPKG_LIBRARIES CACHE)
endif(BUILD_DEB)

if(BUILD_DOCKERAPP)
add_definitions(-DBUILD_DOCKERAPP)
endif(BUILD_DOCKERAPP)
Expand Down Expand Up @@ -377,7 +371,6 @@ set (AKTUALIZR_EXTERNAL_LIBS
${SQLITE3_LIBRARIES}
${LibArchive_LIBRARIES}
${LIBP11_LIBRARIES}
${LIBDPKG_LIBRARIES}
${GLIB2_LIBRARIES}
${SYSTEMD_LIBRARY}
${ZLIB_LIBRARY})
Expand Down
1 change: 0 additions & 1 deletion README.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,6 @@ Some features also require additional packages:
* For PKCS#11 support, you will need `libp11-2 libp11-dev`.
* For systemd support for secondaries, you will need `libsystemd-dev`.
* For fault injection, you will need `fiu-utils libfiu-dev`.
* For Debian packagin support, you will need `libdpkg-dev`.

==== Mac support

Expand Down
2 changes: 0 additions & 2 deletions docker/Dockerfile.debian.testing
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@ RUN apt-get update && apt-get -y install --no-install-suggests --no-install-reco
cmake \
curl \
doxygen \
dpkg-dev \
e2fslibs-dev \
g++ \
gcc \
Expand All @@ -34,7 +33,6 @@ RUN apt-get update && apt-get -y install --no-install-suggests --no-install-reco
libboost-test-dev \
libboost-thread-dev \
libcurl4-openssl-dev \
libdpkg-dev \
libengine-pkcs11-openssl \
libexpat1-dev \
libfuse-dev \
Expand Down
1 change: 0 additions & 1 deletion docker/Dockerfile.ubuntu.bionic
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,6 @@ RUN apt-get update && apt-get -y install --no-install-suggests --no-install-reco
libboost-test-dev \
libboost-thread-dev \
libcurl4-openssl-dev \
libdpkg-dev \
libengine-pkcs11-openssl \
libexpat1-dev \
libffi-dev \
Expand Down
1 change: 0 additions & 1 deletion docker/Dockerfile.ubuntu.xenial
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,6 @@ RUN apt-get update && apt-get -y install --no-install-suggests --no-install-reco
libboost-test-dev \
libboost-thread-dev \
libcurl4-openssl-dev \
libdpkg-dev \
libengine-pkcs11-openssl \
libexpat1-dev \
libffi-dev \
Expand Down
3 changes: 0 additions & 3 deletions src/libaktualizr/package_manager/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,6 @@ add_aktualizr_test(NAME packagemanagerfake SOURCES packagemanagerfake_test.cc)
# Debian backend
if(BUILD_DEB)
set_property(SOURCE packagemanagerfactory.cc packagemanagerfactory_test.cc PROPERTY COMPILE_DEFINITIONS BUILD_DEB)
if (${LIBDPKG_VERSION} VERSION_GREATER "1.19.3")
set_property(SOURCE debianmanager.cc PROPERTY COMPILE_DEFINITIONS LIBDPKG_V011903)
endif()
target_sources(package_manager PRIVATE debianmanager.cc)
add_executable(t_packagemanager_deb EXCLUDE_FROM_ALL debianmanager_test.cc)
add_dependencies(build_tests t_packagemanager_deb)
Expand Down
30 changes: 2 additions & 28 deletions src/libaktualizr/package_manager/debianmanager.cc
Original file line number Diff line number Diff line change
@@ -1,37 +1,11 @@
#include "package_manager/debianmanager.h"

#define LIBDPKG_VOLATILE_API 1
#include <dpkg/dpkg-db.h>
#include <dpkg/dpkg.h>
#include <dpkg/pkg-array.h>
#include <dpkg/pkg-show.h>
#include <stdio.h>
#include <unistd.h>

Json::Value DebianManager::getInstalledPackages() const {
Json::Value packages(Json::arrayValue);
struct pkg_array array {};
dpkg_program_init("a.out");
modstatdb_open(msdbrw_available_readonly);

#ifdef LIBDPKG_V011903
pkg_array_init_from_hash(&array);
#else
pkg_array_init_from_db(&array);
#endif
pkg_array_sort(&array, pkg_sorter_by_nonambig_name_arch);
for (int i = 0; i < array.n_pkgs; ++i) {
// NOLINTNEXTLINE(cppcoreguidelines-pro-bounds-pointer-arithmetic)
struct pkginfo *pkg = array.pkgs[i];
if (pkg->status == PKG_STAT_INSTALLED) {
Json::Value package;
package["name"] = pkg_name(pkg, pnaw_nonambig);
package["version"] = versiondescribe(&pkg->installed.version, vdew_nonambig);
packages.append(package);
}
}
dpkg_program_done();
return packages;
// Currently not implemented
return Json::Value(Json::arrayValue);
}

data::InstallationResult DebianManager::install(const Uptane::Target &target) const {
Expand Down
3 changes: 1 addition & 2 deletions src/load_tests/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -34,8 +34,7 @@ if (BUILD_LOAD_TESTS)
${LIBOSTREE_LIBRARIES}
${LIBP11_LIBRARIES}
${SQLITE3_LIBRARIES}
${SYSTEMD_LIBRARY}
${LIBDPKG_LIBRARIES})
${SYSTEMD_LIBRARY})

install(TARGETS ota-load-tests
COMPONENT aktualizr
Expand Down
13 changes: 0 additions & 13 deletions thirdparty.spdx
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@ Relationship: SPDXRef-DOCUMENT DESCRIBES SPDXRef-sqlite3
Relationship: SPDXRef-DOCUMENT DESCRIBES SPDXRef-asn1c
Relationship: SPDXRef-DOCUMENT DESCRIBES SPDXRef-libp11
Relationship: SPDXRef-DOCUMENT DESCRIBES SPDXRef-systemd
Relationship: SPDXRef-DOCUMENT DESCRIBES SPDXRef-dpkg


PackageName: googletest
Expand Down Expand Up @@ -209,18 +208,6 @@ FilesAnalyzed: false
PackageComment: <text>Dynamically linked.</text>


PackageName: dpkg
SPDXID: SPDXRef-dpkg
PackageDownloadLocation: http://http.debian.net/debian/pool/main/d/dpkg/dpkg_1.19.0.5.tar.xz
PackageHomePage: https://packages.debian.org/source/sid/dpkg
PackageLicenseConcluded: GPL-2.0-or-later
PackageLicenseDeclared: GPL-2.0-or-later
PackageLicenseInfoFromFiles: GPL-2.0-or-later
PackageCopyrightText: <text>NONE</text>
FilesAnalyzed: false
PackageComment: <text>Dynamically linked.</text>


PackageName: systemd
SPDXID: SPDXRef-systemd
PackageDownloadLocation: https://github.com/systemd/systemd/archive/v238.tar.gz
Expand Down

0 comments on commit b5a0d4f

Please sign in to comment.