Hi, I have updated BSD::stat to 1.33 which gives us the new functions utimes() and lutimes(). Unfortunately lutimes() is specific to FreeBSD. So I emulated it with OpenBSD utimensat() and added a test.
ok? bluhm Index: devel/p5-BSD-stat/Makefile =================================================================== RCS file: /data/mirror/openbsd/cvs/ports/devel/p5-BSD-stat/Makefile,v retrieving revision 1.12 diff -u -p -r1.12 Makefile --- devel/p5-BSD-stat/Makefile 30 Aug 2012 21:16:14 -0000 1.12 +++ devel/p5-BSD-stat/Makefile 25 Sep 2012 21:38:27 -0000 @@ -4,8 +4,7 @@ SHARED_ONLY = Yes COMMENT = stat() with BSD 4.4 extentions -DISTNAME = BSD-stat-1.21 -REVISION = 5 +DISTNAME = BSD-stat-1.33 CATEGORIES = devel @@ -14,7 +13,7 @@ MAINTAINER = Alexander Bluhm <bluhm@ope # perl PERMIT_PACKAGE_CDROM = Yes PERMIT_PACKAGE_FTP = Yes -PERMIT_DISTFILES_CDROM = Yes +PERMIT_DISTFILES_CDROM =Yes PERMIT_DISTFILES_FTP = Yes WANTLIB += c Index: devel/p5-BSD-stat/distinfo =================================================================== RCS file: /data/mirror/openbsd/cvs/ports/devel/p5-BSD-stat/distinfo,v retrieving revision 1.2 diff -u -p -r1.2 distinfo --- devel/p5-BSD-stat/distinfo 5 Apr 2007 15:37:57 -0000 1.2 +++ devel/p5-BSD-stat/distinfo 25 Sep 2012 21:25:57 -0000 @@ -1,5 +1,2 @@ -MD5 (BSD-stat-1.21.tar.gz) = 3Yn7dPVXivQRJPguabmVTQ== -RMD160 (BSD-stat-1.21.tar.gz) = IXWyZmD50sH7PhaCBLB3bbSzQrg= -SHA1 (BSD-stat-1.21.tar.gz) = JeLYP2xVsXpO1eA15EnpvEatRv8= -SHA256 (BSD-stat-1.21.tar.gz) = Z56R1HfciIvcvgSnLL3THzIC3b6OnVa4GWTv17u86xo= -SIZE (BSD-stat-1.21.tar.gz) = 8805 +SHA256 (BSD-stat-1.33.tar.gz) = SFVSgwwpIQRXqshvI5vOl1GhdHDVci3TTbMK3X3XbHg= +SIZE (BSD-stat-1.33.tar.gz) = 10479 Index: devel/p5-BSD-stat/patches/patch-stat_xs =================================================================== RCS file: devel/p5-BSD-stat/patches/patch-stat_xs diff -N devel/p5-BSD-stat/patches/patch-stat_xs --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ devel/p5-BSD-stat/patches/patch-stat_xs 25 Sep 2012 22:42:43 -0000 @@ -0,0 +1,36 @@ +$OpenBSD$ +--- stat.xs.orig Tue Aug 21 12:06:12 2012 ++++ stat.xs Wed Sep 26 00:42:32 2012 +@@ -7,8 +7,9 @@ + #include "XSUB.h" + #include <sys/types.h> + #include <sys/stat.h> +-#include <unistd.h> + #include <sys/time.h> ++#include <fcntl.h> ++#include <unistd.h> + + /* + * Perl prior to 5.6.0 lacks newSVuv() +@@ -137,12 +138,21 @@ xs_utimes(double atime, double mtime, char *path){ + + static int + xs_lutimes(double atime, double mtime, char *path){ ++#ifdef __OpenBSD__ ++ struct timespec times[2]; ++ times[0].tv_sec = (int)atime; ++ times[0].tv_nsec = (int)((atime - times[0].tv_sec) * 1e9); ++ times[1].tv_sec = (int)mtime; ++ times[1].tv_nsec = (int)((mtime - times[1].tv_sec) * 1e9); ++ int err = utimensat(AT_FDCWD, path, times, AT_SYMLINK_NOFOLLOW); ++#else + struct timeval times[2]; + times[0].tv_sec = (int)atime; + times[0].tv_usec = (int)((atime - times[0].tv_sec) * 1e6); + times[1].tv_sec = (int)mtime; + times[1].tv_usec = (int)((mtime - times[1].tv_sec) * 1e6); + int err = lutimes(path, times); ++#endif + return setbang(err); + } + Index: devel/p5-BSD-stat/patches/patch-t_utimes_t =================================================================== RCS file: devel/p5-BSD-stat/patches/patch-t_utimes_t diff -N devel/p5-BSD-stat/patches/patch-t_utimes_t --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ devel/p5-BSD-stat/patches/patch-t_utimes_t 25 Sep 2012 22:28:11 -0000 @@ -0,0 +1,27 @@ +$OpenBSD$ +--- t/utimes.t.orig Tue Aug 21 12:06:22 2012 ++++ t/utimes.t Wed Sep 26 00:28:08 2012 +@@ -5,7 +5,7 @@ + use strict; + use warnings; + use BSD::stat; +-use Test::More tests => 5; ++use Test::More tests => 8; + use File::Spec; + + my $target = File::Spec->catfile('t', "test$$"); +@@ -20,8 +20,13 @@ $st = stat($wfh); + close $wfh; + + symlink $target, $symlink or die "symlink $target, $symlink : $!"; +-ok lutimes(0, 0, $symlink), "lutimes($when, $when, $symlink)"; ++ok lutimes(0, 0, $symlink), "lutimes(0, 0, $symlink)"; + is lstat($symlink)->mtime, 0, "lutimes() does touch $symlink"; + is lstat($target)->mtime, 1234567890, "lutimes() leaves $target"; ++ ++$when = 1234.5678; ++ok lutimes($when, $when, $symlink), "lutimes($when, $when, $symlink)"; ++is lstat($symlink)->mtime, 1234, "lutimes() wrong sec on $symlink"; ++is lstat($symlink)->mtimensec, 567800000, "lutimes() wrong nsec on $symlink"; + + unlink($target, $symlink) == 2 or die "unlink($target, $symlink):$!";