tools/python/pkglint/userland.py
changeset 145 1e2390f5555e
parent 117 8f634eb6f66b
child 168 5884bc1edfdf
--- a/tools/python/pkglint/userland.py	Tue Mar 22 10:33:36 2011 -0700
+++ b/tools/python/pkglint/userland.py	Tue Mar 22 16:12:59 2011 -0700
@@ -120,7 +120,7 @@
 			path = action.attrs["path"]
 
 		# check for writable files without a preserve attribute
-		if 'mode' in action.attrs:
+		if "mode" in action.attrs:
 			mode = action.attrs["mode"]
 
 			if (int(mode, 8) & 0222) != 0 and "preserve" not in action.attrs:
@@ -128,6 +128,17 @@
 				_("%(path)s is writable (%(mode)s), but missing a preserve"
 				  " attribute") %  {"path": path, "mode": mode},
 				msgid="%s%s.0" % (self.name, pkglint_id))
+		elif "preserve" in action.attrs:
+			if "mode" in action.attrs:
+				mode = action.attrs["mode"]
+				if (int(mode, 8) & 0222) == 0:
+					engine.error(
+					_("%(path)s has a preserve action, but is not writable (%(mode)s)") %  {"path": path, "mode": mode},
+				msgid="%s%s.4" % (self.name, pkglint_id))
+			else:
+				engine.error(
+				_("%(path)s has a preserve action, but no mode") %  {"path": path, "mode": mode},
+				msgid="%s%s.3" % (self.name, pkglint_id))
 
 		# checks that require a physical file to look at
 		if self.proto_path is not None: