]> cygwin.com Git - cygwin-apps/setup.git/blob - package_meta.h
Don't show source-only packages in package list
[cygwin-apps/setup.git] / package_meta.h
1 /*
2 * Copyright (c) 2001, 2003 Robert Collins.
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
16 #ifndef SETUP_PACKAGE_META_H
17 #define SETUP_PACKAGE_META_H
18
19 class packageversion;
20 class packagemeta;
21 class category;
22
23 /* Required to parse this completely */
24 #include <set>
25 #include "PackageTrust.h"
26 #include "package_version.h"
27 #include "package_message.h"
28
29 typedef std::pair<const std::string, std::vector<packagemeta *> > Category;
30
31 /* NOTE: A packagemeta without 1 packageversion is invalid! */
32 class packagemeta
33 {
34 public:
35 static void ScanDownloadedFiles (bool);
36 packagemeta (packagemeta const &);
37 packagemeta (const std::string& pkgname)
38 : name (pkgname), key(pkgname), user_picked (false)
39 {
40 }
41
42 ~packagemeta ();
43
44 void add_version (packageversion &);
45 void set_installed (packageversion &);
46 void addToCategoryBase();
47 bool hasNoCategories() const;
48 void setDefaultCategories();
49 void addToCategoryAll();
50
51 class _actions
52 {
53 public:
54 _actions ():_value (0) {};
55 _actions (int aInt) {
56 _value = aInt;
57 if (_value < 0 || _value > 3)
58 _value = 0;
59 }
60 _actions & operator ++ ();
61 bool operator == (_actions const &rhs) { return _value == rhs._value; }
62 bool operator != (_actions const &rhs) { return _value != rhs._value; }
63 const char *caption ();
64 private:
65 int _value;
66 };
67 static const _actions Default_action;
68 static const _actions Install_action;
69 static const _actions Reinstall_action;
70 static const _actions Uninstall_action;
71 void set_action (trusts const t);
72 void set_action (_actions, packageversion const & default_version);
73 void uninstall ();
74
75 void set_message (const std::string& message_id, const std::string& message_string)
76 {
77 message.set (message_id, message_string);
78 }
79
80 std::string action_caption () const;
81 packageversion trustp (bool _default, trusts const t) const
82 {
83 /* If the user chose "test" and a "test" version is available, return it. */
84 if (t == TRUST_TEST && exp)
85 return exp;
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
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 }
100 /* Otherwise, if a "curr" version exists, return "curr". */
101 if (curr)
102 return curr;
103 /* Otherwise return the installed version. */
104 return installed;
105 }
106
107 std::string name; /* package name, like "cygwin" */
108 std::string key;
109
110 /* true if package was selected on command-line. */
111 bool isManuallyWanted() const;
112 /* true if package was deleted on command-line. */
113 bool isManuallyDeleted() const;
114 /* SDesc is global in theory, across all package versions.
115 LDesc is not: it can be different per version */
116 const std::string SDesc () const;
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 */
120 void add_category (const std::string& );
121 std::set <std::string, casecompare_lt_op> categories;
122 const std::string getReadableCategoryList () const;
123 std::set <packageversion> versions;
124
125 /* Did the user already pick a version at least once? */
126 bool user_picked;
127 /* which one is installed. */
128 packageversion installed;
129 /* which one is listed as "prev" in our available packages db */
130 packageversion prev;
131 /* ditto for current - stable */
132 packageversion curr;
133 /* and finally the experimental version */
134 packageversion exp;
135 /* Now for the user stuff :] */
136 /* What version does the user want ? */
137 packageversion desired;
138
139 packagemessage message;
140
141 /* can one or more versions be installed? */
142 bool accessible () const;
143 bool sourceAccessible() const;
144
145 bool isBinary() const;
146
147 void logSelectionStatus() const;
148 void logAllVersions() const;
149
150 protected:
151 packagemeta &operator= (packagemeta const &);
152 private:
153 std::string trustLabel(packageversion const &) const;
154 };
155
156 #endif /* SETUP_PACKAGE_META_H */
This page took 0.043674 seconds and 6 git commands to generate.