aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAvatar Ciaran McCreesh <ciaran.mccreesh@googlemail.com> 2007-11-08 23:41:52 +0000
committerAvatar Ciaran McCreesh <ciaran.mccreesh@googlemail.com> 2007-11-08 23:41:52 +0000
commit42df6101694290420b1641d4a4f03816150fcc7b (patch)
treeb3d20ba7a37ee0f281f80439e487da7ff95706f2
parent1e3f66540816679cd156156d6454ac8726d64ac9 (diff)
downloadpaludis-42df6101694290420b1641d4a4f03816150fcc7b.tar.gz
paludis-42df6101694290420b1641d4a4f03816150fcc7b.tar.xz
Metadata options for importare
-rw-r--r--NEWS2
-rw-r--r--paludis/repositories/unpackaged/Makefile.am6
-rw-r--r--paludis/repositories/unpackaged/dep_parser.cc58
-rw-r--r--paludis/repositories/unpackaged/dep_parser.hh39
-rw-r--r--paludis/repositories/unpackaged/dep_printer.cc116
-rw-r--r--paludis/repositories/unpackaged/dep_printer.hh57
-rw-r--r--paludis/repositories/unpackaged/installed_id.cc77
-rw-r--r--paludis/repositories/unpackaged/installed_repository.cc27
-rw-r--r--paludis/repositories/unpackaged/installed_repository_TEST.cc9
-rw-r--r--paludis/repositories/unpackaged/registration.cc17
-rw-r--r--paludis/repositories/unpackaged/unpackaged_id.cc58
-rw-r--r--paludis/repositories/unpackaged/unpackaged_id.hh3
-rw-r--r--paludis/repositories/unpackaged/unpackaged_key.cc140
-rw-r--r--paludis/repositories/unpackaged/unpackaged_key.hh79
-rw-r--r--paludis/repositories/unpackaged/unpackaged_repository.cc6
-rw-r--r--paludis/repositories/unpackaged/unpackaged_repository.sr3
-rw-r--r--paludis/repositories/unpackaged/unpackaged_repository_TEST.cc15
-rw-r--r--src/clients/importare/command_line.cc15
-rw-r--r--src/clients/importare/command_line.hh6
-rw-r--r--src/clients/importare/importare.cc47
20 files changed, 742 insertions, 38 deletions
diff --git a/NEWS b/NEWS
index ea62b04..70f5d51 100644
--- a/NEWS
+++ b/NEWS
@@ -19,6 +19,8 @@ trunk/:
* Paludis now protects further against sandbox clobbering the PATH.
+ * Metadata options for importare.
+
0.26.0_alpha3:
* STILL BROKEN, wait for 0.26.0 if you use these: CRAN, Ruby bindings for
dep specs.
diff --git a/paludis/repositories/unpackaged/Makefile.am b/paludis/repositories/unpackaged/Makefile.am
index aa5aae8..d1ac224 100644
--- a/paludis/repositories/unpackaged/Makefile.am
+++ b/paludis/repositories/unpackaged/Makefile.am
@@ -23,6 +23,8 @@ paludis_repositories_unpackaged_includedir = $(includedir)/paludis-$(PALUDIS_PC_
libpaludisunpackagedrepository_la_LDFLAGS = -version-info @VERSION_LIB_CURRENT@:@VERSION_LIB_REVISION@:0
paludis_repositories_unpackaged_include_HEADERS = \
+ dep_parser.hh \
+ dep_printer.hh \
exceptions.hh \
ndbam.hh \
ndbam-fwd.hh \
@@ -34,17 +36,21 @@ paludis_repositories_unpackaged_include_HEADERS = \
unpackaged_id.hh \
unpackaged_repository.hh \
unpackaged_repository-sr.hh \
+ unpackaged_key.hh \
installed_repository.hh \
installed_repository-sr.hh \
installed_id.hh
libpaludisunpackagedrepository_la_SOURCES = \
+ dep_parser.cc \
+ dep_printer.cc \
exceptions.cc \
ndbam.cc \
ndbam_merger.cc \
ndbam_unmerger.cc \
unpackaged_id.cc \
unpackaged_repository.cc \
+ unpackaged_key.cc \
installed_repository.cc \
installed_id.cc \
registration.cc \
diff --git a/paludis/repositories/unpackaged/dep_parser.cc b/paludis/repositories/unpackaged/dep_parser.cc
new file mode 100644
index 0000000..b5fe2b3
--- /dev/null
+++ b/paludis/repositories/unpackaged/dep_parser.cc
@@ -0,0 +1,58 @@
+/* vim: set sw=4 sts=4 et foldmethod=syntax : */
+
+/*
+ * Copyright (c) 2007 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 <paludis/repositories/unpackaged/dep_parser.hh>
+#include <paludis/util/tokeniser.hh>
+#include <paludis/util/strip.hh>
+#include <paludis/util/exception.hh>
+#include <paludis/dep_spec.hh>
+#include <list>
+
+using namespace paludis;
+using namespace paludis::unpackaged_repositories;
+
+tr1::shared_ptr<const DependencySpecTree::ConstItem>
+DepParser::parse(const std::string & s)
+{
+ Context context("When parsing '" + s + "':");
+
+ tr1::shared_ptr<ConstTreeSequence<DependencySpecTree, AllDepSpec> > result(
+ new ConstTreeSequence<DependencySpecTree, AllDepSpec>(tr1::shared_ptr<AllDepSpec>(new AllDepSpec)));
+
+ std::list<std::string> tokens;
+ Tokeniser<delim_kind::AnyOfTag>::tokenise(s, ",", std::back_inserter(tokens));
+
+ for (std::list<std::string>::const_iterator t(tokens.begin()), t_end(tokens.end()) ;
+ t != t_end ; ++t)
+ {
+ std::string a(strip_leading(strip_trailing(*t, " \t\r\n"), " \t\r\n"));
+ Context local_context("When parsing token '" + a + "':");
+
+ if (a.empty())
+ continue;
+
+ tr1::shared_ptr<TreeLeaf<DependencySpecTree, PackageDepSpec> > spec(
+ new TreeLeaf<DependencySpecTree, PackageDepSpec>(tr1::shared_ptr<PackageDepSpec>(
+ new PackageDepSpec(a, pds_pm_permissive))));
+ result->add(spec);
+ }
+
+ return result;
+}
+
diff --git a/paludis/repositories/unpackaged/dep_parser.hh b/paludis/repositories/unpackaged/dep_parser.hh
new file mode 100644
index 0000000..3959301
--- /dev/null
+++ b/paludis/repositories/unpackaged/dep_parser.hh
@@ -0,0 +1,39 @@
+/* vim: set sw=4 sts=4 et foldmethod=syntax : */
+
+/*
+ * Copyright (c) 2007 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_PALUDIS_REPOSITORIES_UNPACKAGED_DEP_PARSER_HH
+#define PALUDIS_GUARD_PALUDIS_REPOSITORIES_UNPACKAGED_DEP_PARSER_HH 1
+
+#include <paludis/util/instantiation_policy.hh>
+#include <paludis/dep_tree.hh>
+
+namespace paludis
+{
+ namespace unpackaged_repositories
+ {
+ class DepParser :
+ private InstantiationPolicy<DepParser, instantiation_method::NonInstantiableTag>
+ {
+ public:
+ static tr1::shared_ptr<const DependencySpecTree::ConstItem> parse(const std::string &);
+ };
+ }
+}
+
+#endif
diff --git a/paludis/repositories/unpackaged/dep_printer.cc b/paludis/repositories/unpackaged/dep_printer.cc
new file mode 100644
index 0000000..501a71f
--- /dev/null
+++ b/paludis/repositories/unpackaged/dep_printer.cc
@@ -0,0 +1,116 @@
+/* vim: set sw=4 sts=4 et foldmethod=syntax : */
+
+/*
+ * Copyright (c) 2007 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 <paludis/repositories/unpackaged/dep_printer.hh>
+#include <paludis/util/visitor-impl.hh>
+#include <paludis/util/private_implementation_pattern-impl.hh>
+#include <sstream>
+
+using namespace paludis;
+using namespace paludis::unpackaged_repositories;
+
+namespace paludis
+{
+ template <>
+ struct Implementation<DepPrinter>
+ {
+ const DependencySpecTree::ItemFormatter & formatter;
+ const bool flat;
+ std::stringstream result;
+
+ Implementation(const DependencySpecTree::ItemFormatter & f,
+ const bool b) :
+ formatter(f),
+ flat(b)
+ {
+ }
+ };
+}
+
+DepPrinter::DepPrinter(const DependencySpecTree::ItemFormatter & f, const bool b) :
+ PrivateImplementationPattern<DepPrinter>(new Implementation<DepPrinter>(f, b))
+{
+}
+
+DepPrinter::~DepPrinter()
+{
+}
+
+const std::string
+DepPrinter::result() const
+{
+ return _imp->result.str();
+}
+
+void
+DepPrinter::visit_leaf(const PackageDepSpec & s)
+{
+ if (! _imp->result.str().empty())
+ {
+ if (! _imp->flat)
+ _imp->result << _imp->formatter.indent(1);
+ else
+ _imp->result << ", ";
+ }
+
+ _imp->result << s;
+}
+
+void
+DepPrinter::visit_leaf(const NamedSetDepSpec & s)
+{
+ if (! _imp->result.str().empty())
+ {
+ if (! _imp->flat)
+ _imp->result << _imp->formatter.indent(1);
+ else
+ _imp->result << ", ";
+ }
+
+ _imp->result << s;
+}
+
+void
+DepPrinter::visit_leaf(const BlockDepSpec & s)
+{
+ if (! _imp->result.str().empty())
+ {
+ if (! _imp->flat)
+ _imp->result << _imp->formatter.indent(1);
+ else
+ _imp->result << ", ";
+ }
+
+ _imp->result << s;
+}
+
+void
+DepPrinter::visit_leaf(const DependencyLabelsDepSpec & s)
+{
+ if (! _imp->result.str().empty())
+ {
+ if (! _imp->flat)
+ _imp->result << _imp->formatter.indent(1);
+ else
+ _imp->result << ", ";
+ }
+
+ _imp->result << s;
+}
+
diff --git a/paludis/repositories/unpackaged/dep_printer.hh b/paludis/repositories/unpackaged/dep_printer.hh
new file mode 100644
index 0000000..1385a14
--- /dev/null
+++ b/paludis/repositories/unpackaged/dep_printer.hh
@@ -0,0 +1,57 @@
+/* vim: set sw=4 sts=4 et foldmethod=syntax : */
+
+/*
+ * Copyright (c) 2007 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_PALUDIS_REPOSITORIES_UNPACKAGED_DEP_PRINTER_HH
+#define PALUDIS_GUARD_PALUDIS_REPOSITORIES_UNPACKAGED_DEP_PRINTER_HH 1
+
+#include <paludis/util/visitor.hh>
+#include <paludis/util/private_implementation_pattern.hh>
+#include <paludis/dep_tree.hh>
+#include <paludis/formatter.hh>
+
+namespace paludis
+{
+ namespace unpackaged_repositories
+ {
+ class DepPrinter :
+ public ConstVisitor<DependencySpecTree>,
+ public ConstVisitor<DependencySpecTree>::VisitConstSequence<DepPrinter, AllDepSpec>,
+ public ConstVisitor<DependencySpecTree>::VisitConstSequence<DepPrinter, AnyDepSpec>,
+ public ConstVisitor<DependencySpecTree>::VisitConstSequence<DepPrinter, UseDepSpec>,
+ private PrivateImplementationPattern<DepPrinter>
+ {
+ public:
+ DepPrinter(const DependencySpecTree::ItemFormatter &, const bool);
+ ~DepPrinter();
+
+ const std::string result() const;
+
+ void visit_leaf(const BlockDepSpec &);
+ void visit_leaf(const PackageDepSpec &);
+ void visit_leaf(const NamedSetDepSpec &);
+ void visit_leaf(const DependencyLabelsDepSpec &);
+
+ using ConstVisitor<DependencySpecTree>::VisitConstSequence<DepPrinter, AllDepSpec>::visit_sequence;
+ using ConstVisitor<DependencySpecTree>::VisitConstSequence<DepPrinter, AnyDepSpec>::visit_sequence;
+ using ConstVisitor<DependencySpecTree>::VisitConstSequence<DepPrinter, UseDepSpec>::visit_sequence;
+ };
+ }
+}
+
+#endif
diff --git a/paludis/repositories/unpackaged/installed_id.cc b/paludis/repositories/unpackaged/installed_id.cc
index d49e174..d5dc39f 100644
--- a/paludis/repositories/unpackaged/installed_id.cc
+++ b/paludis/repositories/unpackaged/installed_id.cc
@@ -21,6 +21,8 @@
#include <paludis/repositories/unpackaged/installed_repository.hh>
#include <paludis/repositories/unpackaged/ndbam.hh>
#include <paludis/repositories/unpackaged/ndbam_unmerger.hh>
+#include <paludis/repositories/unpackaged/dep_parser.hh>
+#include <paludis/repositories/unpackaged/dep_printer.hh>
#include <paludis/util/private_implementation_pattern-impl.hh>
#include <paludis/util/system.hh>
#include <paludis/util/fs_entry.hh>
@@ -164,6 +166,55 @@ namespace
return *_v;
}
};
+
+ class InstalledUnpackagedDependencyKey :
+ public MetadataSpecTreeKey<DependencySpecTree>
+ {
+ private:
+ mutable tr1::shared_ptr<const DependencySpecTree::ConstItem> _v;
+ mutable Mutex _mutex;
+ const FSEntry _f;
+
+ public:
+ InstalledUnpackagedDependencyKey(const std::string & r, const std::string & h, const FSEntry & f) :
+ MetadataSpecTreeKey<DependencySpecTree>(r, h, mkt_normal),
+ _f(f)
+ {
+ }
+
+ const tr1::shared_ptr<const DependencySpecTree::ConstItem> value() const
+ {
+ Lock l(_mutex);
+ if (_v)
+ return _v;
+
+ Context context("When reading '" + stringify(_f) + "' as an InstalledUnpackagedDependencyKey:");
+
+ std::ifstream f(stringify(_f).c_str());
+ if (! f)
+ throw FSError("Couldn't open '" + stringify(_f) + "' for read");
+
+ _v = DepParser::parse(strip_trailing(
+ std::string((std::istreambuf_iterator<char>(f)), std::istreambuf_iterator<char>()), "\n"));
+ return _v;
+ }
+
+ std::string
+ pretty_print(const DependencySpecTree::ItemFormatter & f) const
+ {
+ DepPrinter p(f, false);
+ value()->accept(p);
+ return p.result();
+ }
+
+ std::string
+ pretty_print_flat(const DependencySpecTree::ItemFormatter & f) const
+ {
+ DepPrinter p(f, true);
+ value()->accept(p);
+ return p.result();
+ }
+ };
}
namespace paludis
@@ -184,6 +235,9 @@ namespace paludis
tr1::shared_ptr<InstalledUnpackagedTimeKey> installed_time_key;
tr1::shared_ptr<InstalledUnpackagedStringKey> source_origin_key;
tr1::shared_ptr<InstalledUnpackagedStringKey> binary_origin_key;
+ tr1::shared_ptr<InstalledUnpackagedStringKey> description_key;
+ tr1::shared_ptr<InstalledUnpackagedDependencyKey> build_dependencies_key;
+ tr1::shared_ptr<InstalledUnpackagedDependencyKey> run_dependencies_key;
Implementation(
const Environment * const e,
@@ -215,6 +269,17 @@ namespace paludis
if ((l / "binary_repository").exists())
binary_origin_key.reset(new InstalledUnpackagedStringKey("binary_repository", "Binary repository", l / "binary_repository"));
+
+ if ((l / "description").exists())
+ description_key.reset(new InstalledUnpackagedStringKey("description", "Description", l / "description"));
+
+ if ((l / "build_dependencies").exists())
+ build_dependencies_key.reset(new InstalledUnpackagedDependencyKey(
+ "build_dependencies", "Build dependencies", l / "build_dependencies"));
+
+ if ((l / "run_dependencies").exists())
+ run_dependencies_key.reset(new InstalledUnpackagedDependencyKey(
+ "run_dependencies", "Run dependencies", l / "run_dependencies"));
}
};
}
@@ -234,6 +299,12 @@ InstalledUnpackagedID::InstalledUnpackagedID(const Environment * const e, const
add_metadata_key(_imp->source_origin_key);
if (_imp->binary_origin_key)
add_metadata_key(_imp->binary_origin_key);
+ if (_imp->description_key)
+ add_metadata_key(_imp->description_key);
+ if (_imp->build_dependencies_key)
+ add_metadata_key(_imp->build_dependencies_key);
+ if (_imp->run_dependencies_key)
+ add_metadata_key(_imp->run_dependencies_key);
}
InstalledUnpackagedID::~InstalledUnpackagedID()
@@ -336,13 +407,13 @@ InstalledUnpackagedID::contained_in_key() const
const tr1::shared_ptr<const MetadataSpecTreeKey<DependencySpecTree> >
InstalledUnpackagedID::build_dependencies_key() const
{
- return tr1::shared_ptr<const MetadataSpecTreeKey<DependencySpecTree> >();
+ return _imp->build_dependencies_key;
}
const tr1::shared_ptr<const MetadataSpecTreeKey<DependencySpecTree> >
InstalledUnpackagedID::run_dependencies_key() const
{
- return tr1::shared_ptr<const MetadataSpecTreeKey<DependencySpecTree> >();
+ return _imp->run_dependencies_key;
}
const tr1::shared_ptr<const MetadataSpecTreeKey<DependencySpecTree> >
@@ -372,7 +443,7 @@ InstalledUnpackagedID::homepage_key() const
const tr1::shared_ptr<const MetadataStringKey>
InstalledUnpackagedID::short_description_key() const
{
- return tr1::shared_ptr<const MetadataStringKey>();
+ return _imp->description_key;
}
const tr1::shared_ptr<const MetadataStringKey>
diff --git a/paludis/repositories/unpackaged/installed_repository.cc b/paludis/repositories/unpackaged/installed_repository.cc
index eb090a0..7322c9b 100644
--- a/paludis/repositories/unpackaged/installed_repository.cc
+++ b/paludis/repositories/unpackaged/installed_repository.cc
@@ -30,6 +30,7 @@
#include <paludis/util/dir_iterator.hh>
#include <paludis/util/system.hh>
#include <paludis/repository_info.hh>
+#include <paludis/stringify_formatter.hh>
#include <paludis/action.hh>
#include <paludis/environment.hh>
#include <paludis/dep_tag.hh>
@@ -260,6 +261,32 @@ InstalledUnpackagedRepository::merge(const MergeOptions & m)
throw InstallActionError("Could not write to '" + stringify(target_ver_dir / "source_repository") + "'");
}
+ if (m.package_id->short_description_key())
+ {
+ std::ofstream description_file(stringify(target_ver_dir / "description").c_str());
+ description_file << m.package_id->short_description_key()->value() << std::endl;
+ if (! description_file)
+ throw InstallActionError("Could not write to '" + stringify(target_ver_dir / "description") + "'");
+ }
+
+ if (m.package_id->build_dependencies_key())
+ {
+ std::ofstream build_dependencies_file(stringify(target_ver_dir / "build_dependencies").c_str());
+ StringifyFormatter f;
+ build_dependencies_file << m.package_id->build_dependencies_key()->pretty_print_flat(f) << std::endl;
+ if (! build_dependencies_file)
+ throw InstallActionError("Could not write to '" + stringify(target_ver_dir / "build_dependencies") + "'");
+ }
+
+ if (m.package_id->run_dependencies_key())
+ {
+ std::ofstream run_dependencies_file(stringify(target_ver_dir / "run_dependencies").c_str());
+ StringifyFormatter f;
+ run_dependencies_file << m.package_id->run_dependencies_key()->pretty_print_flat(f) << std::endl;
+ if (! run_dependencies_file)
+ throw InstallActionError("Could not write to '" + stringify(target_ver_dir / "run_dependencies") + "'");
+ }
+
NDBAMMerger merger(
NDBAMMergerOptions::create()
.environment(_imp->params.environment)
diff --git a/paludis/repositories/unpackaged/installed_repository_TEST.cc b/paludis/repositories/unpackaged/installed_repository_TEST.cc
index d8c3dcb..94166b8 100644
--- a/paludis/repositories/unpackaged/installed_repository_TEST.cc
+++ b/paludis/repositories/unpackaged/installed_repository_TEST.cc
@@ -373,6 +373,9 @@ namespace test_cases
.version(VersionSpec("1.0"))
.slot(SlotName("foo"))
.location(FSEntry("installed_repository_TEST_dir/src4a"))
+ .build_dependencies("")
+ .run_dependencies("")
+ .description("")
));
env.package_database()->add_repository(1, source_repo);
@@ -425,6 +428,9 @@ namespace test_cases
.version(VersionSpec("1.0"))
.slot(SlotName("foo"))
.location(FSEntry("installed_repository_TEST_dir/src4b1"))
+ .build_dependencies("")
+ .run_dependencies("")
+ .description("")
));
env.package_database()->add_repository(1, source_repo);
@@ -479,6 +485,9 @@ namespace test_cases
.version(VersionSpec("1.0"))
.slot(SlotName("foo"))
.location(FSEntry("installed_repository_TEST_dir/src4b2"))
+ .build_dependencies("")
+ .run_dependencies("")
+ .description("")
));
env.package_database()->add_repository(1, source_repo);
diff --git a/paludis/repositories/unpackaged/registration.cc b/paludis/repositories/unpackaged/registration.cc
index 505cc94..f1b122c 100644
--- a/paludis/repositories/unpackaged/registration.cc
+++ b/paludis/repositories/unpackaged/registration.cc
@@ -52,13 +52,28 @@ namespace
if (m->end() == m->find("slot") || ((slot = m->find("slot")->second)).empty())
throw unpackaged_repositories::RepositoryConfigurationError("Key 'slot' not specified or empty");
+ std::string build_dependencies;
+ if (m->end() != m->find("build_dependencies"))
+ build_dependencies = m->find("build_dependencies")->second;
+
+ std::string run_dependencies;
+ if (m->end() != m->find("run_dependencies"))
+ run_dependencies = m->find("run_dependencies")->second;
+
+ std::string description;
+ if (m->end() != m->find("description"))
+ description = m->find("description")->second;
+
return make_shared_ptr(new UnpackagedRepository(RepositoryName("unpackaged"),
unpackaged_repositories::UnpackagedRepositoryParams::create()
.environment(env)
.location(location)
.name(QualifiedPackageName(name))
.version(VersionSpec(version))
- .slot(SlotName(slot))));
+ .slot(SlotName(slot))
+ .build_dependencies(build_dependencies)
+ .run_dependencies(run_dependencies)
+ .description(description)));
}
tr1::shared_ptr<Repository>
diff --git a/paludis/repositories/unpackaged/unpackaged_id.cc b/paludis/repositories/unpackaged/unpackaged_id.cc
index e805ed3..5ca67b3 100644
--- a/paludis/repositories/unpackaged/unpackaged_id.cc
+++ b/paludis/repositories/unpackaged/unpackaged_id.cc
@@ -18,6 +18,9 @@
*/
#include <paludis/repositories/unpackaged/unpackaged_id.hh>
+#include <paludis/repositories/unpackaged/unpackaged_key.hh>
+#include <paludis/repositories/unpackaged/dep_parser.hh>
+#include <paludis/repositories/unpackaged/dep_printer.hh>
#include <paludis/util/private_implementation_pattern-impl.hh>
#include <paludis/util/fs_entry.hh>
#include <paludis/util/stringify.hh>
@@ -34,28 +37,6 @@
using namespace paludis;
using namespace paludis::unpackaged_repositories;
-namespace
-{
- class UnpackagedFSEntryKey :
- public MetadataFSEntryKey
- {
- private:
- const FSEntry _location;
-
- public:
- UnpackagedFSEntryKey(const FSEntry & l) :
- MetadataFSEntryKey("location", "Location", mkt_normal),
- _location(l)
- {
- }
-
- const FSEntry value() const
- {
- return _location;
- }
- };
-}
-
namespace paludis
{
template <>
@@ -67,31 +48,44 @@ namespace paludis
const SlotName slot;
const RepositoryName repository_name;
- tr1::shared_ptr<UnpackagedFSEntryKey> fs_location_key;
+ const tr1::shared_ptr<UnpackagedFSEntryKey> fs_location_key;
+ const tr1::shared_ptr<const MetadataSpecTreeKey<DependencySpecTree> > build_dependencies_key;
+ const tr1::shared_ptr<const MetadataSpecTreeKey<DependencySpecTree> > run_dependencies_key;
+ const tr1::shared_ptr<const MetadataStringKey> description_key;
Implementation(const Environment * const e,
const QualifiedPackageName & q,
const VersionSpec & v,
const SlotName & s,
- const RepositoryName & r,
- const FSEntry & l) :
+ const RepositoryName & n,
+ const FSEntry & l,
+ const std::string & b,
+ const std::string & r,
+ const std::string & d) :
env(e),
name(q),
version(v),
slot(s),
- repository_name(r),
- fs_location_key(new UnpackagedFSEntryKey(l))
+ repository_name(n),
+ fs_location_key(new UnpackagedFSEntryKey("location", "Location", mkt_normal, l)),
+ build_dependencies_key(new UnpackagedDependencyKey("build_dependencies", "Build dependencies", mkt_dependencies, b)),
+ run_dependencies_key(new UnpackagedDependencyKey("run_dependencies", "Run dependencies", mkt_dependencies, r)),
+ description_key(new UnpackagedStringKey("description", "Description", mkt_significant, d))
{
}
};
}
UnpackagedID::UnpackagedID(const Environment * const e, const QualifiedPackageName & q,
- const VersionSpec & v, const SlotName & s, const RepositoryName & n, const FSEntry & l) :
- PrivateImplementationPattern<UnpackagedID>(new Implementation<UnpackagedID>(e, q, v, s, n, l)),
+ const VersionSpec & v, const SlotName & s, const RepositoryName & n, const FSEntry & l,
+ const std::string & b, const std::string & r, const std::string & d) :
+ PrivateImplementationPattern<UnpackagedID>(new Implementation<UnpackagedID>(e, q, v, s, n, l, b, r, d)),
_imp(PrivateImplementationPattern<UnpackagedID>::_imp.get())
{
add_metadata_key(_imp->fs_location_key);
+ add_metadata_key(_imp->build_dependencies_key);
+ add_metadata_key(_imp->run_dependencies_key);
+ add_metadata_key(_imp->description_key);
}
UnpackagedID::~UnpackagedID()
@@ -194,13 +188,13 @@ UnpackagedID::contained_in_key() const
const tr1::shared_ptr<const MetadataSpecTreeKey<DependencySpecTree> >
UnpackagedID::build_dependencies_key() const
{
- return tr1::shared_ptr<const MetadataSpecTreeKey<DependencySpecTree> >();
+ return _imp->build_dependencies_key;
}
const tr1::shared_ptr<const MetadataSpecTreeKey<DependencySpecTree> >
UnpackagedID::run_dependencies_key() const
{
- return tr1::shared_ptr<const MetadataSpecTreeKey<DependencySpecTree> >();
+ return _imp->run_dependencies_key;
}
const tr1::shared_ptr<const MetadataSpecTreeKey<DependencySpecTree> >
@@ -230,7 +224,7 @@ UnpackagedID::homepage_key() const
const tr1::shared_ptr<const MetadataStringKey>
UnpackagedID::short_description_key() const
{
- return tr1::shared_ptr<const MetadataStringKey>();
+ return _imp->description_key;
}
const tr1::shared_ptr<const MetadataStringKey>
diff --git a/paludis/repositories/unpackaged/unpackaged_id.hh b/paludis/repositories/unpackaged/unpackaged_id.hh
index c30e10b..47dda1f 100644
--- a/paludis/repositories/unpackaged/unpackaged_id.hh
+++ b/paludis/repositories/unpackaged/unpackaged_id.hh
@@ -44,7 +44,8 @@ namespace paludis
public:
UnpackagedID(const Environment * const, const QualifiedPackageName &, const VersionSpec &,
- const SlotName &, const RepositoryName &, const FSEntry &);
+ const SlotName &, const RepositoryName &, const FSEntry &,
+ const std::string &, const std::string &, const std::string &);
~UnpackagedID();
diff --git a/paludis/repositories/unpackaged/unpackaged_key.cc b/paludis/repositories/unpackaged/unpackaged_key.cc
new file mode 100644
index 0000000..b25499e
--- /dev/null
+++ b/paludis/repositories/unpackaged/unpackaged_key.cc
@@ -0,0 +1,140 @@
+/* vim: set sw=4 sts=4 et foldmethod=syntax : */
+
+/*
+ * Copyright (c) 2007 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 <paludis/repositories/unpackaged/unpackaged_key.hh>
+#include <paludis/repositories/unpackaged/dep_printer.hh>
+#include <paludis/repositories/unpackaged/dep_parser.hh>
+#include <paludis/util/private_implementation_pattern-impl.hh>
+#include <paludis/util/fs_entry.hh>
+
+using namespace paludis;
+using namespace paludis::unpackaged_repositories;
+
+namespace paludis
+{
+ template <>
+ struct Implementation<UnpackagedFSEntryKey>
+ {
+ const FSEntry value;
+
+ Implementation(const FSEntry & v) :
+ value(v)
+ {
+ }
+ };
+}
+
+UnpackagedFSEntryKey::UnpackagedFSEntryKey(const std::string & r, const std::string & h, const MetadataKeyType t,
+ const FSEntry & v) :
+ MetadataFSEntryKey(r, h, t),
+ PrivateImplementationPattern<UnpackagedFSEntryKey>(new Implementation<UnpackagedFSEntryKey>(v)),
+ _imp(PrivateImplementationPattern<UnpackagedFSEntryKey>::_imp.get())
+{
+}
+
+UnpackagedFSEntryKey::~UnpackagedFSEntryKey()
+{
+}
+
+const FSEntry
+UnpackagedFSEntryKey::value() const
+{
+ return _imp->value;
+}
+
+namespace paludis
+{
+ template <>
+ struct Implementation<UnpackagedStringKey>
+ {
+ const std::string value;
+
+ Implementation(const std::string & v) :
+ value(v)
+ {
+ }
+ };
+}
+
+UnpackagedStringKey::UnpackagedStringKey(const std::string & r, const std::string & h, const MetadataKeyType t,
+ const std::string & v) :
+ MetadataStringKey(r, h, t),
+ PrivateImplementationPattern<UnpackagedStringKey>(new Implementation<UnpackagedStringKey>(v)),
+ _imp(PrivateImplementationPattern<UnpackagedStringKey>::_imp.get())
+{
+}
+
+UnpackagedStringKey::~UnpackagedStringKey()
+{
+}
+
+const std::string
+UnpackagedStringKey::value() const
+{
+ return _imp->value;
+}
+
+namespace paludis
+{
+ template <>
+ struct Implementation<UnpackagedDependencyKey>
+ {
+ const tr1::shared_ptr<const DependencySpecTree::ConstItem> value;
+
+ Implementation(const std::string & v) :
+ value(DepParser::parse(v))
+ {
+ }
+ };
+}
+
+UnpackagedDependencyKey::UnpackagedDependencyKey(const std::string & r, const std::string & h, const MetadataKeyType t,
+ const std::string & v) :
+ MetadataSpecTreeKey<DependencySpecTree>(r, h, t),
+ PrivateImplementationPattern<UnpackagedDependencyKey>(new Implementation<UnpackagedDependencyKey>(v)),
+ _imp(PrivateImplementationPattern<UnpackagedDependencyKey>::_imp.get())
+{
+}
+
+UnpackagedDependencyKey::~UnpackagedDependencyKey()
+{
+}
+
+const tr1::shared_ptr<const DependencySpecTree::ConstItem>
+UnpackagedDependencyKey::value() const
+{
+ return _imp->value;
+}
+
+std::string
+UnpackagedDependencyKey::pretty_print(const DependencySpecTree::ItemFormatter & f) const
+{
+ DepPrinter p(f, false);
+ _imp->value->accept(p);
+ return p.result();
+}
+
+std::string
+UnpackagedDependencyKey::pretty_print_flat(const DependencySpecTree::ItemFormatter & f) const
+{
+ DepPrinter p(f, true);
+ _imp->value->accept(p);
+ return p.result();
+}
+
diff --git a/paludis/repositories/unpackaged/unpackaged_key.hh b/paludis/repositories/unpackaged/unpackaged_key.hh
new file mode 100644
index 0000000..e52fd0c
--- /dev/null
+++ b/paludis/repositories/unpackaged/unpackaged_key.hh
@@ -0,0 +1,79 @@
+/* vim: set sw=4 sts=4 et foldmethod=syntax : */
+
+/*
+ * Copyright (c) 2007 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_PALUDIS_REPOSITORIES_UNPACKAGED_UNPACKAGED_KEY_HH
+#define PALUDIS_GUARD_PALUDIS_REPOSITORIES_UNPACKAGED_UNPACKAGED_KEY_HH 1
+
+#include <paludis/metadata_key.hh>
+#include <paludis/util/private_implementation_pattern.hh>
+
+namespace paludis
+{
+ namespace unpackaged_repositories
+ {
+ class UnpackagedFSEntryKey :
+ public MetadataFSEntryKey,
+ private PrivateImplementationPattern<UnpackagedFSEntryKey>
+ {
+ private:
+ Implementation<UnpackagedFSEntryKey> * const _imp;
+
+ public:
+ UnpackagedFSEntryKey(const std::string &, const std::string &, const MetadataKeyType, const FSEntry & l);
+ ~UnpackagedFSEntryKey();
+
+ const FSEntry value() const;
+ };
+
+ class UnpackagedStringKey :
+ public MetadataStringKey,
+ private PrivateImplementationPattern<UnpackagedStringKey>
+ {
+ private:
+ Implementation<UnpackagedStringKey> * const _imp;
+
+ public:
+ UnpackagedStringKey(const std::string & r, const std::string & h, const MetadataKeyType t, const std::string & v);
+ ~UnpackagedStringKey();
+
+ const std::string value() const;
+ };
+
+ class UnpackagedDependencyKey :
+ public MetadataSpecTreeKey<DependencySpecTree>,
+ private PrivateImplementationPattern<UnpackagedDependencyKey>
+ {
+ private:
+ Implementation<UnpackagedDependencyKey> * const _imp;
+
+ public:
+ UnpackagedDependencyKey(const std::string & r, const std::string & h, const MetadataKeyType t,
+ const std::string & v);
+ ~UnpackagedDependencyKey();
+
+ const tr1::shared_ptr<const DependencySpecTree::ConstItem> value() const;
+
+ std::string pretty_print(const DependencySpecTree::ItemFormatter & f) const;
+
+ std::string pretty_print_flat(const DependencySpecTree::ItemFormatter & f) const;
+ };
+ }
+}
+
+#endif
diff --git a/paludis/repositories/unpackaged/unpackaged_repository.cc b/paludis/repositories/unpackaged/unpackaged_repository.cc
index f55d54d..21c97e5 100644
--- a/paludis/repositories/unpackaged/unpackaged_repository.cc
+++ b/paludis/repositories/unpackaged/unpackaged_repository.cc
@@ -47,7 +47,8 @@ namespace paludis
Implementation(const RepositoryName & n,
const UnpackagedRepositoryParams & p) :
params(p),
- id(new UnpackagedID(params.environment, params.name, params.version, params.slot, n, params.location)),
+ id(new UnpackagedID(params.environment, params.name, params.version, params.slot, n, params.location,
+ params.build_dependencies, params.run_dependencies, params.description)),
ids(new PackageIDSequence),
package_names(new QualifiedPackageNameSet),
category_names(new CategoryNamePartSet)
@@ -87,6 +88,9 @@ UnpackagedRepository::UnpackagedRepository(const RepositoryName & n,
config_info->add_kv("version", stringify(_imp->params.version));
config_info->add_kv("slot", stringify(_imp->params.slot));
config_info->add_kv("format", "unpackaged");
+ config_info->add_kv("build_dependencies", _imp->params.build_dependencies);
+ config_info->add_kv("run_dependencies", _imp->params.run_dependencies);
+ config_info->add_kv("description", _imp->params.description);
_info->add_section(config_info);
}
diff --git a/paludis/repositories/unpackaged/unpackaged_repository.sr b/paludis/repositories/unpackaged/unpackaged_repository.sr
index 472e9b9..366006c 100644
--- a/paludis/repositories/unpackaged/unpackaged_repository.sr
+++ b/paludis/repositories/unpackaged/unpackaged_repository.sr
@@ -10,6 +10,9 @@ make_class_UnpackagedRepositoryParams()
key name QualifiedPackageName
key version VersionSpec
key slot SlotName
+ key build_dependencies std::string
+ key run_dependencies std::string
+ key description std::string
allow_named_args
}
diff --git a/paludis/repositories/unpackaged/unpackaged_repository_TEST.cc b/paludis/repositories/unpackaged/unpackaged_repository_TEST.cc
index 3152aa5..97348f3 100644
--- a/paludis/repositories/unpackaged/unpackaged_repository_TEST.cc
+++ b/paludis/repositories/unpackaged/unpackaged_repository_TEST.cc
@@ -52,6 +52,9 @@ namespace test_cases
.version(VersionSpec("1.0"))
.slot(SlotName("foo"))
.location(FSEntry("unpackaged_repository_TEST_dir/pkg"))
+ .build_dependencies("")
+ .run_dependencies("")
+ .description("")
));
env.package_database()->add_repository(1, repo);
@@ -77,6 +80,9 @@ namespace test_cases
.version(VersionSpec("1.0"))
.slot(SlotName("foo"))
.location(FSEntry("unpackaged_repository_TEST_dir/pkg"))
+ .build_dependencies("")
+ .run_dependencies("")
+ .description("")
));
env.package_database()->add_repository(1, repo);
@@ -107,6 +113,9 @@ namespace test_cases
.version(VersionSpec("1.0"))
.slot(SlotName("foo"))
.location(FSEntry("unpackaged_repository_TEST_dir/pkg"))
+ .build_dependencies("")
+ .run_dependencies("")
+ .description("")
));
env.package_database()->add_repository(1, repo);
@@ -132,6 +141,9 @@ namespace test_cases
.version(VersionSpec("1.0"))
.slot(SlotName("foo"))
.location(FSEntry("unpackaged_repository_TEST_dir/pkg"))
+ .build_dependencies("")
+ .run_dependencies("")
+ .description("")
));
env.package_database()->add_repository(1, repo);
@@ -170,6 +182,9 @@ namespace test_cases
.version(VersionSpec("1.0"))
.slot(SlotName("foo"))
.location(FSEntry("unpackaged_repository_TEST_dir/pkg"))
+ .build_dependencies("")
+ .run_dependencies("")
+ .description("")
));
env.package_database()->add_repository(1, repo);
diff --git a/src/clients/importare/command_line.cc b/src/clients/importare/command_line.cc
index abddbe5..f604d4d 100644
--- a/src/clients/importare/command_line.cc
+++ b/src/clients/importare/command_line.cc
@@ -46,6 +46,13 @@ CommandLine::CommandLine() :
"Options affecting the source image"),
a_location(&source_args, "location", 'l', "Location of source image (default: current directory)"),
+ metadata_args(this, "Metadata options",
+ "Options affecting generated metadata"),
+ a_description(&metadata_args, "description", 'D', "Specify a package description"),
+ a_build_dependency(&metadata_args, "build-dependency", 'B', "Specify a build dependency"),
+ a_run_dependency(&metadata_args, "run-dependency", 'R', "Specify a run dependency"),
+ a_preserve_metadata(&metadata_args, "preserve-metadata", 'P', "If replacing a package, copy its description and dependencies"),
+
install_args(this, "Install options",
"Options which are relevant for --install"),
@@ -78,6 +85,14 @@ CommandLine::CommandLine() :
"from an autotools package) as 'unpackaged/myapp' version 1.23. If 'unpackaged/myapp' is already installed, "
"it will be replaced.");
add_example(
+ "importare --location img/ unpackaged/myapp 1.23 --run-dependency dev-libs/mpfr --run-dependency dev-libs/gmp",
+ "As above, and add dependencies. Dependencies are used for resolution and to provide correct output for "
+ "paludis --uninstall(-unused).");
+ add_example(
+ "importare --location img/ unpackaged/myapp 1.23 --preserve-metadata",
+ "If an existing version of unpackaged/myapp was installed using importare, copies metadata (build and run "
+ "dependencies, and description) from that version.");
+ add_example(
"importare --location /var/empty sys-apps/portage 2.2",
"Install an empty fake package named 'sys-apps/portage', version 2.2. DANGEROUS!");
}
diff --git a/src/clients/importare/command_line.hh b/src/clients/importare/command_line.hh
index d66371c..90405d4 100644
--- a/src/clients/importare/command_line.hh
+++ b/src/clients/importare/command_line.hh
@@ -56,6 +56,12 @@ class CommandLine :
paludis::args::ArgsGroup source_args;
paludis::args::StringArg a_location;
+ paludis::args::ArgsGroup metadata_args;
+ paludis::args::StringArg a_description;
+ paludis::args::StringSetArg a_build_dependency;
+ paludis::args::StringSetArg a_run_dependency;
+ paludis::args::SwitchArg a_preserve_metadata;
+
paludis::args::InstallArgsGroup install_args;
paludis::args::DepListArgsGroup dl_args;
};
diff --git a/src/clients/importare/importare.cc b/src/clients/importare/importare.cc
index add6127..7125dea 100644
--- a/src/clients/importare/importare.cc
+++ b/src/clients/importare/importare.cc
@@ -31,6 +31,10 @@
#include <paludis/about.hh>
#include <paludis/repository_maker.hh>
#include <paludis/fuzzy_finder.hh>
+#include <paludis/query.hh>
+#include <paludis/package_id.hh>
+#include <paludis/metadata_key.hh>
+#include <paludis/stringify_formatter.hh>
#include <algorithm>
#include <iterator>
@@ -121,6 +125,46 @@ main(int argc, char *argv[])
VersionSpec v(params.size() >= 2 ? params[1] : "0");
SlotName s(params.size() >= 3 ? params[2] : "0");
+ std::string build_dependencies, run_dependencies, description;
+
+ if (CommandLine::get_instance()->a_preserve_metadata.specified())
+ {
+ tr1::shared_ptr<const PackageIDSequence> old_ids(
+ env->package_database()->query(query::Package(q), qo_order_by_version));
+ tr1::shared_ptr<const PackageID> old_id;
+ for (PackageIDSequence::ConstIterator i(old_ids->begin()), i_end(old_ids->end()) ;
+ i != i_end ; ++i)
+ {
+ if ((*i)->repository()->format() != "installed_unpackaged")
+ continue;
+ old_id = *i;
+ break;
+ }
+
+ if (! old_id)
+ throw args::DoHelp("--" + CommandLine::get_instance()->a_preserve_metadata.long_name() + " specified but "
+ "no old ID available");
+
+ StringifyFormatter f;
+ if (old_id->short_description_key())
+ description = old_id->short_description_key()->value();
+ if (old_id->build_dependencies_key())
+ build_dependencies = old_id->build_dependencies_key()->pretty_print_flat(f);
+ if (old_id->run_dependencies_key())
+ run_dependencies = old_id->run_dependencies_key()->pretty_print_flat(f);
+ }
+
+ if (CommandLine::get_instance()->a_description.specified())
+ description = CommandLine::get_instance()->a_description.argument();
+ if (CommandLine::get_instance()->a_build_dependency.specified())
+ build_dependencies = join(
+ CommandLine::get_instance()->a_build_dependency.begin_args(),
+ CommandLine::get_instance()->a_build_dependency.end_args(), ", ");
+ if (CommandLine::get_instance()->a_run_dependency.specified())
+ run_dependencies = join(
+ CommandLine::get_instance()->a_run_dependency.begin_args(),
+ CommandLine::get_instance()->a_run_dependency.end_args(), ", ");
+
tr1::shared_ptr<Map<std::string, std::string> > keys(new Map<std::string, std::string>);
keys->insert("location", stringify(
CommandLine::get_instance()->a_location.specified() ?
@@ -130,6 +174,9 @@ main(int argc, char *argv[])
keys->insert("name", stringify(q));
keys->insert("version", stringify(v));
keys->insert("slot", stringify(s));
+ keys->insert("description", description);
+ keys->insert("build_dependencies", build_dependencies);
+ keys->insert("run_dependencies", run_dependencies);
tr1::shared_ptr<Repository> repo((*RepositoryMaker::get_instance()->find_maker("unpackaged"))(env.get(), keys));
env->package_database()->add_repository(10, repo);
tr1::shared_ptr<const PackageIDSequence> ids(repo->package_ids(q));