1 /* 2 * Copyright (C) 2012-2013 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_GOAL_H 22 #define HY_GOAL_H 23 24 #include <glib.h> 25 #include <stdbool.h> 26 27 G_BEGIN_DECLS 28 29 #include "hy-types.h" 30 #include "dnf-sack.h" 31 #include "dnf-utils.h" 32 33 enum _hy_goal_op_flags { 34 HY_CHECK_INSTALLED = 1 << 0, 35 HY_CLEAN_DEPS = 1 << 1, 36 HY_WEAK_SOLV = 1 << 2 37 }; 38 39 typedef enum { 40 DNF_NONE = 0, 41 DNF_ERASE = 1 << 0, 42 DNF_DISTUPGRADE = 1 << 1, 43 DNF_DISTUPGRADE_ALL = 1 << 2, 44 DNF_DOWNGRADE = 1 << 3, 45 DNF_INSTALL = 1 << 4, 46 DNF_UPGRADE = 1 << 5, 47 DNF_UPGRADE_ALL = 1 << 6, 48 49 // hy_goal_run flags 50 DNF_ALLOW_UNINSTALL = 1 << 10, 51 DNF_FORCE_BEST = 1 << 11, 52 DNF_VERIFY = 1 << 12, 53 DNF_IGNORE_WEAK_DEPS = 1 << 13, 54 DNF_ALLOW_DOWNGRADE = 1 << 14, 55 DNF_IGNORE_WEAK = 1 << 15 56 } DnfGoalActions; 57 58 typedef enum { 59 DNF_PACKAGE_STATE_ALL = 0, 60 DNF_PACKAGE_STATE_AVAILABLE = 1, 61 DNF_PACKAGE_STATE_INSTALLED = 2 62 } DnfPackageState; 63 64 #define HY_REASON_DEP 1 65 #define HY_REASON_USER 2 66 #define HY_REASON_CLEAN 3 67 #define HY_REASON_WEAKDEP 4 68 69 HyGoal hy_goal_create(DnfSack *sack); 70 HyGoal hy_goal_clone(HyGoal goal); 71 void hy_goal_free(HyGoal goal); 72 DnfSack *hy_goal_get_sack(HyGoal goal); 73 74 int hy_goal_distupgrade_all(HyGoal goal); 75 int hy_goal_distupgrade(HyGoal goal, DnfPackage *new_pkg); 76 int hy_goal_distupgrade_selector(HyGoal goal, HySelector); 77 78 /** 79 * @brief Mark a package to install. It doesn't check if the package has a lower version than 80 * installed package or even installed. It allows to downgrade dependencies if needed. It return 81 * always 0. 82 * 83 * @param goal HyGoal 84 * @param new_pkg DnfPackage 85 * @return int 86 */ 87 DEPRECATED("Will be removed after 2018-03-01. Use hy_goal_install() instead.") 88 int hy_goal_downgrade_to(HyGoal goal, DnfPackage *new_pkg); 89 int hy_goal_erase(HyGoal goal, DnfPackage *pkg); 90 int hy_goal_erase_flags(HyGoal goal, DnfPackage *pkg, int flags); 91 92 /** 93 * Erase packages specified by the Selector. 94 * 95 * @returns 0 on success, DNF_ERROR_BAD_SELECTOR for an invalid Selector. 96 */ 97 int hy_goal_erase_selector_flags(HyGoal goal, HySelector sltr, int flags); 98 99 /** 100 * @brief Mark package to install or if installed to downgrade or upgrade. It allows to downgrade 101 * dependencies if needed. Return value is always 0. 102 * 103 * @param goal HyGoal 104 * @param new_pkg Package to install 105 * @return int 106 */ 107 int hy_goal_install(HyGoal goal, DnfPackage *new_pkg); 108 109 /** 110 * @brief Mark package to install or if installed to downgrade or upgrade. In case that package 111 * cannot be install, it can be skipped without an error. It allows to downgrade dependencies if 112 * needed. Return value is always 0. 113 * 114 * @param goal HyGoal 115 * @param new_pkg Package to install 116 * @return int 117 */ 118 int hy_goal_install_optional(HyGoal goal, DnfPackage *new_pkg); 119 120 /** 121 * @brief Lock package state. If installed, remains installed. If uninstalled, 122 * remains uninstalled. Returns 0 on success. 123 * 124 * @param goal HyGoal 125 * @param pkg Package to lock 126 * @return int 127 */ 128 int hy_goal_lock(HyGoal goal, DnfPackage *pkg, GError **error); 129 130 /** 131 * @brief Favor package when considering alternatives. Return value is always 0. 132 * 133 * @param goal HyGoal 134 * @param pkg Package to favor 135 * @return int 136 */ 137 int hy_goal_favor(HyGoal goal, DnfPackage *pkg); 138 139 /** 140 * @brief Disfavor package when considering alternatives. Return value is always 0. 141 * 142 * @param goal HyGoal 143 * @param pkg Package to disfavor 144 * @return int 145 */ 146 int hy_goal_disfavor(HyGoal goal, DnfPackage *pkg); 147 148 /** 149 * @brief Mark content of HySelector to install or if installed to downgrade or upgrade. Only one 150 * option will be chosen. It allows to downgrade dependencies if needed. If not supported 151 * combination in selectort, it triggers assertion raise. 152 * 153 * @param goal HyGoal 154 * @param sltr HySelector 155 * @param error p_error:... 156 * @return gboolean 157 */ 158 gboolean hy_goal_install_selector(HyGoal goal, HySelector sltr, GError **error); 159 160 /** 161 * @brief Mark content of HySelector to install or if installed to downgrade or upgrade. In case that 162 * any package in selector cannot be install, it can be skipped without an error. Only one option 163 * will be chosen. It allows to downgrade dependencies if needed. If not supported combination in 164 * selectort, it triggers assertion raise. 165 * 166 * @param goal HyGoal 167 * @param sltr HySelector 168 * @param error p_error:... 169 * @return gboolean 170 */ 171 gboolean hy_goal_install_selector_optional(HyGoal goal, HySelector sltr, GError **error); 172 int hy_goal_upgrade_all(HyGoal goal); 173 int hy_goal_upgrade_to(HyGoal goal, DnfPackage *new_pkg); 174 int hy_goal_upgrade_selector(HyGoal goal, HySelector sltr); 175 int hy_goal_userinstalled(HyGoal goal, DnfPackage *pkg); 176 177 /* introspecting the requests */ 178 int hy_goal_has_actions(HyGoal goal, DnfGoalActions action); 179 180 int hy_goal_req_length(HyGoal goal); 181 182 /* resolving the goal */ 183 int hy_goal_run_flags(HyGoal goal, DnfGoalActions flags); 184 185 /* problems */ 186 int hy_goal_count_problems(HyGoal goal); 187 DnfPackageSet *hy_goal_conflict_all_pkgs(HyGoal goal, DnfPackageState pkg_type); 188 DnfPackageSet *hy_goal_broken_dependency_all_pkgs(HyGoal goal, DnfPackageState pkg_type); 189 190 int hy_goal_log_decisions(HyGoal goal); 191 bool hy_goal_write_debugdata(HyGoal goal, const char *dir, GError **error); 192 193 /* result processing */ 194 GPtrArray *hy_goal_list_erasures(HyGoal goal, GError **error); 195 GPtrArray *hy_goal_list_installs(HyGoal goal, GError **error); 196 GPtrArray *hy_goal_list_obsoleted(HyGoal goal, GError **error); 197 GPtrArray *hy_goal_list_reinstalls(HyGoal goal, GError **error); 198 GPtrArray *hy_goal_list_unneeded(HyGoal goal, GError **error); 199 GPtrArray *hy_goal_list_suggested(HyGoal goal, GError **error); 200 GPtrArray *hy_goal_list_upgrades(HyGoal goal, GError **error); 201 GPtrArray *hy_goal_list_downgrades(HyGoal goal, GError **error); 202 GPtrArray *hy_goal_list_obsoleted_by_package(HyGoal goal, DnfPackage *pkg); 203 int hy_goal_get_reason(HyGoal goal, DnfPackage *pkg); 204 205 G_END_DECLS 206 207 #endif 208