Juan Hernandez has uploaded a new change for review.

Change subject: cli: Always generate the tarball when building RPMs
......................................................................

cli: Always generate the tarball when building RPMs

Currently when building a RPM the tarball is generated using the "git
archive" command and the HEAD tree. This means that changes that haven't
been locally commited aren't included in the result. In addition the
tarball is only generated if there were changes in the Makefile or the
.spec template, which has the same effect. To avoid these two issues
this patch changes the command used to build the tarball and also
changes the Makefile so that the tarball is always regenerated.

Change-Id: Iac7989eb69f7a3ec3447cc1cb729b76528b0d012
Signed-off-by: Juan Hernandez <juan.hernan...@redhat.com>
---
M Makefile
M ovirt-engine-cli.spec.in
2 files changed, 34 insertions(+), 30 deletions(-)


  git pull ssh://gerrit.ovirt.org:29418/ovirt-engine-cli refs/changes/57/39857/1

diff --git a/Makefile b/Makefile
index a06f0d7..7edb497 100644
--- a/Makefile
+++ b/Makefile
@@ -1,40 +1,44 @@
 all: rpm
 
-rpmrelease:=0.2$(rpmsuffix)
-rpmversion=3.6.0.0
-RPMTOP=$(shell bash -c "pwd -P")/rpmtop
-SPEC=ovirt-engine-cli.spec
+PWD=$(shell bash -c "pwd -P")
+version=3.6.0.0
+rpmversion=$(version)
+rpmdist=$(shell rpm --eval '%dist')
+rpmrelease:=0.2$(rpmsuffix)$(rpmdist)
 
-TARBALL=ovirt-engine-cli-$(rpmversion).tar.gz
-SRPM=$(RPMTOP)/SRPMS/ovirt-engine-cli-$(rpmversion)-$(rpmrelease)*.src.rpm
+RPMTOP=$(PWD)/rpmtop
+NAME=ovirt-engine-cli
+SPEC=$(NAME).spec
 
-TESTS=pyflakes
+TARBALL=$(NAME)-$(version).tar.gz
+SRPM=$(RPMTOP)/SRPMS/$(NAME)-$(rpmversion)-$(rpmrelease).src.rpm
 
-test: pyflakes exceptions
-       echo $(rpmrelease) $(rpmversion)
-
-pyflakes:
-       @git ls-files '*.py' | xargs pyflakes \
-           || (echo "Pyflakes errors or pyflakes not found"; exit 1)
+.PHONY: spec
+spec: $(SPEC).in
+       sed \
+               -e 's/@RPM_VERSION@/$(rpmversion)/g' \
+               -e 's/@RPM_RELEASE@/$(rpmrelease)/g' \
+               -e 's/@TARBALL@/$(TARBALL)/g' \
+               < $(SPEC).in \
+               > $(SPEC)
 
 .PHONY: tarball
-tarball: $(TARBALL)
-$(TARBALL): Makefile #$(TESTS)
-       git config tar.umask 0022
-       git archive --format=tar --prefix ovirt-engine-cli/ HEAD | gzip > 
$(TARBALL)
+tarball: spec
+       git ls-files | tar --transform='s|^|$(NAME)/|' --files-from 
/proc/self/fd/0 -czf $(TARBALL) $(SPEC)
 
-.PHONY: srpm rpm
-srpm: $(SRPM)
-$(SRPM): $(TARBALL) ovirt-engine-cli.spec.in
-       sed 's/^Version:.*/Version: $(rpmversion)/;s/^Release:.*/Release: 
$(rpmrelease)%{dist}/;s/%{release}/$(rpmrelease)/' ovirt-engine-cli.spec.in > 
$(SPEC)
-       mkdir -p $(RPMTOP)/{RPMS,SRPMS,SOURCES,BUILD}
-       rpmbuild -bs \
-           --define="_topdir $(RPMTOP)" \
-           --define="_sourcedir ." $(SPEC)
+.PHONY: srpm
+srpm: tarball
+       rpmbuild \
+               --define="_topdir $(RPMTOP)" \
+               -ts $(TARBALL)
 
-rpm: $(SRPM)
-       rpmbuild --define="_topdir $(RPMTOP)" --rebuild $<
+.PHONY: rpm
+rpm: srpm
+       rpmbuild \
+               --define="_topdir $(RPMTOP)" \
+               --rebuild $(SRPM)
 
+.PHONY:
 clean:
-       $(RM) *~ *.pyc ovirt-engine-cli*.tar.gz $(SPEC)
+       $(RM) $(NAME)*.tar.gz $(SPEC)
        $(RM) -r rpmtop
diff --git a/ovirt-engine-cli.spec.in b/ovirt-engine-cli.spec.in
index 23b8678..715d7bc 100644
--- a/ovirt-engine-cli.spec.in
+++ b/ovirt-engine-cli.spec.in
@@ -1,6 +1,6 @@
 Name:           ovirt-engine-cli
-Version:        [?]
-Release:        1%{?dist}
+Version:        @RPM_VERSION@
+Release:        @RPM_RELEASE@
 Summary:        oVirt Engine Command Line Interface
 Group:          Development/Libraries
 License:        ASL 2.0


-- 
To view, visit https://gerrit.ovirt.org/39857
To unsubscribe, visit https://gerrit.ovirt.org/settings

Gerrit-MessageType: newchange
Gerrit-Change-Id: Iac7989eb69f7a3ec3447cc1cb729b76528b0d012
Gerrit-PatchSet: 1
Gerrit-Project: ovirt-engine-cli
Gerrit-Branch: master
Gerrit-Owner: Juan Hernandez <juan.hernan...@redhat.com>
_______________________________________________
Engine-patches mailing list
Engine-patches@ovirt.org
http://lists.ovirt.org/mailman/listinfo/engine-patches

Reply via email to