3 # Copyright (c) 2006 by Aurelien Foret <orelien@chez.com>
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, write to the Free Software
17 # Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307,
28 def __init__(self
, rule
):
34 return "rule = %s" % self
.rule
36 def check(self
, root
, retcode
, localdb
, files
):
42 [test
, args
] = self
.rule
.split("=")
45 test
= test
.lstrip("!")
46 [kind
, case
] = test
.split("_")
48 [key
, value
] = args
.split("|", 1)
50 [key
, value
] = [args
, None]
54 if retcode
!= int(key
):
56 elif case
== "OUTPUT":
57 if not grep(os
.path
.join(root
, LOGFILE
), key
):
60 print "PACMAN rule '%s' not found" % case
63 newpkg
= localdb
.db_read(key
)
67 vprint("\tnewpkg.checksum : %s" % newpkg
.checksum
)
68 vprint("\tnewpkg.mtime : %s" % newpkg
.mtime
)
71 elif case
== "MODIFIED":
72 if not localdb
.ispkgmodified(newpkg
):
74 elif case
== "VERSION":
75 if value
!= newpkg
.version
:
77 elif case
== "GROUPS":
78 if not value
in newpkg
.groups
:
80 elif case
== "PROVIDES":
81 if not value
in newpkg
.provides
:
83 elif case
== "DEPENDS":
84 if not value
in newpkg
.depends
:
86 elif case
== "REQUIREDBY":
87 if not value
in newpkg
.requiredby
:
89 elif case
== "REASON":
90 if newpkg
.reason
!= int(value
):
93 if not value
in newpkg
.files
:
95 elif case
== "BACKUP":
97 for f
in newpkg
.backup
:
98 name
, md5sum
= f
.split("\t")
104 print "PKG rule '%s' not found" % case
107 filename
= os
.path
.join(root
, key
)
109 if not os
.path
.isfile(filename
):
112 if case
== "MODIFIED":
115 if not f
.ismodified():
117 elif case
== "PACNEW":
118 if not os
.path
.isfile("%s%s" % (filename
, PM_PACNEW
)):
120 elif case
== "PACORIG":
121 if not os
.path
.isfile("%s%s" % (filename
, PM_PACORIG
)):
123 elif case
== "PACSAVE":
124 if not os
.path
.isfile("%s%s" % (filename
, PM_PACSAVE
)):
127 print "FILE rule '%s' not found" % case
130 print "Rule kind '%s' not found" % kind
133 if self
.false
and success
!= -1:
134 success
= not success
135 self
.result
= success
139 if __name__
!= "__main__":
140 rule
= pmrule("PKG_EXIST=dummy")
141 # vim: set ts=4 sw=4 et: