aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAvatar Ciaran McCreesh <ciaran.mccreesh@googlemail.com> 2010-03-23 17:20:20 +0000
committerAvatar Ciaran McCreesh <ciaran.mccreesh@googlemail.com> 2010-03-23 17:20:20 +0000
commitbfe183236ad38d16716489f7b604a9f9a7b13f7c (patch)
treeff6c00fff1e4211d15a40b046744532d123b1105
parent7774e20727a6be2e6cc079ef29afc2a69986e01f (diff)
downloadpaludis-bfe183236ad38d16716489f7b604a9f9a7b13f7c.tar.gz
paludis-bfe183236ad38d16716489f7b604a9f9a7b13f7c.tar.xz
Initial cave fix-linkage
-rw-r--r--src/clients/cave/Makefile.am2
-rw-r--r--src/clients/cave/cmd_fix_linkage.cc203
-rw-r--r--src/clients/cave/cmd_fix_linkage.hh46
-rw-r--r--src/clients/cave/command_factory.cc2
4 files changed, 253 insertions, 0 deletions
diff --git a/src/clients/cave/Makefile.am b/src/clients/cave/Makefile.am
index 760f21b..952c0b3 100644
--- a/src/clients/cave/Makefile.am
+++ b/src/clients/cave/Makefile.am
@@ -23,6 +23,7 @@ command_MANS = \
cave-execute-resolution.1 \
cave-find-candidates.1 \
cave-fix-cache.1 \
+ cave-fix-linkage.1 \
cave-help.1 \
cave-import.1 \
cave-info.1 \
@@ -92,6 +93,7 @@ libcave_a_SOURCES = \
cmd_execute_resolution.cc cmd_execute_resolution.hh \
cmd_find_candidates.cc cmd_find_candidates.hh \
cmd_fix_cache.cc cmd_fix_cache.hh \
+ cmd_fix_linkage.cc cmd_fix_linkage.hh \
cmd_help.cc cmd_help.hh \
cmd_import.cc cmd_import.hh \
cmd_info.cc cmd_info.hh \
diff --git a/src/clients/cave/cmd_fix_linkage.cc b/src/clients/cave/cmd_fix_linkage.cc
new file mode 100644
index 0000000..5220df2
--- /dev/null
+++ b/src/clients/cave/cmd_fix_linkage.cc
@@ -0,0 +1,203 @@
+/* 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_fix_linkage.hh"
+#include "cmd_resolve_cmdline.hh"
+#include "resolve_common.hh"
+
+#include <paludis/args/do_help.hh>
+#include <paludis/util/make_shared_ptr.hh>
+#include <paludis/util/stringify.hh>
+#include <paludis/util/join.hh>
+#include <paludis/util/make_named_values.hh>
+#include <paludis/broken_linkage_finder.hh>
+#include <paludis/package_id.hh>
+#include <paludis/name.hh>
+#include <paludis/dep_spec.hh>
+#include <paludis/user_dep_spec.hh>
+#include <paludis/metadata_key.hh>
+#include <paludis/version_operator.hh>
+#include <paludis/version_requirements.hh>
+
+#include <iostream>
+#include <cstdlib>
+
+using namespace paludis;
+using namespace cave;
+
+using std::cout;
+using std::endl;
+
+bool
+FixLinkageCommand::important() const
+{
+ return true;
+}
+
+namespace
+{
+ struct FixLinkageCommandLine :
+ CaveCommandCommandLine
+ {
+ args::ArgsGroup g_linkage_options;
+ args::StringArg a_library;
+ args::SwitchArg a_exact;
+
+ ResolveCommandLineResolutionOptions resolution_options;
+ ResolveCommandLineExecutionOptions execution_options;
+ ResolveCommandLineDisplayOptions display_options;
+ ResolveCommandLineProgramOptions program_options;
+
+ FixLinkageCommandLine() :
+ g_linkage_options(main_options_section(), "Linkage options", "Options relating to linkage"),
+ a_library(&g_linkage_options, "library", '\0', "Only rebuild packages linked against this library, even if it exists"),
+ a_exact(&g_linkage_options, "exact", '\0', "Rebuild the same package version that is currently installed", true),
+ resolution_options(this),
+ execution_options(this),
+ display_options(this),
+ program_options(this)
+ {
+ add_usage_line("[ -x|--execute ] [ --library foo.so.1 ]");
+ }
+
+ std::string app_name() const
+ {
+ return "cave fix-linkage";
+ }
+
+ std::string app_synopsis() const
+ {
+ return "Identify packages with broken linkage that can be fixed by rebuilds.";
+ }
+
+ std::string app_description() const
+ {
+ return "Identifies packages with broken linkage that can be fixed by rebuilds. "
+ "If instructed, then executes the relevant install and uninstall actions to "
+ "do said fixing.";
+ }
+ };
+}
+
+int
+FixLinkageCommand::run(
+ const std::tr1::shared_ptr<Environment> & env,
+ const std::tr1::shared_ptr<const Sequence<std::string > > & args
+ )
+{
+ FixLinkageCommandLine cmdline;
+ cmdline.run(args, "CAVE", "CAVE_FIX_LINKAGE_OPTIONS", "CAVE_FIX_LINKAGE_CMDLINE");
+
+ if (cmdline.a_help.specified())
+ {
+ cout << cmdline;
+ return EXIT_SUCCESS;
+ }
+
+ if (cmdline.begin_parameters() != cmdline.end_parameters())
+ throw args::DoHelp("fix-linkage takes no parameters");
+
+ cmdline.resolution_options.apply_shortcuts();
+ cmdline.resolution_options.verify(env);
+
+ std::string library(cmdline.a_library.argument());
+ if (library.empty())
+ cout << "Searching for broken packages... " << std::flush;
+ else
+ cout << "Searching for packages that depend on " << library << "... " << std::flush;
+
+ BrokenLinkageFinder finder(env.get(), cmdline.a_library.argument());
+
+ cout << endl;
+
+ if (finder.begin_broken_packages() == finder.end_broken_packages())
+ {
+ if (library.empty())
+ cout << "No broken packages found" << endl;
+ else
+ cout << "No packages that depend on " << library << " found" << endl;
+
+ return EXIT_SUCCESS;
+ }
+
+ std::tr1::shared_ptr<Sequence<std::string> > targets(new Sequence<std::string>);
+
+ for (BrokenLinkageFinder::BrokenPackageConstIterator pkg_it(finder.begin_broken_packages()),
+ pkg_it_end(finder.end_broken_packages()); pkg_it_end != pkg_it; ++pkg_it)
+ {
+ cout << endl;
+
+ cout << "* " << **pkg_it << endl;
+
+ for (BrokenLinkageFinder::BrokenFileConstIterator file_it(finder.begin_broken_files(*pkg_it)),
+ file_it_end(finder.end_broken_files(*pkg_it)); file_it_end != file_it; ++file_it)
+ {
+ cout << " " << *file_it;
+ if (library.empty())
+ cout << " (requires "
+ << join(finder.begin_missing_requirements(*pkg_it, *file_it),
+ finder.end_missing_requirements(*pkg_it, *file_it),
+ " ") << ")";
+ cout << endl;
+ }
+
+ PartiallyMadePackageDepSpec part_spec((PartiallyMadePackageDepSpecOptions()));
+ part_spec.package((*pkg_it)->name());
+ if ((*pkg_it)->slot_key())
+ part_spec.slot_requirement(make_shared_ptr(new UserSlotExactRequirement((*pkg_it)->slot_key()->value())));
+
+ if (cmdline.a_exact.specified())
+ part_spec.version_requirement(make_named_values<VersionRequirement>(
+ value_for<n::version_operator>(vo_equal),
+ value_for<n::version_spec>((*pkg_it)->version())));
+
+ targets->push_back(stringify(PackageDepSpec(part_spec)));
+ }
+
+ std::tr1::shared_ptr<const PackageID> orphans;
+ if (finder.begin_broken_files(orphans) != finder.end_broken_files(orphans))
+ {
+ if (library.empty())
+ cout << endl << "The following broken files are not owned by any installed package:" << endl;
+ else
+ cout << endl << "The following files that depend on " << library << " are not owned by any installed package:" << endl;
+
+ for (BrokenLinkageFinder::BrokenFileConstIterator file_it(finder.begin_broken_files(orphans)),
+ file_it_end(finder.end_broken_files(orphans)); file_it_end != file_it; ++file_it)
+ {
+ cout << " " << *file_it;
+ if (library.empty())
+ cout << " (requires "
+ << join(finder.begin_missing_requirements(orphans, *file_it),
+ finder.end_missing_requirements(orphans, *file_it),
+ " ") << ")";
+ cout << endl;
+ }
+ }
+
+ return resolve_common(env, cmdline.resolution_options, cmdline.execution_options, cmdline.display_options,
+ cmdline.program_options, make_null_shared_ptr(), targets);
+}
+
+std::tr1::shared_ptr<args::ArgsHandler>
+FixLinkageCommand::make_doc_cmdline()
+{
+ return make_shared_ptr(new FixLinkageCommandLine);
+}
+
diff --git a/src/clients/cave/cmd_fix_linkage.hh b/src/clients/cave/cmd_fix_linkage.hh
new file mode 100644
index 0000000..2b7667d
--- /dev/null
+++ b/src/clients/cave/cmd_fix_linkage.hh
@@ -0,0 +1,46 @@
+/* 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_FIX_LINKAGE_HH
+#define PALUDIS_GUARD_SRC_CLIENTS_CAVE_CMD_FIX_LINKAGE_HH 1
+
+#include "command.hh"
+
+namespace paludis
+{
+ namespace cave
+ {
+ class PALUDIS_VISIBLE FixLinkageCommand :
+ public Command
+ {
+ public:
+ bool important() const;
+
+ int run(
+ const std::tr1::shared_ptr<Environment> &,
+ const std::tr1::shared_ptr<const Sequence<std::string > > & args
+ );
+
+ std::tr1::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 3174465..04ef390 100644
--- a/src/clients/cave/command_factory.cc
+++ b/src/clients/cave/command_factory.cc
@@ -31,6 +31,7 @@
#include "cmd_execute_resolution.hh"
#include "cmd_find_candidates.hh"
#include "cmd_fix_cache.hh"
+#include "cmd_fix_linkage.hh"
#include "cmd_help.hh"
#include "cmd_import.hh"
#include "cmd_info.hh"
@@ -92,6 +93,7 @@ CommandFactory::CommandFactory() :
_imp->handlers.insert(std::make_pair("execute-resolution", std::tr1::bind(&make_command<ExecuteResolutionCommand>)));
_imp->handlers.insert(std::make_pair("find-candidates", std::tr1::bind(&make_command<FindCandidatesCommand>)));
_imp->handlers.insert(std::make_pair("fix-cache", std::tr1::bind(&make_command<FixCacheCommand>)));
+ _imp->handlers.insert(std::make_pair("fix-linkage", std::tr1::bind(&make_command<FixLinkageCommand>)));
_imp->handlers.insert(std::make_pair("help", std::tr1::bind(&make_command<HelpCommand>)));
_imp->handlers.insert(std::make_pair("import", std::tr1::bind(&make_command<ImportCommand>)));
_imp->handlers.insert(std::make_pair("info", std::tr1::bind(&make_command<InfoCommand>)));