>From 03c6e0aa0ed4d3c08ff71b7ecd3fbcc010a1a067 Mon Sep 17 00:00:00 2001 From: Lukas Slebodnik Date: Mon, 20 May 2013 18:35:45 +0200 Subject: [PATCH] Adding script to create a SRPM Recommended way to create SRPM is to run make (prerelease-)srpm. But in previous case make file have to be generated, therefore configure script should not fail. (all sssd required dependencies have to be installed) Script make_srpm.sh can be runned without running configure, script can be runned only from git repository. https://fedorahosted.org/sssd/ticket/1927 --- contrib/fedora/make_srpm.sh | 104 ++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 104 insertions(+) create mode 100755 contrib/fedora/make_srpm.sh diff --git a/contrib/fedora/make_srpm.sh b/contrib/fedora/make_srpm.sh new file mode 100755 index 0000000000000000000000000000000000000000..b8dc0250a0156dcb9891ad9fa6a81d805eba770e --- /dev/null +++ b/contrib/fedora/make_srpm.sh @@ -0,0 +1,104 @@ +#!/bin/sh + +PACKAGE_NAME="sssd" + +usage(){ + echo "$(basename $0) [OPTIONS]" + echo "\t-p, --prerelease Create prerelease SRPM" + echo "\t-d, --debug Enable debugging." + echo "\t-c, --clean Remove direcotory rpmbuild and exit." + echo "\t-h, --help Print this help and exit." + echo "\t-?, --usage" + + exit 1 +} + +for i in "$@" +do +case $i in + -p|--prerelease) + PRERELEASE=1 + ;; + -d|--debug) + set -x + ;; + -c|--clean) + CLEAN=1 + ;; + -h|--help|-\?|--usage) + usage + ;; + *) + # unknown option + ;; +esac +done + +RPMBUILD="$(pwd)/rpmbuild" +if [ -n "$CLEAN" ]; then + rm -rfv "$RPMBUILD" + exit 0 +fi + +SRC_DIR=$(git rev-parse --show-toplevel) +rc=$? +if [ $rc != 0 ]; then + echo "This script have to be run from $PACKAGE_NAME git repository!" + exit 1; +fi + +if [ "x$SRC_DIR" = x ]; then + echo "Fatal: Could not find source directory!" + exit 1; +fi + +VERSION_FILE="$SRC_DIR/version.m4" +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 + +PACKAGE_VERSION=$(grep "\[VERSION_NUMBER\]" $VERSION_FILE \ + | sed -e 's/.*\[//' -e 's/\]).*$//') +if [ "x$PACKAGE_VERSION" = x ]; then + echo "Fatal: Could parse version from file:$VERSION_FILE!" + exit 1; +fi + +PRERELEASE_VERSION="" +if [ -n "$PRERELEASE" ]; then + PRERELEASE_VERSION=.$(date +%Y%m%d.%H%M).git$(git log -1 --pretty=format:%h) +fi + +mkdir -p $RPMBUILD/BUILD +mkdir -p $RPMBUILD/RPMS +mkdir -p $RPMBUILD/SOURCES +mkdir -p $RPMBUILD/SPECS +mkdir -p $RPMBUILD/SRPMS + +sed -e "s/@PACKAGE_NAME@/$PACKAGE_NAME/" \ + -e "s/@PACKAGE_VERSION@/$PACKAGE_VERSION/" \ + -e "s/@PRERELEASE_VERSION@/$PRERELEASE_VERSION/" \ + -e "s/^%configure/autoreconf -if\n%configure/" \ + < "$SPEC_TEMPLATE" \ + > "$RPMBUILD/SPECS/$PACKAGE_NAME.spec" + +NAME="$PACKAGE_NAME-$PACKAGE_VERSION" +git archive --format=tar.gz --prefix="$NAME"/ \ + --output "$RPMBUILD/SOURCES/$NAME.tar.gz" \ + --remote="file://$SRC_DIR" \ + HEAD + +cp "$SRC_DIR"/contrib/*.patch "$RPMBUILD/SOURCES" + +cd $RPMBUILD +rpmbuild --define "_topdir $RPMBUILD" \ + --define _source_filedigest_algorithm=1 \ + -bs SPECS/$PACKAGE_NAME.spec -- 1.8.1.4