summaryrefslogtreecommitdiff
path: root/yarns/9000-implements.yarn
diff options
context:
space:
mode:
authorLars Wirzenius <liw@liw.fi>2014-01-25 18:38:09 +0000
committerLars Wirzenius <liw@liw.fi>2014-01-25 18:38:09 +0000
commit45cfbb602d1a5d56e6d701df4786c41c1398586a (patch)
treeb19238ed999067ea18546879f18f54aca82cc2f8 /yarns/9000-implements.yarn
parent436739598d8a30acdcd74a1ac24e4783ce8110cf (diff)
downloadobnam-45cfbb602d1a5d56e6d701df4786c41c1398586a.tar.gz
Convert pre-epoch-mtime to a yarn
Diffstat (limited to 'yarns/9000-implements.yarn')
-rw-r--r--yarns/9000-implements.yarn22
1 files changed, 22 insertions, 0 deletions
diff --git a/yarns/9000-implements.yarn b/yarns/9000-implements.yarn
index aeb253d1..5ac48997 100644
--- a/yarns/9000-implements.yarn
+++ b/yarns/9000-implements.yarn
@@ -61,6 +61,28 @@ Some directories will be tagged as cache directories
printf 'Signature: 8a477f597d28d172789f06886806bc55' \
> "$DATADIR/$MATCH_1/CACHEDIR.TAG"
+Sometimes it is necessary to set the modification filestamp of a file.
+Actually, it's usually useful to set both `st_mtime` and `st_atime` to
+the same value. The timestamp is given in the "seconds after epoch" in
+UTC format, as is common in Unix.
+
+ IMPLEMENTS GIVEN file (\S+) has Unix timestamp (-?\d+)
+ parent=$(dirname "$MATCH_1")
+ if [ ! -e "$DATADIR/$parent" ]
+ then
+ mkdir "$DATADIR/$parent"
+ fi
+ touch "$DATADIR/$MATCH_1"
+ python -c '
+ import os
+ filename = os.path.join(
+ os.environ["DATADIR"],
+ os.environ["MATCH_1"])
+ timestamp = int(os.environ["MATCH_2"])
+ os.utime(filename, (timestamp, timestamp))
+ '
+
+
Manifest creation and checking
------------------------------