makepkg: allow specifying alternative build directory
[pacman-ng.git] / test / pacman / pmfile.py
blobbd03a24e2c599268e1e76dad6a353ce594d83906
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 import util
23 class pmfile(object):
24 """File object
25 """
27 def __init__(self, root, name):
28 self.name = name
29 self.root = root
30 self.filename = os.path.join(self.root, self.name)
32 self.checksum = util.getmd5sum(self.filename)
33 self.mtime = util.getmtime(self.filename)
35 def __str__(self):
36 return "%s (%s / %lu)" % (self.name, self.checksum, self.mtime)
38 def ismodified(self):
39 """
40 """
41 checksum = util.getmd5sum(self.filename)
42 mtime = util.getmtime(self.filename)
44 util.vprint("\tismodified(%s)" % self.name)
45 util.vprint("\t\told: %s / %s" % (self.checksum, self.mtime))
46 util.vprint("\t\tnew: %s / %s" % (checksum, mtime))
48 if self.checksum != checksum \
49 or (self.mtime[1], self.mtime[2]) != (mtime[1], mtime[2]):
50 return 1
52 return 0
54 # vim: set ts=4 sw=4 et: