aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAvatar Ciaran McCreesh <ciaran.mccreesh@googlemail.com> 2010-07-31 16:12:28 +0100
committerAvatar Ciaran McCreesh <ciaran.mccreesh@googlemail.com> 2010-07-31 16:12:28 +0100
commit695d2a37fa986eae0ad560eee887c6d50b1d9bb6 (patch)
treeaaa029acdccd750a234067a4de12efeea556a841
parent9d25bf3a35e477fe9aba38615ebf7609cedfd7aa (diff)
downloadpaludis-695d2a37fa986eae0ad560eee887c6d50b1d9bb6.tar.gz
paludis-695d2a37fa986eae0ad560eee887c6d50b1d9bb6.tar.xz
Move mtime fixing into Merger
-rw-r--r--paludis/fs_merger.cc32
-rw-r--r--paludis/merger.cc8
-rw-r--r--paludis/merger.hh3
-rw-r--r--paludis/tar_merger.cc1
4 files changed, 15 insertions, 29 deletions
diff --git a/paludis/fs_merger.cc b/paludis/fs_merger.cc
index 659948a..4dc0b53 100644
--- a/paludis/fs_merger.cc
+++ b/paludis/fs_merger.cc
@@ -78,6 +78,7 @@ FSMerger::FSMerger(const FSMergerParams & p) :
Pimp<FSMerger>(p),
Merger(make_named_values<MergerParams>(
n::environment() = p.environment(),
+ n::fix_mtimes_before() = p.fix_mtimes_before(),
n::get_new_ids_or_minus_one() = p.get_new_ids_or_minus_one(),
n::image() = p.image(),
n::install_under() = p.install_under(),
@@ -333,19 +334,9 @@ FSMerger::install_file(const FSEntry & src, const FSEntry & dst_dir, const std::
_imp->merged_ids.insert(make_pair(src.lowlevel_id(), stringify(dst_real)));
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)
+ if (touch && ! _imp->params.options()[mo_preserve_mtimes])
+ if (! d.utime(Timestamp::now()))
throw FSMergerError("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);
@@ -405,9 +396,6 @@ FSMerger::install_file(const FSEntry & src, const FSEntry & dst_dir, const std::
if (_imp->params.options()[mo_preserve_mtimes])
{
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] = timestamp.as_timespec();
if (0 != ::futimens(output_fd, ts))
@@ -457,19 +445,9 @@ FSMerger::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 (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)
+ if (touch && ! _imp->params.options()[mo_preserve_mtimes])
+ if (! FSEntry(*d).utime(Timestamp::now()))
throw FSMergerError("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.cc b/paludis/merger.cc
index 4a49b1b..342daf9 100644
--- a/paludis/merger.cc
+++ b/paludis/merger.cc
@@ -23,6 +23,7 @@
#include <paludis/util/dir_iterator.hh>
#include <paludis/util/log.hh>
#include <paludis/util/pimp-impl.hh>
+#include <paludis/util/timestamp.hh>
#include <paludis/selinux/security_context.hh>
#include <paludis/environment.hh>
#include <paludis/hook.hh>
@@ -254,7 +255,10 @@ Merger::on_file(bool is_check, const FSEntry & src, const FSEntry & dst)
}
}
- on_file_main(is_check, src, dst);
+ if (is_check && src.mtim() < _imp->params.fix_mtimes_before())
+ FSEntry(src).utime(_imp->params.fix_mtimes_before());
+
+ on_file_main(is_check, FSEntry(stringify(src)), dst);
if (is_check &&
0 != _imp->params.environment()->perform_hook(extend_hook(
@@ -346,7 +350,7 @@ Merger::on_sym(bool is_check, const FSEntry & src, const FSEntry & dst)
rewrite_symlink_as_needed(src, dst);
}
- on_sym_main(is_check, src, dst);
+ on_sym_main(is_check, FSEntry(stringify(src)), dst);
if (is_check &&
0 != _imp->params.environment()->perform_hook(extend_hook(
diff --git a/paludis/merger.hh b/paludis/merger.hh
index 4eb3dfc..7020940 100644
--- a/paludis/merger.hh
+++ b/paludis/merger.hh
@@ -24,6 +24,7 @@
#include <paludis/util/named_value.hh>
#include <paludis/util/fs_entry.hh>
#include <paludis/util/options.hh>
+#include <paludis/util/timestamp.hh>
#include <paludis/hook-fwd.hh>
#include <paludis/environment-fwd.hh>
#include <paludis/merger_entry_type.hh>
@@ -33,6 +34,7 @@ namespace paludis
namespace n
{
typedef Name<struct environment_name> environment;
+ typedef Name<struct fix_mtimes_before_name> fix_mtimes_before;
typedef Name<struct get_new_ids_or_minus_one_name> get_new_ids_or_minus_one;
typedef Name<struct image_name> image;
typedef Name<struct install_under_name> install_under;
@@ -53,6 +55,7 @@ namespace paludis
struct MergerParams
{
NamedValue<n::environment, Environment *> environment;
+ NamedValue<n::fix_mtimes_before, Timestamp> fix_mtimes_before;
NamedValue<n::get_new_ids_or_minus_one, std::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/tar_merger.cc b/paludis/tar_merger.cc
index 41a1e0d..caccfb0 100644
--- a/paludis/tar_merger.cc
+++ b/paludis/tar_merger.cc
@@ -110,6 +110,7 @@ TarMerger::TarMerger(const TarMergerParams & p) :
Pimp<TarMerger>(p),
Merger(make_named_values<MergerParams>(
n::environment() = p.environment(),
+ n::fix_mtimes_before() = p.fix_mtimes_before(),
n::get_new_ids_or_minus_one() = p.get_new_ids_or_minus_one(),
n::image() = p.image(),
n::install_under() = FSEntry("/"),