Jim Meyering
2008-Jun-15 20:59 UTC
[Ovirt-devel] [PATCH 1/4] Makefile, build-all adjustments
Here are some simplifications and clean-up changes. One thing I didn't change is that once you have made a git release, "make bumprelease" no longer works. However, a manual "make bumprelease NEWRELEASE=2" does work. For now, I've merely unified wui/Makefile and ovirt-host-creator/Makefile. Considering the amount of duplication, eventually I expect to factor those parts into a common file and include that file from both places.>From 40baed400add87aaf1fb6667d8d90e45438e5ea1 Mon Sep 17 00:00:00 2001Date: Sun, 15 Jun 2008 13:01:12 +0200 Subject: [PATCH] Makefile clean-up * ovirt-host-creator/Makefile: Remove "-" (ignore command failure) prefixes. Rather than GNU make-specific $(shell command...) syntax, use more concise Bourne shell syntax, $$(command...). (X): Simplify definition by using r[2] unconditionally. (git_head): Define. (GITRELEASE): Use it (no need to determine branch name). (RPM_FLAGS): Start body on a separate line, unindented, to avoid wrapped lines. * wui/Makefile: Likewise. --- ovirt-host-creator/Makefile | 50 ++++++++++++++++++++------------------ wui/Makefile | 56 ++++++++++++++++++++---------------------- 2 files changed, 53 insertions(+), 53 deletions(-) diff --git a/ovirt-host-creator/Makefile b/ovirt-host-creator/Makefile index b7d98ec..9dc1e00 100644 --- a/ovirt-host-creator/Makefile +++ b/ovirt-host-creator/Makefile @@ -1,50 +1,53 @@ -VERSION = $(shell echo `awk '{ print $$1 }' version`) -NEWVERSION = $(shell printf "%.2f" `dc -e "$(VERSION) .01 + p"`) -RELEASE = $(shell echo `awk '{ print $$2 }' version`) -NEWRELEASE = $(shell echo $$(($(RELEASE) + 1))) -X = $(shell echo `awk '{ if (split($$2,r,".") >= 2) { if (r[1]=="0") {print r[2]+1} else print 1 } else print 1 }' version`) -GITRELEASE = $(shell echo 0.$(X).`date --utc +%Y%m%d%H%M`git`git show-ref --heads --hash=7 $$(git branch|awk '$$1="*" {print $$2}')`) -DIST = $(shell rpm --eval '%{dist}') -ARCH = $(shell uname -i) - -SPEC_FILE = ovirt-host-image.spec +VERSION = $$(awk '{ print $$1 }' version) +NEWVERSION = $$(awk 'BEGIN { printf "%.2f", $(VERSION) + .01 }')) +RELEASE = $$(awk '{ print $$2 }' version) +NEWRELEASE = $$(($(RELEASE) + 1))) +X = $$(awk '{ split($$2,r,"."); \ + printf("%d.%d\n", r[1], r[2]+1) }' version) +git_head = $$(git show-ref --hash=7 HEAD) +GITRELEASE = $(X).$$(date --utc +%Y%m%d%H%M)git$(git_head) +DIST = $$(rpm --eval '%{dist}') +ARCH = $$(uname -i) + NAME = ovirt-host-image +SPEC_FILE = $(NAME).spec NV = $(NAME)-$(VERSION) -RPM_FLAGS = --define "_topdir %(pwd)/rpm-build" \ - --define "_builddir %{_topdir}" \ - --define "_rpmdir %{_topdir}" \ - --define "_srcrpmdir %{_topdir}" \ - --define '_rpmfilename %%{NAME}-%%{VERSION}-%%{RELEASE}.%%{ARCH}.rpm' \ - --define "_specdir %{_topdir}" \ - --define "_sourcedir %{_topdir}" +RPM_FLAGS = \ + --define "_topdir %(pwd)/rpm-build" \ + --define "_builddir %{_topdir}" \ + --define "_rpmdir %{_topdir}" \ + --define "_srcrpmdir %{_topdir}" \ + --define '_rpmfilename %%{NAME}-%%{VERSION}-%%{RELEASE}.%%{ARCH}.rpm' \ + --define "_specdir %{_topdir}" \ + --define "_sourcedir %{_topdir}" all: rpms bumpgit: - -echo "$(VERSION) $(GITRELEASE)" > version + echo "$(VERSION) $(GITRELEASE)" > version bumprelease: - -echo "$(VERSION) $(NEWRELEASE)" > version + echo "$(VERSION) $(NEWRELEASE)" > version setversion: - -echo "$(VERSION) $(RELEASE)" > version + echo "$(VERSION) $(RELEASE)" > version bumpversion: -echo "$(NEWVERSION) 0" > version clean: - -rm -rf ovirt-host-image-* ovirt-pxe.log + rm -rf ovirt-host-image-* ovirt-pxe.log repos.ks: repos.ks.in cp repos.ks.in repos.ks build: ovirt-$(ARCH).ks common-install.ks common-pkgs.ks common-post.ks repos.ks - -rm -rf tftpboot/ + rm -rf tftpboot/ ./ovirt-pxe.sh > ovirt-pxe.log 2>&1 tar: clean build - mv $(shell cat iso-file) ovirt.iso + mv $$(cat iso-file) ovirt.iso mkdir -p $(NV) cp -a ovirt-host-image.spec ovirt.iso tftpboot/* $(NV) mkdir -p rpm-build @@ -56,4 +59,3 @@ new-rpms: bumprelease rpms rpms: tar rpmbuild $(RPM_FLAGS) -ba $(SPEC_FILE) - diff --git a/wui/Makefile b/wui/Makefile index eede4d6..3784d23 100644 --- a/wui/Makefile +++ b/wui/Makefile @@ -1,43 +1,41 @@ -VERSION = $(shell echo `awk '{ print $$1 }' version`) -NEWVERSION = $(shell printf "%.2f" `dc -e "$(VERSION) .01 + p"`) -RELEASE = $(shell echo `awk '{ print $$2 }' version`) -NEWRELEASE = $(shell echo $$(($(RELEASE) + 1))) -X = $(shell echo `awk '{ if (split($$2,r,".") >= 2) { if (r[1]=="0") {print r[2]+1} else print 1 } else print 1 }' version`) -GITRELEASE = $(shell echo 0.$(X).`date --utc +%Y%m%d%H%M`git`git show-ref --heads --hash=7 $$(git branch|awk '$$1="*" {print $$2}')`) -DIST = $(shell rpm --eval '%{dist}') -ARCH = $(shell uname -i) - -SPEC_FILE = ovirt-wui.spec +VERSION = $$(awk '{ print $$1 }' version) +NEWVERSION = $$(awk 'BEGIN { printf "%.2f", $(VERSION) + .01 }')) +RELEASE = $$(awk '{ print $$2 }' version) +NEWRELEASE = $$(($(RELEASE) + 1))) +X = $$(awk '{ split($$2,r,"."); \ + printf("%d.%d\n", r[1], r[2]+1) }' version) +git_head = $$(git show-ref --hash=7 HEAD) +GITRELEASE = $(X).$$(date --utc +%Y%m%d%H%M)git$(git_head) +DIST = $$(rpm --eval '%{dist}') +ARCH = $$(uname -i) + NAME = ovirt-wui +SPEC_FILE = $(NAME).spec NV = $(NAME)-$(VERSION) -RPM_FLAGS = --define "_topdir %(pwd)/rpm-build" \ - --define "_builddir %{_topdir}" \ - --define "_rpmdir %{_topdir}" \ - --define "_srcrpmdir %{_topdir}" \ - --define '_rpmfilename %%{NAME}-%%{VERSION}-%%{RELEASE}.%%{ARCH}.rpm' \ - --define "_specdir %{_topdir}" \ - --define "_sourcedir %{_topdir}" - -DATADIR = $(shell rpm --eval "%{_datadir}") +RPM_FLAGS = \ + --define "_topdir %(pwd)/rpm-build" \ + --define "_builddir %{_topdir}" \ + --define "_rpmdir %{_topdir}" \ + --define "_srcrpmdir %{_topdir}" \ + --define '_rpmfilename %%{NAME}-%%{VERSION}-%%{RELEASE}.%%{ARCH}.rpm' \ + --define "_specdir %{_topdir}" \ + --define "_sourcedir %{_topdir}" all: rpms bumpgit: - -echo "$(VERSION) $(GITRELEASE)" > version - -bumprelease: - -echo "$(VERSION) $(NEWRELEASE)" > version + echo "$(VERSION) $(GITRELEASE)" > version -setversion: - -echo "$(VERSION) $(RELEASE)" > version +bumprelease: + echo "$(VERSION) $(NEWRELEASE)" > version bumpversion: - -echo "$(NEWVERSION) 0" > version + echo "$(NEWVERSION) 0" > version clean: - -rm -f ovirt*.gz ovirt*.rpm - -rm -rf ovirt-wui-* dist build + rm -f ovirt*.gz ovirt*.rpm + rm -rf ovirt-wui-* dist build genlangs: cd src; rake updatepo; rake makemo @@ -54,7 +52,7 @@ tar: clean new-rpms: bumprelease rpms -rpms: tar +rpms: tar rpmbuild $(RPM_FLAGS) -ba $(SPEC_FILE) # convience method to simulate make install, not for production use -- 1.5.6.rc2.47.g075fa
Alan Pevec
2008-Jun-16 16:05 UTC
[Ovirt-devel] [PATCH 1/4] Makefile, build-all adjustments
Jim Meyering wrote:> git release, "make bumprelease" no longer works. > However, a manual "make bumprelease NEWRELEASE=2" does work.right, need to fix bumprelease to read only till dot in release field> of duplication, eventually I expect to factor those parts > into a common file and include that file from both places.yes, we need Makefile.common> --- a/wui/Makefile > +++ b/wui/Makefile > -VERSION = $(shell echo `awk '{ print $$1 }' version`) > -NEWVERSION = $(shell printf "%.2f" `dc -e "$(VERSION) .01 + p"`)> +VERSION = $$(awk '{ print $$1 }' version) > +NEWVERSION = $$(awk 'BEGIN { printf "%.2f", $(VERSION) + .01 }'))This fails: make bumpversion echo "$(awk 'BEGIN { printf "%.2f", $(awk '{ print $1 }' version) + .01 }')) 0" > version awk: BEGIN { printf "%.2f", $(awk { awk: ^ syntax error awk: cmd. line:1: BEGIN { printf "%.2f", $(awk { awk: cmd. line:1: ^ unexpected newline or end of string