aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAvatar Ciaran McCreesh <ciaran.mccreesh@googlemail.com> 2011-02-20 15:59:40 +0000
committerAvatar Ciaran McCreesh <ciaran.mccreesh@googlemail.com> 2011-02-20 17:10:17 +0000
commit519382831287501084a67bc25be2e50fca275d58 (patch)
tree486fba6ceb2237bab3fa5832c548ade29b68d401
parentd4a242b1691f34bcdb8ceb0a7785e5029e0baf22 (diff)
downloadpaludis-519382831287501084a67bc25be2e50fca275d58.tar.gz
paludis-519382831287501084a67bc25be2e50fca275d58.tar.xz
Track SCM revision for installed packages
-rw-r--r--paludis/repositories/e/e_installed_repository_id.cc6
-rw-r--r--paludis/repositories/e/e_installed_repository_id.hh6
-rw-r--r--paludis/repositories/e/e_repository_id.cc8
-rw-r--r--paludis/repositories/e/e_repository_id.hh11
-rw-r--r--paludis/repositories/e/eapis/exheres-0.conf7
-rw-r--r--paludis/repositories/e/ebuild.cc10
-rw-r--r--paludis/repositories/e/ebuild/exheres-0/output_functions.bash5
-rw-r--r--paludis/repositories/e/ebuild_id.cc30
-rw-r--r--paludis/repositories/e/ebuild_id.hh4
-rw-r--r--paludis/repositories/e/pipe_command_handler.cc23
-rw-r--r--paludis/repositories/e/pipe_command_handler.hh6
11 files changed, 105 insertions, 11 deletions
diff --git a/paludis/repositories/e/e_installed_repository_id.cc b/paludis/repositories/e/e_installed_repository_id.cc
index aa77358..ae7b713 100644
--- a/paludis/repositories/e/e_installed_repository_id.cc
+++ b/paludis/repositories/e/e_installed_repository_id.cc
@@ -1117,3 +1117,9 @@ EInstalledRepositoryID::is_installed() const
return true;
}
+void
+EInstalledRepositoryID::set_scm_revision(const std::string & s) const
+{
+ throw CannotChangeSCMRevision(stringify(*this), s);
+}
+
diff --git a/paludis/repositories/e/e_installed_repository_id.hh b/paludis/repositories/e/e_installed_repository_id.hh
index 342740e..91b81a1 100644
--- a/paludis/repositories/e/e_installed_repository_id.hh
+++ b/paludis/repositories/e/e_installed_repository_id.hh
@@ -90,10 +90,8 @@ namespace paludis
virtual const std::shared_ptr<const MetadataCollectionKey<Set<std::string> > > defined_phases_key() const;
virtual const std::shared_ptr<const MetadataSpecTreeKey<LicenseSpecTree> > license_key() const;
virtual const std::shared_ptr<const MetadataSpecTreeKey<RequiredUseSpecTree> > required_use_key() const;
-
- virtual const std::shared_ptr<const MetadataCollectionKey<Set<std::string> > > behaviours_key() const;
-
virtual const std::shared_ptr<const MetadataValueKey<std::string> > scm_revision_key() const;
+ virtual const std::shared_ptr<const MetadataCollectionKey<Set<std::string> > > behaviours_key() const;
virtual bool supports_action(const SupportsActionTestBase &) const PALUDIS_ATTRIBUTE((warn_unused_result));
virtual void perform_action(Action &) const;
@@ -117,6 +115,8 @@ namespace paludis
virtual void purge_invalid_cache() const;
virtual void can_drop_in_memory_cache() const;
+
+ virtual void set_scm_revision(const std::string &) const PALUDIS_ATTRIBUTE((noreturn));
};
}
}
diff --git a/paludis/repositories/e/e_repository_id.cc b/paludis/repositories/e/e_repository_id.cc
index 8f208bc..6c88596 100644
--- a/paludis/repositories/e/e_repository_id.cc
+++ b/paludis/repositories/e/e_repository_id.cc
@@ -1,7 +1,7 @@
/* vim: set sw=4 sts=4 et foldmethod=syntax : */
/*
- * Copyright (c) 2007, 2008, 2010 Ciaran McCreesh
+ * Copyright (c) 2007, 2008, 2010, 2011 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
@@ -36,3 +36,9 @@ ERepositoryID::breaks_portage() const
return why;
}
+CannotChangeSCMRevision::CannotChangeSCMRevision(const std::string & id_s, const std::string & revision) throw () :
+ Exception("Cannot change SCM revision for '" + id_s + "' to '" + revision + "'")
+{
+}
+
+
diff --git a/paludis/repositories/e/e_repository_id.hh b/paludis/repositories/e/e_repository_id.hh
index a030811..43c0f41 100644
--- a/paludis/repositories/e/e_repository_id.hh
+++ b/paludis/repositories/e/e_repository_id.hh
@@ -22,12 +22,20 @@
#include <paludis/package_id.hh>
#include <paludis/util/tribool.hh>
+#include <paludis/util/exception.hh>
#include <paludis/repositories/e/eapi-fwd.hh>
namespace paludis
{
namespace erepository
{
+ class PALUDIS_VISIBLE CannotChangeSCMRevision :
+ public Exception
+ {
+ public:
+ CannotChangeSCMRevision(const std::string & id_s, const std::string & revision) throw ();
+ };
+
class ERepositoryID :
public PackageID
{
@@ -47,6 +55,7 @@ namespace paludis
virtual const std::shared_ptr<const MetadataCollectionKey<Set<std::string> > > raw_use_expand_hidden_key() const = 0;
virtual const std::shared_ptr<const MetadataCollectionKey<Set<std::string> > > defined_phases_key() const = 0;
virtual const std::shared_ptr<const MetadataSpecTreeKey<RequiredUseSpecTree> > required_use_key() const = 0;
+ virtual const std::shared_ptr<const MetadataValueKey<std::string> > scm_revision_key() const = 0;
virtual std::shared_ptr<const Set<std::string> > breaks_portage() const PALUDIS_ATTRIBUTE((warn_unused_result));
@@ -58,6 +67,8 @@ namespace paludis
virtual void add_build_options(const std::shared_ptr<Choices> &) const = 0;
virtual void purge_invalid_cache() const = 0;
+
+ virtual void set_scm_revision(const std::string &) const = 0;
};
}
}
diff --git a/paludis/repositories/e/eapis/exheres-0.conf b/paludis/repositories/e/eapis/exheres-0.conf
index be46eb9..1655cd7 100644
--- a/paludis/repositories/e/eapis/exheres-0.conf
+++ b/paludis/repositories/e/eapis/exheres-0.conf
@@ -45,7 +45,7 @@ vdb_from_env_unless_empty_variables = \
EXTRA_ECONF EXTRA_EINSTALL EXTRA_EMAKE LDFLAGS LIBCXXFLAGS \
REPOSITORY BINARY_REPOSITORY RESTRICT BUGS_TO REMOTE_IDS UPSTREAM_CHANGELOG \
UPSTREAM_RELEASE_NOTES UPSTREAM_DOCUMENTATION DESCRIPTION \
- DEFINED_PHASES
+ DEFINED_PHASES SCM_REVISION
binary_from_env_variables = \
CHOST DEPENDENCIES DESCRIPTION EAPI HOMEPAGE INHERITED MYOPTIONS PLATFORMS LICENCES \
@@ -53,7 +53,8 @@ binary_from_env_variables = \
ASFLAGS CBUILD CC CFLAGS CHOST CTARGET CXX CXXFLAGS \
EXTRA_ECONF EXTRA_EINSTALL EXTRA_EMAKE LDFLAGS LIBCXXFLAGS \
GENERATED_FROM_REPOSITORY PLATFORMS BINARY_PLATFORMS BINARY_URI \
- SUMMARY BUGS_TO REMOTE_IDS UPSTREAM_CHANGELOG UPSTREAM_RELEASE_NOTES UPSTREAM_DOCUMENTATION
+ SUMMARY BUGS_TO REMOTE_IDS UPSTREAM_CHANGELOG UPSTREAM_RELEASE_NOTES \
+ UPSTREAM_DOCUMENTATION SCM_REVISION
non_empty_variables = \
PNV PV PR PN PVR PNVR CATEGORY build:FILES build:EXLIBSDIRS build:FETCHEDDIR build:REPODIR \
@@ -247,7 +248,7 @@ description_choices = Options
description_use_expand = Suboptions
description_use_expand_hidden = Hidden suboptions
description_defined_phases = Defined phases
-description_scm_revision = SCM_REVISION
+description_scm_revision = SCM revision
flat_list_minimum_size = -1
flat_list_build_depend = -1
diff --git a/paludis/repositories/e/ebuild.cc b/paludis/repositories/e/ebuild.cc
index 2a1fa5c..e2863c2 100644
--- a/paludis/repositories/e/ebuild.cc
+++ b/paludis/repositories/e/ebuild.cc
@@ -1053,6 +1053,11 @@ WriteVDBEntryCommand::operator() ()
join(params.package_id()->raw_iuse_effective_key()->value()->begin(),
params.package_id()->raw_iuse_effective_key()->value()->end(), " "));
+ if (! params.package_id()->eapi()->supported()->ebuild_metadata_variables()->scm_revision()->name().empty())
+ if (params.package_id()->scm_revision_key())
+ process.setenv(params.package_id()->eapi()->supported()->ebuild_metadata_variables()->scm_revision()->name(),
+ params.package_id()->scm_revision_key()->value());;
+
if (params.maybe_output_manager())
process
.capture_stderr(params.maybe_output_manager()->stderr_stream())
@@ -1294,6 +1299,11 @@ WriteBinaryEbuildCommand::operator() ()
.pipe_command_handler("PALUDIS_PIPE_COMMAND", std::bind(&pipe_command_handler, params.environment(),
params.package_id(), false, _1, params.maybe_output_manager()));
+ if (! params.package_id()->eapi()->supported()->ebuild_metadata_variables()->scm_revision()->name().empty())
+ if (params.package_id()->scm_revision_key())
+ process.setenv(params.package_id()->eapi()->supported()->ebuild_metadata_variables()->scm_revision()->name(),
+ params.package_id()->scm_revision_key()->value());;
+
if (0 != process.run().wait())
throw ActionFailedError("Write binary command failed");
}
diff --git a/paludis/repositories/e/ebuild/exheres-0/output_functions.bash b/paludis/repositories/e/ebuild/exheres-0/output_functions.bash
index 92aaa3b..5aa237e 100644
--- a/paludis/repositories/e/ebuild/exheres-0/output_functions.bash
+++ b/paludis/repositories/e/ebuild/exheres-0/output_functions.bash
@@ -35,3 +35,8 @@ exlogfailure()
paludis_pipe_command KEEP_LOGS "$EAPI" "$@" >/dev/null
}
+exsetscmrevision()
+{
+ paludis_pipe_command SET_SCM_REVISION "$EAPI" "$@" >/dev/null
+}
+
diff --git a/paludis/repositories/e/ebuild_id.cc b/paludis/repositories/e/ebuild_id.cc
index d4c9d27..e8c338f 100644
--- a/paludis/repositories/e/ebuild_id.cc
+++ b/paludis/repositories/e/ebuild_id.cc
@@ -167,7 +167,7 @@ namespace paludis
mutable std::shared_ptr<const LiteralMetadataTimeKey> generated_time;
mutable std::shared_ptr<const LiteralMetadataValueKey<std::string> > generated_using;
mutable std::shared_ptr<const LiteralMetadataStringSetKey> behaviours;
-
+ mutable std::shared_ptr<const LiteralMetadataValueKey<std::string> > scm_revision;
Imp(const QualifiedPackageName & q, const VersionSpec & v,
const Environment * const e,
@@ -1403,6 +1403,13 @@ EbuildID::slot_key() const
return _imp->slot;
}
+const std::shared_ptr<const MetadataValueKey<std::string> >
+EbuildID::scm_revision_key() const
+{
+ need_keys_added();
+ return _imp->scm_revision;
+}
+
namespace
{
std::string get_description(const std::shared_ptr<const UseDesc> & use_desc, const std::string & override_description,
@@ -1672,3 +1679,24 @@ EbuildID::is_installed() const
return false;
}
+void
+EbuildID::set_scm_revision(const std::string & s) const
+{
+ Lock l(_imp->mutex);
+
+ if ((! eapi()->supported()) ||
+ eapi()->supported()->ebuild_metadata_variables()->scm_revision()->name().empty() ||
+ _imp->scm_revision)
+ throw CannotChangeSCMRevision(stringify(*this), s);
+ else
+ {
+ _imp->scm_revision = std::make_shared<LiteralMetadataValueKey<std::string> >(
+ eapi()->supported()->ebuild_metadata_variables()->scm_revision()->name(),
+ eapi()->supported()->ebuild_metadata_variables()->scm_revision()->description(),
+ mkt_normal,
+ s);
+
+ add_metadata_key(_imp->scm_revision);
+ }
+}
+
diff --git a/paludis/repositories/e/ebuild_id.hh b/paludis/repositories/e/ebuild_id.hh
index 8691c21..5f1c7b8 100644
--- a/paludis/repositories/e/ebuild_id.hh
+++ b/paludis/repositories/e/ebuild_id.hh
@@ -24,6 +24,7 @@
#include <paludis/metadata_key.hh>
#include <paludis/repositories/e/eapi-fwd.hh>
#include <paludis/repositories/e/e_repository_id.hh>
+#include <paludis/util/exception.hh>
namespace paludis
{
@@ -97,6 +98,7 @@ namespace paludis
virtual const std::shared_ptr<const MetadataCollectionKey<Set<std::string> > > raw_use_expand_hidden_key() const;
virtual const std::shared_ptr<const MetadataCollectionKey<Set<std::string> > > defined_phases_key() const;
virtual const std::shared_ptr<const MetadataSpecTreeKey<RequiredUseSpecTree> > required_use_key() const;
+ virtual const std::shared_ptr<const MetadataValueKey<std::string> > scm_revision_key() const;
virtual const std::shared_ptr<const MetadataCollectionKey<Set<std::string> > > behaviours_key() const;
@@ -168,6 +170,8 @@ namespace paludis
virtual void purge_invalid_cache() const;
bool might_be_binary() const;
+
+ virtual void set_scm_revision(const std::string &) const;
};
}
}
diff --git a/paludis/repositories/e/pipe_command_handler.cc b/paludis/repositories/e/pipe_command_handler.cc
index 14dbefa..8a81d03 100644
--- a/paludis/repositories/e/pipe_command_handler.cc
+++ b/paludis/repositories/e/pipe_command_handler.cc
@@ -23,6 +23,7 @@
#include <paludis/repositories/e/fix_locked_dependencies.hh>
#include <paludis/repositories/e/dep_parser.hh>
#include <paludis/repositories/e/spec_tree_pretty_printer.hh>
+#include <paludis/repositories/e/e_repository_id.hh>
#include <paludis/util/log.hh>
#include <paludis/util/join.hh>
#include <paludis/util/exception.hh>
@@ -158,7 +159,7 @@ namespace
std::string
paludis::erepository::pipe_command_handler(const Environment * const environment,
- const std::shared_ptr<const PackageID> & package_id, bool in_metadata_generation,
+ const std::shared_ptr<const ERepositoryID> & package_id, bool in_metadata_generation,
const std::string & s, const std::shared_ptr<OutputManager> & maybe_output_manager)
{
Context context("In ebuild pipe command handler:");
@@ -226,6 +227,26 @@ paludis::erepository::pipe_command_handler(const Environment * const environment
maybe_output_manager->ignore_succeeded();
return "O0;";
}
+ else if (tokens[0] == "SET_SCM_REVISION")
+ {
+ if (tokens.size() != 3)
+ {
+ Log::get_instance()->message("e.pipe_commands.set_scm_revision.bad", ll_warning, lc_context) << "Got too short SET_SCM_REVISION pipe command";
+ return "Ebad SET_SCM_REVISION command";
+ }
+ else
+ {
+ try
+ {
+ package_id->set_scm_revision(tokens[2]);
+ return "O0;";
+ }
+ catch (const Exception & e)
+ {
+ return "Egot error '" + e.message() + "' (" + e.what() + ") when trying to SET_SCM_REVISION";
+ }
+ }
+ }
else if (tokens[0] == "MESSAGE")
{
if (tokens.size() == 3)
diff --git a/paludis/repositories/e/pipe_command_handler.hh b/paludis/repositories/e/pipe_command_handler.hh
index 64c5b04..6bc9979 100644
--- a/paludis/repositories/e/pipe_command_handler.hh
+++ b/paludis/repositories/e/pipe_command_handler.hh
@@ -1,7 +1,7 @@
/* vim: set sw=4 sts=4 et foldmethod=syntax : */
/*
- * Copyright (c) 2008, 2009, 2010 Ciaran McCreesh
+ * Copyright (c) 2008, 2009, 2010, 2011 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
@@ -30,8 +30,10 @@ namespace paludis
{
namespace erepository
{
+ struct ERepositoryID;
+
std::string pipe_command_handler(const Environment * const,
- const std::shared_ptr<const PackageID> &,
+ const std::shared_ptr<const ERepositoryID> &,
bool in_metadata_generation,
const std::string & s,
const std::shared_ptr<OutputManager> & maybe_output_manager);