2015-09-16 21:45:38 +00:00
|
|
|
#!/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
|
2015-09-25 11:52:05 +00:00
|
|
|
git_ceph_url=$3
|
2015-09-16 21:45:38 +00:00
|
|
|
sha1=$4
|
2015-10-13 11:43:24 +00:00
|
|
|
flavor=$5
|
2016-03-25 14:47:29 +00:00
|
|
|
arch=$6
|
2015-09-16 21:45:38 +00:00
|
|
|
|
2016-05-14 16:15:43 +00:00
|
|
|
suse=false
|
|
|
|
[[ $codename =~ suse ]] && suse=true
|
|
|
|
|
|
|
|
if [ "$suse" = true ] ; then
|
|
|
|
sudo zypper -n install git
|
|
|
|
else
|
|
|
|
sudo yum install -y git
|
|
|
|
fi
|
2015-09-16 21:45:38 +00:00
|
|
|
|
|
|
|
source $(dirname $0)/common.sh
|
|
|
|
|
2015-10-12 16:46:38 +00:00
|
|
|
init_ceph $git_ceph_url $sha1
|
2015-09-16 21:45:38 +00:00
|
|
|
|
2016-09-05 11:26:59 +00:00
|
|
|
distro=$( source /etc/os-release ; echo $ID )
|
|
|
|
distro_version=$( source /etc/os-release ; echo $VERSION )
|
|
|
|
releasedir=$base/$distro/WORKDIR
|
2015-09-16 21:45:38 +00:00
|
|
|
#
|
|
|
|
# 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
|
|
|
|
#
|
2016-03-04 05:34:06 +00:00
|
|
|
vers=$(git describe --match "v*" | sed s/^v//)
|
2015-09-16 21:45:38 +00:00
|
|
|
ceph_dir=$(pwd)
|
|
|
|
|
|
|
|
#
|
|
|
|
# Create a repository in a directory with a name structured
|
|
|
|
# as
|
|
|
|
#
|
2015-10-13 11:43:24 +00:00
|
|
|
base=ceph-rpm-$codename-$arch-$flavor
|
2015-09-16 21:45:38 +00:00
|
|
|
|
|
|
|
function setup_rpmmacros() {
|
|
|
|
if ! grep -q find_debuginfo_dwz_opts $HOME/.rpmmacros ; then
|
|
|
|
echo '%_find_debuginfo_dwz_opts %{nil}' >> $HOME/.rpmmacros
|
|
|
|
fi
|
2016-09-05 11:26:59 +00:00
|
|
|
if [ "x${distro}x" = "xcentosx" ] && echo $distro_version | grep -q '7' ; then
|
2015-09-16 21:45:38 +00:00
|
|
|
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).
|
|
|
|
#
|
2016-05-14 16:15:43 +00:00
|
|
|
if [ "$suse" = true ] ; then
|
2016-07-01 09:16:07 +00:00
|
|
|
sudo zypper -n install bzip2
|
2016-05-14 16:15:43 +00:00
|
|
|
else
|
|
|
|
sudo yum install -y bzip2
|
|
|
|
fi
|
2016-08-23 09:34:04 +00:00
|
|
|
# autotools only works in jewel and below
|
|
|
|
if [[ ! -e "make-dist" ]] ; then
|
|
|
|
./autogen.sh
|
|
|
|
./configure $(flavor2configure $flavor) --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
|
|
|
|
else
|
2016-09-05 13:07:53 +00:00
|
|
|
# kraken and above
|
|
|
|
./make-dist
|
2016-08-23 09:34:04 +00:00
|
|
|
fi
|
2015-09-16 21:45:38 +00:00
|
|
|
# Set up build area
|
|
|
|
setup_rpmmacros
|
2016-05-14 16:15:43 +00:00
|
|
|
if [ "$suse" = true ] ; then
|
|
|
|
sudo zypper -n install rpm-build
|
|
|
|
else
|
|
|
|
sudo yum install -y rpm-build
|
|
|
|
fi
|
2015-09-16 21:45:38 +00:00
|
|
|
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
|
2016-09-05 19:42:53 +00:00
|
|
|
CEPH_TARBALL=( ceph-*.tar.bz2 )
|
|
|
|
cp -a $CEPH_TARBALL ${buildarea}/SOURCES/.
|
2015-09-16 21:45:38 +00:00
|
|
|
cp -a rpm/*.patch ${buildarea}/SOURCES || true
|
|
|
|
(
|
|
|
|
cd ${buildarea}/SPECS
|
|
|
|
ccache=$(echo /usr/lib*/ccache)
|
|
|
|
# Build RPMs
|
2016-07-01 09:16:07 +00:00
|
|
|
if [ "$suse" = true ]; then
|
|
|
|
sed -i -e '0,/%package/s//%debug_package\n&/' \
|
2016-09-01 07:56:13 +00:00
|
|
|
-e 's/%{epoch}://g' \
|
|
|
|
-e '/^Epoch:/d' \
|
|
|
|
-e 's/%bcond_with ceph_test_package/%bcond_without ceph_test_package/' \
|
2016-09-05 19:42:53 +00:00
|
|
|
-e "s/^Source0:.*$/Source0: $CEPH_TARBALL/" \
|
2016-09-01 07:56:13 +00:00
|
|
|
ceph.spec
|
2016-07-01 09:16:07 +00:00
|
|
|
fi
|
2015-09-16 21:45:38 +00:00
|
|
|
buildarea=`readlink -fn ${releasedir}` ### rpm wants absolute path
|
2015-11-12 19:16:02 +00:00
|
|
|
PATH=$ccache:$PATH rpmbuild -ba --define "_unpackaged_files_terminate_build 0" --define "_topdir ${buildarea}" ceph.spec
|
2015-09-16 21:45:38 +00:00
|
|
|
)
|
|
|
|
}
|
|
|
|
|
|
|
|
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
|
|
|
|
|
2016-05-14 16:15:43 +00:00
|
|
|
if [ "$suse" = true ] ; then
|
|
|
|
sudo zypper -n install createrepo
|
|
|
|
else
|
|
|
|
sudo yum install -y createrepo
|
|
|
|
fi
|
2015-09-16 21:45:38 +00:00
|
|
|
|
|
|
|
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
|
|
|
|
|
2015-11-14 12:26:00 +00:00
|
|
|
link_same ${buildarea}/../$codename/$base/ref $ceph_dir $sha1
|
2015-09-16 21:45:38 +00:00
|
|
|
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
|