[infra] revisions->srcmap cleanup

This commit is contained in:
Mike Aizatsky 2016-10-20 13:15:28 -07:00
parent fc9a4c4871
commit 6ccbe7f757
4 changed files with 11 additions and 19 deletions

View File

@ -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"]

View File

@ -15,7 +15,6 @@
#
################################################################################
revisions
echo "---------------------------------------------------------------"
echo -n "Compiling libFuzzer into /usr/lib/libfuzzer.a ..."

View File

@ -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

View File

@ -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/"
}
}