tools/python/pkglint/userland.py
changeset 623 15f87c23a86e
parent 495 4153db6738f5
child 1020 4740049105f5
child 2528 788328aeec2a
equal deleted inserted replaced
622:fd8f0e501744 623:15f87c23a86e
    47 			self.proto_path = None
    47 			self.proto_path = None
    48 		self.runpath_re = [
    48 		self.runpath_re = [
    49 			re.compile('^/lib(/.*)?$'),
    49 			re.compile('^/lib(/.*)?$'),
    50 			re.compile('^/usr/'),
    50 			re.compile('^/usr/'),
    51 			re.compile('^\$ORIGIN/')
    51 			re.compile('^\$ORIGIN/')
       
    52 		]
       
    53 		self.runpath_64_re = [
       
    54 			re.compile('^.*/64(/.*)?$'),
       
    55 			re.compile('^.*/amd64(/.*)?$'),
       
    56 			re.compile('^.*/sparcv9(/.*)?$')
    52 		]
    57 		]
    53 		self.initscript_re = re.compile("^etc/(rc.|init)\.d")
    58 		self.initscript_re = re.compile("^etc/(rc.|init)\.d")
    54 
    59 
    55                 self.lint_paths = {}
    60                 self.lint_paths = {}
    56                 self.ref_paths = {}
    61                 self.ref_paths = {}
   193 			else:
   198 			else:
   194 				result = os.path.join(result, frag)
   199 				result = os.path.join(result, frag)
   195 
   200 
   196 		return result
   201 		return result
   197 
   202 
   198 	def __elf_runpath_check(self, path):
   203 	def __elf_runpath_check(self, path, engine):
   199 		result = None
   204 		result = None
   200 		list = []
   205 		list = []
   201 
   206 
   202 		ed = elf.get_dynamic(path)
   207 		ed = elf.get_dynamic(path)
       
   208 		ei = elf.get_info(path)
       
   209 		bits = ei.get("bits")
   203 		for dir in ed.get("runpath", "").split(":"):
   210 		for dir in ed.get("runpath", "").split(":"):
   204 			if dir == None or dir == '':
   211 			if dir == None or dir == '':
   205 				continue
   212 				continue
   206 
   213 
   207 			match = False
   214 			match = False
   211 					break
   218 					break
   212 
   219 
   213 			if match == False:
   220 			if match == False:
   214 				list.append(dir)
   221 				list.append(dir)
   215 
   222 
       
   223 			if bits == 32:
       
   224 				for expr in self.runpath_64_re:
       
   225 					if expr.search(dir):
       
   226 						engine.warning(
       
   227 							_("64-bit runpath in 32-bit binary, '%s' includes '%s'") % (path, dir),
       
   228 							msgid="%s%s.3" % (self.name, "001"))
       
   229 			else:
       
   230 				match = False
       
   231 				for expr in self.runpath_64_re:
       
   232 					if expr.search(dir):
       
   233 						match = True
       
   234 						break
       
   235 				if match == False:
       
   236 					engine.warning(
       
   237 						_("32-bit runpath in 64-bit binary, '%s' includes '%s'") % (path, dir),
       
   238 						msgid="%s%s.3" % (self.name, "001"))
   216 		if len(list) > 0:
   239 		if len(list) > 0:
   217 			result = _("bad RUNPATH, '%%s' includes '%s'" %
   240 			result = _("bad RUNPATH, '%%s' includes '%s'" %
   218 				   ":".join(list))
   241 				   ":".join(list))
   219 
   242 
   220 		return result
   243 		return result
   296 				# 32/64 bit in wrong place
   319 				# 32/64 bit in wrong place
   297 				result = self.__elf_wrong_location_check(fullpath)
   320 				result = self.__elf_wrong_location_check(fullpath)
   298 				if result != None:
   321 				if result != None:
   299 					engine.error(result % path, 
   322 					engine.error(result % path, 
   300 						msgid="%s%s.2" % (self.name, pkglint_id))
   323 						msgid="%s%s.2" % (self.name, pkglint_id))
   301 				result = self.__elf_runpath_check(fullpath)
   324 				result = self.__elf_runpath_check(fullpath, engine)
   302 				if result != None:
   325 				if result != None:
   303 					engine.error(result % path, 
   326 					engine.error(result % path, 
   304 						msgid="%s%s.3" % (self.name, pkglint_id))
   327 						msgid="%s%s.3" % (self.name, pkglint_id))
   305 
   328 
   306 	file_action.pkglint_desc = _("Paths should exist in the proto area.")
   329 	file_action.pkglint_desc = _("Paths should exist in the proto area.")