make_srpm.sh revision f31b698549231d68451dbb8fd1184ad375eb5e64
# Authors:
# Lukas Slebodnik <lslebodn@redhat.com>
#
# Copyright (C) 2013 Red Hat
#
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 3 of the License, 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 General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
PACKAGE_NAME="sssd"
echo -e "\t-p, --prerelease Create prerelease SRPM"
echo -e "\t-d, --debug Enable debugging."
echo -e "\t-c, --clean Remove directory rpmbuild and exit."
echo -e "\t-P, --patches Requires list of patches for SRPM."
echo -e "\t-h, --help Print this help and exit."
echo -e "\t-?, --usage"
exit 1
}
spec_file=$1
shift
source_dir=$1
shift
# These keep track of our spec file substitutions.
i=1
prefix="Source0:"
prepprefix="%setup"
# If no patches exist, just exit.
return 0
fi
# Add the patches to the specfile.
cp "$p" "$source_dir"
p=$(basename $p)
echo "Adding patch to spec file - $p"
prefix="Patch${i}:"
prepprefix="%patch${i}"
i=$(($i+1))
done
}
for i in "$@"
do
case $i in
-p|--prerelease)
shift
;;
-d|--debug)
set -x
shift
;;
-c|--clean)
CLEAN=1
shift
;;
-P|--patches)
shift
break
;;
;;
*)
# unknown option
;;
esac
done
if [ -n "$CLEAN" ]; then
exit 0
fi
rc=$?
if [ $rc != 0 ]; then
echo "This script must be run from the $PACKAGE_NAME git repository!"
exit 1;
fi
if [ "x$SRC_DIR" = x ]; then
echo "Fatal: Could not find source directory!"
exit 1;
fi
SPEC_TEMPLATE="$SRC_DIR/contrib/$PACKAGE_NAME.spec.in"
if [ ! -f "$VERSION_FILE" ]; then
echo "Fatal: Could not find file version.m4 in source directory!"
exit 1;
fi
if [ ! -f "$SPEC_TEMPLATE" ]; then
echo "Fatal: Could not find $PACKAGE_NAME.spec.in in contrib subdirectory!"
exit 1;
fi
if [ "x$PACKAGE_VERSION" = x ]; then
echo "Fatal: Could parse version from file:$VERSION_FILE!"
exit 1;
fi
if [ -n "$PRERELEASE" ]; then
fi
sed -e "s/@PACKAGE_NAME@/$PACKAGE_NAME/" \
-e "s/@PACKAGE_VERSION@/$PACKAGE_VERSION/" \
-e "s/@PRERELEASE_VERSION@/$PRERELEASE_VERSION/" \
< "$SPEC_TEMPLATE" \
> "$RPMBUILD/SPECS/$PACKAGE_NAME.spec"
HEAD \
add_patches "$RPMBUILD/SPECS/$PACKAGE_NAME.spec" \
"$RPMBUILD/SOURCES" \
"${patches[@]}"
cd $RPMBUILD