aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAvatar Ciaran McCreesh <ciaran.mccreesh@googlemail.com> 2006-05-02 20:54:21 +0000
committerAvatar Ciaran McCreesh <ciaran.mccreesh@googlemail.com> 2006-05-02 20:54:21 +0000
commit772618db2d843a7a8960f767d7409f9edc8e6d5f (patch)
tree4c3ca2561768e3b260f68eb9a9288cd68031ed22
parent834c1ba8fb264eba018c39dc30cef99b6ee4ca9d (diff)
downloadpaludis-772618db2d843a7a8960f767d7409f9edc8e6d5f.tar.gz
paludis-772618db2d843a7a8960f767d7409f9edc8e6d5f.tar.xz
GLEP 42 support
-rw-r--r--hooks/Makefile.am.m422
-rwxr-xr-xhooks/news.bash51
-rw-r--r--paludis/config_file.cc30
-rw-r--r--paludis/config_file.hh59
-rw-r--r--paludis/portage_repository.cc118
-rw-r--r--paludis/portage_repository.hh4
-rw-r--r--paludis/repository.hh7
-rw-r--r--src/Makefile.am1
-rw-r--r--src/command_line.cc7
-rw-r--r--src/command_line.hh15
-rw-r--r--src/install.cc16
-rw-r--r--src/news.cc50
-rw-r--r--src/news.hh34
-rw-r--r--src/paludis.cc10
14 files changed, 413 insertions, 11 deletions
diff --git a/hooks/Makefile.am.m4 b/hooks/Makefile.am.m4
index f83685e..9bcb9f8 100644
--- a/hooks/Makefile.am.m4
+++ b/hooks/Makefile.am.m4
@@ -7,17 +7,23 @@ MAINTAINERCLEANFILES = Makefile.in Makefile.am
CLEANFILES = *~ gmon.out *.gcov *.gcno *.gcda .keep
SUBDIRS = .
+installvarlibpaludisnewsdir = /var/lib/paludis/news
+
installhookcommonprogdir = $(libexecdir)/paludis/hooks/common
installhookinstallallpostdir = $(libexecdir)/paludis/hooks/install_all_post
installhookcommonprog_SCRIPTS = \
gnu_info_index.bash \
eselect_env_update.bash \
- log.bash
+ log.bash \
+ news.bash
installhookinstallallpost_SCRIPTS = \
find_config_updates.bash
+installvarlibpaludisnews_SCRIPTS = \
+ .keep
+
TESTS_ENVIRONMENT = env \
PALUDIS_EBUILD_DIR="$(srcdir)/ebuild/" \
TEST_SCRIPT_DIR="$(srcdir)/" \
@@ -44,6 +50,8 @@ userhook(`install_pre')
userhook(`install_post')
userhook(`install_all_pre')
userhook(`install_all_post')
+userhook(`install_pretend_pre')
+userhook(`install_pretend_post')
userhook(`uninstall_pre')
userhook(`uninstall_post')
userhook(`uninstall_all_pre')
@@ -101,12 +109,16 @@ systemhook(`install_pre')
systemhook(`install_post')
systemhook(`install_all_pre')
systemhook(`install_all_post')
+systemhook(`install_pretend_pre')
+systemhook(`install_pretend_post')
systemhook(`uninstall_pre')
systemhook(`uninstall_post')
systemhook(`uninstall_all_pre')
systemhook(`uninstall_all_post')
systemhook(`sync_pre')
systemhook(`sync_post')
+systemhook(`sync_all_pre')
+systemhook(`sync_all_post')
systemhook(`fetch_all_pre')
systemhook(`fetch_all_post')
systemhook(`fetch_all_all_pre')
@@ -121,8 +133,12 @@ install-data-local :
install -d $(DESTDIR)/$(libexecdir)/paludis/hooks/install_post/
install -d $(DESTDIR)/$(libexecdir)/paludis/hooks/install_all_pre/
install -d $(DESTDIR)/$(libexecdir)/paludis/hooks/install_all_post/
+ install -d $(DESTDIR)/$(libexecdir)/paludis/hooks/install_pretend_pre/
+ install -d $(DESTDIR)/$(libexecdir)/paludis/hooks/install_pretend_post/
install -d $(DESTDIR)/$(libexecdir)/paludis/hooks/sync_pre/
install -d $(DESTDIR)/$(libexecdir)/paludis/hooks/sync_post/
+ install -d $(DESTDIR)/$(libexecdir)/paludis/hooks/sync_all_pre/
+ install -d $(DESTDIR)/$(libexecdir)/paludis/hooks/sync_all_post/
install -d $(DESTDIR)/$(libexecdir)/paludis/hooks/fetch_all_pre/
install -d $(DESTDIR)/$(libexecdir)/paludis/hooks/fetch_all_post/
install -d $(DESTDIR)/$(libexecdir)/paludis/hooks/fetch_pre/
@@ -145,11 +161,15 @@ install-data-local :
ln -sf ../common/log.bash $(DESTDIR)/$(libexecdir)/paludis/hooks/uninstall_post/
ln -sf ../common/log.bash $(DESTDIR)/$(libexecdir)/paludis/hooks/sync_pre/
ln -sf ../common/log.bash $(DESTDIR)/$(libexecdir)/paludis/hooks/sync_post/
+ ln -sf ../common/news.bash $(DESTDIR)/$(libexecdir)/paludis/hooks/sync_all_post/
+ ln -sf ../common/news.bash $(DESTDIR)/$(libexecdir)/paludis/hooks/install_all_post/
+ ln -sf ../common/news.bash $(DESTDIR)/$(libexecdir)/paludis/hooks/install_pretend_post/
uninstall-local :
rm $(DESTDIR)/$(libexecdir)/paludis/hooks/*/gnu_info_index.bash
rm $(DESTDIR)/$(libexecdir)/paludis/hooks/*/eselect_env_update.bash
rm $(DESTDIR)/$(libexecdir)/paludis/hooks/*/log.bash
+ rm $(DESTDIR)/$(libexecdir)/paludis/hooks/*/news.bash
Makefile.am : Makefile.am.m4
$(top_srcdir)/misc/do_m4.bash Makefile.am
diff --git a/hooks/news.bash b/hooks/news.bash
new file mode 100755
index 0000000..22946c5
--- /dev/null
+++ b/hooks/news.bash
@@ -0,0 +1,51 @@
+#!/bin/bash
+# vim: set et sw=4 sts=4 :
+
+# Copyright (c) 2006 Ciaran McCreesh <ciaran.mccreesh@blueyonder.co.uk>
+#
+# This file is part of the Paludis package manager. Paludis is free software;
+# you can redistribute it and/or modify it under the terms of the GNU General
+# Public License as published by the Free Software Foundation; either version
+# 2 of the License, or (at your option) any later version.
+#
+# Paludis is distributed in the hope that it will be useful, but WITHOUT ANY
+# WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
+# FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
+# details.
+#
+# You should have received a copy of the GNU General Public License along with
+# this program; if not, write to the Free Software Foundation, Inc., 59 Temple
+# Place, Suite 330, Boston, MA 02111-1307 USA
+
+source /sbin/functions.sh
+
+mkdir -p ${ROOT}/var/lib/paludis/news/
+
+done_echo=
+
+if [[ "${HOOK/pretend}" == "${HOOK}" ]] ; then
+ [[ -z "${done_echo}" ]] && echo ; done_echo=yes
+ einfo "Checking for news items..."
+
+ ${PALUDIS_COMMAND} --update-news
+fi
+
+count=0
+for f in "${ROOT}/var/lib/paludis/news/"news-*.unread ; do
+ [[ -f "${f}" ]] || continue
+ if grep --silent . "${f}" ; then
+ count=$(( count + $(grep --count . < "${f}" ) ))
+ fi
+done
+
+if [[ ${count} -gt 0 ]] ; then
+ [[ -z "${done_echo}" ]] && echo ; done_echo=yes
+ ewarn "You have ${count} unread news items"
+ echo
+elif [[ "${HOOK/pretend}" == "${HOOK}" ]] ; then
+ [[ -z "${done_echo}" ]] && echo ; done_echo=yes
+ einfo "No unread news items found"
+fi
+
+true
+
diff --git a/paludis/config_file.cc b/paludis/config_file.cc
index 918e5f6..9f4850d 100644
--- a/paludis/config_file.cc
+++ b/paludis/config_file.cc
@@ -21,6 +21,7 @@
#include <fstream>
#include <paludis/config_file.hh>
#include <paludis/util/exception.hh>
+#include <paludis/util/log.hh>
#include <paludis/util/stringify.hh>
#include <paludis/util/strip.hh>
#include <paludis/util/tokeniser.hh>
@@ -455,3 +456,32 @@ AdvisoryFile::sanitise()
if ((_entries["Affected"].size() + _entries["Unaffected"].size()) == 0)
throw AdvisoryFileError("Missing either 'Affected' or 'Unaffected' key.");
}
+
+NewsFile::NewsFile(const FSEntry & filename) :
+ ConfigFile(filename),
+ _in_header(true)
+{
+ need_lines();
+}
+
+void
+NewsFile::accept_line(const std::string & line) const
+{
+ if (_in_header)
+ {
+ std::string::size_type p(line.find(':'));
+ if (std::string::npos == p)
+ _in_header = false;
+ else
+ {
+ std::string k(strip_leading(strip_trailing(line.substr(0, p), " \t\n"), " \t\n"));
+ std::string v(strip_leading(strip_trailing(line.substr(p + 1), " \t\n"), " \t\n"));
+ if (k == "Display-If-Installed")
+ _display_if_installed.push_back(v);
+ else if (k == "Display-If-Keyword")
+ _display_if_keyword.push_back(v);
+ if (k == "Display-If-Profile")
+ _display_if_profile.push_back(v);
+ }
+ }
+}
diff --git a/paludis/config_file.hh b/paludis/config_file.hh
index d923534..75417a7 100644
--- a/paludis/config_file.hh
+++ b/paludis/config_file.hh
@@ -497,6 +497,65 @@ namespace paludis
}
};
+ /**
+ * A NewsFile represents a GLEP 42 news file.
+ *
+ * \ingroup grpconfigfile
+ */
+ class NewsFile :
+ protected ConfigFile
+ {
+ private:
+ mutable bool _in_header;
+ mutable std::list<std::string> _display_if_installed;
+ mutable std::list<std::string> _display_if_keyword;
+ mutable std::list<std::string> _display_if_profile;
+
+ protected:
+ void accept_line(const std::string &) const;
+
+ public:
+ /**
+ * Constructor, from a filename.
+ */
+ NewsFile(const FSEntry & filename);
+
+ typedef std::list<std::string>::const_iterator DisplayIfInstalledIterator;
+
+ DisplayIfInstalledIterator begin_display_if_installed() const
+ {
+ return _display_if_installed.begin();
+ }
+
+ DisplayIfInstalledIterator end_display_if_installed() const
+ {
+ return _display_if_installed.end();
+ }
+
+ typedef std::list<std::string>::const_iterator DisplayIfKeywordIterator;
+
+ DisplayIfKeywordIterator begin_display_if_keyword() const
+ {
+ return _display_if_keyword.begin();
+ }
+
+ DisplayIfKeywordIterator end_display_if_keyword() const
+ {
+ return _display_if_keyword.end();
+ }
+
+ typedef std::list<std::string>::const_iterator DisplayIfProfileIterator;
+
+ DisplayIfProfileIterator begin_display_if_profile() const
+ {
+ return _display_if_profile.begin();
+ }
+
+ DisplayIfProfileIterator end_display_if_profile() const
+ {
+ return _display_if_profile.end();
+ }
+ };
}
#endif
diff --git a/paludis/portage_repository.cc b/paludis/portage_repository.cc
index 7fc5df7..6eb2110 100644
--- a/paludis/portage_repository.cc
+++ b/paludis/portage_repository.cc
@@ -134,6 +134,9 @@ namespace paludis
/// Sets dir
FSEntry setsdir;
+ /// News dir
+ FSEntry newsdir;
+
/// Sync URL
std::string sync;
@@ -234,6 +237,7 @@ Implementation<PortageRepository>::Implementation(const PortageRepositoryParams
eclassdir(p.get<prpk_eclassdir>()),
distdir(p.get<prpk_distdir>()),
setsdir(p.get<prpk_setsdir>()),
+ newsdir(p.get<prpk_newsdir>()),
sync(p.get<prpk_sync>()),
sync_exclude(p.get<prpk_sync_exclude>()),
root(p.get<prpk_root>()),
@@ -450,6 +454,7 @@ PortageRepository::PortageRepository(const PortageRepositoryParams & p) :
_info.insert(std::make_pair(std::string("eclassdir"), stringify(_imp->eclassdir)));
_info.insert(std::make_pair(std::string("distdir"), stringify(_imp->distdir)));
_info.insert(std::make_pair(std::string("setsdir"), stringify(_imp->setsdir)));
+ _info.insert(std::make_pair(std::string("newsdir"), stringify(_imp->newsdir)));
_info.insert(std::make_pair(std::string("format"), std::string("portage")));
_info.insert(std::make_pair(std::string("root"), stringify(_imp->root)));
if (! _imp->sync.empty())
@@ -1055,6 +1060,10 @@ PortageRepository::make_portage_repository(
if (m.end() == m.find("setsdir") || ((setsdir = m.find("setsdir")->second)).empty())
setsdir = location + "/sets";
+ std::string newsdir;
+ if (m.end() == m.find("newsdir") || ((newsdir = m.find("newsdir")->second)).empty())
+ newsdir = location + "/metadata/news";
+
std::string cache;
if (m.end() == m.find("cache") || ((cache = m.find("cache")->second)).empty())
cache = location + "/metadata/cache";
@@ -1080,6 +1089,7 @@ PortageRepository::make_portage_repository(
param<prpk_eclassdir>(eclassdir),
param<prpk_distdir>(distdir),
param<prpk_setsdir>(setsdir),
+ param<prpk_newsdir>(newsdir),
param<prpk_sync>(sync),
param<prpk_sync_exclude>(sync_exclude),
param<prpk_root>(root)))));
@@ -1661,3 +1671,111 @@ PortageRepository::end_provide_map() const
return _imp->provide_map.end();
}
+void
+PortageRepository::update_news() const
+{
+ Context context("When updating news for repository '" + stringify(name()) + "':");
+
+ if (! _imp->newsdir.is_directory())
+ return;
+
+ std::set<std::string> skip;
+ FSEntry
+ skip_file(_imp->root / "var" / "lib" / "paludis" / "news" /
+ ("news-" + stringify(name()) + ".skip")),
+ unread_file(_imp->root / "var" / "lib" / "paludis" / "news" /
+ ("news-" + stringify(name()) + ".unread"));
+
+ if (skip_file.is_regular_file())
+ {
+ Context local_context("When handling news skip file '" + stringify(skip_file) + "':");
+ LineConfigFile s(skip_file);
+ std::copy(s.begin(), s.end(), std::inserter(skip, skip.end()));
+ }
+
+ for (DirIterator d(_imp->newsdir), d_end ; d != d_end ; ++d)
+ {
+ Context local_context("When handling news entry '" + stringify(*d) + "':");
+
+ if (! d->is_directory())
+ continue;
+ if (! (*d / (d->basename() + ".en.txt")).is_regular_file())
+ continue;
+
+ if (skip.end() != skip.find(d->basename()))
+ continue;
+
+ try
+ {
+ NewsFile news(*d / (d->basename() + ".en.txt"));
+ bool show(true);
+
+ if (news.begin_display_if_installed() != news.end_display_if_installed())
+ {
+ bool local_show(false);
+ for (NewsFile::DisplayIfInstalledIterator i(news.begin_display_if_installed()),
+ i_end(news.end_display_if_installed()) ; i != i_end ; ++i)
+ if (! _imp->env->package_database()->query(PackageDepAtom::Pointer(
+ new PackageDepAtom(*i)), is_installed_only)->empty())
+ local_show = true;
+ show &= local_show;
+ }
+
+ if (news.begin_display_if_keyword() != news.end_display_if_keyword())
+ {
+ if (! _imp->has_profile)
+ {
+ _imp->add_profile(_imp->profile.realpath());
+ _imp->has_profile = true;
+ }
+
+ bool local_show(false);
+ for (NewsFile::DisplayIfKeywordIterator i(news.begin_display_if_keyword()),
+ i_end(news.end_display_if_keyword()) ; i != i_end ; ++i)
+ if (_imp->profile_env["ARCH"] == *i)
+ local_show = true;
+ show &= local_show;
+ }
+
+ if (news.begin_display_if_profile() != news.end_display_if_profile())
+ {
+ bool local_show(false);
+ std::string profile(strip_leading_string(strip_trailing_string(
+ strip_leading_string(stringify(_imp->profile.realpath()),
+ stringify(_imp->location.realpath())), "/"), "/"));
+ Log::get_instance()->message(ll_debug, "Profile path is '" + profile + "'");
+ for (NewsFile::DisplayIfProfileIterator i(news.begin_display_if_profile()),
+ i_end(news.end_display_if_profile()) ; i != i_end ; ++i)
+ if (profile == *i)
+ local_show = true;
+ show &= local_show;
+ }
+
+ if (show)
+ {
+ std::ofstream s(stringify(skip_file).c_str(), std::ios::out | std::ios::app);
+ if (! s)
+ Log::get_instance()->message(ll_warning, "Cannot append to news skip file '"
+ + stringify(skip_file) + "', skipping news item '" + stringify(*d) + "'");
+
+ std::ofstream t(stringify(unread_file).c_str(), std::ios::out | std::ios::app);
+ if (! t)
+ Log::get_instance()->message(ll_warning, "Cannot append to unread file '"
+ + stringify(unread_file) + "', skipping news item '" + stringify(*d) + "'");
+
+ if (s && t)
+ {
+ s << d->basename() << std::endl;
+ t << d->basename() << std::endl;
+ }
+ }
+ }
+ catch (const ConfigFileError & e)
+ {
+ Log::get_instance()->message(ll_warning, "Skipping news item '"
+ + stringify(*d) + "' because of exception '" + e.message() + "' ("
+ + e.what() + ")");
+ }
+ }
+}
+
diff --git a/paludis/portage_repository.hh b/paludis/portage_repository.hh
index d73d078..91c3bf1 100644
--- a/paludis/portage_repository.hh
+++ b/paludis/portage_repository.hh
@@ -53,6 +53,7 @@ namespace paludis
prpk_distdir,
prpk_eclassdir,
prpk_setsdir,
+ prpk_newsdir,
prpk_sync,
prpk_sync_exclude,
prpk_root,
@@ -76,6 +77,7 @@ namespace paludis
SmartRecordKey<prpk_distdir, const FSEntry>,
SmartRecordKey<prpk_eclassdir, const FSEntry>,
SmartRecordKey<prpk_setsdir, const FSEntry>,
+ SmartRecordKey<prpk_newsdir, const FSEntry>,
SmartRecordKey<prpk_sync, const std::string>,
SmartRecordKey<prpk_sync_exclude, const std::string>,
SmartRecordKey<prpk_root, const FSEntry>
@@ -202,6 +204,8 @@ namespace paludis
virtual void remove_from_world(const QualifiedPackageName &) const
{
}
+
+ virtual void update_news() const;
};
/**
diff --git a/paludis/repository.hh b/paludis/repository.hh
index b808d7d..18bdb6c 100644
--- a/paludis/repository.hh
+++ b/paludis/repository.hh
@@ -522,6 +522,13 @@ namespace paludis
* Remove this package from world, if it is present.
*/
virtual void remove_from_world(const QualifiedPackageName &) const = 0;
+
+ /**
+ * Update our news.unread file.
+ */
+ virtual void update_news() const
+ {
+ }
};
/**
diff --git a/src/Makefile.am b/src/Makefile.am
index 33b16a5..7ee3abf 100644
--- a/src/Makefile.am
+++ b/src/Makefile.am
@@ -19,6 +19,7 @@ paludis_SOURCES = \
licence.hh licence.cc \
contents.hh contents.cc \
owner.hh owner.cc \
+ news.hh news.cc \
paludis.cc
paludis_LDADD = \
diff --git a/src/command_line.cc b/src/command_line.cc
index b9e8c00..f05650d 100644
--- a/src/command_line.cc
+++ b/src/command_line.cc
@@ -35,11 +35,14 @@ CommandLine::CommandLine() :
a_list_dep_tag_categories(&action_args, "list-dep-tag-categories", '\0', "List known dep tag categories"),
a_contents(&action_args, "contents", 'k', "Display contents of a package"),
a_owner(&action_args, "owner", 'o', "Display the owner of a file"),
- a_has_version(&action_args, "has-version", '\0', "Check whether the specified atom is installed"),
- a_best_version(&action_args, "best-version", '\0', "Display the best version of the specified atom"),
a_version(&action_args, "version", 'V', "Display program version"),
a_help(&action_args, "help", 'h', "Display program help"),
+ action_args_internal(this, "More actions (internal use)"),
+ a_has_version(&action_args_internal, "has-version", '\0', "Check whether the specified atom is installed"),
+ a_best_version(&action_args_internal, "best-version", '\0', "Display the best version of the specified atom"),
+ a_update_news(&action_args_internal, "update-news", '\0', "Regenerate news.unread files"),
+
general_args(this, "General options"),
a_log_level(&general_args, "log-level", '\0', "Specify the log level",
paludis::args::EnumArg::EnumArgOptions("debug", "Show debug output (noisy)")
diff --git a/src/command_line.hh b/src/command_line.hh
index 4f7b5ea..e3ade12 100644
--- a/src/command_line.hh
+++ b/src/command_line.hh
@@ -86,17 +86,24 @@ class CommandLine :
/// --owner
paludis::args::SwitchArg a_owner;
+ /// --version
+ paludis::args::SwitchArg a_version;
+
+ /// --help
+ paludis::args::SwitchArg a_help;
+
+ /// Action arguments (internal).
+ paludis::args::ArgsGroup action_args_internal;
+
/// --has-version
paludis::args::SwitchArg a_has_version;
/// --best-version
paludis::args::SwitchArg a_best_version;
- /// --version
- paludis::args::SwitchArg a_version;
+ /// --update-news
+ paludis::args::SwitchArg a_update_news;
- /// --help
- paludis::args::SwitchArg a_help;
///}
diff --git a/src/install.cc b/src/install.cc
index 20feb81..c6eab33 100644
--- a/src/install.cc
+++ b/src/install.cc
@@ -141,6 +141,11 @@ do_install()
{
dep_list.add(targets);
+ if (CommandLine::get_instance()->a_pretend.specified())
+ env->perform_hook(p::Hook("install_pretend_pre")("TARGETS", p::join(
+ CommandLine::get_instance()->begin_parameters(),
+ CommandLine::get_instance()->end_parameters(), " ")));
+
std::set<p::DepTag::ConstPointer, p::DepTag::Comparator> all_tags;
for (p::DepList::Iterator dep(dep_list.begin()), dep_end(dep_list.end()) ;
@@ -233,11 +238,8 @@ do_install()
cout << endl << "Total: " << max_count <<
(max_count == 1 ? " package" : " packages") << endl << endl;
- if (CommandLine::get_instance()->a_pretend.specified())
+ if (CommandLine::get_instance()->a_pretend.specified() && ! all_tags.empty())
{
- if (all_tags.empty())
- return return_code;
-
TagDisplayer tag_displayer;
std::set<std::string> tag_categories;
@@ -271,7 +273,13 @@ do_install()
if (! c->post_text().empty())
cout << c->post_text() << endl << endl;
}
+ }
+ if (CommandLine::get_instance()->a_pretend.specified())
+ {
+ env->perform_hook(p::Hook("install_pretend_post")("TARGETS", p::join(
+ CommandLine::get_instance()->begin_parameters(),
+ CommandLine::get_instance()->end_parameters(), " ")));
return return_code;
}
diff --git a/src/news.cc b/src/news.cc
new file mode 100644
index 0000000..b3a90dd
--- /dev/null
+++ b/src/news.cc
@@ -0,0 +1,50 @@
+/* vim: set sw=4 sts=4 et foldmethod=syntax : */
+
+/*
+ * Copyright (c) 2006 Ciaran McCreesh <ciaran.mccreesh@blueyonder.co.uk>
+ *
+ * This file is part of the Paludis package manager. Paludis is free software;
+ * you can redistribute it and/or modify it under the terms of the GNU General
+ * Public License version 2, as published by the Free Software Foundation.
+ *
+ * Paludis is distributed in the hope that it will be useful, but WITHOUT ANY
+ * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
+ * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
+ * details.
+ *
+ * You should have received a copy of the GNU General Public License along with
+ * this program; if not, write to the Free Software Foundation, Inc., 59 Temple
+ * Place, Suite 330, Boston, MA 02111-1307 USA
+ */
+
+#include "src/colour.hh"
+#include "src/news.hh"
+#include <functional>
+#include <iomanip>
+#include <iostream>
+#include <paludis/paludis.hh>
+#include <string>
+
+/** \file
+ * Handle the --update-news action for the main paludis program.
+ */
+
+namespace p = paludis;
+
+int
+do_update_news()
+{
+ int return_code(0);
+
+ p::Context context("When performing update-news action from command line:");
+ p::Environment * const env(p::DefaultEnvironment::get_instance());
+
+ for (p::PackageDatabase::RepositoryIterator r(env->package_database()->begin_repositories()),
+ r_end(env->package_database()->end_repositories()) ; r != r_end ; ++r)
+ (*r)->update_news();
+
+ return return_code;
+}
+
+
+
diff --git a/src/news.hh b/src/news.hh
new file mode 100644
index 0000000..8d8b54b
--- /dev/null
+++ b/src/news.hh
@@ -0,0 +1,34 @@
+/* vim: set sw=4 sts=4 et foldmethod=syntax : */
+
+/*
+ * Copyright (c) 2006 Ciaran McCreesh <ciaran.mccreesh@blueyonder.co.uk>
+ *
+ * This file is part of the Paludis package manager. Paludis is free software;
+ * you can redistribute it and/or modify it under the terms of the GNU General
+ * Public License version 2, as published by the Free Software Foundation.
+ *
+ * Paludis is distributed in the hope that it will be useful, but WITHOUT ANY
+ * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
+ * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
+ * details.
+ *
+ * You should have received a copy of the GNU General Public License along with
+ * this program; if not, write to the Free Software Foundation, Inc., 59 Temple
+ * Place, Suite 330, Boston, MA 02111-1307 USA
+ */
+
+#ifndef PALUDIS_GUARD_SRC_NEWS_HH
+#define PALUDIS_GUARD_SRC_NEWS_HH 1
+
+#include "src/command_line.hh"
+
+/** \file
+ * Declaration for the do_update_news function.
+ */
+
+/// Handle --update-news.
+int do_update_news();
+
+#endif
+
+
diff --git a/src/paludis.cc b/src/paludis.cc
index a33ece7..cfe2dc2 100644
--- a/src/paludis.cc
+++ b/src/paludis.cc
@@ -26,6 +26,7 @@
#include "src/query.hh"
#include "src/applets.hh"
#include "src/sync.hh"
+#include "src/news.hh"
#include "config.h"
#include <paludis/paludis.hh>
@@ -97,6 +98,7 @@ main(int argc, char *argv[])
CommandLine::get_instance()->a_contents.specified() +
CommandLine::get_instance()->a_owner.specified() +
CommandLine::get_instance()->a_has_version.specified() +
+ CommandLine::get_instance()->a_update_news.specified() +
CommandLine::get_instance()->a_best_version.specified()))
{
if ((1 == std::distance(CommandLine::get_instance()->begin_parameters(),
@@ -246,6 +248,14 @@ main(int argc, char *argv[])
return do_best_version();
}
+ if (CommandLine::get_instance()->a_update_news.specified())
+ {
+ if (! CommandLine::get_instance()->empty())
+ throw DoHelp("update-news action takes no parameters");
+
+ return do_update_news();
+ }
+
throw p::InternalError(__PRETTY_FUNCTION__, "no action?");
}
catch (const DoVersion &)