mirror of https://github.com/google/oss-fuzz.git
msan_builder: automatically include corresponding -dev packages.
Rather than having to specify them manually.
This commit is contained in:
parent
c2388b53fc
commit
7c3acdbd45
|
@ -30,17 +30,10 @@ WORKDIR /msan
|
|||
ENV PYTHONUNBUFFERED 1
|
||||
RUN msan_build.py --work-dir=$WORK --create-subdirs \
|
||||
libarchive13 \
|
||||
libarchive-dev \
|
||||
libfreetype6 \
|
||||
libfreetype6-dev \
|
||||
libpcre2-posix0 \
|
||||
libpcre2-dev \
|
||||
libpcre3 \
|
||||
libpcre3-dev \
|
||||
libpng12-0 \
|
||||
libpng12-dev \
|
||||
libssl1.0.0 \
|
||||
libssl-dev \
|
||||
zlib1g \
|
||||
zlib1g-dev \
|
||||
/msan
|
||||
|
|
|
@ -26,6 +26,7 @@ import subprocess
|
|||
import tempfile
|
||||
|
||||
import apt
|
||||
from apt import debfile
|
||||
|
||||
from packages import package
|
||||
import wrapper_utils
|
||||
|
@ -120,14 +121,32 @@ def SetUpEnvironment(work_dir):
|
|||
def FindPackageDebs(package_name, work_directory):
|
||||
"""Find package debs."""
|
||||
deb_paths = []
|
||||
cache = apt.Cache()
|
||||
|
||||
for filename in os.listdir(work_directory):
|
||||
file_path = os.path.join(work_directory, filename)
|
||||
if not file_path.endswith('.deb'):
|
||||
continue
|
||||
|
||||
if filename.startswith(package_name + '_'):
|
||||
# Matching package name.
|
||||
deb = debfile.DebPackage(file_path)
|
||||
if deb.pkgname == package_name:
|
||||
deb_paths.append(file_path)
|
||||
continue
|
||||
|
||||
# Also include -dev packages that depend on the runtime package.
|
||||
pkg = cache[deb.pkgname]
|
||||
if pkg.section != 'libdevel':
|
||||
continue
|
||||
|
||||
# But ignore -dbg packages.
|
||||
if deb.pkgname.endswith('-dbg'):
|
||||
continue
|
||||
|
||||
for dependency in deb.depends:
|
||||
if any(dep[0] == package_name for dep in dependency):
|
||||
deb_paths.append(file_path)
|
||||
break
|
||||
|
||||
return deb_paths
|
||||
|
||||
|
@ -180,7 +199,7 @@ def ExtractLibraries(deb_paths, work_directory, output_directory):
|
|||
|
||||
def GetPackage(package_name):
|
||||
apt_cache = apt.Cache()
|
||||
version = apt_cache[package_name].versions[0]
|
||||
version = apt_cache[package_name].candidate
|
||||
source_name = version.source_name
|
||||
|
||||
custom_package_path = os.path.join(PACKAGES_DIR, source_name) + '.py'
|
||||
|
@ -249,7 +268,7 @@ def _CollectDependencies(apt_cache, pkg, cache, dependencies):
|
|||
return True
|
||||
|
||||
is_c_or_cxx = False
|
||||
for dependency in pkg.versions[0].dependencies:
|
||||
for dependency in pkg.candidate.dependencies:
|
||||
dependency = dependency[0]
|
||||
|
||||
if dependency.name in cache:
|
||||
|
@ -269,11 +288,6 @@ def GetBuildList(package_name):
|
|||
apt_cache = apt.Cache()
|
||||
pkg = apt_cache[package_name]
|
||||
|
||||
if pkg.section == 'libdevel':
|
||||
# Ignore dependencies from -dev packages to keep things simple. These must
|
||||
# be specified alongside the corresponding runtime package.
|
||||
return [package_name]
|
||||
|
||||
dependencies = []
|
||||
_CollectDependencies(apt_cache, pkg, {}, dependencies)
|
||||
return dependencies
|
||||
|
@ -333,6 +347,8 @@ class MSanBuilder(object):
|
|||
if not deb_paths:
|
||||
raise MSanBuildException('Failed to find .deb packages.')
|
||||
|
||||
print('Extracting', ' '.join(deb_paths))
|
||||
|
||||
if create_subdirs:
|
||||
extract_directory = os.path.join(output_directory, package_name)
|
||||
else:
|
||||
|
|
Loading…
Reference in New Issue