integ/utilities/build-info/centos/build_srpm
Scott Little 143b0c5cac Relocate build-info to stx-integ/utilities/build-info
Move content from stx-utils into stx-integ or stx-update

Packages will be relocated to

stx-update:
    enable-dev-patch
    extras

stx-integ:
    config-files/
        io-scheduler

    filesystem/
        filesystem-scripts

    grub/
        grubby

    logging/
        logmgmt

    tools/
        collector
        monitor-tools

    tools/engtools/
        hostdata-collectors
        parsers

    utilities/
        build-info
        branding   (formerly wrs-branding)
        platform-util

Change-Id: I78b1aa7574ae84ea89072d146bd41425fe553c60
Story: 2002801
Task: 22687
Signed-off-by: Scott Little <scott.little@windriver.com>
2018-08-01 16:07:29 -04:00

131 lines
3.5 KiB
Plaintext
Executable File

#
# Copyright (c) 2016 Wind River Systems, Inc.
#
# SPDX-License-Identifier: Apache-2.0
#
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="/build-info-1.0"
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"
# Additional files to include in the archive (if they exist).
EXTRA_FILES="./release-info.inc"
if [ -f $MY_WORKSPACE/BUILD ]; then
EXTRA_FILES+=" $MY_WORKSPACE/BUILD"
else
if [ -f $MY_WORKSPACE/../BUILD ]; then
EXTRA_FILES+=" $MY_WORKSPACE/../BUILD"
fi
fi
mkdir -p $BUILD_DIR/SRPMS
TAR_UNCOMPRESSED="$TAR_NAME-$VERSION.tar"
TAR="${TAR_UNCOMPRESSED}.gz"
COMPRESS="gzip"
TAR_PATH="$BUILD_DIR/SOURCES"
# copy the LICENSE for rpm spec %license directive
cp .$SRC_DIR/LICENSE $BUILD_DIR/SOURCES/
# Check to see if our tarball needs updating
TAR_NEEDED=0
if [ -f $TAR_PATH/$TAR ]; then
n=`find . -cnewer $TAR_PATH/$TAR -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
# check to see if any of our EXTRA_FILES are newer than the archive
for file in "$EXTRA_FILES"; do
if [ $file -nt $TAR_PATH/$TAR ]; then
TAR_NEEDED=1
fi
done
else
TAR_NEEDED=1
fi
if [ $TAR_NEEDED -gt 0 ]; then
tar cvf $TAR_PATH/$TAR_UNCOMPRESSED .$SRC_DIR \
--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 file in $EXTRA_FILES; do
if [ -e $file ]; then
tar rf $TAR_PATH/$TAR_UNCOMPRESSED -C $(dirname "${file}") $(basename "${file}")
fi
done
$COMPRESS $TAR_PATH/$TAR_UNCOMPRESSED
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