aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAvatar Ciaran McCreesh <ciaran.mccreesh@googlemail.com> 2010-10-17 14:55:07 +0100
committerAvatar Ciaran McCreesh <ciaran.mccreesh@googlemail.com> 2010-10-17 14:55:07 +0100
commitdfd739aecdc3143ea600e3444a40cc9615a2c3e3 (patch)
tree11d8e03ea675f9358dcc11d33562c97c5429c6de
parent7881968648d0a82af3e2fc3bd10ee5a6af5897e7 (diff)
downloadpaludis-dfd739aecdc3143ea600e3444a40cc9615a2c3e3.tar.gz
paludis-dfd739aecdc3143ea600e3444a40cc9615a2c3e3.tar.xz
cave sync-protocol-options
Fixes: ticket:997
-rw-r--r--.gitignore1
-rw-r--r--doc/clients/Makefile.am1
-rw-r--r--src/clients/cave/Makefile.am2
-rw-r--r--src/clients/cave/cmd_sync_protocol_options.cc122
-rw-r--r--src/clients/cave/cmd_sync_protocol_options.hh44
-rw-r--r--src/clients/cave/command_factory.cc2
6 files changed, 172 insertions, 0 deletions
diff --git a/.gitignore b/.gitignore
index b60201d..ca61a57 100644
--- a/.gitignore
+++ b/.gitignore
@@ -126,6 +126,7 @@ paludis-*.*.*.tar.bz2
/doc/clients/cave-show.html
/doc/clients/cave-size.html
/doc/clients/cave-sync.html
+/doc/clients/cave-sync-protocol-options.html
/doc/clients/cave-uninstall.html
/doc/clients/cave-update-world.html
/doc/clients/cave-verify.html
diff --git a/doc/clients/Makefile.am b/doc/clients/Makefile.am
index a961bb2..2a33cf3 100644
--- a/doc/clients/Makefile.am
+++ b/doc/clients/Makefile.am
@@ -70,6 +70,7 @@ CAVE_COMMANDS_HTML = \
cave-show.html \
cave-size.html \
cave-sync.html \
+ cave-sync-protocol-options.html \
cave-uninstall.html \
cave-update-world.html \
cave-verify.html
diff --git a/src/clients/cave/Makefile.am b/src/clients/cave/Makefile.am
index d2e2989..02cbed7 100644
--- a/src/clients/cave/Makefile.am
+++ b/src/clients/cave/Makefile.am
@@ -67,6 +67,7 @@ command_MANS = \
cave-show.1 \
cave-size.1 \
cave-sync.1 \
+ cave-sync-protocol-options.1 \
cave-uninstall.1 \
cave-update-world.1 \
cave-verify.1
@@ -167,6 +168,7 @@ libcave_a_SOURCES = \
cmd_show.cc cmd_show.hh cmd_show-fmt.hh \
cmd_size.cc cmd_size.hh \
cmd_sync.cc cmd_sync.hh cmd_sync-fmt.hh \
+ cmd_sync_protocol_options.cc cmd_sync_protocol_options.hh \
cmd_uninstall.cc cmd_uninstall.hh \
cmd_update_world.cc cmd_update_world.hh cmd_update_world-fmt.hh \
cmd_verify.cc cmd_verify.hh cmd_verify-fmt.hh \
diff --git a/src/clients/cave/cmd_sync_protocol_options.cc b/src/clients/cave/cmd_sync_protocol_options.cc
new file mode 100644
index 0000000..68b6b11
--- /dev/null
+++ b/src/clients/cave/cmd_sync_protocol_options.cc
@@ -0,0 +1,122 @@
+/* vim: set sw=4 sts=4 et foldmethod=syntax : */
+
+/*
+ * Copyright (c) 2010 Ciaran McCreesh
+ *
+ * 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 "cmd_sync_protocol_options.hh"
+
+#include <paludis/args/args.hh>
+#include <paludis/args/do_help.hh>
+#include <paludis/environment.hh>
+#include <paludis/package_database.hh>
+#include <paludis/repository.hh>
+#include <paludis/util/fs_iterator.hh>
+#include <paludis/util/fs_stat.hh>
+#include <paludis/util/log.hh>
+#include <paludis/util/process.hh>
+#include <paludis/util/system.hh>
+
+#include <cstdlib>
+#include <iostream>
+#include <set>
+
+#include "command_command_line.hh"
+
+using namespace paludis;
+using namespace cave;
+using std::cout;
+using std::endl;
+
+namespace
+{
+ struct SyncProtocolOptionsCommandLine :
+ CaveCommandCommandLine
+ {
+ virtual std::string app_name() const
+ {
+ return "cave sync-protocol-options";
+ }
+
+ virtual std::string app_synopsis() const
+ {
+ return "Displays options for a given sync protocol.";
+ }
+
+ virtual std::string app_description() const
+ {
+ return "Displays options for a given sync protocol.";
+ }
+
+ SyncProtocolOptionsCommandLine()
+ {
+ add_usage_line("protocol");
+ }
+ };
+}
+
+int
+SyncProtocolOptionsCommand::run(
+ const std::shared_ptr<Environment> & env,
+ const std::shared_ptr<const Sequence<std::string > > & args
+ )
+{
+ SyncProtocolOptionsCommandLine cmdline;
+ cmdline.run(args, "CAVE", "CAVE_SYNC_PROTOCOL_OPTIONS_OPTIONS", "CAVE_SYNC_PROTOCOL_OPTIONS_CMDLINE");
+
+ if (cmdline.a_help.specified())
+ {
+ cout << cmdline;
+ return EXIT_SUCCESS;
+ }
+
+ if (1 != std::distance(cmdline.begin_parameters(), cmdline.end_parameters()))
+ throw args::DoHelp("sync-protocol-options takes exactly one parameter");
+ std::string format(*cmdline.begin_parameters());
+
+ auto syncer_dirs(env->syncers_dirs());
+ FSPath syncer("/dev/null");
+ bool ok(false);
+ for (auto d(syncer_dirs->begin()), d_end(syncer_dirs->end()) ;
+ d != d_end && ! ok; ++d)
+ {
+ syncer = FSPath(*d) / ("do" + format);
+ FSStat syncer_stat(syncer);
+ if (syncer_stat.exists() && 0 != (syncer_stat.permissions() & S_IXUSR))
+ ok = true;
+ }
+
+ if (! ok)
+ throw args::DoHelp("syncer '" + format + "' does not exist");
+
+ Process process(ProcessCommand({stringify(syncer), "--help"}));
+ process
+ .setenv("PALUDIS_FETCHERS_DIRS", join(syncer_dirs->begin(), syncer_dirs->end(), " "))
+ .setenv("PALUDIS_EBUILD_DIR", getenv_with_default("PALUDIS_EBUILD_DIR", LIBEXECDIR "/paludis"));
+ if (0 != process.run().wait())
+ Log::get_instance()->message("paludis.syncer_help.failure", ll_warning, lc_context)
+ << "Syncer help command '" << syncer << " --help' failed";
+ cout << endl;
+
+ return EXIT_SUCCESS;
+}
+
+std::shared_ptr<args::ArgsHandler>
+SyncProtocolOptionsCommand::make_doc_cmdline()
+{
+ return std::make_shared<SyncProtocolOptionsCommandLine>();
+}
+
diff --git a/src/clients/cave/cmd_sync_protocol_options.hh b/src/clients/cave/cmd_sync_protocol_options.hh
new file mode 100644
index 0000000..2fe5216
--- /dev/null
+++ b/src/clients/cave/cmd_sync_protocol_options.hh
@@ -0,0 +1,44 @@
+/* vim: set sw=4 sts=4 et foldmethod=syntax : */
+
+/*
+ * Copyright (c) 2010 Ciaran McCreesh
+ *
+ * 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_CLIENTS_CAVE_CMD_SYNC_PROTOCOL_OPTIONS_HH
+#define PALUDIS_GUARD_SRC_CLIENTS_CAVE_CMD_SYNC_PROTOCOL_OPTIONS_HH 1
+
+#include "command.hh"
+
+namespace paludis
+{
+ namespace cave
+ {
+ class PALUDIS_VISIBLE SyncProtocolOptionsCommand :
+ public Command
+ {
+ public:
+ int run(
+ const std::shared_ptr<Environment> &,
+ const std::shared_ptr<const Sequence<std::string > > & args
+ );
+
+ std::shared_ptr<args::ArgsHandler> make_doc_cmdline();
+ };
+ }
+}
+
+
+#endif
diff --git a/src/clients/cave/command_factory.cc b/src/clients/cave/command_factory.cc
index 9c13998..6974c9e 100644
--- a/src/clients/cave/command_factory.cc
+++ b/src/clients/cave/command_factory.cc
@@ -80,6 +80,7 @@
#include "cmd_show.hh"
#include "cmd_size.hh"
#include "cmd_sync.hh"
+#include "cmd_sync_protocol_options.hh"
#include "cmd_uninstall.hh"
#include "cmd_update_world.hh"
#include "cmd_verify.hh"
@@ -192,6 +193,7 @@ CommandFactory::CommandFactory() :
_imp->handlers.insert(std::make_pair("show", std::bind(&make_command<ShowCommand>)));
_imp->handlers.insert(std::make_pair("size", std::bind(&make_command<SizeCommand>)));
_imp->handlers.insert(std::make_pair("sync", std::bind(&make_command<SyncCommand>)));
+ _imp->handlers.insert(std::make_pair("sync-protocol-options", std::bind(&make_command<SyncProtocolOptionsCommand>)));
_imp->handlers.insert(std::make_pair("uninstall", std::bind(&make_command<UninstallCommand>)));
_imp->handlers.insert(std::make_pair("update-world", std::bind(&make_command<UpdateWorldCommand>)));
_imp->handlers.insert(std::make_pair("verify", std::bind(&make_command<VerifyCommand>)));