Update RPM spec file

Update the RPM file with the comments from submittal spec
file to the Fedora Project. This update also differntiates
between the project name 'gluster-swift' and the Fedora
distribution name 'glusterfs-openstack-swift'.  This simple
changes makes it less confusing when downloading the source
on http://launchpad.net/gluster-swift .

For more information on the Fedora Project submittal status
please see: https://bugzilla.redhat.com/show_bug.cgi?id=1003089

This fix also creates a tar.gz source file so that Jenkins
can archive it.  This can be used for distributions other
than RPM based systems.

Change-Id: Ia9b85d53cf576a7754aaa018396adb70cb0f2855
Signed-off-by: Luis Pabon <lpabon@redhat.com>
Reviewed-on: http://review.gluster.org/6261
Reviewed-by: Thiago Da Silva <thiago@redhat.com>
Tested-by: Thiago Da Silva <thiago@redhat.com>
This commit is contained in:
Luis Pabon 2013-11-13 16:01:40 -05:00
parent 40553ff958
commit f54e06b612
4 changed files with 88 additions and 99 deletions

View File

@ -22,6 +22,7 @@ class PkgInfo(object):
self.release = release
self.name = name
self.final = final
self.full_version = self.canonical_version + '-' + self.release
def save_config(self, filename):
"""
@ -44,6 +45,6 @@ class PkgInfo(object):
###
### Change the Package version here
###
_pkginfo = PkgInfo('1.10.1', '0', 'glusterfs-openstack-swift', False)
_pkginfo = PkgInfo('1.10.1', '0', 'gluster_swift', False)
__version__ = _pkginfo.pretty_version
__canonical_version__ = _pkginfo.canonical_version

View File

@ -1,19 +1,3 @@
############################################################################################################
# Command to build rpms.#
# $ rpmbuild -ta %{name}-%{version}-%{release}.tar.gz #
############################################################################################################
# Setting up the environment. #
# * Create a directory %{name}-%{version} under $HOME/rpmbuild/SOURCES #
# * Copy the contents of gluster directory into $HOME/rpmbuild/SOURCES/%{name}-%{version} #
# * tar zcvf %{name}-%{version}-%{release}.tar.gz $HOME/rpmbuild/SOURCES/%{name}-%{version} %{name}.spec #
# For more information refer #
# http://fedoraproject.org/wiki/How_to_create_an_RPM_package #
############################################################################################################
%if ! (0%{?fedora} > 12 || 0%{?rhel} > 5)
%{!?python_sitelib: %global python_sitelib %(%{__python} -c "from distutils.sysconfig import get_python_lib; print(get_python_lib())")}
%endif
%define _confdir %{_sysconfdir}/swift
# The following values are provided by passing the following arguments
@ -29,10 +13,10 @@ Name : %{_name}
Version : %{_version}
Release : %{_release}%{?dist}
Group : Application/File
Vendor : Red Hat, Inc.
URL : http://launchpad.net/gluster-swift
Vendor : Fedora Project
Source0 : %{_name}-%{_version}-%{_release}.tar.gz
Packager : gluster-users@gluster.org
License : Apache
License : ASL 2.0
BuildArch: noarch
BuildRequires: python
BuildRequires: python-setuptools
@ -44,6 +28,7 @@ Requires : openstack-swift-account = 1.10.0
Requires : openstack-swift-container = 1.10.0
Requires : openstack-swift-object = 1.10.0
Requires : openstack-swift-proxy = 1.10.0
Requires : glusterfs-api >= 3.4.1
Obsoletes: glusterfs-swift-plugin
Obsoletes: glusterfs-swift
Obsoletes: glusterfs-ufo
@ -60,7 +45,7 @@ objects in files, containers are maintained as top-level directories of volumes,
where accounts are mapped one-to-one to gluster volumes.
%prep
%setup -q
%setup -q -n gluster_swift-%{_version}
%build
%{__python} setup.py build
@ -73,20 +58,16 @@ rm -rf %{buildroot}
mkdir -p %{buildroot}/%{_confdir}/
cp -r etc/* %{buildroot}/%{_confdir}/
mkdir -p %{buildroot}/%{_bindir}/
cp bin/gluster-swift-gen-builders %{buildroot}/%{_bindir}/
cp bin/gluster-swift-print-metadata %{buildroot}/%{_bindir}/
# Remove tests
%{__rm} -rf %{buildroot}/%{python_sitelib}/test
%clean
rm -rf %{buildroot}
# Remove files provided by glusterfs-api
%{__rm} -rf %{buildroot}/%{python_sitelib}/gluster/__init__.p*
%files
%defattr(-,root,root)
%{python_sitelib}/gluster
%{python_sitelib}/gluster_swift-%{version}-*.egg-info
%{python_sitelib}/gluster_swift-%{_version}_*.egg-info
%{_bindir}/gluster-swift-gen-builders
%{_bindir}/gluster-swift-print-metadata
%{_bindir}/swauth-add-account
@ -99,12 +80,12 @@ rm -rf %{buildroot}
%{_bindir}/swauth-set-account-service
%dir %{_confdir}
%config %{_confdir}/account-server.conf-gluster
%config %{_confdir}/container-server.conf-gluster
%config %{_confdir}/object-server.conf-gluster
%config %{_confdir}/swift.conf-gluster
%config %{_confdir}/proxy-server.conf-gluster
%config %{_confdir}/fs.conf-gluster
%config(noreplace) %{_confdir}/account-server.conf-gluster
%config(noreplace) %{_confdir}/container-server.conf-gluster
%config(noreplace) %{_confdir}/object-server.conf-gluster
%config(noreplace) %{_confdir}/swift.conf-gluster
%config(noreplace) %{_confdir}/proxy-server.conf-gluster
%config(noreplace) %{_confdir}/fs.conf-gluster
%changelog
* Mon Oct 28 2013 Luis Pabon <lpabon@redhat.com> - 1.10.1-0

View File

@ -2,84 +2,94 @@
# Simple script to create RPMs for G4S
## RPM NAME
RPMNAME=glusterfs-openstack-swift
cleanup()
{
rm -rf ${RPMBUILDDIR} > /dev/null 2>&1
rm -f ${PKGCONFIG} > /dev/null 2>&1
rm -rf ${RPMBUILDDIR} > /dev/null 2>&1
rm -f ${PKGCONFIG} > /dev/null 2>&1
}
fail()
{
cleanup
echo $1
exit $2
cleanup
echo $1
exit $2
}
create_dir()
{
if [ ! -d "$1" ] ; then
mkdir -p "$1"
if [ $? -ne 0 ] ; then
fail "Unable to create dir $1" $?
fi
fi
if [ ! -d "$1" ] ; then
mkdir -p "$1"
if [ $? -ne 0 ] ; then
fail "Unable to create dir $1" $?
fi
fi
}
gittotar()
{
# Only archives committed changes
gitarchive_dir="${RPMBUILDDIR}/gitarchive"
specfile="${gitarchive_dir}/${SRCTAR_DIR}/${PKG_NAME}.spec"
create_dir "${gitarchive_dir}"
# Only archives committed changes
gitarchive_dir="${RPMBUILDDIR}/gitarchive"
specfile="${gitarchive_dir}/${SRCTAR_DIR}/${RPMNAME}.spec"
create_dir "${gitarchive_dir}"
# Export the current commited git changes to a directory
git archive --format=tar --prefix=${SRCTAR_DIR}/ HEAD | (cd ${gitarchive_dir} && tar xf -)
# Export the current commited git changes to a directory
git archive --format=tar --prefix=${SRCTAR_DIR}/ HEAD | (cd ${gitarchive_dir} && tar xf -)
# Create a new spec file with the current package version information
sed -e "s#__PKG_RELEASE__#${PKG_RELEASE}#" \
-e "s#__PKG_NAME__#${RPMNAME}#" \
-e "s#__PKG_VERSION__#${PKG_VERSION}#" \
${specfile} > ${specfile}.new
mv ${specfile}.new ${specfile}
# Create a new spec file with the current package version information
sed -e "s#__PKG_RELEASE__#${PKG_RELEASE}#" \
-e "s#__PKG_NAME__#${PKG_NAME}#" \
-e "s#__PKG_VERSION__#${PKG_VERSION}#" \
${specfile} > ${specfile}.new
mv ${specfile}.new ${specfile}
# Now create a tar file
( cd ${gitarchive_dir} && tar cf - ${SRCTAR_DIR} | gzip -c > ${SRCTAR} )
if [ $? -ne 0 -o \! -s ${SRCTAR} ] ; then
fail "Unable to create git archive" $?
fi
# Now create a tar file
( cd ${gitarchive_dir} && tar cf - ${SRCTAR_DIR} | gzip -c > ${SRCTAR} )
if [ $? -ne 0 -o \! -s ${SRCTAR} ] ; then
fail "Unable to create git archive" $?
fi
}
prep()
{
rm -rf ${RPMBUILDDIR} > /dev/null 2>&1
create_dir ${RPMBUILDDIR}
rm -rf ${RPMBUILDDIR} > /dev/null 2>&1
create_dir ${RPMBUILDDIR}
# Create a tar file out of the current committed changes
gittotar
# Create a tar file out of the current committed changes
gittotar
}
create_rpm()
{
# Create the rpm
# _topdir Notifies rpmbuild the location of the root directory
# containing the RPM information
# _release Allows Jenkins to setup the version using the
# build number
rpmbuild --define "_topdir ${RPMBUILDDIR}" \
-ta ${SRCTAR}
if [ $? -ne 0 ] ; then
fail "Unable to create rpm" $?
fi
# Create the rpm
# _topdir Notifies rpmbuild the location of the root directory
# containing the RPM information
# _release Allows Jenkins to setup the version using the
# build number
rpmbuild --define "_topdir ${RPMBUILDDIR}" \
-ta ${SRCTAR}
if [ $? -ne 0 ] ; then
fail "Unable to create rpm" $?
fi
# Move the rpms to the root directory
mv ${RPMBUILDDIR_RPMS}/noarch/*rpm ${BUILDDIR}
mv ${RPMBUILDDIR_SRPMS}/*rpm ${BUILDDIR}
if [ $? -ne 0 ] ; then
fail "Unable to move rpm to ${BUILDDIR}" $?
fi
# Move the rpms to the root directory
mv ${RPMBUILDDIR_RPMS}/noarch/*rpm ${BUILDDIR}
mv ${RPMBUILDDIR_SRPMS}/*rpm ${BUILDDIR}
if [ $? -ne 0 ] ; then
fail "Unable to move rpm to ${BUILDDIR}" $?
fi
echo "RPMS are now available in ${BUILDDIR}"
echo "RPMS are now available in ${BUILDDIR}"
}
create_src()
{
python setup.py sdist --format=gztar --dist-dir=${BUILDDIR}
if [ $? -ne 0 ] ; then
fail "Unable to create source archive"
fi
}
################## MAIN #####################
@ -88,19 +98,19 @@ create_rpm()
PKGCONFIG=${PWD}/pkgconfig.in
env python pkgconfig.py
if [ ! -f "${PKGCONFIG}" ] ; then
fail "Unable to create package information file ${PKGCONFIG}" 1
fail "Unable to create package information file ${PKGCONFIG}" 1
fi
# Get package version information
. ${PKGCONFIG}
if [ -z "${NAME}" ] ; then
fail "Unable to read the package name from the file created by pkgconfig.py" 1
fail "Unable to read the package name from the file created by pkgconfig.py" 1
fi
if [ -z "${VERSION}" ] ; then
fail "Unable to read the package version from the file created by pkgconfig.py" 1
fail "Unable to read the package version from the file created by pkgconfig.py" 1
fi
if [ -z "${RELEASE}" ] ; then
fail "Unable to read the package version from the file created by pkgconfig.py" 1
fail "Unable to read the package version from the file created by pkgconfig.py" 1
fi
PKG_NAME=$NAME
@ -113,19 +123,20 @@ PKG_VERSION=$VERSION
# a default value
#
if [ -z "$PKG_RELEASE" ] ; then
PKG_RELEASE="${RELEASE}"
PKG_RELEASE="${RELEASE}"
else
PKG_RELEASE="${RELEASE}.${PKG_RELEASE}"
PKG_RELEASE="${RELEASE}.${PKG_RELEASE}"
fi
BUILDDIR=$PWD/build
RPMBUILDDIR=${BUILDDIR}/rpmbuild
RPMBUILDDIR_RPMS=${RPMBUILDDIR}/RPMS
RPMBUILDDIR_SRPMS=${RPMBUILDDIR}/SRPMS
SRCNAME=${PKG_NAME}-${PKG_VERSION}-${PKG_RELEASE}
SRCNAME=${RPMNAME}-${PKG_VERSION}-${PKG_RELEASE}
SRCTAR_DIR=${PKG_NAME}-${PKG_VERSION}
SRCTAR=${RPMBUILDDIR}/${SRCNAME}.tar.gz
prep
create_src
create_rpm
cleanup

View File

@ -15,21 +15,17 @@
# limitations under the License.
from setuptools import setup, find_packages
from gluster.swift import __canonical_version__ as version
name = 'gluster_swift'
from gluster.swift import _pkginfo
setup(
name=name,
version=version,
name=_pkginfo.name,
version=_pkginfo.full_version,
description='Gluster For Swift',
license='Apache License (2.0)',
author='Red Hat, Inc.',
author_email='gluster-users@gluster.org',
url='https://forge.gluster.org/gluster-swift',
url='http://launchpad.net/gluster-swift',
packages=find_packages(exclude=['test', 'bin']),
test_suite='nose.collector',
classifiers=[