1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
|
diff --git a/paludis/repositories/e/e_repository_news.cc b/paludis/repositories/e/e_repository_news.cc
index 8a16893..647ce8d 100644
--- a/paludis/repositories/e/e_repository_news.cc
+++ b/paludis/repositories/e/e_repository_news.cc
@@ -161,13 +161,14 @@ ERepositoryNews::update_news() const
NewsFile news(*d / (d->basename() + ".en.txt"));
bool show(true);
- const EAPI & eapi(*erepository::EAPIData::get_instance()->eapi_from_string(
- _imp->e_repository->params().profile_eapi_when_unspecified()));
-
if (news.begin_display_if_installed() != news.end_display_if_installed())
{
Context header_context("When checking Display-If-Installed headers:");
+ const EAPI & eapi(*erepository::EAPIData::get_instance()->eapi_from_string(
+ (news.version().compare(0, 2, "2.",0, 2) == 0 ) ? "5" :
+ (news.version().compare(0, 2, "1.",0, 2) == 0 ) ? "0" :
+ _imp->e_repository->params().profile_eapi_when_unspecified()));
bool local_show(false);
for (NewsFile::DisplayIfInstalledConstIterator i(news.begin_display_if_installed()),
i_end(news.end_display_if_installed()) ; i != i_end ; ++i)
@@ -206,9 +207,23 @@ ERepositoryNews::update_news() const
Log::get_instance()->message("e.news.profile_path", ll_debug, lc_no_context) <<
"Profile path is '" << profile << "'";
for (NewsFile::DisplayIfProfileConstIterator i(news.begin_display_if_profile()),
- i_end(news.end_display_if_profile()) ; i != i_end ; ++i)
- if (profile == *i)
- local_show = true;
+ i_end(news.end_display_if_profile()) ; i != i_end ; ++i){
+ if ( 0 == news.version().compare(0, 2, "1.", 0, 2))
+ {
+ if (profile == *i)
+ local_show = true;
+ }
+ else if ( 0 == news.version().compare(0, 2, "2.", 0, 2))
+ {
+ // Check wildcard ( "/*" ) profile paths
+ if ( 0 == (*i).compare((*i).length() - 2, 2, "/*")){
+ if ( 0 == (profile.compare(0, (*i).length()-2, *i, 0, (*i).length() -2 )))
+ local_show = true;
+ }
+ else if ( profile == *i )
+ local_show = true;
+ }
+ }
}
show &= local_show;
}
@@ -263,6 +278,7 @@ namespace paludis
DisplayIfList display_if_installed;
DisplayIfList display_if_keyword;
DisplayIfList display_if_profile;
+ std::string version;
};
}
@@ -318,12 +334,27 @@ NewsFile::NewsFile(const FSPath & our_filename) :
throw NewsError(our_filename, "Multiple News-Item-Format headers specified");
seen_news_item_format = true;
- if (0 != v.compare(0, 2, "1.", 0, 2))
+ if ( 0 == v.compare(0, 2, "1.",0, 2) )
+ {
+ if ( v != "1.0" )
+ {
+ Log::get_instance()->message("e.news.format", ll_warning, lc_context) <<
+ "News file '" << our_filename << "' uses news item format '" << v << "', but we only support "
+ "version 1 news up to 1.0.";
+ }
+ }
+ else if ( 0 == v.compare(0, 2, "2.", 0, 2))
+ {
+ if ( v != "2.0")
+ {
+ Log::get_instance()->message("e.news.format", ll_warning, lc_context) <<
+ "News file '" << our_filename << "' uses news item format '" << v << "', but we only support "
+ "version 2 news items up to 2.0.";
+ }
+ }
+ else
throw NewsError(our_filename, "Unsupported News-Item-Format '" + v + "'");
- if (v != "1.0")
- Log::get_instance()->message("e.news.format", ll_warning, lc_context) <<
- "News file '" << our_filename << "' uses news item format '" << v << "', but we only support "
- "versions up to 1.0.";
+ _imp->version = v;
}
else if (k == "Posted")
seen_posted = true;
@@ -338,7 +369,7 @@ NewsFile::NewsFile(const FSPath & our_filename) :
throw NewsError(our_filename, "No News-Item-Format header specified");
if (! seen_author)
throw NewsError(our_filename, "No Author header specified");
- if (! seen_content_type)
+ if ( _imp->version == "1.0" && ! seen_content_type)
throw NewsError(our_filename, "No Content-Type header specified");
if (! seen_title)
throw NewsError(our_filename, "No Title header specified");
@@ -391,6 +422,10 @@ NewsError::NewsError(const FSPath & f, const std::string & m) noexcept :
{
}
+std::string NewsFile::version() const{
+ return _imp->version;
+}
+
namespace paludis
{
template class WrappedForwardIterator<NewsFile::DisplayIfInstalledConstIteratorTag, const std::string>;
diff --git a/paludis/repositories/e/e_repository_news.hh b/paludis/repositories/e/e_repository_news.hh
index 55beb3f..d3cd860 100644
--- a/paludis/repositories/e/e_repository_news.hh
+++ b/paludis/repositories/e/e_repository_news.hh
@@ -93,6 +93,7 @@ namespace paludis
///\}
+ std::string version() const;
///\name Iterate over our Display-If-Installed headers
///\{
|