[DEFAULT]
pristine-tar = False
no-create-orig = True
pbuilder = True

prebuild = bash -c "
    # Show execution trace
    set -x &&
    # Use debian/changelog (not VERSION_CURRENT) to get upstream version to build
    upstream_version=$(dpkg-parsechangelog | sed -E -n 's/^Version: +(.*)-.*/\1/p') &&
    # Determine list of embedded sources to exclude from Debian source package
    zlib_filter_files=\"$(find src/zlib-* -mindepth 1 -maxdepth 1 \! -name zconf.h.in -printf "mongo-c-driver-\${upstream_version}/%p ")\" &&
    zlib_rm_files=\"$(find src/zlib-* -mindepth 1 -maxdepth 1 \! -name zconf.h.in -printf '%p ')\" &&
    # Determine if we are on a release branch and set the reference to use later
    # to create the upstream tarball (when on a release branch use the most
    # recent release tag, and when on any other branch use HEAD)
    release_branch=$(cd $GBP_GIT_DIR/..; git symbolic-ref --short HEAD | sed -n '/^r[0-9]\./p') &&
    if [ -n \"\${release_branch}\" ]; then archive_ref=$(cd $GBP_GIT_DIR/..; git describe --tags --abbrev=0 --match '1.*'); else archive_ref=HEAD; fi &&
    # Create upstream tarball from reference, exclude items that do not belong
    pushd $GBP_GIT_DIR/.. &&
    git archive --format=tar --prefix=mongo-c-driver-\${upstream_version}/ \${archive_ref} | tar -f - --delete mongo-c-driver-\${upstream_version}/debian \$zlib_filter_files | gzip > $GBP_BUILD_DIR/../mongo-c-driver_\${upstream_version}.orig.tar.gz &&
    popd &&
    rm -rf \$zlib_rm_files"

upstream-tree = BRANCH
upstream-branch = master
upstream-tag = %(version)s
debian-branch = master
