[SSSD] [PATCH] Adding script to create a SRPM

Lukas Slebodnik lslebodn at redhat.com
Wed May 22 12:35:46 UTC 2013


On (22/05/13 08:05), Stephen Gallagher wrote:
>On 05/22/2013 04:09 AM, Lukas Slebodnik wrote:
>> On (22/05/13 09:16), Sumit Bose wrote:
>>> On Wed, May 22, 2013 at 08:24:08AM +0200, Lukas Slebodnik wrote:
>>>> ehlo,
>>>> 
>>>> 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
>>>> 
>>>> Patch is attached.
>>> 
>>> Hi Lukas,
>>> 
>>> I haven't tested the script yet, nevertheless I have two
>>> comments. Please add a copyright notice and a licence.
>>> Additionally I think '--define
>> I added copyright.
>> 
>>> _source_filedigest_algorithm=1' should be switch on by an option.
>>> Iirc we added it because RHEL5 could not handle newer hash
>>> algorithms here. But on newer platforms we should use the
>>> platform defaults.
>> I removed line with _source_filedigest_algorithm, because sssd
>> master no longer compiles on rhel5, nightly builds for rhel5 are
>> done from sssd-1-9 branch. But if you think, that it isn't proper
>> solution I can add new switch for this.
>> 
>> Thank you very much for comments.
>> 
>> New patch attached.
>> 
>
>Almost an ack :)
>
>I am attaching two patches, one that should be squashed in and another
>that can go in on its own since it's related.
>
>
>Patch 0001: Fix English grammar and remove one sed line.
>There's no reason to substitute autoreconf into the spec file, as it's
>already in there. The resulting spec would be calling it twice, which
>is wasteful.
I don't know why I thought, that there wasn't autoreconf.
Honestly, I didn't look to sssd.spec.in first time.
Thank you.

I squashed the first patch to my patch.

>
>Patch 0002: Given the argument above regarding
>_source_filedigest_algorithm (which is correct), I added a patch to
>remove that from the Makefile.am as well.
I am attaching the second patch unchanged.

LS
-------------- next part --------------
>From 9da5f5d58263dca456f247e6c9df46e3386adede Mon Sep 17 00:00:00 2001
From: Lukas Slebodnik <lslebodn at redhat.com>
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 | 120 ++++++++++++++++++++++++++++++++++++++++++++
 1 file changed, 120 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..41bc6fa7dd29b029c92fb5c5715f3f1f73b91f5f
--- /dev/null
+++ b/contrib/fedora/make_srpm.sh
@@ -0,0 +1,120 @@
+#!/bin/sh
+
+#    Authors:
+#        Lukas Slebodnik <lslebodn at redhat.com>
+#
+#    Copyright (C) 2013 Red Hat
+#
+#    This program is free software; you can redistribute it and/or modify
+#    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"
+
+usage(){
+    echo "$(basename $0) [OPTIONS]"
+    echo "\t-p, --prerelease   Create prerelease SRPM"
+    echo "\t-d, --debug        Enable debugging."
+    echo "\t-c, --clean        Remove directory 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 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
+
+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/" \
+    < "$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" \
+         -bs SPECS/$PACKAGE_NAME.spec
-- 
1.8.1.4

-------------- next part --------------
>From d3eadb3817f0f8c9318c10acc3ffcc516292f771 Mon Sep 17 00:00:00 2001
From: Stephen Gallagher <sgallagh at redhat.com>
Date: Wed, 22 May 2013 07:59:04 -0400
Subject: [PATCH 2/2] Remove old hash support from example spec

SSSD 1.10 and later will no longer support RHEL 5, so we should be
using the native hash algorithm on the newer versions of RPM by
default.
---
 Makefile.am | 1 -
 1 file changed, 1 deletion(-)

diff --git a/Makefile.am b/Makefile.am
index cfac3061d215940d124519f398e48523208273b7..2bcb71457af4a21ab4144a379148bc31820b7469 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -1999,7 +1999,6 @@ endif
 srpm: rpmbrprep
 	cd $(RPMBUILD); \
 	rpmbuild --define "_topdir $(RPMBUILD)" \
-	         --define _source_filedigest_algorithm=1 \
 	         -bs SPECS/sssd.spec
 
 if GIT_CHECKOUT
-- 
1.8.2.1



More information about the sssd-devel mailing list