aboutsummaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorGravatar Oliver Chang <oliverchang@users.noreply.github.com>2021-09-21 10:10:06 +1000
committerGravatar GitHub <noreply@github.com>2021-09-21 10:10:06 +1000
commit77d6eb33bc462d19b719b11a90cd69819d638d6d (patch)
tree30814973beb6e94fc8ab845fae5899d8fa8d6695
parent219af13b2b603ca36887bf3ef057b478b0bed6bf (diff)
Helper fixes for external projects. (#6458)
- Add ":v1" suffix to Dockerfile template. - Support relative paths for external project directories.
-rwxr-xr-xinfra/helper.py14
-rw-r--r--infra/helper_test.py2
-rwxr-xr-xinfra/templates.py2
3 files changed, 10 insertions, 8 deletions
diff --git a/infra/helper.py b/infra/helper.py
index ffadb17f..db9f76b6 100755
--- a/infra/helper.py
+++ b/infra/helper.py
@@ -86,8 +86,8 @@ class Project:
build_integration_path=constants.DEFAULT_EXTERNAL_BUILD_INTEGRATION_PATH):
self.is_external = is_external
if self.is_external:
- self.name = os.path.basename(os.path.abspath(project_name_or_path))
- self.path = project_name_or_path
+ self.path = os.path.abspath(project_name_or_path)
+ self.name = os.path.basename(self.path)
self.build_integration_path = os.path.join(self.path,
build_integration_path)
else:
@@ -137,15 +137,17 @@ class Project:
def main(): # pylint: disable=too-many-branches,too-many-return-statements
"""Gets subcommand from program arguments and does it. Returns 0 on success 1
on error."""
- os.chdir(OSS_FUZZ_DIR)
- if not os.path.exists(BUILD_DIR):
- os.mkdir(BUILD_DIR)
-
logging.basicConfig(level=logging.INFO)
parser = get_parser()
args = parse_args(parser)
+ # Note: this has to happen after parse_args above as parse_args needs to know
+ # the original CWD for external projects.
+ os.chdir(OSS_FUZZ_DIR)
+ if not os.path.exists(BUILD_DIR):
+ os.mkdir(BUILD_DIR)
+
# We have different default values for `sanitizer` depending on the `engine`.
# Some commands do not have `sanitizer` argument, so `hasattr` is necessary.
if hasattr(args, 'sanitizer') and not args.sanitizer:
diff --git a/infra/helper_test.py b/infra/helper_test.py
index bb365037..951eba47 100644
--- a/infra/helper_test.py
+++ b/infra/helper_test.py
@@ -165,7 +165,7 @@ class ProjectTest(fake_filesystem_unittest.TestCase):
def setUp(self):
self.project_name = 'project'
self.internal_project = helper.Project(self.project_name)
- self.external_project_path = os.path.join('path', 'to', self.project_name)
+ self.external_project_path = os.path.join('/path', 'to', self.project_name)
self.external_project = helper.Project(self.external_project_path,
is_external=True)
self.setUpPyfakefs()
diff --git a/infra/templates.py b/infra/templates.py
index 35a74825..9247285b 100755
--- a/infra/templates.py
+++ b/infra/templates.py
@@ -47,7 +47,7 @@ COPY build.sh $SRC/
"""
EXTERNAL_DOCKER_TEMPLATE = """\
-FROM gcr.io/oss-fuzz-base/%(base_builder)s
+FROM gcr.io/oss-fuzz-base/%(base_builder)s:v1
RUN apt-get update && apt-get install -y make autoconf automake libtool
RUN COPY . $SRC/%(project_name)s
WORKDIR %(project_name)s