From c34671dcc85e10cb2507fc5096d3f9a5ef593cd6 Mon Sep 17 00:00:00 2001
From: David Leverton
Date: Sun, 20 Nov 2011 17:42:37 +0000
Subject: Support for generating thin Manifests
---
NEWS | 3 +
doc/configuration/repositories/e.html.part | 4 ++
paludis/distributions/exherbo/e.conf | 1 +
paludis/distributions/gentoo/e.conf | 1 +
paludis/repositories/e/e_repository.cc | 75 +++++++++++++++--------
paludis/repositories/e/e_repository_TEST.cc | 17 +++++
paludis/repositories/e/e_repository_TEST_setup.sh | 60 ++++++++++++++++++
paludis/repositories/e/e_repository_params.hh | 2 +
paludis/repositories/e/extra_distribution_data.cc | 2 +
paludis/repositories/e/extra_distribution_data.hh | 2 +
vim/syntax/paludis-repositories-conf.vim | 2 +-
11 files changed, 143 insertions(+), 26 deletions(-)
diff --git a/NEWS b/NEWS
index 41d7987ad..c7370a7cb 100644
--- a/NEWS
+++ b/NEWS
@@ -4,6 +4,9 @@ News for Paludis
This file lists the major changes between versions. For a more detailed list
of every change, see the Git log.
+master:
+ * Generation of thin Manifests is now supported.
+
0.70.1:
* 'cave search' now has a '--case-sensitive' option.
diff --git a/doc/configuration/repositories/e.html.part b/doc/configuration/repositories/e.html.part
index ecfeff4d0..3c7a0829a 100644
--- a/doc/configuration/repositories/e.html.part
+++ b/doc/configuration/repositories/e.html.part
@@ -99,6 +99,10 @@ for e
format repositories:
MD5
, RMD160
, SHA1
, SHA256
, SHA512
and
WHIRLPOOL
. Optional, usually set by the distribution or the repository's metadata/layout.conf
.
+ thin_manifests
+ If set to true
, generated Manifest
files will only contain DIST
entries.
+ Optional, usually set by the distribution or the repository's metadata/layout.conf
.
+
binary_destination
If set to true
, this repository is treated as a destination when creating binary packages.
diff --git a/paludis/distributions/exherbo/e.conf b/paludis/distributions/exherbo/e.conf
index bc63998f6..9f7bbc6a2 100644
--- a/paludis/distributions/exherbo/e.conf
+++ b/paludis/distributions/exherbo/e.conf
@@ -7,5 +7,6 @@ default_manifest_hashes =
default_names_cache = /var/cache/paludis/names
default_profile_eapi = exheres-0
default_profile_layout = exheres
+default_thin_manifests = false
default_write_cache = /var/cache/paludis/metadata
news_directory = /var/lib/exherbo/news
diff --git a/paludis/distributions/gentoo/e.conf b/paludis/distributions/gentoo/e.conf
index 673216ccf..215977a15 100644
--- a/paludis/distributions/gentoo/e.conf
+++ b/paludis/distributions/gentoo/e.conf
@@ -7,5 +7,6 @@ default_manifest_hashes = RMD160 SHA1 SHA256
default_profile_layout = traditional
default_names_cache =
default_profile_eapi = 0
+default_thin_manifests = false
default_write_cache = /var/empty
news_directory = /var/lib/gentoo/news
diff --git a/paludis/repositories/e/e_repository.cc b/paludis/repositories/e/e_repository.cc
index 83b132efd..68380b58e 100644
--- a/paludis/repositories/e/e_repository.cc
+++ b/paludis/repositories/e/e_repository.cc
@@ -266,6 +266,7 @@ namespace paludis
std::shared_ptr > profile_eapi_when_unspecified_key;
std::shared_ptr > use_manifest_key;
std::shared_ptr > > manifest_hashes_key;
+ std::shared_ptr > thin_manifests_key;
std::shared_ptr info_pkgs_key;
std::shared_ptr > > info_vars_key;
std::shared_ptr > binary_destination_key;
@@ -347,6 +348,8 @@ namespace paludis
"use_manifest", "use_manifest", mkt_normal, stringify(params.use_manifest()))),
manifest_hashes_key(std::make_shared(
"manifest_hashes", "manifest_hashes", mkt_normal, params.manifest_hashes())),
+ thin_manifests_key(std::make_shared >(
+ "thin_manifests", "thin_manifests", mkt_normal, params.thin_manifests())),
info_pkgs_key(layout->info_packages_files()->end() != std::find_if(layout->info_packages_files()->begin(),
layout->info_packages_files()->end(),
std::bind(std::mem_fn(&FSStat::is_regular_file_or_symlink_to_regular_file),
@@ -579,6 +582,7 @@ ERepository::_add_metadata_keys() const
add_metadata_key(_imp->master_repositories_key);
add_metadata_key(_imp->use_manifest_key);
add_metadata_key(_imp->manifest_hashes_key);
+ add_metadata_key(_imp->thin_manifests_key);
if (_imp->info_pkgs_key)
add_metadata_key(_imp->info_pkgs_key);
if (_imp->info_vars_key)
@@ -1032,31 +1036,34 @@ ERepository::make_manifest(const QualifiedPackageName & qpn)
std::vector, std::string> > lines;
auto files(_imp->layout->manifest_files(qpn, package_dir));
- for (auto f(files->begin()) ; f != files->end() ; ++f)
+ if (! _imp->params.thin_manifests())
{
- FSPath file(f->first);
- FSStat file_stat(file);
- std::string filename = file.basename();
- std::string file_type(f->second);
-
- if ("AUX" == file_type)
+ for (auto f(files->begin()) ; f != files->end() ; ++f)
{
- filename = stringify(file).substr(stringify(package_dir / "files").length()+1);
- }
+ FSPath file(f->first);
+ FSStat file_stat(file);
+ std::string filename = file.basename();
+ std::string file_type(f->second);
- SafeIFStream file_stream(file);
+ if ("AUX" == file_type)
+ {
+ filename = stringify(file).substr(stringify(package_dir / "files").length()+1);
+ }
- std::string line(file_type + " " + filename + " " + stringify(file.stat().file_size()));
+ SafeIFStream file_stream(file);
- for (Set::ConstIterator it(_imp->params.manifest_hashes()->begin()),
- it_end(_imp->params.manifest_hashes()->end()); it_end != it; ++it)
- {
- file_stream.clear();
- file_stream.seekg(0, std::ios::beg);
- line += " " + *it + " " + DigestRegistry::get_instance()->get(*it)(file_stream);
- }
+ std::string line(file_type + " " + filename + " " + stringify(file.stat().file_size()));
+
+ for (Set::ConstIterator it(_imp->params.manifest_hashes()->begin()),
+ it_end(_imp->params.manifest_hashes()->end()); it_end != it; ++it)
+ {
+ file_stream.clear();
+ file_stream.seekg(0, std::ios::beg);
+ line += " " + *it + " " + DigestRegistry::get_instance()->get(*it)(file_stream);
+ }
- lines.push_back(std::make_pair(std::make_pair(file_type, filename), line));
+ lines.push_back(std::make_pair(std::make_pair(file_type, filename), line));
+ }
}
std::shared_ptr versions;
@@ -1104,12 +1111,16 @@ ERepository::make_manifest(const QualifiedPackageName & qpn)
std::sort(lines.begin(), lines.end());
FSPath(package_dir / "Manifest").unlink();
- SafeOFStream manifest(FSPath(package_dir / "Manifest"), -1, true);
- if (! manifest)
- throw ERepositoryConfigurationError("Couldn't open Manifest for writing.");
- for (auto it(lines.begin()), it_end(lines.end()); it_end != it; ++it)
- manifest << it->second << std::endl;
+ if (! lines.empty())
+ {
+ SafeOFStream manifest(FSPath(package_dir / "Manifest"), -1, true);
+ if (! manifest)
+ throw ERepositoryConfigurationError("Couldn't open Manifest for writing.");
+
+ for (auto it(lines.begin()), it_end(lines.end()); it_end != it; ++it)
+ manifest << it->second << std::endl;
+ }
}
void
@@ -1473,8 +1484,21 @@ ERepository::repository_factory_create(
*DistributionData::get_instance()->distribution_from_string(
env->distribution()))->default_manifest_hashes();
- bool binary_destination(false);
+ bool thin_manifests(false);
+ if (! f("thin_manifests").empty())
+ {
+ Context item_context("When handling thin_manifests key:");
+ thin_manifests = destringify(f("thin_manifests"));
+ }
+ else if (layout_conf && ! layout_conf->get("thin-manifests").empty())
+ // match Portage parsing
+ thin_manifests = tolower(layout_conf->get("thin-manifests")) == "true";
+ else
+ thin_manifests = EExtraDistributionData::get_instance()->data_from_distribution(
+ *DistributionData::get_instance()->distribution_from_string(
+ env->distribution()))->default_thin_manifests();
+ bool binary_destination(false);
if (! f("binary_destination").empty())
{
Context item_context("When handling binary_destination key:");
@@ -1523,6 +1547,7 @@ ERepository::repository_factory_create(
n::setsdir() = FSPath(setsdir).realpath_if_exists(),
n::sync() = sync,
n::sync_options() = sync_options,
+ n::thin_manifests() = thin_manifests,
n::use_manifest() = use_manifest,
n::write_bin_uri_prefix() = "",
n::write_cache() = FSPath(write_cache).realpath_if_exists()
diff --git a/paludis/repositories/e/e_repository_TEST.cc b/paludis/repositories/e/e_repository_TEST.cc
index 90a0e425a..448fe14c3 100644
--- a/paludis/repositories/e/e_repository_TEST.cc
+++ b/paludis/repositories/e/e_repository_TEST.cc
@@ -676,6 +676,23 @@ TEST(ERepository, Manifest)
repo2->make_manifest(QualifiedPackageName("category/package"));
EXPECT_EQ(contents("e_repository_TEST_dir/repo11a/Manifest_correct"), contents("e_repository_TEST_dir/repo11a/category/package/Manifest"));
+
+ std::shared_ptr