makepkg: skip devel_check() when repackaging
[pacman-ng.git] / pactest / pmfile.py
blobab4aa2c7f8e911386244d0c596b5cf68cf07f155
1 #! /usr/bin/python
3 # Copyright (c) 2006 by Aurelien Foret <orelien@chez.com>
4 #
5 # This program is free software; you can redistribute it and/or modify
6 # it under the terms of the GNU General Public License as published by
7 # the Free Software Foundation; either version 2 of the License, or
8 # (at your option) any later version.
10 # This program is distributed in the hope that it will be useful,
11 # but WITHOUT ANY WARRANTY; without even the implied warranty of
12 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 # GNU General Public License for more details.
15 # You should have received a copy of the GNU General Public License
16 # along with this program. If not, see <http://www.gnu.org/licenses/>.
19 import os
21 from util import *
24 class pmfile:
25 """File object
26 """
28 def __init__(self, root, name):
29 self.name = name
30 self.root = root
32 filename = os.path.join(self.root, self.name)
33 self.checksum = getmd5sum(filename)
34 self.mtime = getmtime(filename)
36 def __str__(self):
37 return "%s (%s / %lu)" % (self.name, self.checksum, self.mtime)
39 def ismodified(self):
40 """
41 """
43 retval = 0
45 filename = os.path.join(self.root, self.name)
46 checksum = getmd5sum(filename)
47 mtime = getmtime(filename)
49 vprint("\tismodified(%s)" % self.name)
50 vprint("\t\told: %s / %s" % (self.checksum, self.mtime))
51 vprint("\t\tnew: %s / %s" % (checksum, mtime))
53 if self.checksum != checksum \
54 or (self.mtime[1], self.mtime[2]) != (mtime[1], mtime[2]):
55 retval = 1
57 return retval
59 def resettimes(self):
60 """
61 """
63 filename = os.path.join(self.root, self.name)
64 os.utime(filename, (355, 355))
65 self.mtime = getmtime(filename)
66 vprint("\tmtime reset (%s)" % self.name)
68 if __name__ == "__main__":
69 f = pmfile("/tmp", "foobar")
70 print f
71 # vim: set ts=4 sw=4 et: