---
Makefile | 158
+++++++++++++++++++++++++++++++++++++++++++++++++-------------
1 files changed, 126 insertions(+), 32 deletions(-)
diff --git a/Makefile b/Makefile
index fb21817..bf8b563 100644
--- a/Makefile
+++ b/Makefile
@@ -1,71 +1,165 @@
-# Stupid, stupid makefile. I am ashamed of this.
Finally we're not ashamed of the Makefile :-)
-VERSION=$(shell echo `gawk '$$1~/^Version:/{print $$2}'
autoqa.spec`)
+NAME=autoqa
-# paths
+# Common autoqa paths
PREFIX=
-EVENT_DIR=/usr/share/autoqa/events
-WATCHER_DIR=/usr/share/autoqa/watchers
+EVENT_DIR=/usr/share/$(NAME)/events
+WATCHER_DIR=/usr/share/$(NAME)/watchers
AUTOTEST_DIR=/usr/share/autotest
TEST_DIR=$(AUTOTEST_DIR)/client/site_tests
HTTPCONF_DIR=/etc/httpd/conf.d/
PYTHON=python
+# Packaging defaults
+WORKDIR := $(shell pwd)/build
+SRCRPMDIR = $(WORKDIR)/SRPMS
+## SRCRPMDIR_MD5 = $(WORKDIR)/SRPMS_MD5
+BUILDDIR = $(WORKDIR)/BUILD
+BUILDROOTDIR = $(WORKDIR)/BUILDROOT
+SOURCEDIR = $(WORKDIR)/SOURCES
+SPECDIR = $(WORKDIR)/SPECS
+RPMDIR = $(WORKDIR)/RPMS
+## RPMDIR_MD5 = $(WORKDIR)/RPMS_MD5
+MOCKDIR = $(WORKDIR)/MOCK
+RPM_DEFINES = --define "_specdir $(SPECDIR)" \
+ --define "_sourcedir $(SOURCEDIR)" \
+ --define "_builddir $(BUILDDIR)" \
+ --define "_buildrootdir $(BUILDROOTDIR)" \
+ --define "_srcrpmdir $(SRCRPMDIR)" \
+ --define "_rpmdir $(RPMDIR)"
+EL5_DEFINES= --define "dist .el5" \
+ --define "_source_filedigest_algorithm 1" \
+ --define "_binary_filedigest_algorithm 1"
+## --define "_rpmdir $(RPMDIR_MD5)" \
+## --define "_srcrpmdir $(SRCRPMDIR_MD5)" \
+
+# Variables used for packaging
+SPECFILE=$(NAME).spec
+VERSION=$(shell echo `gawk '$$1~/^Version:/{print $$2}' $(SPECFILE)`)
+VER_REL := $(shell rpm $(RPM_DEFINES) -q --qf "%{VERSION}
%{RELEASE}\n" --specfile $(SPECFILE)| head -1)
+ifneq ($(strip $(VERSION)),$(strip $(word 1, $(VER_REL))))
+$(error "VERSION in Makefile does not match VERSION in spec file")
+endif
+RELEASE := $(word 2, $(VER_REL))
+## RELEASEVER=$(shell curl
"https://fedoraproject.org/w/api.php?action=expandtemplates&text=\{\{Template:FedoraVersionNumber\}\}&format=txt"
2>/dev/null | grep "\[\*\]" | gawk '{print $$3}')
+RELEASEVER=devel
+BASEARCH=$(shell uname -i)
+# RELEASE used for EL5 builds
+RELEASE_EL5 := $(shell rpm $(RPM_DEFINES) $(EL5_DEFINES) -q --qf
"%{RELEASE}" --specfile $(SPECFILE))
+
+
default: build
clean:
find . -name "*.py[co]" -exec rm -f {} +
- rm -f autoqa-$(VERSION).tar.gz
- rm -rf lib/autoqa/build
+ rm -f $(NAME)-$(VERSION).tar.gz
+ rm -rf lib/$(NAME)/build
+ rm -rf $(WORKDIR)
install: build
install -d $(PREFIX)/usr/bin
- install -d -m 0775 $(PREFIX)/var/cache/autoqa
- install autoqa $(PREFIX)/usr/bin/
- install -d $(PREFIX)/etc/autoqa
- [ -f $(PREFIX)/etc/autoqa/autoqa.conf ] || install -m 0644
conf/autoqa.conf $(PREFIX)/etc/autoqa/
- [ -f $(PREFIX)/etc/autoqa/fas.conf ] || install -m 0640
conf/fas.conf $(PREFIX)/etc/autoqa
+ install -d -m 0775 $(PREFIX)/var/cache/$(NAME)
+ install $(NAME) $(PREFIX)/usr/bin/
+ install -d $(PREFIX)/etc/$(NAME)
+ [ -f $(PREFIX)/etc/$(NAME)/$(NAME).conf ] || install -m 0644
conf/$(NAME).conf $(PREFIX)/etc/$(NAME)/
+ [ -f $(PREFIX)/etc/$(NAME)/fas.conf ] || install -m 0640
conf/fas.conf $(PREFIX)/etc/$(NAME)
# if running under root, then we're not building the package in mock,
but rather \
# installing from source on a developer machine; because rpm will not
change \
# fas.conf ownership for us, we have to do it manually here \
- if [ `id -u` -eq 0 ]; then chgrp autotest
$(PREFIX)/etc/autoqa/fas.conf; fi
- install -m 0644 conf/repoinfo.conf $(PREFIX)/etc/autoqa/
- install -m 0644 conf/log_template.html $(PREFIX)/etc/autoqa/
+ if [ `id -u` -eq 0 ]; then chgrp autotest
$(PREFIX)/etc/$(NAME)/fas.conf; fi
+ install -m 0644 conf/repoinfo.conf $(PREFIX)/etc/$(NAME)/
+ install -m 0644 conf/log_template.html $(PREFIX)/etc/$(NAME)/
install -d $(PREFIX)$(EVENT_DIR)
for h in events/*; do cp -a $$h $(PREFIX)$(EVENT_DIR); done
install -d $(PREFIX)$(WATCHER_DIR)
for h in watchers/*; do cp -a $$h $(PREFIX)$(WATCHER_DIR); done
## git-post-receive setup
install -d $(PREFIX)/usr/sbin
- mv $(PREFIX)$(WATCHER_DIR)/git-post-receive/autoqa-git-hook.wsgi
$(PREFIX)/usr/sbin/
+ mv $(PREFIX)$(WATCHER_DIR)/git-post-receive/$(NAME)-git-hook.wsgi
$(PREFIX)/usr/sbin/
install -d $(PREFIX)/$(HTTPCONF_DIR)
- mv $(PREFIX)$(WATCHER_DIR)/git-post-receive/autoqa-git-hook.conf
$(PREFIX)/$(HTTPCONF_DIR)/
- [ -f $(PREFIX)$(WATCHER_DIR)/autoqa.cron ] || install -m 0644
conf/autoqa.cron $(PREFIX)$(WATCHER_DIR)/
+ mv $(PREFIX)$(WATCHER_DIR)/git-post-receive/$(NAME)-git-hook.conf
$(PREFIX)/$(HTTPCONF_DIR)/
+ [ -f $(PREFIX)$(WATCHER_DIR)/$(NAME).cron ] || install -m 0644
conf/$(NAME).cron $(PREFIX)$(WATCHER_DIR)/
install -d $(PREFIX)$(TEST_DIR)
for t in tests/*; do cp -a $$t $(PREFIX)$(TEST_DIR); done
install -d $(PREFIX)$(AUTOTEST_DIR)/client/{bin,common_lib}
install -m 0644 lib/autotest/site_utils.py
$(PREFIX)$(AUTOTEST_DIR)/client/bin/
install -d $(PREFIX)$(AUTOTEST_DIR)/server
install -m 0644 lib/autotest/site_autotest.py
$(PREFIX)$(AUTOTEST_DIR)/server/
- ( cd lib/autoqa; $(PYTHON) setup.py install --skip-build --root
$(PREFIX)/ )
+ ( cd lib/$(NAME); $(PYTHON) setup.py install --skip-build --root
$(PREFIX)/ )
-build: lib/autoqa/build
+build: lib/$(NAME)/build
-lib/autoqa/build:
- ( cd lib/autoqa; $(PYTHON) setup.py build )
+lib/$(NAME)/build:
+ ( cd lib/$(NAME); $(PYTHON) setup.py build )
-tarball: clean autoqa-$(VERSION).tar.gz
+test:
+ bash runtests.sh
-rpms: rpm
+#
+# Tarball
+#
-rpm: tarball
- rpmbuild -ta autoqa-$(VERSION).tar.gz
+upload: $(SOURCEDIR)/$(NAME)-$(VERSION).tar.gz
+ @scp $(SOURCEDIR)/$(NAME)-$(VERSION).tar.gz fedorahosted.org:$(NAME)
-autoqa-$(VERSION).tar.gz:
+$(SOURCEDIR)/$(NAME)-$(VERSION).tar.gz:
[ -d .git ] # CHECKING TO SEE IF THIS IS A GIT TREE
- git archive HEAD --prefix=autoqa-$(VERSION)/ | gzip -c9 > $@
+ mkdir -p $(SOURCEDIR)
+ git archive HEAD --prefix=$(NAME)-$(VERSION)/ | gzip -c9 > /$@
-upload: tarball
- @scp autoqa-$(VERSION).tar.gz fedorahosted.org:autoqa
+#
+# BUILD RPMS either with or without the EL5_DEFINES (EPEL-5)
+#
-test:
- bash runtests.sh
+nvr:
+ @echo $(NAME)-$(VERSION)-$(RELEASE)
+
+nvr_el5:
+ @echo $(NAME)-$(VERSION)-$(RELEASE_EL5)
+
+install-buildrequires:
+ yum install $$(grep ^BuildRequires: $(SPECFILE) | cut -d ' ' -f 2)
This is cool. Could we add also "install-requires" target? It would help when
checking out autoqa from git onto new computers.
+
+# Extra level of indirection to allow for pre-processing (aka
variable
+# substitution) of the spec file
+$(SPECDIR)/$(SPECFILE): $(SPECFILE)
+ @mkdir -p $(SPECDIR)
+ @cp $(SPECFILE) $(SPECDIR)/
+
+$(SRCRPMDIR)/$(NAME)-$(VERSION)-$(RELEASE).src.rpm:
$(SPECDIR)/$(SPECFILE) $(SOURCEDIR)/$(NAME)-$(VERSION).tar.gz
+ mkdir -p $(SRCRPMDIR) $(BUILDDIR) $(RPMDIR)
+ rpmbuild $(RPM_DEFINES) -bs --nodeps $<
+
+$(RPMDIR)/noarch/$(NAME)-$(VERSION)-$(RELEASE).noarch.rpm:
$(SPECDIR)/$(SPECFILE) $(SOURCEDIR)/$(NAME)-$(VERSION).tar.gz
+ mkdir -p $(SRCRPMDIR) $(BUILDDIR) $(RPMDIR)
+ rpmbuild $(RPM_DEFINES) -ba $<
+
+srpm: $(SRCRPMDIR)/$(NAME)-$(VERSION)-$(RELEASE).src.rpm
+rpm: $(RPMDIR)/noarch/$(NAME)-$(VERSION)-$(RELEASE).noarch.rpm
+
+$(SRCRPMDIR)/$(NAME)-$(VERSION)-$(RELEASE_EL5).src.rpm:
$(SPECDIR)/$(SPECFILE) $(SOURCEDIR)/$(NAME)-$(VERSION).tar.gz
+ mkdir -p $(SRCRPMDIR) $(BUILDDIR) $(RPMDIR)
+ rpmbuild $(RPM_DEFINES) $(EL5_DEFINES) -bs --nodeps $<
+
+$(RPMDIR)/noarch/$(NAME)-$(VERSION)-$(RELEASE_EL5).noarch.rpm:
$(SPECDIR)/$(SPECFILE) $(SOURCEDIR)/$(NAME)-$(VERSION).tar.gz
+ mkdir -p $(SRCRPMDIR) $(BUILDDIR) $(RPMDIR)
+ rpmbuild $(RPM_DEFINES) $(EL5_DEFINES) -ba $<
+
+srpm_el5: $(SRCRPMDIR)/$(NAME)-$(VERSION)-$(RELEASE_EL5).src.rpm
+rpm_el5:
$(RPMDIR)/noarch/$(NAME)-$(VERSION)-$(RELEASE_EL5).noarch.rpm
+
+#
+# Mock builds
+#
+
+mock-fedora:
$(MOCKDIR)/fedora-$(RELEASEVER)-$(BASEARCH)/$(NAME)-$(VERSION)-$(RELEASE).src.rpm
+
+$(MOCKDIR)/fedora-$(RELEASEVER)-$(BASEARCH)/$(NAME)-$(VERSION)-$(RELEASE).src.rpm:
$(SRCRPMDIR)/$(NAME)-$(VERSION)-$(RELEASE).src.rpm
+ mock -r fedora-$(RELEASEVER)-$(BASEARCH) --rebuild
--resultdir=$(MOCKDIR)/fedora-$(RELEASEVER)-$(BASEARCH) $<
+
+mock-epel:
$(MOCKDIR)/epel-$(RELEASEVER)-$(BASEARCH)/$(NAME)-$(VERSION)-$(RELEASE_EL5).src.rpm
+
+$(MOCKDIR)/epel-5-$(BASEARCH)/$(NAME)-$(VERSION)-$(RELEASE_EL5).src.rpm:
$(SRCRPMDIR)/$(NAME)-$(VERSION)-$(RELEASE_EL5).src.rpm
+ mock -r epel-5-$(BASEARCH) --rebuild
--resultdir=$(MOCKDIR)/epel-5-$(BASEARCH) $<
+
+$(MOCKDIR)/epel-6-$(BASEARCH)/$(NAME)-$(VERSION)-$(RELEASE).src.rpm:
$(SRCRPMDIR)/$(NAME)-$(VERSION)-$(RELEASE).src.rpm
+ mock -r epel-6-$(BASEARCH) --rebuild
--resultdir=$(MOCKDIR)/epel-6-$(BASEARCH) $<
--
1.7.5.4
I have not tested the patch but I don't have any concerns about the changes. What I
would like to see is the documentation page [1] linked in the Makefile so that it's
easy to understand the process (which targets to call and in what sequence). Also it will
be great if every target has a very brief description (one-liner) of what it does. For
example in a few seconds I can't say the difference between "make rpm" and
"make nvr". A few words description would help.
Thanks,
Kamil
[1]
https://fedoraproject.org/wiki/AutoQA_Build_Process