]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
buildpackages: make rpm packages
authorLoic Dachary <ldachary@redhat.com>
Wed, 16 Sep 2015 21:45:38 +0000 (23:45 +0200)
committerLoic Dachary <ldachary@redhat.com>
Sat, 26 Sep 2015 12:09:21 +0000 (14:09 +0200)
Signed-off-by: Loic Dachary <loic@dachary.org>
(cherry picked from commit 7e3a271a89d4e7794a1ee547a3105a871f76f9f1)

13 files changed:
suites/teuthology/buildpackages/% [new file with mode: 0644]
suites/teuthology/buildpackages/+ [deleted file]
suites/teuthology/buildpackages/buildpackages.yaml [deleted file]
suites/teuthology/buildpackages/distros [new symlink]
suites/teuthology/buildpackages/tasks/builpackages.yaml [new file with mode: 0644]
suites/teuthology/buildpackages/ubuntu_14.04.yaml [deleted symlink]
tasks/buildpackages.py
tasks/buildpackages/Makefile
tasks/buildpackages/common.sh [new file with mode: 0644]
tasks/buildpackages/make-deb.sh [new file with mode: 0755]
tasks/buildpackages/make-debs.sh [deleted file]
tasks/buildpackages/make-rpm.sh [new file with mode: 0755]
tasks/buildpackages/user-data.txt [new file with mode: 0644]

diff --git a/suites/teuthology/buildpackages/% b/suites/teuthology/buildpackages/%
new file mode 100644 (file)
index 0000000..e69de29
diff --git a/suites/teuthology/buildpackages/+ b/suites/teuthology/buildpackages/+
deleted file mode 100644 (file)
index e69de29..0000000
diff --git a/suites/teuthology/buildpackages/buildpackages.yaml b/suites/teuthology/buildpackages/buildpackages.yaml
deleted file mode 100644 (file)
index 53c02bf..0000000
+++ /dev/null
@@ -1,9 +0,0 @@
-roles:
-    - [mon.0, client.0]
-tasks:
-    - buildpackages:
-    - install:
-        machine:
-          disk: 40 # GB
-          ram: 15000 # MB
-          cpus: 16
diff --git a/suites/teuthology/buildpackages/distros b/suites/teuthology/buildpackages/distros
new file mode 120000 (symlink)
index 0000000..c5d5935
--- /dev/null
@@ -0,0 +1 @@
+../../../distros/supported
\ No newline at end of file
diff --git a/suites/teuthology/buildpackages/tasks/builpackages.yaml b/suites/teuthology/buildpackages/tasks/builpackages.yaml
new file mode 100644 (file)
index 0000000..577552f
--- /dev/null
@@ -0,0 +1,9 @@
+roles:
+    - [mon.0, client.0]
+tasks:
+    - buildpackages:
+        machine:
+          disk: 40 # GB
+          ram: 15000 # MB
+          cpus: 16
+    - install:
diff --git a/suites/teuthology/buildpackages/ubuntu_14.04.yaml b/suites/teuthology/buildpackages/ubuntu_14.04.yaml
deleted file mode 120000 (symlink)
index b6def03..0000000
+++ /dev/null
@@ -1 +0,0 @@
-../../../distros/supported/ubuntu_14.04.yaml
\ No newline at end of file
index a2bdb669ac2ee74bad6b2d411f7e4840cbaf1b7d..ecf7dbcca5af4e91a83edaacf7388e638387c641 100644 (file)
@@ -1,5 +1,10 @@
 """
 Build ceph packages
+
+Integration tests:
+
+teuthology-openstack --verbose --key-name myself --key-filename ~/Downloads/myself --ceph hammer --suite teuthology/buildpackages
+
 """
 import logging
 import os
@@ -82,17 +87,24 @@ def task(ctx, config):
         else:
             ref = ''
         subprocess.check_call(
+            "flock /tmp/buildpackages " +
             "make -C " + d + " " + os.environ['HOME'] + "/.ssh_agent",
             shell=True)
         target = os.path.dirname(urlparse.urlparse(url).path.strip('/'))
         target = os.path.dirname(target) + '-' + sha1
         openstack = OpenStack()
         select = '^(vps|eg)-'
