From 494df01ad169bcc4b49cea15ba933909009e2125 Mon Sep 17 00:00:00 2001
From: Jan Lieskovsky <jlieskov@redhat.com>
Date: Mon, 18 Nov 2013 14:07:39 +0100
Subject: [PATCH] [Fedora] Update versioning scheme: - move fedorassgrelease to
 be part of upstream version - rename it to fedorassgversion to avoid name
 collision   with actual Fedora RPM package Release.

Signed-off-by: Jan Lieskovsky <jlieskov@redhat.com>
---
 Fedora/scap-security-guide.spec | 15 ++++++++++-----
 Makefile                        | 16 +++++++++-------
 2 files changed, 19 insertions(+), 12 deletions(-)

diff --git a/Fedora/scap-security-guide.spec b/Fedora/scap-security-guide.spec
index dc21c7d..85f9e2d 100644
--- a/Fedora/scap-security-guide.spec
+++ b/Fedora/scap-security-guide.spec
@@ -5,16 +5,16 @@
 # file one level up - in the main scap-security-guide directory (instead of
 # this one).
 
-%global	fedorassgrelease	3
+%global	fedorassgversion	3
 
 Name:		scap-security-guide
-Version:	0.1
-Release:	%{fedorassgrelease}%{?dist}
+Version:	0.1.%{fedorassgversion}
+Release:	1%{?dist}
 Summary:	Security guidance and baselines in SCAP formats
 Group:		Applications/System
 License:	Public Domain
 URL:		https://fedorahosted.org/scap-security-guide/
-Source0:	http://fedorapeople.org/~jlieskov/%{name}-%{version}-%{fedorassgrelease}.tar.gz
+Source0:	http://fedorapeople.org/~jlieskov/%{name}-%{version}.tar.gz
 BuildArch:	noarch
 BuildRequires:	libxslt, expat, python, openscap-utils >= 0.9.1, python-lxml
 Requires:	xml-common, openscap-utils >= 0.9.1
@@ -32,7 +32,7 @@ conforms to provided guideline. Refer to scap-security-guide(8) manual page for
 further information.
 
 %prep
-%setup -q -n %{name}-%{version}-%{fedorassgrelease}
+%setup -q -n %{name}-%{version}
 
 %build
 cd Fedora && make dist
@@ -53,6 +53,11 @@ cp -a Fedora/input/auxiliary/scap-security-guide.8 %{buildroot}%{_mandir}/en/man
 %doc Fedora/LICENSE Fedora/output/ssg-fedora-guide.html
 
 %changelog
+* Mon Nov 18 2013 Jan iankko Lieskovsky <jlieskov@redhat.com> 0.1.3-1
+- Update versioning scheme - move fedorassgrelease to be part of
+  upstream version. Rename it to fedorassgversion to avoid name collision
+  with Fedora package release.
+
 * Tue Oct 22 2013 Jan iankko Lieskovsky <jlieskov@redhat.com> 0.1-3
 - Add .gitignore for Fedora output directory
 - Set up Fedora release name and CPE based on build system properties
diff --git a/Makefile b/Makefile
index 1a1c388..3aa12b5 100644
--- a/Makefile
+++ b/Makefile
@@ -21,9 +21,10 @@ RPMBUILD_ARGS := --define '_topdir $(RPM_TOPDIR)'  --define '_tmppath $(RPM_TMPD
 FEDORA_SPEC := $(ROOT_DIR)/Fedora/scap-security-guide.spec
 FEDORA_RPM_DEPS := $(FEDORA_SPEC) Makefile
 FEDORA_NAME := $(PKGNAME)
