diff options
author | 2018-10-01 23:13:59 -0700 | |
---|---|---|
committer | 2018-10-01 23:13:59 -0700 | |
commit | d39e0f7ea009dafc1fcf9f6d43ef4ad92afc2668 (patch) | |
tree | 17a469d2c58b638dab1b9c62ec653a04579dc2a1 /infra/base-images | |
parent | 4afcfab869ec9f4eb8548204dd3e14b61c58665a (diff) |
[infra] Restore srcmap binary back to base-builder image (follow-up #1848).
Diffstat (limited to 'infra/base-images')
-rw-r--r-- | infra/base-images/base-builder/Dockerfile | 2 | ||||
-rwxr-xr-x | infra/base-images/base-builder/srcmap | 60 |
2 files changed, 61 insertions, 1 deletions
diff --git a/infra/base-images/base-builder/Dockerfile b/infra/base-images/base-builder/Dockerfile index 1a4c8496..2a9a85e3 100644 --- a/infra/base-images/base-builder/Dockerfile +++ b/infra/base-images/base-builder/Dockerfile @@ -63,6 +63,6 @@ RUN mkdir honggfuzz && \ tar -xzv --strip-components=1 -f $SRC/oss-fuzz.tar.gz && \ rm -rf $SRC/oss-fuzz.tar.gz -COPY compile compile_afl compile_libfuzzer compile_honggfuzz /usr/local/bin/ +COPY compile compile_afl compile_libfuzzer compile_honggfuzz srcmap /usr/local/bin/ CMD ["compile"] diff --git a/infra/base-images/base-builder/srcmap b/infra/base-images/base-builder/srcmap new file mode 100755 index 00000000..48a0d88d --- /dev/null +++ b/infra/base-images/base-builder/srcmap @@ -0,0 +1,60 @@ +#!/bin/bash -eu +# Copyright 2016 Google Inc. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# +################################################################################ + +# Deterimine srcmap of checked out source code + +SRCMAP=$(tempfile) +echo "{}" > $SRCMAP + +# $1 - json file, $2 - jq program +function jq_inplace() { + F=$(tempfile) && cat $1 | jq "$2" > $F && mv $F $1 +} + +# Git +for DOT_GIT_DIR in $(find $SRC -name ".git" -type d); do + GIT_DIR=$(dirname $DOT_GIT_DIR) + cd $GIT_DIR + GIT_URL=$(git config --get remote.origin.url) + GIT_REV=$(git rev-parse HEAD) + jq_inplace $SRCMAP ".\"$GIT_DIR\" = { type: \"git\", url: \"$GIT_URL\", rev: \"$GIT_REV\" }" +done + +# Subversion +for DOT_SVN_DIR in $(find $SRC -name ".svn" -type d); do + SVN_DIR=$(dirname $DOT_SVN_DIR) + cd $SVN_DIR + SVN_URL=$(svn info | grep "^URL:" | sed 's/URL: //g') + SVN_REV=$(svn info -r HEAD | grep "^Revision:" | sed 's/Revision: //g') + jq_inplace $SRCMAP ".\"$SVN_DIR\" = { type: \"svn\", url: \"$SVN_URL\", rev: \"$SVN_REV\" }" +done + +# Mercurial +for DOT_HG_DIR in $(find $SRC -name ".hg" -type d); do + HG_DIR=$(dirname $DOT_HG_DIR) + cd $HG_DIR + HG_URL=$(hg paths default) + HG_REV=$(hg --debug id -i) + jq_inplace $SRCMAP ".\"$HG_DIR\" = { type: \"hg\", url: \"$HG_URL\", rev: \"$HG_REV\" }" +done + +if [ "${OSSFUZZ_REVISION-}" != "" ]; then + jq_inplace $SRCMAP ".\"/src\" = { type: \"git\", url: \"https://github.com/google/oss-fuzz.git\", rev: \"$OSSFUZZ_REVISION\" }" +fi + +cat $SRCMAP +rm $SRCMAP |