1 /*
2  * Copyright (C) 2012-2015 Red Hat, Inc.
3  *
4  * Licensed under the GNU Lesser General Public License Version 2.1
5  *
6  * This library is free software; you can redistribute it and/or
7  * modify it under the terms of the GNU Lesser General Public
8  * License as published by the Free Software Foundation; either
9  * version 2.1 of the License, or (at your option) any later version.
10  *
11  * This library is distributed in the hope that it will be useful,
12  * but WITHOUT ANY WARRANTY; without even the implied warranty of
13  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14  * Lesser General Public License for more details.
15  *
16  * You should have received a copy of the GNU Lesser General Public
17  * License along with this library; if not, write to the Free Software
18  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
19  */
20 
21 #ifndef HY_SACK_INTERNAL_H
22 #define HY_SACK_INTERNAL_H
23 
24 #include <stdio.h>
25 #include <solv/pool.h>
26 #include <vector>
27 
28 #include "dnf-sack.h"
29 #include "hy-query.h"
30 #include "sack/packageset.hpp"
31 #include "sack/query.hpp"
32 #include "module/ModulePackage.hpp"
33 #include "module/ModulePackageContainer.hpp"
34 
35 typedef Id  (*dnf_sack_running_kernel_fn_t) (DnfSack    *sack);
36 
37 /**
38  * @brief Store Map with only pkg_solvables to increase query performance
39  *
40  * @param sack p_sack:...
41  * @param pkg_solvables Map with only all pkg_solvables
42  * @param pool_nsolvables Number of pool_nsolvables in pool. It used as checksum.
43  */
44 void dnf_sack_set_pkg_solvables(DnfSack *sack, Map *pkg_solvables, int pool_nsolvables);
45 
46 /**
47  * @brief Returns number of pool_nsolvables at time of creation of pkg_solvables. It can be used to
48  *        verify Map contant
49  *
50  * @param sack p_sack:...
51  * @return int
52  */
53 int dnf_sack_get_pool_nsolvables(DnfSack *sack);
54 
55 /**
56  * @brief Returns pointer PackageSet with every package solvable in pool
57  *
58  * @param sack p_sack:...
59  * @return Map*
60  */
61 libdnf::PackageSet *dnf_sack_get_pkg_solvables(DnfSack *sack);
62 libdnf::ModulePackageContainer * dnf_sack_set_module_container(
63     DnfSack *sack, libdnf::ModulePackageContainer * newConteiner);
64 libdnf::ModulePackageContainer * dnf_sack_get_module_container(DnfSack *sack);
65 void         dnf_sack_make_provides_ready   (DnfSack    *sack);
66 Id           dnf_sack_running_kernel        (DnfSack    *sack);
67 void         dnf_sack_recompute_considered_map  (DnfSack * sack, Map ** considered, libdnf::Query::ExcludeFlags flags);
68 void         dnf_sack_recompute_considered  (DnfSack    *sack);
69 Id           dnf_sack_last_solvable         (DnfSack    *sack);
70 const char * dnf_sack_get_arch              (DnfSack    *sack);
71 void         dnf_sack_set_provides_not_ready(DnfSack    *sack);
72 void         dnf_sack_set_considered_to_update(DnfSack * sack);
73 Queue       *dnf_sack_get_installonly       (DnfSack    *sack);
74 void         dnf_sack_set_running_kernel_fn (DnfSack    *sack,
75                                              dnf_sack_running_kernel_fn_t fn);
76 DnfPackage  *dnf_sack_add_cmdline_package_flags   (DnfSack *sack,
77                             const char *fn, const int flags);
78 std::pair<std::vector<std::vector<std::string>>, libdnf::ModulePackageContainer::ModuleErrorType> dnf_sack_filter_modules_v2(
79     DnfSack *sack, libdnf::ModulePackageContainer * moduleContainer, const char ** hotfixRepos,
80     const char *install_root, const char * platformModule, bool updateOnly, bool debugSolver, bool applyObsoletes);
81 
82 std::vector<libdnf::ModulePackage *> requiresModuleEnablement(DnfSack * sack, const libdnf::PackageSet * installSet);
83 
84 /**
85  * @brief Return fingerprint of installed RPMs.
86  * The format is <count>:<hash>.
87  * <count> is a count of installed RPMs.
88  * <hash> is a sha1 hash of sorted sha1hdr hashes of installed RPMs.
89  *
90  * The count can be computed from the command line by running:
91  * rpm -qa --qf='%{name}\n' | grep -v '^gpg-pubkey$' | wc -l
92  *
93  * The hash can be computed from the command line by running:
94  * rpm -qa --qf='%{name} %{sha1header}\n' | grep -v '^gpg-pubkey ' \
95  * | cut -d ' ' -f 2 | LC_ALL=C sort | tr -d '\n' | sha1sum
96  */
97 std::string dnf_sack_get_rpmdb_version(DnfSack *sack);
98 
99 #endif // HY_SACK_INTERNAL_H
100