diff -r 3131859d555c MoinMoin/packages.py
--- a/MoinMoin/packages.py	Tue Jul 30 17:58:46 2013 +0200
+++ b/MoinMoin/packages.py	Fri Nov 01 23:52:24 2013 +0100
@@ -4,11 +4,13 @@
 
     @copyright: 2005 MoinMoin:AlexanderSchremmer,
                 2007-2010 MoinMoin:ReimarBauer
+                2013 MoinMoin:PaulBoddie
     @license: GNU GPL, see COPYING for details.
 """
 
 import os, re, sys
 import zipfile
+import subprocess, time
 
 from MoinMoin import config, wikiutil, caching, user
 from MoinMoin.Page import Page
@@ -48,12 +50,12 @@
     elog = eventlog.EventLog(self.request)
     elog.add(self.request, eventtype, {'pagename': pagename}, 1, mtime_usecs)
 
-def edit_logfile_append(self, pagename, pagefile, rev, action, logname='edit-log', comment=u'', author=u"Scripting Subsystem"):
+def edit_logfile_append(self, pagename, pagefile, rev, action, logname='edit-log', comment=u'', author=u"Scripting Subsystem", mtime=None):
     glog = editlog.EditLog(self.request, uid_override=author)
     pagelog = Page(self.request, pagename).getPagePath(logname, use_underlay=0, isfile=1)
     llog = editlog.EditLog(self.request, filename=pagelog,
                                uid_override=author)
-    mtime_usecs = wikiutil.timestamp2version(os.path.getmtime(pagefile))
+    mtime_usecs = wikiutil.timestamp2version(mtime and int(mtime) or os.path.getmtime(pagefile))
     host = '::1'
     extra = u''
     glog.add(self.request, mtime_usecs, rev, action, pagename, host, comment)
@@ -96,18 +98,24 @@
     """
     return (string.lower() in ('yes', 'true', '1'))
 
+class IAmRoot(object):
+    def __getattr__(self, name):
+        return lambda *args, **kwargs: True
+
 class ScriptEngine:
     """
     The script engine supplies the needed commands to execute the installation
     script.
     """
 
-    def _extractToFile(self, source, target):
+    def _extractToFile(self, source, target, mtime=None):
         """ Extracts source and writes the contents into target. """
-        # TODO, add file dates
+        # TODO, add file dates using some kind of native Python library supporting fdutimensat or equivalent
         target_file = open(target, "wb")
         target_file.write(self.extract_file(source))
         target_file.close()
+        if mtime is not None:
+            subprocess.call(["touch", "-m", "-d", time.strftime("%Y-%m-%d %H:%M:%S +0000", time.gmtime(int(mtime))), target])
 
     def __init__(self):
         self.themename = None
@@ -118,7 +126,7 @@
         self.msg = getattr(self, "msg", "")
         self.request = getattr(self, "request", None)
 
-    def do_addattachment(self, zipname, filename, pagename, author=u"Scripting Subsystem", comment=u""):
+    def do_addattachment(self, zipname, filename, pagename, author=u"Scripting Subsystem", comment=u"", mtime=None):
         """
         Installs an attachment
 
@@ -137,12 +145,12 @@
             rev = page.current_rev()
             path = page.getPagePath(check_create=0)
             if not os.path.exists(target):
-                self._extractToFile(zipname, target)
+                self._extractToFile(zipname, target, mtime)
                 if os.path.exists(target):
                     filesys.chmod(target, 0666 & config.umask)
                     action = 'ATTNEW'
                     edit_logfile_append(self, pagename, path, rev, action, logname='edit-log',
-                                       comment=u'%(filename)s' % {"filename": filename}, author=author)
+                                       comment=u'%(filename)s' % {"filename": filename}, author=author, mtime=mtime)
                 self.msg += u"%(filename)s attached \n" % {"filename": filename}
             else:
                 self.msg += u"%(filename)s not attached \n" % {"filename": filename}
@@ -286,7 +294,7 @@
 
         self.msg += package.msg
 
-    def do_addrevision(self, filename, pagename, author=u"Scripting Subsystem", comment=u"", trivial=u"No"):
+    def do_addrevision(self, filename, pagename, author=u"Scripting Subsystem", comment=u"", mtime=None, trivial=u"No"):
         """ Adds a revision to a page.
 
         @param filename: name of the file in this package
@@ -298,7 +306,7 @@
         _ = self.request.getText
         trivial = str2boolean(trivial)
         if self.request.user.may.write(pagename):
-            page = PageEditor(self.request, pagename, do_editor_backup=0)
+            page = PageEditor(self.request, pagename, do_editor_backup=0, uid_override=author, mtime=mtime and int(mtime))
             try:
                 page.saveText(self.extract_file(filename).decode("utf-8"), 0, trivial=trivial, comment=comment)
             except PageEditor.Unchanged:
@@ -555,6 +563,7 @@
     # Setup MoinMoin environment
     from MoinMoin.web.contexts import ScriptContext
     request = ScriptContext(url=request_url)
+    request.user.may = IAmRoot()
 
     package = ZipPackage(request, packagefile)
     if not package.isPackage():
