#!/bin/bash

# helper script to be invoked by jenkins/buildbot

# $1 [optional]: the build type - release | nightly | test
buildtype=${1:-test}

set -x
set -e

PARALLEL=${PARALLEL:-1}
TMP=$(mktemp -d /tmp/debuild.XXXXXX)

function cleanup() {
  [[ -d $TMP ]] && rm -rf $TMP
}
trap cleanup EXIT

. scripts/git-tag.sh

git archive HEAD --prefix=bcc/ --format=tar.gz -o $TMP/bcc_$revision.orig.tar.gz

pushd $TMP
tar xf bcc_$revision.orig.tar.gz
cd bcc

debuild=debuild
if [[ "$buildtype" = "test" ]]; then
  # when testing, use faster compression options
  debuild+=" --preserve-envvar PATH"
  echo -e '#!/bin/bash\nexec /usr/bin/dpkg-deb -z1 "$@"' \
    | sudo tee /usr/local/bin/dpkg-deb
  sudo chmod +x /usr/local/bin/dpkg-deb
  dch -b -v $revision-$release "$git_subject"
fi
if [[ "$buildtype" = "nightly" ]]; then
  dch -v $revision-$release "$git_subject"
fi

DEB_BUILD_OPTIONS="nocheck parallel=${PARALLEL}" $debuild -us -uc
popd

cp $TMP/*.deb .

#!/bin/bash

# helper script to be invoked by jenkins/buildbot

# $1 [optional]: the build type - release | nightly | test
buildtype=${1:-test}

set -x
set -e

PARALLEL=${PARALLEL:-1}
TMP=$(mktemp -d /tmp/debuild.XXXXXX)

function cleanup() {
  [[ -d $TMP ]] && rm -rf $TMP
}
trap cleanup EXIT

. scripts/git-tag.sh

git archive HEAD --prefix=bcc/ --format=tar.gz -o $TMP/bcc_$revision.orig.tar.gz

pushd $TMP
tar xf bcc_$revision.orig.tar.gz
cd bcc

if [[ "$buildtype" = "test" ]]; then
  dch -b -v $revision-$release "$git_subject"
fi
if [[ "$buildtype" = "nightly" ]]; then
  dch -v $revision-$release "$git_subject"
fi

DEB_BUILD_OPTIONS="nocheck parallel=${PARALLEL}" debuild -us -uc
popd

cp $TMP/*.deb .

--- 
+++ 
@@ -24,20 +24,14 @@
 tar xf bcc_$revision.orig.tar.gz
 cd bcc
 
-debuild=debuild
 if [[ "$buildtype" = "test" ]]; then
-  # when testing, use faster compression options
-  debuild+=" --preserve-envvar PATH"
-  echo -e '#!/bin/bash\nexec /usr/bin/dpkg-deb -z1 "$@"' \
-    | sudo tee /usr/local/bin/dpkg-deb
-  sudo chmod +x /usr/local/bin/dpkg-deb
   dch -b -v $revision-$release "$git_subject"
 fi
 if [[ "$buildtype" = "nightly" ]]; then
   dch -v $revision-$release "$git_subject"
 fi
 
-DEB_BUILD_OPTIONS="nocheck parallel=${PARALLEL}" $debuild -us -uc
+DEB_BUILD_OPTIONS="nocheck parallel=${PARALLEL}" debuild -us -uc
 popd
 
 cp $TMP/*.deb .
Use fast compression in test deb builds

Builds on GCE/ubuntu image were taking a long time due to combination of
disk speed/single core, and the default dpkg-deb compression level
(-z9). The dpkg-deb alone step was taking up to 5 minutes. Reduce to ~1
minute by forcing -z1. Unfortunately, it was not obvious how to capture
the option in debuild command, so this is a bit hacky.

Signed-off-by: Brenden Blanco <8e41c261aa8ddb01230a40c21c26a049c1f6d041@gmail.com>
