update/cgcs-patch/centos/build_srpm

102 lines
2.8 KiB
Plaintext
Executable File

source "$SRC_BASE/build-tools/spec-utils"
if [ "x$DATA" == "x" ]; then
echo "ERROR: Environment variable 'DATA' not defined."
exit 1
fi
if [ ! -f "$DATA" ]; then
echo "ERROR: Couldn't find '$PWD/$DATA'"
exit 1
fi
unset TIS_PATCH_VER # Ensure there's nothing in the env already
source $DATA
if [ -z "$TIS_PATCH_VER" ]; then
echo "ERROR: TIS_PATCH_VER must be defined"
exit 1
fi
SRC_DIR="cgcs-patch"
EXTRA_DIR="bin"
VERSION=$(grep '^Version:' PKG-INFO | awk -F ': ' '{print $2}' | sed -e 's/^[[:space:]]*//')
TAR_NAME=$(grep '^Name:' PKG-INFO | awk -F ': ' '{print $2}' | sed -e 's/^[[:space:]]*//')
CUR_DIR=`pwd`
BUILD_DIR="$RPMBUILD_BASE"
mkdir -p $BUILD_DIR/SRPMS
TAR="$TAR_NAME-$VERSION.tar.gz"
TAR_PATH="$BUILD_DIR/SOURCES/$TAR"
# copy the LICENSE for rpm spec %license directive
cp $SRC_DIR/LICENSE $BUILD_DIR/SOURCES/
TAR_NEEDED=0
if [ -f $TAR_PATH ]; then
n=`find . -cnewer $TAR_PATH -and ! -path './.git*' \
-and ! -path './build/*' \
-and ! -path './.pc/*' \
-and ! -path './patches/*' \
-and ! -path "./$DISTRO/*" \
-and ! -path './pbr-*.egg/*' \
| wc -l`
if [ $n -gt 0 ]; then
TAR_NEEDED=1
fi
else
TAR_NEEDED=1
fi
if [ $TAR_NEEDED -gt 0 ]; then
tar czvf $TAR_PATH $SRC_DIR $EXTRA_DIR \
--exclude='cgcs-patch/cgcs_patch_id' \
--exclude='cgcs-patch/cgcs_make_patch' \
--exclude='.git*' \
--exclude='build' \
--exclude='.pc' \
--exclude='patches' \
--exclude="$DISTRO" \
--exclude='pbr-*.egg' \
--transform "s,^$SRC_DIR/LICENSE,LICENSE," \
--transform "s,^$SRC_DIR,$TAR_NAME-$VERSION,"
fi
for SPEC in `ls $BUILD_DIR/SPECS`; do
SPEC_PATH="$BUILD_DIR/SPECS/$SPEC"
RELEASE=`spec_find_tag Release "$SPEC_PATH" 2>> /dev/null`
if [ $? -ne 0 ]; then
echo "ERROR: 'Release' not found in '$SPEC_PATH'"
fi
NAME=`spec_find_tag Name "$SPEC_PATH" 2>> /dev/null`
if [ $? -ne 0 ]; then
echo "ERROR: 'Name' not found in '$SPEC_PATH'"
fi
SRPM="$NAME-$VERSION-$RELEASE.src.rpm"
SRPM_PATH="$BUILD_DIR/SRPMS/$SRPM"
BUILD_NEEDED=0
if [ -f $SRPM_PATH ]; then
n=`find . -cnewer $SRPM_PATH | wc -l`
if [ $n -gt 0 ]; then
BUILD_NEEDED=1
fi
else
BUILD_NEEDED=1
fi
if [ $BUILD_NEEDED -gt 0 ]; then
echo "SPEC file: $SPEC_PATH"
echo "SRPM build directory: $BUILD_DIR"
echo "TIS_PATCH_VER: $TIS_PATCH_VER"
sed -i -e "1 i%define tis_patch_ver $TIS_PATCH_VER" $SPEC_PATH
rpmbuild -bs $SPEC_PATH --define="%_topdir $BUILD_DIR" --define="_tis_dist .tis"
fi
done