1
0
mirror of https://github.com/moparisthebest/pacman synced 2024-11-15 22:05:02 -05:00

pmrule.py: add FILE_CONTENTS rule

Signed-off-by: Andrew Gregory <andrew.gregory.8@gmail.com>
Signed-off-by: Allan McRae <allan@archlinux.org>
This commit is contained in:
Andrew Gregory 2015-11-11 19:19:57 -05:00 committed by Allan McRae
parent 23f128ad5e
commit e03fa67445
2 changed files with 7 additions and 0 deletions

View File

@ -303,6 +303,7 @@ its DEPENDS field.
. FILE rules . FILE rules
FILE_CONTENTS=path/to/file|contents
FILE_EXIST=path/to/file FILE_EXIST=path/to/file
FILE_EMPTY=path/to/file FILE_EMPTY=path/to/file
FILE_MODIFIED=path/to/file FILE_MODIFIED=path/to/file

View File

@ -120,6 +120,12 @@ class pmrule(object):
if not (os.path.isfile(filename) if not (os.path.isfile(filename)
and os.path.getsize(filename) == 0): and os.path.getsize(filename) == 0):
success = 0 success = 0
elif case == "CONTENTS":
try:
with open(filename, 'r') as f:
success = f.read() == value
except:
success = 0
elif case == "MODIFIED": elif case == "MODIFIED":
for f in test.files: for f in test.files:
if f.name == key: if f.name == key: