]>
Commit | Line | Data |
---|---|---|
7939f6d1 | 1 | /* |
d55e14fe | 2 | * Copyright (c) 2001, 2003 Robert Collins. |
7939f6d1 RC |
3 | * |
4 | * This program is free software; you can redistribute it and/or modify | |
5 | * it under the terms of the GNU General Public License as published by | |
6 | * the Free Software Foundation; either version 2 of the License, or | |
7 | * (at your option) any later version. | |
8 | * | |
9 | * A copy of the GNU General Public License can be found at | |
10 | * http://www.gnu.org/ | |
11 | * | |
12 | * Written by Robert Collins <rbtcollins@hotmail.com> | |
13 | * | |
14 | */ | |
15 | ||
c93bc6d0 MB |
16 | #ifndef SETUP_PACKAGE_META_H |
17 | #define SETUP_PACKAGE_META_H | |
7939f6d1 | 18 | |
f3992588 JT |
19 | class SolvableVersion; |
20 | typedef SolvableVersion packageversion; | |
bb849dbd | 21 | class packagemeta; |
7939f6d1 | 22 | |
3c196821 | 23 | #include <set> |
621df5b3 | 24 | #include <vector> |
076654e7 | 25 | #include "PackageTrust.h" |
3c196821 | 26 | #include "package_version.h" |
f38044ff | 27 | #include "package_message.h" |
621df5b3 | 28 | #include "script.h" |
8ba85a54 | 29 | #include "ActionList.h" |
bb849dbd | 30 | |
d19f12fd | 31 | typedef std::pair<const std::string, std::vector<packagemeta *> > Category; |
ee4ad3a7 | 32 | |
1c159e0a | 33 | /* NOTE: A packagemeta without 1 version is invalid! */ |
7939f6d1 RC |
34 | class packagemeta |
35 | { | |
36 | public: | |
f1486891 | 37 | static void ScanDownloadedFiles (bool); |
3c196821 | 38 | packagemeta (packagemeta const &); |
10cac838 | 39 | packagemeta (const std::string& pkgname) |
4c46018d | 40 | : name (pkgname), user_picked (false), |
8efd971b | 41 | _action(NoChange_action), _picked(false), _srcpicked(false) |
7939f6d1 | 42 | { |
3c054baf | 43 | } |
fa0c0d10 | 44 | |
7c6ef2c3 | 45 | ~packagemeta (); |
7939f6d1 | 46 | |
fa6e8a64 | 47 | SolvableVersion add_version (const SolverPool::addPackageData &); |
1c159e0a | 48 | void set_installed_version (const std::string &); |
0407753c | 49 | void addToCategoryBase(); |
31f0ccce RC |
50 | bool hasNoCategories() const; |
51 | void setDefaultCategories(); | |
358712d8 | 52 | void addToCategoryAll(); |
7e8fc33c | 53 | |
9ae1ac43 JT |
54 | enum _actions |
55 | { | |
916f2b80 | 56 | NoChange_action = 1, // keep if installed, skip if not installed |
9ae1ac43 JT |
57 | Install_action, |
58 | Reinstall_action, | |
59 | Uninstall_action, | |
60 | }; | |
f34a20e7 | 61 | static unsigned int action_caption (_actions value); |
9ae1ac43 | 62 | |
dbd295e7 JT |
63 | void set_action (_actions, packageversion const & default_version, |
64 | bool useraction = false); | |
8ba85a54 JT |
65 | ActionList *list_actions(trusts const trust); |
66 | void select_action (int id, trusts const deftrust); | |
76dc99c1 | 67 | void toggle_action (); |
8efd971b | 68 | _actions get_action () { return _action; } |
8aac1adc | 69 | |
f38044ff CF |
70 | void set_message (const std::string& message_id, const std::string& message_string) |
71 | { | |
72 | message.set (message_id, message_string); | |
73 | } | |
7939f6d1 | 74 | |
d2e0c29e JT |
75 | void set_version_blacklist(std::set <std::string> &_list) |
76 | { | |
77 | version_blacklist = _list; | |
78 | } | |
79 | ||
f34a20e7 | 80 | std::wstring action_caption () const; |
ced3a1ae | 81 | packageversion trustp (bool _default, trusts const t) const |
97647369 | 82 | { |
ced3a1ae | 83 | /* If the user chose "test" and a "test" version is available, return it. */ |
ec9c1d70 AK |
84 | if (t == TRUST_TEST && exp) |
85 | return exp; | |
ced3a1ae CV |
86 | /* Are we looking for the default version and does the installed version |
87 | have a higher version number than the "curr" package? This means the | |
88 | user has installed a "test" version, or built her own version newer | |
3e62a083 CV |
89 | than "curr". Rather than pulling the user back to "curr", we install |
90 | "test" if a "test" version is available and the version number is higher, | |
91 | or we stick to "installed" if not. This reflects the behaviour of | |
92 | `yum update' on Fedora. */ | |
93 | if (_default && curr && installed | |
94 | && packageversion::compareVersions (curr, installed) < 0) | |
95 | { | |
96 | if (exp && packageversion::compareVersions (installed, exp) < 0) | |
97 | return exp; | |
98 | return installed; | |
99 | } | |
ced3a1ae CV |
100 | /* Otherwise, if a "curr" version exists, return "curr". */ |
101 | if (curr) | |
ec9c1d70 | 102 | return curr; |
ced3a1ae CV |
103 | /* Otherwise return the installed version. */ |
104 | return installed; | |
97647369 | 105 | } |
cbfc4215 | 106 | |
1eb2461a | 107 | std::string name; /* package name, like "cygwin" */ |
f480a7df | 108 | |
0407753c | 109 | /* true if package was selected on command-line. */ |
bacef89a | 110 | bool isManuallyWanted(packageversion &version) const; |
a667a8b2 CV |
111 | /* true if package was deleted on command-line. */ |
112 | bool isManuallyDeleted() const; | |
e8f2c078 | 113 | |
1eb2461a | 114 | const std::string SDesc () const; |
e8f2c078 JT |
115 | const std::string LDesc () const; |
116 | ||
bb849dbd RC |
117 | /* what categories does this package belong in. Note that if multiple versions |
118 | * of a package disagree.... the first one read in will take precedence. | |
119 | */ | |
1eb2461a | 120 | void add_category (const std::string& ); |
d19f12fd | 121 | std::set <std::string, casecompare_lt_op> categories; |
1eb2461a | 122 | const std::string getReadableCategoryList () const; |
666bf37d | 123 | std::set <packageversion> versions; |
fa0c0d10 | 124 | |
10cac838 CV |
125 | /* Did the user already pick a version at least once? */ |
126 | bool user_picked; | |
7939f6d1 | 127 | /* which one is installed. */ |
3c196821 | 128 | packageversion installed; |
ec7c556d | 129 | /* which one is listed as "current" (stable) in our available packages db */ |
3c196821 | 130 | packageversion curr; |
ec7c556d | 131 | /* ditto for "test" (experimental) */ |
3c196821 | 132 | packageversion exp; |
eb09ab39 | 133 | /* which one is the default according to the solver */ |
9deed604 | 134 | packageversion default_version; |
bb849dbd RC |
135 | /* Now for the user stuff :] */ |
136 | /* What version does the user want ? */ | |
3c196821 | 137 | packageversion desired; |
7e8fc33c | 138 | |
4209699d JT |
139 | bool picked() const; /* true if desired version is to be (re-)installed */ |
140 | void pick(bool); /* trigger an install/reinstall */ | |
141 | ||
142 | bool srcpicked() const; /* true if source for desired version is to be installed */ | |
143 | void srcpick(bool); | |
144 | ||
3c196821 RC |
145 | /* can one or more versions be installed? */ |
146 | bool accessible () const; | |
147 | bool sourceAccessible() const; | |
148 | ||
c23d96d6 JT |
149 | bool isBinary() const; |
150 | ||
d55e14fe | 151 | void logSelectionStatus() const; |
f416a2b6 RC |
152 | void logAllVersions() const; |
153 | ||
621df5b3 JT |
154 | void addScript(Script const &); |
155 | std::vector <Script> &scripts(); | |
156 | ||
d2e0c29e JT |
157 | /* this version is undesirable */ |
158 | bool isBlacklisted(const packageversion &version) const; | |
159 | ||
cbfc4215 | 160 | protected: |
cbfc4215 | 161 | packagemeta &operator= (packagemeta const &); |
f416a2b6 | 162 | private: |
1eb2461a | 163 | std::string trustLabel(packageversion const &) const; |
621df5b3 | 164 | std::vector <Script> scripts_; |
e8cc4542 | 165 | static bool scan (const packageversion &pkg, bool mirror_mode); |
bacef89a | 166 | const packageversion * findVersion(std::string &version) const; |
c58b62ea | 167 | |
8efd971b JT |
168 | _actions _action; |
169 | ||
4209699d JT |
170 | bool _picked; /* true if desired version is to be (re)installed */ |
171 | bool _srcpicked; | |
d2e0c29e | 172 | |
feed8d92 | 173 | packagemessage message; |
d2e0c29e | 174 | std::set <std::string> version_blacklist; |
7939f6d1 RC |
175 | }; |
176 | ||
c93bc6d0 | 177 | #endif /* SETUP_PACKAGE_META_H */ |