#!/bin/bash
set -ex
-BRANCH=`branch_slash_filter $BRANCH`
-
-
-cd $WORKSPACE
-
-get_bptag() {
- dist=$1
-
- [ "$dist" = "sid" ] && dver=""
- [ "$dist" = "jessie" ] && dver="~bpo80+1"
- [ "$dist" = "wheezy" ] && dver="~bpo70+1"
- [ "$dist" = "squeeze" ] && dver="~bpo60+1"
- [ "$dist" = "lenny" ] && dver="~bpo50+1"
- [ "$dist" = "xenial" ] && dver="$dist"
- [ "$dist" = "trusty" ] && dver="$dist"
- [ "$dist" = "saucy" ] && dver="$dist"
- [ "$dist" = "precise" ] && dver="$dist"
- [ "$dist" = "oneiric" ] && dver="$dist"
- [ "$dist" = "natty" ] && dver="$dist"
- [ "$dist" = "maverick" ] && dver="$dist"
- [ "$dist" = "lucid" ] && dver="$dist"
- [ "$dist" = "karmic" ] && dver="$dist"
-
- echo $dver
-}
-
-BPTAG=`get_bptag $DIST`
-
-chacra_ref="$BRANCH"
-vers=`cat ./dist/version`
-
-# We used to detect the $distro variable by inspecting at the host, but this is
-# not accurate because we are using pbuilder and just ubuntu to build
-# everything. That would cause POSTing binaries to incorrect chacra endpoints
-# like project/ref/ubuntu/jessie/.
-distro=""
-case $DIST in
- jessie|wheezy)
- distro="debian"
- ;;
- *)
- distro="ubuntu"
- ;;
-esac
-
-debian_version=${vers}-1
-
-gen_debian_version() {
- raw=$1
- dist=$2
-
- [ "$dist" = "sid" ] && dver="$raw"
- [ "$dist" = "jessie" ] && dver="$raw~bpo80+1"
- [ "$dist" = "wheezy" ] && dver="$raw~bpo70+1"
- [ "$dist" = "squeeze" ] && dver="$raw~bpo60+1"
- [ "$dist" = "lenny" ] && dver="$raw~bpo50+1"
- [ "$dist" = "precise" ] && dver="$raw$dist"
- [ "$dist" = "saucy" ] && dver="$raw$dist"
- [ "$dist" = "trusty" ] && dver="$raw$dist"
- [ "$dist" = "xenial" ] && dver="$raw$dist"
-
- echo $dver
-}
-
-bpvers=`gen_debian_version $debian_version $DIST`
-
-# Normalize variables across rpm/deb builds
-NORMAL_DISTRO=$distro
-NORMAL_DISTRO_VERSION=$DIST
-NORMAL_ARCH=$ARCH
-
-# Write these values to a file so the failure
-# script can consume them if the build fails
-cat > $WORKSPACE/build_info << EOF
-NORMAL_DISTRO=$distro
-NORMAL_DISTRO_VERSION=$DIST
-NORMAL_ARCH=$ARCH
-EOF
-
-# create build status in shaman
-create_build_status "started" "ceph" $NORMAL_DISTRO $NORMAL_DISTRO_VERSION $NORMAL_ARCH
-
-# look for a specific package to tell if we can avoid the build
-chacra_endpoint="ceph/${chacra_ref}/${SHA1}/${distro}/${DIST}/${ARCH}/flavors/${FLAVOR}"
-chacra_repo_endpoint="ceph/${chacra_ref}/${SHA1}/${distro}/${DIST}/flavors/${FLAVOR}"
-DEB_ARCH=`dpkg-architecture | grep DEB_BUILD_ARCH\= | cut -d '=' -f 2`
-chacra_check_url="${chacra_endpoint}/librados2_${bpvers}_${DEB_ARCH}.deb"
-
-if [ "$THROWAWAY" = false ] ; then
- # this exists in scripts/build_utils.sh
- check_binary_existence $chacra_check_url
-fi
-
-HOST=$(hostname --short)
-echo "Building on $(hostname)"
-echo " DIST=${DIST}"
-echo " BPTAG=${BPTAG}"
-echo " WS=$WORKSPACE"
-echo " PWD=$(pwd)"
-echo " BUILD SOURCE=$COPYARTIFACT_BUILD_NUMBER_CEPH_SETUP"
-echo "*****"
-env
-echo "*****"
-
# create a release directory for ceph-build tools
mkdir -p release
cp -a dist release/${vers}
--- /dev/null
+#!/bin/bash
+
+set -ex
+HOST=$(hostname --short)
+echo "Building on $(hostname)"
+echo " DIST=${DIST}"
+echo " BPTAG=${BPTAG}"
+echo " KEYID=${KEYID}"
+echo " WS=$WORKSPACE"
+echo " PWD=$(pwd)"
+echo " BUILD SOURCE=$COPYARTIFACT_BUILD_NUMBER_CEPH_SETUP"
+echo "*****"
+env
+echo "*****"
+
+DIR=/tmp/install-deps.$$
+trap "rm -fr $DIR" EXIT
+mkdir -p $DIR
+if test $(id -u) != 0 ; then
+ SUDO=sudo
+fi
+export LC_ALL=C # the following is vulnerable to i18n
+
+$SUDO apt-get install -y lsb-release
+
+# unpack the tar.gz that contains the debian dir
+cd dist
+tar xzf *.orig.tar.gz
+cd ceph-*
+pwd
+
+BRANCH=`branch_slash_filter $BRANCH`
+
+cd $WORKSPACE
+
+get_bptag() {
+ dist=$1
+
+ [ "$dist" = "sid" ] && dver=""
+ [ "$dist" = "jessie" ] && dver="~bpo80+1"
+ [ "$dist" = "wheezy" ] && dver="~bpo70+1"
+ [ "$dist" = "squeeze" ] && dver="~bpo60+1"
+ [ "$dist" = "lenny" ] && dver="~bpo50+1"
+ [ "$dist" = "xenial" ] && dver="$dist"
+ [ "$dist" = "trusty" ] && dver="$dist"
+ [ "$dist" = "saucy" ] && dver="$dist"
+ [ "$dist" = "precise" ] && dver="$dist"
+ [ "$dist" = "oneiric" ] && dver="$dist"
+ [ "$dist" = "natty" ] && dver="$dist"
+ [ "$dist" = "maverick" ] && dver="$dist"
+ [ "$dist" = "lucid" ] && dver="$dist"
+ [ "$dist" = "karmic" ] && dver="$dist"
+
+ echo $dver
+}
+
+BPTAG=`get_bptag $DIST`
+
+chacra_ref="$BRANCH"
+vers=`cat ./dist/version`
+
+# We used to detect the $distro variable by inspecting at the host, but this is
+# not accurate because we are using pbuilder and just ubuntu to build
+# everything. That would cause POSTing binaries to incorrect chacra endpoints
+# like project/ref/ubuntu/jessie/.
+distro=""
+case $DIST in
+ jessie|wheezy)
+ distro="debian"
+ ;;
+ *)
+ distro="ubuntu"
+ ;;
+esac
+
+debian_version=${vers}-1
+
+gen_debian_version() {
+ raw=$1
+ dist=$2
+
+ [ "$dist" = "sid" ] && dver="$raw"
+ [ "$dist" = "jessie" ] && dver="$raw~bpo80+1"
+ [ "$dist" = "wheezy" ] && dver="$raw~bpo70+1"
+ [ "$dist" = "squeeze" ] && dver="$raw~bpo60+1"
+ [ "$dist" = "lenny" ] && dver="$raw~bpo50+1"
+ [ "$dist" = "precise" ] && dver="$raw$dist"
+ [ "$dist" = "saucy" ] && dver="$raw$dist"
+ [ "$dist" = "trusty" ] && dver="$raw$dist"
+ [ "$dist" = "xenial" ] && dver="$raw$dist"
+
+ echo $dver
+}
+
+bpvers=`gen_debian_version $debian_version $DIST`
+
+# Normalize variables across rpm/deb builds
+NORMAL_DISTRO=$distro
+NORMAL_DISTRO_VERSION=$DIST
+NORMAL_ARCH=$ARCH
+
+# Write these values to a file so the failure
+# script can consume them if the build fails
+cat > $WORKSPACE/build_info << EOF
+NORMAL_DISTRO=$distro
+NORMAL_DISTRO_VERSION=$DIST
+NORMAL_ARCH=$ARCH
+SHA1=$SHA1
+EOF
+
+# create build status in shaman
+create_build_status "started" "ceph" $NORMAL_DISTRO $NORMAL_DISTRO_VERSION $NORMAL_ARCH
+
+pkgs=( "chacractl>=0.0.4" )
+install_python_packages "pkgs[@]"
+
+# ask shaman which chacra instance to use
+chacra_url=`curl -f -u $SHAMAN_API_USER:$SHAMAN_API_KEY https://shaman.ceph.com/api/nodes/next/`
+# create the .chacractl config file using global variables
+make_chacractl_config $chacra_url
+
+# look for a specific package to tell if we can avoid the build
+chacra_endpoint="ceph/${chacra_ref}/${SHA1}/${distro}/${DIST}/${ARCH}/flavors/${FLAVOR}"
+chacra_repo_endpoint="ceph/${chacra_ref}/${SHA1}/${distro}/${DIST}/flavors/${FLAVOR}"
+DEB_ARCH=`dpkg-architecture | grep DEB_BUILD_ARCH\= | cut -d '=' -f 2`
+chacra_check_url="${chacra_endpoint}/librados2_${bpvers}_${DEB_ARCH}.deb"
+
+if [ "$THROWAWAY" = false ] ; then
+ # this exists in scripts/build_utils.sh
+ # TODO if this exits we need to post to shaman a success
+ check_binary_existence $chacra_check_url
+fi