diff --git a/infra/base-images/base-libfuzzer/Dockerfile b/infra/base-images/base-libfuzzer/Dockerfile index 703defbeb..b0226190f 100644 --- a/infra/base-images/base-libfuzzer/Dockerfile +++ b/infra/base-images/base-libfuzzer/Dockerfile @@ -27,7 +27,7 @@ ENV FUZZER_LDFLAGS "-Wl,-whole-archive /usr/local/lib/libc++.a /usr/local/lib/li RUN mkdir /out && chmod a+w /out RUN mkdir /src/bin -COPY compile revisions run test /src/bin/ +COPY compile srcmap run test /src/bin/ ENV PATH=/src/bin:$PATH WORKDIR /src CMD ["compile"] diff --git a/infra/base-images/base-libfuzzer/compile b/infra/base-images/base-libfuzzer/compile index 3800b8aa8..347253bb7 100755 --- a/infra/base-images/base-libfuzzer/compile +++ b/infra/base-images/base-libfuzzer/compile @@ -15,7 +15,6 @@ # ################################################################################ -revisions echo "---------------------------------------------------------------" echo -n "Compiling libFuzzer into /usr/lib/libfuzzer.a ..." diff --git a/infra/base-images/base-libfuzzer/revisions b/infra/base-images/base-libfuzzer/srcmap similarity index 78% rename from infra/base-images/base-libfuzzer/revisions rename to infra/base-images/base-libfuzzer/srcmap index 92dbbe034..24e318082 100755 --- a/infra/base-images/base-libfuzzer/revisions +++ b/infra/base-images/base-libfuzzer/srcmap @@ -15,9 +15,10 @@ # ################################################################################ -# Deterimine revisions of checked out source code +# Deterimine srcmap of checked out source code -echo "{}" > /out/srcmap.json +SRCMAP=$(tempfile) +echo "{}" > $SRCMAP # $1 - json file, $2 - jq program function jq_inplace() { @@ -29,7 +30,7 @@ for DOT_GIT_DIR in $(find /src -name ".git" -type d); do cd $GIT_DIR GIT_URL=$(git config --get remote.origin.url) GIT_REV=$(git rev-parse HEAD) - jq_inplace /out/srcmap.json ".\"$GIT_DIR\" = { type: \"git\", url: \"$GIT_URL\", rev: \"$GIT_REV\" }" + jq_inplace $SRCMAP ".\"$GIT_DIR\" = { type: \"git\", url: \"$GIT_URL\", rev: \"$GIT_REV\" }" done for DOT_SVN_DIR in $(find /src -name ".svn" -type d); do @@ -37,8 +38,8 @@ for DOT_SVN_DIR in $(find /src -name ".svn" -type d); do 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 /out/srcmap.json ".\"$SVN_DIR\" = { type: \"svn\", url: \"$SVN_URL\", rev: \"$SVN_REV\" }" + jq_inplace $SRCMAP ".\"$SVN_DIR\" = { type: \"svn\", url: \"$SVN_URL\", rev: \"$SVN_REV\" }" done -cat /out/srcmap.json -chmod a+r /out/srcmap.json +cat $SRCMAP +rm $SRCMAP diff --git a/infra/libfuzzer-pipeline.groovy b/infra/libfuzzer-pipeline.groovy index 6b1a12a7c..0f33d2a35 100644 --- a/infra/libfuzzer-pipeline.groovy +++ b/infra/libfuzzer-pipeline.groovy @@ -41,7 +41,7 @@ def call(body) { def uid = 0 // TODO: try to make $USER to work echo "using uid $uid" - def revisionsFile = "$workspace/${projectName}.rev" + def srcmapFile = "$workspace/srcmap.json" def dockerTag = "ossfuzz/$projectName" echo "Building $dockerTag" @@ -49,7 +49,6 @@ def call(body) { sh "mkdir -p $workspace/out" stage("docker image") { - def revisions = [:] dir('oss-fuzz') { git url: "https://github.com/google/oss-fuzz.git" } @@ -57,7 +56,6 @@ def call(body) { if (gitUrl != null) { dir(checkoutDir) { git url: gitUrl - revisions[gitUrl] = sh(returnStdout: true, script: 'git rev-parse HEAD').trim() } } if (svnUrl != null) { @@ -74,9 +72,7 @@ def call(body) { sh "docker build --no-cache -t $dockerTag -f $dockerfile $dockerContextDir" - def revText = groovy.json.JsonOutput.toJson(revisions) - writeFile file: revisionsFile, text: revText - echo "revisions: $revText" + sh "docker run --rm -t $dockerTag srcmap > $srcmapFile" } for (int i = 0; i < sanitizers.size(); i++) { @@ -149,13 +145,9 @@ def call(body) { def sanitizer = sanitizers[i] dir (sanitizer) { def zipFile = "$projectName-$sanitizer-${date}.zip" - def revFile = "$projectName-$sanitizer-${date}.rev" - sh "cp $revisionsFile $revFile" sh "zip -j $zipFile *" sh "gsutil cp $zipFile gs://clusterfuzz-builds/$projectName/" - sh "gsutil cp $revFile gs://clusterfuzz-builds/$projectName/" - def srcmapFile = "$projectName-$sanitizer-${date}.srcmap.json" - sh "cp srcmap.json $srcmapFile" + sh "cp $srcmapFile $projectName-$sanitizer-${date}.srcmap.json" sh "gsutil cp $srcmapFile gs://clusterfuzz-builds/$projectName/" } }