diff options
author | Marc Espie <espie@cvs.openbsd.org> | 2014-07-10 10:32:02 +0000 |
---|---|---|
committer | Marc Espie <espie@cvs.openbsd.org> | 2014-07-10 10:32:02 +0000 |
commit | 26272f4879b28d9022d68be8b9aed4ced62a25d6 (patch) | |
tree | 3596ec2eb03e9a7fb92e6aa5b6c3a9d46318ceca /usr.sbin | |
parent | d1a74f4761e5bc6134acdd258afb314f6bbe22e1 (diff) |
add a separate timestamp annotation to have this as metadata
Diffstat (limited to 'usr.sbin')
-rw-r--r-- | usr.sbin/pkg_add/OpenBSD/Add.pm | 5 | ||||
-rw-r--r-- | usr.sbin/pkg_add/OpenBSD/PackingElement.pm | 35 |
2 files changed, 38 insertions, 2 deletions
diff --git a/usr.sbin/pkg_add/OpenBSD/Add.pm b/usr.sbin/pkg_add/OpenBSD/Add.pm index c001ee30d8d..622094c4d2c 100644 --- a/usr.sbin/pkg_add/OpenBSD/Add.pm +++ b/usr.sbin/pkg_add/OpenBSD/Add.pm @@ -1,5 +1,5 @@ # ex:ts=8 sw=4: -# $OpenBSD: Add.pm,v 1.158 2014/07/07 16:45:03 espie Exp $ +# $OpenBSD: Add.pm,v 1.159 2014/07/10 10:32:01 espie Exp $ # # Copyright (c) 2003-2014 Marc Espie <espie@openbsd.org> # @@ -278,6 +278,9 @@ sub set_modes $self->{mode}, $name); } } + if (defined $self->{ts}) { + utime $self->{ts}, $self->{ts}, $name; + } } package OpenBSD::PackingElement::Meta; diff --git a/usr.sbin/pkg_add/OpenBSD/PackingElement.pm b/usr.sbin/pkg_add/OpenBSD/PackingElement.pm index 8732340a15e..09190d331b2 100644 --- a/usr.sbin/pkg_add/OpenBSD/PackingElement.pm +++ b/usr.sbin/pkg_add/OpenBSD/PackingElement.pm @@ -1,5 +1,5 @@ # ex:ts=8 sw=4: -# $OpenBSD: PackingElement.pm,v 1.234 2014/03/18 18:53:29 espie Exp $ +# $OpenBSD: PackingElement.pm,v 1.235 2014/07/10 10:32:01 espie Exp $ # # Copyright (c) 2003-2014 Marc Espie <espie@openbsd.org> # @@ -366,6 +366,9 @@ sub write if (defined $self->{size}) { print $fh "\@size ", $self->{size}, "\n"; } + if (defined $self->{ts}) { + print $fh "\@ts ", $self->{ts}, "\n"; + } if (defined $self->{symlink}) { print $fh "\@symlink ", $self->{symlink}, "\n"; } @@ -401,6 +404,12 @@ sub add_size $self->{size} = $sz; } +sub add_timestamp +{ + my ($self, $ts) = @_; + $self->{ts} = $ts; +} + # XXX symlink/hardlinks are properties of File, # because we want to use inheritance for other stuff. @@ -832,6 +841,19 @@ sub add return; } +package OpenBSD::PackingElement::ts; +our @ISA=qw(OpenBSD::PackingElement::Annotation); + +__PACKAGE__->register_with_factory('ts'); + +sub add +{ + my ($class, $plist, $args) = @_; + + $plist->{state}->{lastfile}->add_timestamp($args); + return; +} + package OpenBSD::PackingElement::Option; our @ISA=qw(OpenBSD::PackingElement::Meta); @@ -1532,6 +1554,11 @@ sub add_size &OpenBSD::PackingElement::FileBase::add_size; } +sub add_timestamp +{ + # just don't +} + sub compute_digest { &OpenBSD::PackingElement::FileObject::compute_digest; @@ -1748,6 +1775,12 @@ sub time_to_iso8601 $year+1900, $month+1, $day, $hour, $min, $sec); } +sub iso8601 +{ + my $self = shift; + return time_to_iso8601($self->{timestamp}); +} + sub iso8601_to_time { if ($_[0] =~ m/^(\d{4})\-(\d{2})\-(\d{2})T(\d{2})\:(\d{2})\:(\d{2})Z$/) { |