summaryrefslogtreecommitdiffstats
path: root/makerpm.sh
diff options
context:
space:
mode:
authorLuis Pabon <lpabon@redhat.com>2013-11-13 16:01:40 -0500
committerLuis Pabon <lpabon@redhat.com>2013-11-14 15:14:35 -0800
commitf54e06b612a6fdf04827ae32503dac5a7da5eb4e (patch)
treec052ba337f0975725d9820d74f83f64080ac3d58 /makerpm.sh
parent40553ff9586aedccbddfbc57ce9c65463aac95b7 (diff)
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>
Diffstat (limited to 'makerpm.sh')
-rw-r--r--makerpm.sh133
1 files changed, 72 insertions, 61 deletions
diff --git a/makerpm.sh b/makerpm.sh
index b00d5d7..591190a 100644
--- a/makerpm.sh
+++ b/makerpm.sh
@@ -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}"
-
- # 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__#${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
+ # 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 -)
+ # 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}
+
+ # 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
-
- # 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}"
+ # 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
+
+ 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