-        flavor = openstack.flavor(config['machine'], select)
-        cmd = (". " + os.environ['HOME'] + "/.ssh_agent ; make -C " + d +
+        build_flavor = openstack.flavor(config['machine'], select)
+        http_flavor = openstack.flavor({
+            'disk': 10, # GB
+            'ram': 1024, # MB
+            'cpus': 1,
+        }, select)
+        cmd = (". " + os.environ['HOME'] + "/.ssh_agent ; flock /tmp/buildpackages make -C " + d +
                " CEPH_GIT_BASE_URL=" + teuth_config.ceph_git_base_url + 
-               " CEPH_OS_TYPE=" + gitbuilder.os_type +
-               " CEPH_OS_VERSION=" + gitbuilder.os_version +
+               " CEPH_PKG_TYPE=" + gitbuilder.pkg_type +
+               " CEPH_OS_TYPE=" + ctx.config['os_type'] +
+               " CEPH_OS_VERSION=" + ctx.config['os_version'] +
                " CEPH_DIST=" + gitbuilder.distro +
                " CEPH_ARCH=" + gitbuilder.arch +
                " CEPH_SHA1=" + (sha1 or '')  +
@@ -100,7 +112,8 @@ def task(ctx, config):
                " CEPH_BRANCH=" + (branch or '') +
                " CEPH_REF=" + ref +
                " GITBUILDER_URL=" + url +
-               " FLAVOR=" + flavor +
+               " BUILD_FLAVOR=" + build_flavor +
+               " HTTP_FLAVOR=" + http_flavor +
                " " + target +
                " ")
         log.info("buildpackages: " + cmd)
index 354caf9b9094e60cde277629f905c2b3246dc1b1..21eb4010693a650fc86178cd5b6e4b762b637a89 100644 (file)
@@ -14,24 +14,21 @@ ${HOME}/.ssh_agent:
        grep -q ssh_agent ~/.bashrc_teuthology || echo 'source ${HOME}/.ssh_agent' >> ~/.bashrc_teuthology
 
 packages-repository:
-       openstack server create --image 'teuthology-ubuntu-14.04' --flavor 'vps-ssd-1' --key-name teuthology --security-group teuthology --property ownedby=${MY_IP} --wait $@ ; sleep 30
+       openstack server create --image 'teuthology-ubuntu-14.04' --flavor ${HTTP_FLAVOR} --key-name teuthology --security-group teuthology --property ownedby=${MY_IP} --wait $@ ; sleep 30
        ip=$(call get_ip,$@) ; \
        ssh $$ip sudo apt-get install -y nginx ; \
        ssh $$ip sudo chown -R ubuntu /usr/share/nginx/html ; \
        perl -pi -e "s/^gitbuilder_host:.*/gitbuilder_host: $$ip/" ~/.teuthology.yaml
        mkdir -p ${D}/${@D} ; touch ${D}/$@
 
-FLAVOR=vps-ssd-1
-
-ceph-deb-${CEPH_DIST}-${CEPH_ARCH}-basic-${CEPH_SHA1}: packages-repository
-       openstack server create --image 'teuthology-${CEPH_OS_TYPE}-${CEPH_OS_VERSION}' --flavor ${FLAVOR} --key-name teuthology --security-group teuthology --property ownedby=${MY_IP} --wait $@ ; sleep 30
+ceph-${CEPH_PKG_TYPE}-${CEPH_DIST}-${CEPH_ARCH}-basic-${CEPH_SHA1}: packages-repository
+       openstack server create --image 'teuthology-${CEPH_OS_TYPE}-${CEPH_OS_VERSION}' --flavor ${BUILD_FLAVOR} --key-name teuthology --security-group teuthology --property ownedby=${MY_IP} --user-data user-data.txt --wait $@ ; sleep 30
        set -ex ; \
+       trap "openstack server delete $@" EXIT ; \
        ip=$(call get_ip,$@) ; \
-       echo 'sudo apt-get update ; sudo apt-get install -y git ; test -d ceph || git clone ${CEPH_GIT_BASE_URL}/ceph ; cd ceph ; git checkout ${CEPH_SHA1}' | ssh $$ip bash ; \
-       scp make-debs.sh $$ip: ; \
+       scp make-${CEPH_PKG_TYPE}.sh common.sh ubuntu@$$ip: ; \
        packages_repository=$(call get_ip,${<F}) ; \
-       echo 'cd ceph ; sudo chown $${USER} /opt ; sudo apt-get install -y reprepro ; git checkout origin/master install-deps.sh ; ./install-deps.sh ; ../make-debs.sh /opt/release '$$packages_repository | ssh -A $$ip bash
-       openstack server delete $@
+       ssh -tt -A ubuntu@$$ip bash ./make-${CEPH_PKG_TYPE}.sh $$packages_repository ${CEPH_DIST} ${CEPH_GIT_BASE_URL} ${CEPH_SHA1}
        mkdir -p ${D}/${@D} ; touch ${D}/$@
 
 clobber:
diff --git a/tasks/buildpackages/common.sh b/tasks/buildpackages/common.sh
new file mode 100644 (file)
index 0000000..520fda5
--- /dev/null
@@ -0,0 +1,29 @@
+#!/bin/bash
+#
+# Copyright (C) 2015 Red Hat <contact@redhat.com>
+#
+# Author: Loic Dachary <loic@dachary.org>
+#
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU Library Public License as published by
+# the Free Software Foundation; either version 2, or (at your option)
+# any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+# GNU Library Public License for more details.
+#
+function install_deps() {
+    git archive --remote=git://git.ceph.com/ceph.git master install-deps.sh | tar -xvf -
+    bash -x install-deps.sh
+}
+
+function get_ceph() {
+    local git_base_url=$1
+    local sha1=$2
+
+    test -d ceph || git clone ${git_base_url}/ceph
+    cd ceph
+    git checkout ${sha1}
+}
diff --git a/tasks/buildpackages/make-deb.sh b/tasks/buildpackages/make-deb.sh
new file mode 100755 (executable)
index 0000000..63b46c7
--- /dev/null
@@ -0,0 +1,151 @@
+#!/bin/bash
+#
+# Copyright (C) 2015 Red Hat <contact@redhat.com>
+#
+# Author: Loic Dachary <loic@dachary.org>
+#
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU Library Public License as published by
+# the Free Software Foundation; either version 2, or (at your option)
+# any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+# GNU Library Public License for more details.
+#
+
+# 
+# Create and upload a deb repository with the same naming conventions
+# as https://github.com/ceph/autobuild-ceph/blob/master/build-ceph-deb.sh
+#
+set -xe
+
+base=/tmp/release
+gitbuilder_host=$1
+codename=$2
+git_base_url=$3
+sha1=$4
+
+sudo apt-get update
+sudo apt-get install -y git
+
+source $(dirname $0)/common.sh
+
+get_ceph $git_base_url $sha1
+install_deps
+
+#codename=$(lsb_release -sc)
+releasedir=$base/$(lsb_release -si)/WORKDIR
+#
+# git describe provides a version that is
+# a) human readable
+# b) is unique for each commit
+# c) compares higher than any previous commit
+# d) contains the short hash of the commit
+#
+vers=$(git describe --match "v*" | sed s/^v//)
+#
+# always set the debian version to 1 which is ok because the debian
+# directory is included in the sources and the upstream version will
+# change each time it is modified.
+#
+dvers="$vers-1"
+sha1=$(git rev-parse HEAD)
+: ${NPROC:=$(nproc)}
+ceph_dir=$(pwd)
+
+function build_package() {
+
+    rm -fr $releasedir
+    mkdir -p $releasedir
+    #
+    # remove all files not under git so they are not
+    # included in the distribution.
+    #
+    git clean -qdxff
+    #
+    # creating the distribution tarbal requires some configure
+    # options (otherwise parts of the source tree will be left out).
+    #
+    ./autogen.sh
+    ./configure --with-rocksdb --with-ocf \
+        --with-nss --with-debug --enable-cephfs-java \
+        --with-lttng --with-babeltrace
+    #
+    # use distdir= to set the name of the top level directory of the
+    # tarbal to match the desired version
+    #
+    make distdir=ceph-$vers dist
+    #
+    # rename the tarbal to match debian conventions and extract it
+    #
+    mv ceph-$vers.tar.gz $releasedir/ceph_$vers.orig.tar.gz
+    tar -C $releasedir -zxf $releasedir/ceph_$vers.orig.tar.gz
+    #
+    # copy the debian directory over
+    #
+    cp -a debian $releasedir/ceph-$vers/debian
+    cd $releasedir
+    #
+    # uncomment to remove -dbg packages
+    # because they are large and take time to build
+    #
+    #perl -ni -e 'print if(!(/^Package: .*-dbg$/../^$/))' ceph-$vers/debian/control
+    #perl -pi -e 's/--dbg-package.*//' ceph-$vers/debian/rules
+    #
+    # update the changelog to match the desired version
+    #
+    cd ceph-$vers
+    local chvers=$(head -1 debian/changelog | perl -ne 's/.*\(//; s/\).*//; print')
+    if [ "$chvers" != "$dvers" ]; then
+        DEBEMAIL="contact@ceph.com" dch -D $codename --force-distribution -b -v "$dvers" "new version"
+    fi
+    #
+    # create the packages
+    # a) with ccache to speed things up when building repeatedly
+    # b) do not sign the packages
+    # c) use half of the available processors
+    #
+    if test $NPROC -gt 1 ; then
+        j=-j${NPROC}
+    fi
+    PATH=/usr/lib/ccache:$PATH dpkg-buildpackage $j -uc -us
+}
+
+function build_repo() {
+    local gitbuilder_host=$1
+
+    sudo apt-get install -y reprepro
+    cd ${releasedir}/..
+    #
+    # Create a repository in a directory with a name structured
+    # as
+    #
+    arch=x86_64
+    base=ceph-deb-$codename-$arch-basic
+    sha1_dir=$codename/$base/sha1/$sha1
+    mkdir -p $sha1_dir/conf
+    cat > $sha1_dir/conf/distributions <<EOF
+Codename: $codename
+Suite: stable
+Components: main
+Architectures: i386 amd64 source
+EOF
+    reprepro --basedir $sha1_dir include $codename WORKDIR/*.changes
+    echo $dvers > $sha1_dir/version
+    echo $sha1 > $sha1_dir/sha1
+    ref_dir=$codename/$base/ref
+    mkdir -p $ref_dir
+    ( cd ${ceph_dir} ; git for-each-ref refs/tags/** refs/heads/** ) | grep $sha1 | while read sha1 type ref ; do
+        base_ref=$(basename $ref)
+        ( cd $ref_dir ; ln -sf ../sha1/$sha1 $base_ref )
+    done
+    if test "$gitbuilder_host" ; then
+        cd $codename
+        RSYNC_RSH='ssh -o StrictHostKeyChecking=false' rsync -av $base/ $gitbuilder_host:/usr/share/nginx/html/$base/
+    fi
+}
+
+build_package
+build_repo $gitbuilder_host
diff --git a/tasks/buildpackages/make-debs.sh b/tasks/buildpackages/make-debs.sh
deleted file mode 100755 (executable)
index 7a35ab6..0000000
+++ /dev/null
@@ -1,134 +0,0 @@
-#!/bin/bash
-#
-# Copyright (C) 2015 Red Hat <contact@redhat.com>
-#
-# Author: Loic Dachary <loic@dachary.org>
-#
-# This program is free software; you can redistribute it and/or modify
-# it under the terms of the GNU Library Public License as published by
-# the Free Software Foundation; either version 2, or (at your option)
-# any later version.
-#
-# This program is distributed in the hope that it will be useful,
-# but WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
-# GNU Library Public License for more details.
-#
-set -xe
-
-base=${1:-/tmp/release}
-gitbuilder_host=$2
-
-codename=$(lsb_release -sc)
-releasedir=$base/$(lsb_release -si)/WORKDIR
-#
-# git describe provides a version that is
-# a) human readable
-# b) is unique for each commit
-# c) compares higher than any previous commit
-# d) contains the short hash of the commit
-#
-vers=$(git describe --match "v*" | sed s/^v//)
-#
-# always set the debian version to 1 which is ok because the debian
-# directory is included in the sources and the upstream version will
-# change each time it is modified.
-#
-dvers="$vers-1"
-sha1=$(git rev-parse HEAD)
-: ${NPROC:=$(nproc)}
-ceph_dir=$(pwd)
-
-function build_package() {
-
-    rm -fr $releasedir
-    mkdir -p $releasedir
-    #
-    # remove all files not under git so they are not
-    # included in the distribution.
-    #
-    git clean -qdxff
-    #
-    # creating the distribution tarbal requires some configure
-    # options (otherwise parts of the source tree will be left out).
-    #
-    ./autogen.sh
-    ./configure --with-rocksdb --with-ocf \
-        --with-nss --with-debug --enable-cephfs-java \
-        --with-lttng --with-babeltrace
-    #
-    # use distdir= to set the name of the top level directory of the
-    # tarbal to match the desired version
-    #
-    make distdir=ceph-$vers dist
-    #
-    # rename the tarbal to match debian conventions and extract it
-    #
-    mv ceph-$vers.tar.gz $releasedir/ceph_$vers.orig.tar.gz
-    tar -C $releasedir -zxf $releasedir/ceph_$vers.orig.tar.gz
-    #
-    # copy the debian directory over
-    #
-    cp -a debian $releasedir/ceph-$vers/debian
-    cd $releasedir
-    #
-    # uncomment to remove -dbg packages
-    # because they are large and take time to build
-    #
-    #perl -ni -e 'print if(!(/^Package: .*-dbg$/../^$/))' ceph-$vers/debian/control
-    #perl -pi -e 's/--dbg-package.*//' ceph-$vers/debian/rules
-    #
-    # update the changelog to match the desired version
-    #
-    cd ceph-$vers
-    local chvers=$(head -1 debian/changelog | perl -ne 's/.*\(//; s/\).*//; print')
-    if [ "$chvers" != "$dvers" ]; then
-        DEBEMAIL="contact@ceph.com" dch -D $codename --force-distribution -b -v "$dvers" "new version"
-    fi
-    #
-    # create the packages
-    # a) with ccache to speed things up when building repeatedly
-    # b) do not sign the packages
-    # c) use half of the available processors
-    #
-    if test $NPROC -gt 1 ; then
-        j=-j${NPROC}
-    fi
-    PATH=/usr/lib/ccache:$PATH dpkg-buildpackage $j -uc -us
-}
-
-function build_repo() {
-    local gitbuilder_host=$1
-
-    cd ${releasedir}/..
-    #
-    # Create a repository in a directory with a name structured
-    # as
-    #
-    arch=x86_64
-    base=ceph-deb-$codename-$arch-basic
-    sha1_dir=$codename/$base/sha1/$sha1
-    mkdir -p $sha1_dir/conf
-    cat > $sha1_dir/conf/distributions <<EOF
-Codename: $codename
-Suite: stable
-Components: main
-Architectures: i386 amd64 source
-EOF
-    reprepro --basedir $sha1_dir include $codename WORKDIR/*.changes
-    echo $dvers > $sha1_dir/version
-    echo $sha1 > $sha1_dir/sha1
-    ref_dir=$codename/$base/ref
-    mkdir -p $ref_dir
-    ( cd ${ceph_dir} ; git for-each-ref refs/tags/** refs/heads/** ) | grep $sha1 | while read sha1 type ref ; do
-        base_ref=$(basename $ref)
-        ( cd $ref_dir ; ln -sf ../sha1/$sha1 $base_ref )
-    done
-    if test "$gitbuilder_host" ; then
-        cd $codename
-        RSYNC_RSH='ssh -o StrictHostKeyChecking=false' rsync -av $base/ $gitbuilder_host:/usr/share/nginx/html/$base/
-    fi
-}
-
-build_package
-build_repo $gitbuilder_host
diff --git a/tasks/buildpackages/make-rpm.sh b/tasks/buildpackages/make-rpm.sh
new file mode 100755 (executable)
index 0000000..8c7f56a
--- /dev/null
@@ -0,0 +1,252 @@
+#!/bin/bash
+#
+# Copyright (C) 2015 Red Hat <contact@redhat.com>
+#
+# Author: Loic Dachary <loic@dachary.org>
+#
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU Library Public License as published by
+# the Free Software Foundation; either version 2, or (at your option)
+# any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+# GNU Library Public License for more details.
+#
+
+# 
+# Create and upload a RPM repository with the same naming conventions
+# as https://github.com/ceph/autobuild-ceph/blob/master/build-ceph-rpm.sh
+#
+
+set -xe
+
+base=/tmp/release
+gitbuilder_host=$1
+codename=$2
+git_base_url=$3
+sha1=$4
+
+sudo yum install -y git
+
+source $(dirname $0)/common.sh
+
+get_ceph $git_base_url $sha1
+install_deps
+
+#id=$(lsb_release -s -i | tr A-Z a-z)
+#major=$(lsb_release -s -r | sed -s "s;\..*;;g")
+#codename="${id}${major}"
+releasedir=$base/$(lsb_release -si)/WORKDIR
+#
+# git describe provides a version that is
+# a) human readable
+# b) is unique for each commit
+# c) compares higher than any previous commit
+# d) contains the short hash of the commit
+#
+vers=$(git describe --long --match "v*" | sed s/^v//)
+sha1=$(git rev-parse HEAD)
+: ${NPROC:=$(nproc)}
+ceph_dir=$(pwd)
+
+#
+# Create a repository in a directory with a name structured
+# as
+#
+arch=x86_64
+base=ceph-rpm-$codename-$arch-basic
+
+function setup_rpmmacros() {
+    if ! grep -q find_debuginfo_dwz_opts $HOME/.rpmmacros ; then
+        echo '%_find_debuginfo_dwz_opts %{nil}' >> $HOME/.rpmmacros
+    fi
+    if lsb_release -d -s | grep CentOS | grep -q 'release 7' ; then
+        if ! grep -q '%dist .el7' $HOME/.rpmmacros ; then
+            echo '%dist .el7' >> $HOME/.rpmmacros
+        fi
+    fi
+}
+
+function build_package() {
+    rm -fr $releasedir
+    mkdir -p $releasedir
+    #
+    # remove all files not under git so they are not
+    # included in the distribution.
+    #
+    git clean -qdxff
+    #
+    # creating the distribution tarbal requires some configure
+    # options (otherwise parts of the source tree will be left out).
+    #
+    sudo yum install -y bzip2
+    ./autogen.sh
+    ./configure --with-debug --with-radosgw --with-fuse --with-libatomic-ops --with-gtk2 --with-nss
+    #
+    # use distdir= to set the name of the top level directory of the
+    # tarbal to match the desired version
+    #
+    make dist-bzip2
+    # Set up build area
+    setup_rpmmacros
+    sudo yum install -y rpm-build
+    local buildarea=$releasedir
+    mkdir -p ${buildarea}/SOURCES
+    mkdir -p ${buildarea}/SRPMS
+    mkdir -p ${buildarea}/SPECS
+    cp ceph.spec ${buildarea}/SPECS
+    mkdir -p ${buildarea}/RPMS
+    mkdir -p ${buildarea}/BUILD
+    cp -a ceph-*.tar.bz2 ${buildarea}/SOURCES/.
+    cp -a rpm/*.patch ${buildarea}/SOURCES || true
+    (
+        cd ${buildarea}/SPECS
+        ccache=$(echo /usr/lib*/ccache)
+        # Build RPMs
+        buildarea=`readlink -fn ${releasedir}`   ### rpm wants absolute path
+        PATH=$ccache:$PATH rpmbuild -ba --define "_topdir ${buildarea}" ceph.spec
+    )
+}
+
+function build_rpm_release() {
+    local buildarea=$1
+    local sha1=$2
+    local gitbuilder_host=$3
+    local base=$4
+
+    cat <<EOF > ${buildarea}/SPECS/ceph-release.spec
+Name:           ceph-release
+Version:        1
+Release:        0%{?dist}
+Summary:        Ceph repository configuration
+Group:          System Environment/Base
+License:        GPLv2
+URL:            http://gitbuilder.ceph.com/$dist
+Source0:        ceph.repo
+#Source0:        RPM-GPG-KEY-CEPH
+#Source1:        ceph.repo
+BuildRoot:      %{_tmppath}/%{name}-%{version}-%{release}-root-%(%{__id_u} -n)
+BuildArch:     noarch
+
+%description
+This package contains the Ceph repository GPG key as well as configuration
+for yum and up2date.
+
+%prep
+
+%setup -q  -c -T
+install -pm 644 %{SOURCE0} .
+#install -pm 644 %{SOURCE1} .
+
+%build
+
+%install
+rm -rf %{buildroot}
+#install -Dpm 644 %{SOURCE0} \
+#    %{buildroot}/%{_sysconfdir}/pki/rpm-gpg/RPM-GPG-KEY-CEPH
+%if 0%{defined suse_version}
+install -dm 755 %{buildroot}/%{_sysconfdir}/zypp
+install -dm 755 %{buildroot}/%{_sysconfdir}/zypp/repos.d
+install -pm 644 %{SOURCE0} \
+    %{buildroot}/%{_sysconfdir}/zypp/repos.d
+%else
+install -dm 755 %{buildroot}/%{_sysconfdir}/yum.repos.d
+install -pm 644 %{SOURCE0} \
+    %{buildroot}/%{_sysconfdir}/yum.repos.d
+%endif
+
+%clean
+#rm -rf %{buildroot}
+
+%post
+
+%postun
+
+%files
+%defattr(-,root,root,-)
+#%doc GPL
+%if 0%{defined suse_version}
+/etc/zypp/repos.d/*
+%else
+/etc/yum.repos.d/*
+%endif
+#/etc/pki/rpm-gpg/*
+
+%changelog
+* Tue Mar 10 2013 Gary Lowell <glowell@inktank.com> - 1-0
+- Handle both yum and zypper
+- Use URL to ceph git repo for key
+- remove config attribute from repo file
+* Tue Aug 27 2012 Gary Lowell <glowell@inktank.com> - 1-0
+- Initial Package
+EOF
+
+    cat <<EOF > $buildarea/SOURCES/ceph.repo
+[Ceph]
+name=Ceph packages for \$basearch
+baseurl=http://${gitbuilder_host}/${base}/sha1/${sha1}/\$basearch
+enabled=1
+gpgcheck=0
+type=rpm-md
+
+[Ceph-noarch]
+name=Ceph noarch packages
+baseurl=http://${gitbuilder_host}/${base}/sha1/${sha1}/noarch
+enabled=1
+gpgcheck=0
+type=rpm-md
+
+[ceph-source]
+name=Ceph source packages
+baseurl=http://${gitbuilder_host}/${base}/sha1/${sha1}/SRPMS
+enabled=1
+gpgcheck=0
+type=rpm-md
+EOF
+
+    rpmbuild -bb --define "_topdir ${buildarea}" ${buildarea}/SPECS/ceph-release.spec
+}
+
+function build_rpm_repo() {
+    local buildarea=$1
+    local gitbuilder_host=$2
+    local base=$3
+
+    sudo yum install -y createrepo
+
+    for dir in ${buildarea}/SRPMS ${buildarea}/RPMS/*
+    do
+        createrepo ${dir}
+    done
+
+    local sha1_dir=${buildarea}/../$codename/$base/sha1/$sha1
+    mkdir -p $sha1_dir
+    echo $vers > $sha1_dir/version
+    echo $sha1 > $sha1_dir/sha1
+    echo ceph > $sha1_dir/name
+
+    for dir in ${buildarea}/SRPMS ${buildarea}/RPMS/*
+    do
+        cp -fla ${dir} $sha1_dir
+    done
+
+    ref_dir=${buildarea}/../$codename/$base/ref
+    mkdir -p $ref_dir
+    ( cd ${ceph_dir} ; git for-each-ref refs/tags/** refs/heads/** ) | grep $sha1 | while read sha1 type ref ; do
+        base_ref=$(basename $ref)
+        ( cd $ref_dir ; ln -sf ../sha1/$sha1 $base_ref )
+    done
+    if test "$gitbuilder_host" ; then
+        (
+            cd ${buildarea}/../$codename
+            RSYNC_RSH='ssh -o StrictHostKeyChecking=false' rsync -av $base/ ubuntu@$gitbuilder_host:/usr/share/nginx/html/$base/
+        )
+    fi
+}
+
+setup_rpmmacros
+build_package
+build_rpm_release $releasedir $sha1 $gitbuilder_host $base
+build_rpm_repo $releasedir $gitbuilder_host $base
diff --git a/tasks/buildpackages/user-data.txt b/tasks/buildpackages/user-data.txt
new file mode 100644 (file)
index 0000000..e987e48
--- /dev/null
@@ -0,0 +1,4 @@
+#cloud-config
+system_info:
+  default_user:
+    name: ubuntu