aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAvatar Ciaran McCreesh <ciaran.mccreesh@googlemail.com> 2010-01-02 20:05:33 +0000
committerAvatar Ciaran McCreesh <ciaran.mccreesh@googlemail.com> 2010-01-03 00:56:18 +0000
commit59671017e08df7a04393d091119ed03c6517bca0 (patch)
tree79da746d40ba7f81938bc129911842b2983df0eb
parent09fd9de589f9b5edbaa23cc242d28ebc2ae62531 (diff)
downloadpaludis-59671017e08df7a04393d091119ed03c6517bca0.tar.gz
paludis-59671017e08df7a04393d091119ed03c6517bca0.tar.xz
mtime fixing
-rw-r--r--paludis/merger.cc41
-rw-r--r--paludis/merger.hh13
-rw-r--r--paludis/merger_TEST.cc33
-rwxr-xr-xpaludis/merger_TEST_setup.sh16
-rw-r--r--paludis/ndbam_merger.cc3
-rw-r--r--paludis/ndbam_merger.hh4
-rw-r--r--paludis/repositories/accounts/accounts_id.cc5
-rw-r--r--paludis/repositories/e/e_repository.cc5
-rw-r--r--paludis/repositories/e/eapi.cc3
-rw-r--r--paludis/repositories/e/eapi.hh4
-rw-r--r--paludis/repositories/e/eapis/0.conf1
-rw-r--r--paludis/repositories/e/eapis/exheres-0.conf1
-rw-r--r--paludis/repositories/e/eapis/paludis-1.conf1
-rw-r--r--paludis/repositories/e/eapis/pbin-1+exheres-0.conf1
-rw-r--r--paludis/repositories/e/ebuild_flat_metadata_cache.cc5
-rw-r--r--paludis/repositories/e/exndbam_repository.cc6
-rw-r--r--paludis/repositories/e/vdb_merger.cc3
-rw-r--r--paludis/repositories/e/vdb_merger.hh3
-rw-r--r--paludis/repositories/e/vdb_merger_TEST.cc1
-rw-r--r--paludis/repositories/e/vdb_repository.cc5
-rw-r--r--paludis/repositories/unpackaged/installed_repository.cc3
-rw-r--r--paludis/repositories/unpackaged/unpackaged_id.cc5
-rw-r--r--paludis/repository.hh12
-rw-r--r--paludis/util/fs_entry.cc17
-rw-r--r--paludis/util/fs_entry.hh6
25 files changed, 165 insertions, 32 deletions
diff --git a/paludis/merger.cc b/paludis/merger.cc
index 8d14f81..ab913d6 100644
--- a/paludis/merger.cc
+++ b/paludis/merger.cc
@@ -1,7 +1,7 @@
/* vim: set sw=4 sts=4 et foldmethod=syntax : */
/*
- * Copyright (c) 2007, 2008, 2009 Ciaran McCreesh
+ * Copyright (c) 2007, 2008, 2009, 2010 Ciaran McCreesh
* Copyright (c) 2008 Fernando J. Pereda
*
* This file is part of the Paludis package manager. Paludis is free software;
@@ -752,8 +752,20 @@ Merger::install_file(const FSEntry & src, const FSEntry & dst_dir, const std::st
bool touch(_imp->merged_ids.end() == _imp->merged_ids.find(src.lowlevel_id()));
_imp->merged_ids.insert(make_pair(src.lowlevel_id(), stringify(dst_real)));
- if ((! _imp->params.options()[mo_preserve_mtimes]) && touch && ! dst_real.utime())
- throw MergerError("utime(" + stringify(dst_real) + ", 0) failed: " + stringify(::strerror(errno)));
+ FSEntry d(stringify(dst_real));
+ if (touch && (
+ (! _imp->params.options()[mo_preserve_mtimes]) ||
+ (d.mtim() < _imp->params.fix_mtimes_before())
+ ))
+ {
+ bool ok(false);
+ if (d.mtim() < _imp->params.fix_mtimes_before())
+ ok = d.utime(_imp->params.fix_mtimes_before());
+ else
+ ok = d.utime(Timestamp::now());
+ if (! ok)
+ throw MergerError("utime(" + stringify(dst_real) + ", 0) failed: " + stringify(::strerror(errno)));
+ }
/* set*id bits get partially clobbered on a rename on linux */
dst_real.chmod(src_perms);
@@ -812,9 +824,12 @@ Merger::install_file(const FSEntry & src, const FSEntry & dst_dir, const std::st
/* might need to copy mtime */
if (_imp->params.options()[mo_preserve_mtimes])
{
- /* futimens is POSIX, futimes isn't */
+ Timestamp timestamp(src.mtim());
+ if (timestamp < _imp->params.fix_mtimes_before())
+ timestamp = _imp->params.fix_mtimes_before();
+
struct timespec ts[2];
- ts[0] = ts[1] = src.mtim().as_timespec();
+ ts[0] = ts[1] = timestamp.as_timespec();
if (0 != ::futimens(output_fd, ts))
throw MergerError("Cannot futimens '" + stringify(dst) + "': " + stringify(::strerror(errno)));
}
@@ -890,8 +905,20 @@ Merger::track_renamed_dir_recursive(const FSEntry & dst)
{
bool touch(_imp->merged_ids.end() == _imp->merged_ids.find(d->lowlevel_id()));
_imp->merged_ids.insert(make_pair(d->lowlevel_id(), stringify(*d)));
- if ((! _imp->params.options()[mo_preserve_mtimes]) && touch && ! FSEntry(*d).utime())
- throw MergerError("utime(" + stringify(*d) + ", 0) failed: " + stringify(::strerror(errno)));
+
+ if (touch && (
+ (! _imp->params.options()[mo_preserve_mtimes]) ||
+ (d->mtim() < _imp->params.fix_mtimes_before())
+ ))
+ {
+ bool ok(false);
+ if (d->mtim() < _imp->params.fix_mtimes_before())
+ ok = FSEntry(*d).utime(_imp->params.fix_mtimes_before());
+ else
+ ok = FSEntry(*d).utime(Timestamp::now());
+ if (! ok)
+ throw MergerError("utime(" + stringify(*d) + ", 0) failed: " + stringify(::strerror(errno)));
+ }
track_install_file(*d, dst, stringify(d->basename()), merged_how + msi_parent_rename);
}
continue;
diff --git a/paludis/merger.hh b/paludis/merger.hh
index 021bb3e..071204a 100644
--- a/paludis/merger.hh
+++ b/paludis/merger.hh
@@ -1,7 +1,7 @@
/* vim: set sw=4 sts=4 et foldmethod=syntax : */
/*
- * Copyright (c) 2007, 2008, 2009 Ciaran McCreesh
+ * Copyright (c) 2007, 2008, 2009, 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
@@ -25,6 +25,7 @@
#include <paludis/util/exception.hh>
#include <paludis/util/options.hh>
#include <paludis/util/named_value.hh>
+#include <paludis/util/timestamp.hh>
#include <paludis/merger_entry_type.hh>
#include <iosfwd>
#include <sys/stat.h>
@@ -49,6 +50,7 @@ namespace paludis
namespace n
{
struct environment;
+ struct fix_mtimes_before;
struct get_new_ids_or_minus_one;
struct image;
struct install_under;
@@ -69,6 +71,15 @@ namespace paludis
struct MergerParams
{
NamedValue<n::environment, Environment *> environment;
+
+ /**
+ * Rewrite any mtimes that are before this time to this time, even if
+ * preserving mtimes.
+ *
+ * \since 0.44
+ */
+ NamedValue<n::fix_mtimes_before, Timestamp> fix_mtimes_before;
+
NamedValue<n::get_new_ids_or_minus_one, std::tr1::function<std::pair<uid_t, gid_t> (const FSEntry &)> > get_new_ids_or_minus_one;
NamedValue<n::image, FSEntry> image;
NamedValue<n::install_under, FSEntry> install_under;
diff --git a/paludis/merger_TEST.cc b/paludis/merger_TEST.cc
index 391ef0b..7862949 100644
--- a/paludis/merger_TEST.cc
+++ b/paludis/merger_TEST.cc
@@ -1,7 +1,7 @@
/* vim: set sw=4 sts=4 et foldmethod=syntax : */
/*
- * Copyright (c) 2007, 2008, 2009 Ciaran McCreesh
+ * Copyright (c) 2007, 2008, 2009, 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
@@ -167,6 +167,7 @@ namespace
env(FSEntry("merger_TEST_dir/hooks")),
merger(make_named_values<MergerParams>(
value_for<n::environment>(&env),
+ value_for<n::fix_mtimes_before>(Timestamp(0, 0)),
value_for<n::get_new_ids_or_minus_one>(&get_new_ids_or_minus_one),
value_for<n::image>(image_dir),
value_for<n::install_under>(FSEntry("/")),
@@ -178,13 +179,16 @@ namespace
{
}
- MergerTest(const std::string & custom_test, const MergerOptions & o = MergerOptions() + mo_rewrite_symlinks + mo_allow_empty_dirs) :
+ MergerTest(const std::string & custom_test,
+ const MergerOptions & o = MergerOptions() + mo_rewrite_symlinks + mo_allow_empty_dirs,
+ const bool fix = false) :
TestCase("merge " + custom_test + " test"),
image_dir("merger_TEST_dir/" + custom_test + "/image"),
root_dir("merger_TEST_dir/" + custom_test + "/root"),
env(FSEntry("merger_TEST_dir/hooks")),
merger(make_named_values<MergerParams>(
value_for<n::environment>(&env),
+ value_for<n::fix_mtimes_before>(fix ? FSEntry("merger_TEST_dir/reference").mtim() : Timestamp(0, 0)),
value_for<n::get_new_ids_or_minus_one>(&get_new_ids_or_minus_one),
value_for<n::image>(image_dir),
value_for<n::install_under>(FSEntry("/")),
@@ -548,7 +552,32 @@ namespace test_cases
TEST_CHECK((root_dir / "new_file").mtim() == m_new);
TEST_CHECK((root_dir / "existing_file").mtim() == m_existing);
+ TEST_CHECK(Timestamp::now().seconds() - (root_dir / "dodgy_file").mtim().seconds() >= (60 * 60 * 24 * 365 * 3) - 1);
+
+ TEST_CHECK((root_dir / "dir" / "new_file").mtim() == m_new);
+ TEST_CHECK(Timestamp::now().seconds() - (root_dir / "dir" / "dodgy_file").mtim().seconds() >= (60 * 60 * 24 * 365 * 3) - 1);
}
} test_merger_mtimes;
+
+ struct MergerMtimesFixTest : MergerTest
+ {
+ MergerMtimesFixTest() : MergerTest("mtimes_fix", MergerOptions() + mo_preserve_mtimes, true) { }
+
+ void run()
+ {
+ Timestamp m_new((image_dir / "new_file").mtim());
+ Timestamp m_existing((image_dir / "existing_file").mtim());
+
+ TEST_CHECK(merger.check());
+ merger.merge();
+
+ TEST_CHECK((root_dir / "new_file").mtim() == m_new);
+ TEST_CHECK((root_dir / "existing_file").mtim() == m_existing);
+ TEST_CHECK((root_dir / "dodgy_file").mtim() == FSEntry("merger_TEST_dir/reference").mtim());
+
+ TEST_CHECK((root_dir / "dir" / "new_file").mtim() == m_new);
+ TEST_CHECK((root_dir / "dir" / "dodgy_file").mtim() == FSEntry("merger_TEST_dir/reference").mtim());
+ }
+ } test_merger_mtimes_fix;
}
diff --git a/paludis/merger_TEST_setup.sh b/paludis/merger_TEST_setup.sh
index dc6d087..d3e7436 100755
--- a/paludis/merger_TEST_setup.sh
+++ b/paludis/merger_TEST_setup.sh
@@ -4,6 +4,9 @@
mkdir merger_TEST_dir || exit 2
cd merger_TEST_dir || exit 3
+# must be before anything else, since timestamps before this are treated as
+# dodgy
+touch reference
mkdir -p sym_over_nothing_dir/{image,root}
ln -s image_dst sym_over_nothing_dir/image/sym
@@ -91,11 +94,22 @@ for d in *_dir; do
ln -s ${d} ${d%_dir}
done
-mkdir -p mtimes/{image,root}
+mkdir -p mtimes/{image/dir,root}
> mtimes/image/new_file
> mtimes/image/existing_file
+touch -d '3 years ago' mtimes/image/dodgy_file
+> mtimes/image/dir/new_file
+touch -d '3 years ago' mtimes/image/dir/dodgy_file
> mtimes/root/existing_file
+mkdir -p mtimes_fix/{image/dir,root}
+> mtimes_fix/image/new_file
+> mtimes_fix/image/existing_file
+touch -d '3 years ago' mtimes_fix/image/dodgy_file
+> mtimes_fix/image/dir/new_file
+touch -d '3 years ago' mtimes_fix/image/dir/dodgy_file
+> mtimes_fix/root/existing_file
+
mkdir hooks
cd hooks
mkdir \
diff --git a/paludis/ndbam_merger.cc b/paludis/ndbam_merger.cc
index 2545b79..e05e7b4 100644
--- a/paludis/ndbam_merger.cc
+++ b/paludis/ndbam_merger.cc
@@ -1,7 +1,7 @@
/* vim: set sw=4 sts=4 et foldmethod=syntax : */
/*
- * Copyright (c) 2007, 2008, 2009 Ciaran McCreesh
+ * Copyright (c) 2007, 2008, 2009, 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
@@ -70,6 +70,7 @@ namespace paludis
NDBAMMerger::NDBAMMerger(const NDBAMMergerParams & p) :
Merger(make_named_values<MergerParams>(
value_for<n::environment>(p.environment()),
+ value_for<n::fix_mtimes_before>(p.fix_mtimes_before()),
value_for<n::get_new_ids_or_minus_one>(p.get_new_ids_or_minus_one()),
value_for<n::image>(p.image()),
value_for<n::install_under>(p.install_under()),
diff --git a/paludis/ndbam_merger.hh b/paludis/ndbam_merger.hh
index b41258e..1e518b5 100644
--- a/paludis/ndbam_merger.hh
+++ b/paludis/ndbam_merger.hh
@@ -1,7 +1,7 @@
/* vim: set sw=4 sts=4 et foldmethod=syntax : */
/*
- * Copyright (c) 2007, 2008, 2009 Ciaran McCreesh
+ * Copyright (c) 2007, 2008, 2009, 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
@@ -34,6 +34,7 @@ namespace paludis
struct config_protect_mask;
struct contents_file;
struct environment;
+ struct fix_mtimes_before;
struct get_new_ids_or_minus_one;
struct image;
struct install_under;
@@ -50,6 +51,7 @@ namespace paludis
NamedValue<n::config_protect_mask, std::string> config_protect_mask;
NamedValue<n::contents_file, FSEntry> contents_file;
NamedValue<n::environment, Environment *> environment;
+ NamedValue<n::fix_mtimes_before, Timestamp> fix_mtimes_before;
NamedValue<n::get_new_ids_or_minus_one, std::tr1::function<std::pair<uid_t, gid_t> (const FSEntry &)> > get_new_ids_or_minus_one;
NamedValue<n::image, FSEntry> image;
NamedValue<n::install_under, FSEntry> install_under;
diff --git a/paludis/repositories/accounts/accounts_id.cc b/paludis/repositories/accounts/accounts_id.cc
index 60fe4f8..ac2da84 100644
--- a/paludis/repositories/accounts/accounts_id.cc
+++ b/paludis/repositories/accounts/accounts_id.cc
@@ -1,7 +1,7 @@
/* vim: set sw=4 sts=4 et foldmethod=syntax : */
/*
- * Copyright (c) 2009 Ciaran McCreesh
+ * Copyright (c) 2009, 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
@@ -463,6 +463,8 @@ namespace
void
AccountsID::perform_action(Action & action) const
{
+ Timestamp build_start_time(Timestamp::now());
+
const InstallAction * const install_action(simple_visitor_cast<const InstallAction>(action));
if (! install_action)
throw ActionFailedError("Unsupported action: " + stringify(action));
@@ -483,6 +485,7 @@ AccountsID::perform_action(Action & action) const
{
(*install_action->options.destination()).destination_interface()->merge(
make_named_values<MergeParams>(
+ value_for<n::build_start_time>(build_start_time),
value_for<n::environment_file>(FSEntry("/dev/null")),
value_for<n::image_dir>(fs_location_key()->value()),
value_for<n::merged_entries>(make_shared_ptr(new FSEntrySet)),
diff --git a/paludis/repositories/e/e_repository.cc b/paludis/repositories/e/e_repository.cc
index 1c66c1f..8c4b342 100644
--- a/paludis/repositories/e/e_repository.cc
+++ b/paludis/repositories/e/e_repository.cc
@@ -1,7 +1,7 @@
/* vim: set sw=4 sts=4 et foldmethod=syntax : */
/*
- * Copyright (c) 2005, 2006, 2007, 2008, 2009 Ciaran McCreesh
+ * Copyright (c) 2005, 2006, 2007, 2008, 2009, 2010 Ciaran McCreesh
* Copyright (c) 2006 Danny van Dyk
*
* This file is part of the Paludis package manager. Paludis is free software;
@@ -2183,6 +2183,8 @@ ERepository::install(const std::tr1::shared_ptr<const ERepositoryID> & id,
+ join(indirect_iterator(install_action.options.replacing()->begin()),
indirect_iterator(install_action.options.replacing()->end()), "', '") + "' }") + ":");
+ Timestamp build_start_time(Timestamp::now());
+
std::tr1::shared_ptr<OutputManager> output_manager(install_action.options.make_output_manager()(install_action));
bool userpriv_restrict, test_restrict, strip_restrict;
@@ -2337,6 +2339,7 @@ ERepository::install(const std::tr1::shared_ptr<const ERepositoryID> & id,
(*install_action.options.destination()).destination_interface()->merge(
make_named_values<MergeParams>(
+ value_for<n::build_start_time>(build_start_time),
value_for<n::environment_file>(package_builddir / "temp" / "loadsaveenv"),
value_for<n::image_dir>(package_builddir / "image"),
value_for<n::merged_entries>(merged_entries),
diff --git a/paludis/repositories/e/eapi.cc b/paludis/repositories/e/eapi.cc
index e82ae74..a5ff023 100644
--- a/paludis/repositories/e/eapi.cc
+++ b/paludis/repositories/e/eapi.cc
@@ -1,7 +1,7 @@
/* vim: set sw=4 sts=4 et foldmethod=syntax : */
/*
- * Copyright (c) 2007, 2008, 2009 Ciaran McCreesh
+ * Copyright (c) 2007, 2008, 2009, 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
@@ -169,6 +169,7 @@ namespace
value_for<n::ebuild_must_not_set_variables>(check_get(k, "ebuild_must_not_set_variables")),
value_for<n::eclass_must_not_set_variables>(check_get(k, "eclass_must_not_set_variables")),
value_for<n::f_function_prefix>(check_get(k, "f_function_prefix")),
+ value_for<n::fix_mtimes>(destringify_key<bool>(k, "fix_mtimes")),
value_for<n::ignore_pivot_env_functions>(check_get(k, "ignore_pivot_env_functions")),
value_for<n::ignore_pivot_env_variables>(check_get(k, "ignore_pivot_env_variables")),
value_for<n::load_modules>(check_get(k, "load_modules")),
diff --git a/paludis/repositories/e/eapi.hh b/paludis/repositories/e/eapi.hh
index dcb5e6d..971bce3 100644
--- a/paludis/repositories/e/eapi.hh
+++ b/paludis/repositories/e/eapi.hh
@@ -1,7 +1,7 @@
/* vim: set sw=4 sts=4 et foldmethod=syntax : */
/*
- * Copyright (c) 2007, 2008, 2009 Ciaran McCreesh
+ * Copyright (c) 2007, 2008, 2009, 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
@@ -113,6 +113,7 @@ namespace paludis
struct f_function_prefix;
struct failure_is_fatal;
struct fancy_test_flag;
+ struct fix_mtimes;
struct flat_list_index;
struct has_expensive_tests;
struct has_optional_tests;
@@ -373,6 +374,7 @@ namespace paludis
NamedValue<n::ebuild_must_not_set_variables, std::string> ebuild_must_not_set_variables;
NamedValue<n::eclass_must_not_set_variables, std::string> eclass_must_not_set_variables;
NamedValue<n::f_function_prefix, std::string> f_function_prefix;
+ NamedValue<n::fix_mtimes, bool> fix_mtimes;
NamedValue<n::ignore_pivot_env_functions, std::string> ignore_pivot_env_functions;
NamedValue<n::ignore_pivot_env_variables, std::string> ignore_pivot_env_variables;
NamedValue<n::load_modules, std::string> load_modules;
diff --git a/paludis/repositories/e/eapis/0.conf b/paludis/repositories/e/eapis/0.conf
index cbbe6cd..dca560d 100644
--- a/paludis/repositories/e/eapis/0.conf
+++ b/paludis/repositories/e/eapis/0.conf
@@ -23,6 +23,7 @@ f_function_prefix = ebuild_f
ignore_pivot_env_functions =
ignore_pivot_env_variables =
userpriv_cannot_use_root = false
+fix_mtimes = false
has_optional_tests = true
has_recommended_tests = false
diff --git a/paludis/repositories/e/eapis/exheres-0.conf b/paludis/repositories/e/eapis/exheres-0.conf
index bf5647d..05489c2 100644
--- a/paludis/repositories/e/eapis/exheres-0.conf
+++ b/paludis/repositories/e/eapis/exheres-0.conf
@@ -339,6 +339,7 @@ dosym_mkdir = false
doins_symlink = true
failure_is_fatal = true
no_s_workdir_fallback = true
+fix_mtimes = true
unpack_suffixes = tar tar.gz,tgz,tar.Z tar.bz2,tbz2,tbz zip,ZIP,jar gz,Z,z bz2 rar,RAR lha,LHa,LHA,lzh a,deb tar.lzma lzma 7z,7Z tar.xz xz
diff --git a/paludis/repositories/e/eapis/paludis-1.conf b/paludis/repositories/e/eapis/paludis-1.conf
index a073028..9f45ef7 100644
--- a/paludis/repositories/e/eapis/paludis-1.conf
+++ b/paludis/repositories/e/eapis/paludis-1.conf
@@ -29,6 +29,7 @@ has_optional_tests = false
has_recommended_tests = true
has_expensive_tests = false
no_s_workdir_fallback = false
+fix_mtimes = false
vdb_from_env_variables = \
CATEGORY CHOST COUNTER DEPEND DESCRIPTION EAPI FEATURES \
diff --git a/paludis/repositories/e/eapis/pbin-1+exheres-0.conf b/paludis/repositories/e/eapis/pbin-1+exheres-0.conf
index c06b856..08395c2 100644
--- a/paludis/repositories/e/eapis/pbin-1+exheres-0.conf
+++ b/paludis/repositories/e/eapis/pbin-1+exheres-0.conf
@@ -9,6 +9,7 @@ ebuild_module_suffixes = pbin-1 ${ebuild_module_suffixes}
support_exlibs = false
has_optional_tests = false
has_recommended_tests = false
+fix_mtimes = false
non_empty_variables = \
PNV PV PR PN PVR PNVR CATEGORY build:FILES build:FETCHEDDIR build:REPODIR \
diff --git a/paludis/repositories/e/ebuild_flat_metadata_cache.cc b/paludis/repositories/e/ebuild_flat_metadata_cache.cc
index d44e7dc..319df88 100644
--- a/paludis/repositories/e/ebuild_flat_metadata_cache.cc
+++ b/paludis/repositories/e/ebuild_flat_metadata_cache.cc
@@ -1,7 +1,7 @@
/* vim: set sw=4 sts=4 et foldmethod=syntax : */
/*
- * Copyright (c) 2006, 2007, 2008, 2009 Ciaran McCreesh
+ * Copyright (c) 2006, 2007, 2008, 2009, 2010 Ciaran McCreesh
* Copyright (c) 2008 David Leverton
*
* This file is part of the Paludis package manager. Paludis is free software;
@@ -826,8 +826,7 @@ EbuildFlatMetadataCache::save(const std::tr1::shared_ptr<const EbuildID> & id)
SafeOFStream cache_file(_imp->filename);
cache_file << cache.str();
}
- struct ::utimbuf times = { _imp->ebuild.mtim().seconds(), _imp->ebuild.mtim().seconds() };
- _imp->filename.utime(&times);
+ _imp->filename.utime(Timestamp(_imp->ebuild.mtim().seconds(), 0));
}
catch (const SafeOFStreamError & e)
{
diff --git a/paludis/repositories/e/exndbam_repository.cc b/paludis/repositories/e/exndbam_repository.cc
index 57109ba..0cd9a77 100644
--- a/paludis/repositories/e/exndbam_repository.cc
+++ b/paludis/repositories/e/exndbam_repository.cc
@@ -1,7 +1,7 @@
/* vim: set sw=4 sts=4 et foldmethod=syntax : */
/*
- * Copyright (c) 2008, 2009 Ciaran McCreesh
+ * Copyright (c) 2008, 2009, 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
@@ -399,12 +399,16 @@ ExndbamRepository::merge(const MergeParams & m)
{
}
+ bool fix_mtimes(std::tr1::static_pointer_cast<const ERepositoryID>(
+ m.package_id())->eapi()->supported()->ebuild_options()->fix_mtimes());
+
NDBAMMerger merger(
make_named_values<NDBAMMergerParams>(
value_for<n::config_protect>(config_protect),
value_for<n::config_protect_mask>(config_protect_mask),
value_for<n::contents_file>(target_ver_dir / "contents"),
value_for<n::environment>(_imp->params.environment()),
+ value_for<n::fix_mtimes_before>(fix_mtimes ? m.build_start_time() : Timestamp(0, 0)),
value_for<n::get_new_ids_or_minus_one>(std::tr1::bind(&get_new_ids_or_minus_one, _imp->params.environment(), std::tr1::placeholders::_1)),
value_for<n::image>(m.image_dir()),
value_for<n::install_under>(FSEntry("/")),
diff --git a/paludis/repositories/e/vdb_merger.cc b/paludis/repositories/e/vdb_merger.cc
index bcf0a8a..76c707d 100644
--- a/paludis/repositories/e/vdb_merger.cc
+++ b/paludis/repositories/e/vdb_merger.cc
@@ -1,7 +1,7 @@
/* vim: set sw=4 sts=4 et foldmethod=syntax : */
/*
- * Copyright (c) 2007, 2008, 2009 Ciaran McCreesh
+ * Copyright (c) 2007, 2008, 2009, 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
@@ -82,6 +82,7 @@ namespace
VDBMerger::VDBMerger(const VDBMergerParams & p) :
Merger(make_named_values<MergerParams>(
value_for<n::environment>(p.environment()),
+ value_for<n::fix_mtimes_before>(p.fix_mtimes_before()),
value_for<n::get_new_ids_or_minus_one>(std::tr1::bind(&get_new_ids_or_minus_one, p.environment(), std::tr1::placeholders::_1)),
value_for<n::image>(p.image()),
value_for<n::install_under>(FSEntry("/")),
diff --git a/paludis/repositories/e/vdb_merger.hh b/paludis/repositories/e/vdb_merger.hh
index 2167dab..16b0f52 100644
--- a/paludis/repositories/e/vdb_merger.hh
+++ b/paludis/repositories/e/vdb_merger.hh
@@ -1,7 +1,7 @@
/* vim: set sw=4 sts=4 et foldmethod=syntax : */
/*
- * Copyright (c) 2007, 2008, 2009 Ciaran McCreesh
+ * Copyright (c) 2007, 2008, 2009, 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
@@ -58,6 +58,7 @@ namespace paludis
NamedValue<n::config_protect_mask, std::string> config_protect_mask;
NamedValue<n::contents_file, FSEntry> contents_file;
NamedValue<n::environment, Environment *> environment;
+ NamedValue<n::fix_mtimes_before, Timestamp> fix_mtimes_before;
NamedValue<n::image, FSEntry> image;
NamedValue<n::merged_entries, std::tr1::shared_ptr<FSEntrySet> > merged_entries;
NamedValue<n::options, MergerOptions> options;
diff --git a/paludis/repositories/e/vdb_merger_TEST.cc b/paludis/repositories/e/vdb_merger_TEST.cc
index 893278d..eb9789a 100644
--- a/paludis/repositories/e/vdb_merger_TEST.cc
+++ b/paludis/repositories/e/vdb_merger_TEST.cc
@@ -84,6 +84,7 @@ namespace
value_for<n::config_protect_mask>("/protected_dir/unprotected_file /protected_dir/unprotected_dir"),
value_for<n::contents_file>(FSEntry::cwd() / "vdb_merger_TEST_dir/CONTENTS" / what),
value_for<n::environment>(&env),
+ value_for<n::fix_mtimes_before>(Timestamp(0, 0)),
value_for<n::image>(FSEntry::cwd() / "vdb_merger_TEST_dir" / what / "image"),
value_for<n::merged_entries>(make_shared_ptr(new FSEntrySet)),
value_for<n::options>(MergerOptions() + mo_rewrite_symlinks + mo_allow_empty_dirs),
diff --git a/paludis/repositories/e/vdb_repository.cc b/paludis/repositories/e/vdb_repository.cc
index a3c92ad..db6487e 100644
--- a/paludis/repositories/e/vdb_repository.cc
+++ b/paludis/repositories/e/vdb_repository.cc
@@ -1,7 +1,7 @@
/* vim: set sw=4 sts=4 et foldmethod=syntax : */
/*
- * Copyright (c) 2006, 2007, 2008, 2009 Ciaran McCreesh
+ * Copyright (c) 2006, 2007, 2008, 2009, 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
@@ -915,6 +915,8 @@ VDBRepository::merge(const MergeParams & m)
vdb_dir /= stringify(m.package_id()->name().category());
vdb_dir /= (stringify(m.package_id()->name().package()) + "-" + stringify(m.package_id()->version()));
+ bool fix_mtimes(std::tr1::static_pointer_cast<const ERepositoryID>(
+ m.package_id())->eapi()->supported()->ebuild_options()->fix_mtimes());
VDBMerger merger(
make_named_values<VDBMergerParams>(
@@ -922,6 +924,7 @@ VDBRepository::merge(const MergeParams & m)
value_for<n::config_protect_mask>(config_protect_mask),
value_for<n::contents_file>(vdb_dir / "CONTENTS"),
value_for<n::environment>(_imp->params.environment()),
+ value_for<n::fix_mtimes_before>(fix_mtimes ? m.build_start_time() : Timestamp(0, 0)),
value_for<n::image>(m.image_dir()),
value_for<n::merged_entries>(m.merged_entries()),
value_for<n::options>(m.options()),
diff --git a/paludis/repositories/unpackaged/installed_repository.cc b/paludis/repositories/unpackaged/installed_repository.cc
index aad70c4..8d53214 100644
--- a/paludis/repositories/unpackaged/installed_repository.cc
+++ b/paludis/repositories/unpackaged/installed_repository.cc
@@ -1,7 +1,7 @@
/* vim: set sw=4 sts=4 et foldmethod=syntax : */
/*
- * Copyright (c) 2007, 2008, 2009 Ciaran McCreesh
+ * Copyright (c) 2007, 2008, 2009, 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
@@ -347,6 +347,7 @@ InstalledUnpackagedRepository::merge(const MergeParams & m)
value_for<n::config_protect_mask>(getenv_with_default("CONFIG_PROTECT_MASK", "")),
value_for<n::contents_file>(target_ver_dir / "contents"),
value_for<n::environment>(_imp->params.environment()),
+ value_for<n::fix_mtimes_before>(m.build_start_time()),
value_for<n::get_new_ids_or_minus_one>(std::tr1::bind(&get_new_ids_or_minus_one,
_imp->params.environment(), rewrite_ids_over_to_root, _1)),
value_for<n::image>(m.image_dir()),
diff --git a/paludis/repositories/unpackaged/unpackaged_id.cc b/paludis/repositories/unpackaged/unpackaged_id.cc
index 5f684f2..8d40a51 100644
--- a/paludis/repositories/unpackaged/unpackaged_id.cc
+++ b/paludis/repositories/unpackaged/unpackaged_id.cc
@@ -1,7 +1,7 @@
/* vim: set sw=4 sts=4 et foldmethod=syntax : */
/*
- * Copyright (c) 2007, 2008, 2009 Ciaran McCreesh
+ * Copyright (c) 2007, 2008, 2009, 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
@@ -336,6 +336,8 @@ namespace
void
UnpackagedID::perform_action(Action & action) const
{
+ Timestamp build_start_time(Timestamp::now());
+
const InstallAction * const install_action(simple_visitor_cast<const InstallAction>(action));
if (! install_action)
throw ActionFailedError("Unsupported action: " + stringify(action));
@@ -404,6 +406,7 @@ UnpackagedID::perform_action(Action & action) const
extra_merger_options += mo_nondestructive;
(*install_action->options.destination()).destination_interface()->merge(
make_named_values<MergeParams>(
+ value_for<n::build_start_time>(build_start_time),
value_for<n::environment_file>(FSEntry("/dev/null")),
value_for<n::image_dir>(fs_location_key()->value()),
value_for<n::merged_entries>(make_shared_ptr(new FSEntrySet)),
diff --git a/paludis/repository.hh b/paludis/repository.hh
index 2ebe999..3c410ff 100644
--- a/paludis/repository.hh
+++ b/paludis/repository.hh
@@ -1,7 +1,7 @@
/* vim: set sw=4 sts=4 et foldmethod=syntax : */
/*
- * Copyright (c) 2005, 2006, 2007, 2008, 2009 Ciaran McCreesh
+ * Copyright (c) 2005, 2006, 2007, 2008, 2009, 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
@@ -32,6 +32,7 @@
#include <paludis/util/wrapped_forward_iterator-fwd.hh>
#include <paludis/util/options.hh>
#include <paludis/util/named_value.hh>
+#include <paludis/util/timestamp.hh>
#include <paludis/output_manager-fwd.hh>
#include <paludis/version_spec.hh>
#include <paludis/metadata_key-fwd.hh>
@@ -56,6 +57,7 @@ namespace paludis
namespace n
{
struct arch;
+ struct build_start_time;
struct destination_interface;
struct environment_file;
struct environment_variable_interface;
@@ -132,6 +134,14 @@ namespace paludis
*/
struct MergeParams
{
+ /**
+ * The start of the build time (for binaries, should really be when the
+ * binary was originally built).
+ *
+ * \since 0.44
+ */
+ NamedValue<n::build_start_time, Timestamp> build_start_time;
+
NamedValue<n::environment_file, FSEntry> environment_file;
NamedValue<n::image_dir, FSEntry> image_dir;
diff --git a/paludis/util/fs_entry.cc b/paludis/util/fs_entry.cc
index a83e2c9..1ada08a 100644
--- a/paludis/util/fs_entry.cc
+++ b/paludis/util/fs_entry.cc
@@ -1,7 +1,7 @@
/* vim: set sw=4 sts=4 et foldmethod=syntax : */
/*
- * Copyright (c) 2005, 2006, 2007, 2008, 2009 Ciaran McCreesh
+ * Copyright (c) 2005, 2006, 2007, 2008, 2009, 2010 Ciaran McCreesh
* Copyright (c) 2006 Mark Loeser
* Copyright (c) 2008 Fernando J. Pereda
*
@@ -40,6 +40,7 @@
#include <unistd.h>
#include <errno.h>
#include <limits.h>
+#include <fcntl.h>
#include <cstring>
#include <cstdlib>
#include <cstdio>
@@ -517,7 +518,10 @@ FSEntry::ctim() const
_stat();
if (! _imp->exists)
+ {
+ Context context("When fetching ctime of '" + stringify(_imp->path) + "':");
throw FSError("Filesystem entry '" + _imp->path + "' does not exist");
+ }
return Timestamp((*_imp->stat_info).st_ctim);
}
@@ -528,7 +532,10 @@ FSEntry::mtim() const
_stat();
if (! _imp->exists)
+ {
+ Context context("When fetching mtime of '" + stringify(_imp->path) + "':");
throw FSError("Filesystem entry '" + _imp->path + "' does not exist");
+ }
return Timestamp((*_imp->stat_info).st_mtim);
}
@@ -617,16 +624,20 @@ FSEntry::rmdir()
}
bool
-FSEntry::utime(const struct ::utimbuf * buf)
+FSEntry::utime(const Timestamp & t)
{
- if (0 == ::utime(_imp->path.c_str(), buf))
+ struct timespec ts[2] = { t.as_timespec(), t.as_timespec() };
+ if (0 == ::utimensat(AT_FDCWD, _imp->path.c_str(), ts, 0))
return true;
int e(errno);
if (e == ENOENT)
return false;
else
+ {
+ Context context("When setting utime for '" + stringify(_imp->path) + "':");
throw FSError("utime '" + _imp->path + "' failed: " + ::strerror(e));
+ }
}
std::string
diff --git a/paludis/util/fs_entry.hh b/paludis/util/fs_entry.hh
index e0763d1..ee611c5 100644
--- a/paludis/util/fs_entry.hh
+++ b/paludis/util/fs_entry.hh
@@ -1,7 +1,7 @@
/* vim: set sw=4 sts=4 et foldmethod=syntax : */
/*
- * Copyright (c) 2005, 2006, 2007, 2008, 2009 Ciaran McCreesh
+ * Copyright (c) 2005, 2006, 2007, 2008, 2009, 2010 Ciaran McCreesh
* Copyright (c) 2006 Mark Loeser
*
* This file is part of the Paludis package manager. Paludis is free software;
@@ -364,8 +364,10 @@ namespace paludis
*
* \exception FSError If an error other than us already not
* existing ocurrs.
+ *
+ * \since 0.44 takes a Timestamp
*/
- bool utime(const struct ::utimbuf * buf = 0);
+ bool utime(const Timestamp &);
/**
* Change our ownership, following symlinks.