From 8a19b1c66fc67bc16be435d7c3e62cc457afc958 Mon Sep 17 00:00:00 2001 From: Karen Arutyunov Date: Mon, 30 Jan 2023 14:42:15 +0300 Subject: Continue adding Fedora support --- bpkg/system-package-manager-fedora.hxx | 95 ++++++++++++++++++++++++---------- 1 file changed, 69 insertions(+), 26 deletions(-) (limited to 'bpkg/system-package-manager-fedora.hxx') diff --git a/bpkg/system-package-manager-fedora.hxx b/bpkg/system-package-manager-fedora.hxx index 129a9d2..8047836 100644 --- a/bpkg/system-package-manager-fedora.hxx +++ b/bpkg/system-package-manager-fedora.hxx @@ -14,6 +14,8 @@ namespace bpkg // The system package manager implementation for Fedora and alike (Red Hat // Enterprise Linux, CentOS, etc) using the DNF frontend. // + // NOTE: the below description is also reproduced in the bpkg manual. + // // For background, a library in Fedora is normally split up into several // packages: the shared library package (e.g., libfoo), the development // files package (e.g., libfoo-devel), the static library package (e.g., @@ -27,7 +29,7 @@ namespace bpkg // name has it (see some examples below). // // For mixed packages which include both applications and libraries, the - // shared library package normally have the -libs suffix (e.g., foo-libs). + // shared library package normally has the -libs suffix (e.g., foo-libs). // // A package name may also include an upstream version based suffix if // multiple versions of the package can be installed simultaneously (e.g., @@ -51,7 +53,7 @@ namespace bpkg // // icu libicu libicu-devel libicu-doc // - // openssl openssl-devel openssl-libs + // openssl openssl-libs openssl-devel // // curl libcurl libcurl-devel // @@ -73,7 +75,7 @@ namespace bpkg // For application packages there is normally no -devel packages but // -debug*, -doc, and -common are plausible. // - // The format of the fedora-name (or alike) manifest value value is a comma- + // The format of the fedora-name (or alike) manifest value is a comma- // separated list of one or more package groups: // // [, ...] @@ -110,12 +112,12 @@ namespace bpkg // The Fedora package version has the [:]- form // where the parts correspond to the Epoch (optional upstream versioning // scheme), Version (upstream version), and Release (Fedora's package - // revision) RPM tags (see the Fedora package Versioning Guidelines and RPM - // tags documentation for details). If no explicit mapping to bpkg version - // is specified with the fedora-to-downstream-version manifest values (or - // alike), then we fallback to using the part as bpkg version. If - // explicit mapping is specified, then we match it against the - // [:] parts ignoring . + // revision) RPM tags (see the Fedora Package Versioning Guidelines and RPM + // tags documentation for details). If no explicit mapping to the bpkg + // version is specified with the fedora-to-downstream-version (or alike) + // manifest values or none match, then we fallback to using the + // part as the bpkg version. If explicit mapping is specified, then we match + // it against the [:] parts ignoring . // struct system_package_status_fedora: system_package_status { @@ -127,28 +129,56 @@ namespace bpkg string common; strings extras; - string devel_fallback; // Fallback based on project name. + string fallback; // Fallback based on project name. - // @@ Rename. package_info? - // - // The `apt-cache policy` output. + // The `dnf list` output. // - struct package_policy + struct package_info { string name; string installed_version; // Empty if none. string candidate_version; // Empty if none and no installed_version. + // The installed/candidate package version architecture. Can be the host + // architecture or noarch. + // + // Note that in Fedora the same package version can be available for + // multiple architectures or be architecture-independent. For example: + // + // dbus-libs-1:1.12.22-1.fc35.i686 + // dbus-libs-1:1.12.22-1.fc35.x86_64 + // dbus-common-1:1.12.22-1.fc35.noarch + // code-insiders-1.75.0-1675123170.el7.armv7hl + // code-insiders-1.75.0-1675123170.el7.aarch64 + // code-insiders-1.75.0-1675123170.el7.x86_64 + // + // Thus, on package query you normally need to qualify the package with + // the architecture suffix or filter the query result, normally skipping + // packages which are specific for architecture other than the host + // architecture. + // + string installed_arch; + string candidate_arch; + explicit - package_policy (string n): name (move (n)) {} + package_info (string n): name (move (n)) {} + + bool + unknown () const + { + return installed_version.empty () && candidate_version.empty (); + } + + bool + known () const {return !unknown ();} }; - vector package_policies; - size_t package_policies_main = 0; // Size of the main group. + vector package_infos; + size_t package_infos_main = 0; // Size of the main group. explicit - system_package_status_fedora (string m, string d = {}) - : main (move (m)), devel (move (d)) + system_package_status_fedora (string m, string d = {}, string f = {}) + : main (move (m)), devel (move (d)), fallback (move (f)) { assert (!main.empty () || !devel.empty ()); } @@ -166,9 +196,8 @@ namespace bpkg pkg_install (const vector&) override; public: - // Note: expects os_release::name_id to be "fedora" or os_release::like_id - // to contain "fedora". - // + // Expects os_release::name_id to be "fedora" or os_release::like_ids to + // contain "fedora". using system_package_manager::system_package_manager; // Implementation details exposed for testing (see definitions for @@ -176,16 +205,30 @@ namespace bpkg // public: using package_status = system_package_status_fedora; - using package_policy = package_status::package_policy; + using package_info = package_status::package_info; void - dnf_list (vector&, size_t = 0); + dnf_list (vector&, size_t = 0); vector> - dnf_repoquery_requires (const string&, const string&); + dnf_repoquery_requires (const string&, const string&, const string&); + + void + dnf_makecache (); + + void + dnf_install (const strings&); + + pair + dnf_common (const char*); static package_status - parse_name_value (const string&, bool, bool, bool); + parse_name_value (const package_name&, const string&, bool, bool, bool); + + static string + main_from_dev (const string&, + const string&, + const vector>&); // @@ TODO // -- cgit v1.1