From 887e55191922f4412a502b06bff996c43d83a0fc Mon Sep 17 00:00:00 2001 From: Sage Weil Date: Mon, 18 Feb 2013 21:09:50 -0800 Subject: [PATCH] build-auto: determine gitbuilder behavior from the hostname Figure out what the build should do based on keywords in the hostname. Similarly, rsync to the remote target using the fields in the hostname: gitbuilder-PROJECT-WHAT-DISTRO-ARCH-FLAVOR PROJECT is ceph, ... WHAT is deb or rpm (so far) DISTRO is precise, etc. ARCH is amd64, i386 (although the VM knows this anyway) FLAVOR is basic, notcmalloc, gcov, ... This will simplify the fabfile a bit (at least for new builder VMs). We also solve the problem is passing the environment into the package build from one central location (build-auto.sh) which has enough context/state in the hostname to do the right thing. Signed-off-by: Sage Weil --- build-auto.sh | 28 ++++++++++++++++++++++++++++ fabfile.py | 38 ++++++++++++++++++++++++++++---------- 2 files changed, 56 insertions(+), 10 deletions(-) create mode 100644 build-auto.sh diff --git a/build-auto.sh b/build-auto.sh new file mode 100644 index 0000000..3330eee --- /dev/null +++ b/build-auto.sh @@ -0,0 +1,28 @@ +#!/bin/sh -x + +mydir=`dirname $0` + +if ! hostname | grep -q ^gitbuilder- ; then + echo "hostname "`hostname`"does not make sense to me; i fail" + exit 1 +fi + +if hostname | grep -q -- -notcmalloc- ; then + echo "hostname has -notcmalloc-, will build --without-tcmalloc" + export CEPH_EXTRA_CONFIGURE_ARGS+=" --without-tcmalloc" +fi +if hostname | grep -q -- -gcov- ; then + echo "hostname has -gcov-, will --enable-coverage" + export CEPH_EXTRA_CONFIGURE_ARGS+=" --enable-coverage" +fi + +if hostname | grep -q -- -deb- ; then + exec $mydir/build-ceph-deb-native.sh +fi +if hostname | grep -q -- -rpm- ; then + exec $mydir/build-ceph-rpm.sh +fi + +echo "i don't know what to do with hostname "`hostname` +exit 1 + diff --git a/fabfile.py b/fabfile.py index 9f519c8..f237236 100644 --- a/fabfile.py +++ b/fabfile.py @@ -45,6 +45,10 @@ env.roledefs['gitbuilder_ceph_deb_native'] = [ 'ubuntu@gitbuilder-squeeze-deb-amd64.front.sepia.ceph.com', ] +env.roledefs['gitbuilder_auto'] = [ + 'ubuntu@gitbuilder-ceph-deb-precise-amd64-notcmalloc.front.sepia.ceph.com', + ] + #env.roledefs['gitbuilder_ceph_deb_ndn'] = [ # 'ubuntu@10.3.14.65', # ] @@ -541,6 +545,12 @@ def gitbuilder_ceph_deb_native(): sudo('start autobuild-ceph || /etc/init.d/autobuild-ceph start') _sync_to_gitbuilder('ceph', 'deb', 'basic') +@roles('gitbuilder_auto') +def gitbuilder_ceph_auto(): + _deb_builder('https://github.com/ceph/ceph.git', 'auto') + sudo('start autobuild-ceph || /etc/init.d/autobuild-ceph start') + _sync_to_gitbuilder_from_hostname() + @roles('gitbuilder_ceph_rpm') def gitbuilder_ceph_rpm(): _gitbuilder_ceph_rpm('https://github.com/ceph/ceph.git', 'ceph-rpm') @@ -630,16 +640,24 @@ def _sync_to_gitbuilder(package, format, flavor): with cd('/srv/autobuild-ceph'): # fugliness sudo("echo gitbuilder@gitbuilder.ceph.com:gitbuilder.ceph.com/%s-%s-`lsb_release -s -c`-`uname -m`-%s > rsync-target" % (package,format,flavor)) - if not exists('rsync-key'): - if not os.path.exists('rsync-key'): - print >> sys.stderr, 'Required rsync keys to gitbuilder.ceph.com missing!' - sys.exit(1) - # for whatever reason, put doesn't seem to honor cd and use_sudo fails - put("rsync-key") - put("rsync-key.pub") - sudo("mv /home/ubuntu/rsync-key* ./") - sudo("chmod 600 rsync-key* ; chown autobuild-ceph.autobuild-ceph rsync-key*") - + _sync_rsync_keys() + +def _sync_rsync_keys(): + if not exists('rsync-key'): + if not os.path.exists('rsync-key'): + print >> sys.stderr, 'Required rsync keys to gitbuilder.ceph.com missing!' + sys.exit(1) + # for whatever reason, put doesn't seem to honor cd and use_sudo fails + put("rsync-key") + put("rsync-key.pub") + sudo("mv /home/ubuntu/rsync-key* ./") + sudo("chmod 600 rsync-key* ; chown autobuild-ceph.autobuild-ceph rsync-key*") + +def _sync_to_gitbuilder_from_hostname(): + with cd('/srv/autobuild-ceph'): + # fugliness + sudo("echo gitbuilder@gitbuilder.ceph.com:gitbuilder.ceph.com/`hostname | cut --delimiter=- -f 2`-`hostname | cut --delimiter=- -f 3`-`lsb_release -s -c`-`uname -m`-`hostname | cut --delimiter=- -f 6` > rsync-target") + _sync_rsync_keys() # # build ndn debs for dho -- 2.39.5