-FEDORA_VERSION := $(shell sed -ne 's/Version:\t\(.*\)/\1/p' $(FEDORA_SPEC))
-FEDORA_SSG_RELEASE := $(shell sed -ne 's/^\(.*\)\tfedorassgrelease\t\(.*\)/\2/p' $(FEDORA_SPEC))
-FEDORA_PKG := $(FEDORA_NAME)-$(FEDORA_VERSION)-$(FEDORA_SSG_RELEASE)
+FEDORA_SSG_VERSION := $(shell sed -ne 's/^\(.*\)\tfedorassgversion\t\(.*\)/\2/p' $(FEDORA_SPEC))
+FEDORA_RPM_VERSION := $(shell sed -ne 's/Version:\t\(.*\)/\1/p' $(FEDORA_SPEC))
+$(eval FEDORA_RPM_VERSION := $(shell echo $(FEDORA_RPM_VERSION) | sed -ne 's/%{fedorassgversion}/$(FEDORA_SSG_VERSION)/p'))
+FEDORA_PKG := $(FEDORA_NAME)-$(FEDORA_RPM_VERSION)
 FEDORA_TARBALL := $(RPM_TOPDIR)/SOURCES/$(FEDORA_PKG).tar.gz
 FEDORA_DIST := $(shell rpm --eval '%{dist}')
 
@@ -128,10 +129,9 @@ fedora-srpm: $(FEDORA_RPM_DEPS)
 	$(call rpm-prep)
 	# Obtain the source from Fedora's spec file
 	$(eval FEDORA_SOURCE := $(shell sed -ne 's/Source0:\t\(.*\)/\1/p' $(FEDORA_SPEC)))
-	# Substitute %{name}, %{version}, and %{fedorassgrelease} with their actual values
+	# Substitute %{name} and %{version} with their actual values
 	$(eval FEDORA_SOURCE := $(shell echo $(FEDORA_SOURCE) | sed -ne "s/%{name}/$(FEDORA_NAME)/p"))
-	$(eval FEDORA_SOURCE := $(shell echo $(FEDORA_SOURCE) | sed -ne "s/%{version}/$(FEDORA_VERSION)/p"))
-	$(eval FEDORA_SOURCE := $(shell echo $(FEDORA_SOURCE) | sed -ne "s/%{fedorassgrelease}/$(FEDORA_SSG_RELEASE)/p"))
+	$(eval FEDORA_SOURCE := $(shell echo $(FEDORA_SOURCE) | sed -ne "s/%{version}/$(FEDORA_RPM_VERSION)/p"))
 	# Download the tarball
 	@echo "Downloading the $(FEDORA_SOURCE) tarball..."
 	@wget -O $(FEDORA_TARBALL) $(FEDORA_SOURCE)
@@ -145,8 +145,10 @@ rpm: srpm
 	 cd $(RPM_TOPDIR)/SRPMS && rpmbuild --rebuild --target=$(ARCH) $(RPMBUILD_ARGS) --buildroot $(RPM_BUILDROOT) -bb $(PKG)$(REDHAT_DIST).src.rpm
 
 fedora-rpm: fedora-srpm
+	$(eval FEDORA_RPM_RELEASE := $(shell sed -ne 's/Release:\t\(.*\)/\1/p' $(FEDORA_SPEC)))
+	$(eval FEDORA_RPM_RELEASE := $(shell echo $(FEDORA_RPM_RELEASE) | sed -ne 's/%{?dist}/$(FEDORA_DIST)/p'))
 	@echo "Building Fedora $(FEDORA_PKG) RPM package..."
-	cd $(RPM_TOPDIR)/SRPMS && rpmbuild --rebuild --target=$(ARCH) $(RPMBUILD_ARGS) --buildroot $(RPM_BUILDROOT) -bb $(FEDORA_PKG)$(FEDORA_DIST).src.rpm
+	cd $(RPM_TOPDIR)/SRPMS && rpmbuild --rebuild --target=$(ARCH) $(RPMBUILD_ARGS) --buildroot $(RPM_BUILDROOT) -bb $(FEDORA_PKG)-$(FEDORA_RPM_RELEASE).src.rpm
 
 clean:
 	rm -rf $(RPM_TMPDIR)
-- 
1.8.3.1

