1 # Copyright (C) 2008 Red Hat, Inc.
3 # This program is free software; you can redistribute it and/or modify
4 # it under the terms of the GNU General Public License as published by
5 # the Free Software Foundation; version 2 of the License.
7 # This program is distributed in the hope that it will be useful,
8 # but WITHOUT ANY WARRANTY; without even the implied warranty of
9 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
10 # GNU General Public License for more details.
12 # You should have received a copy of the GNU General Public License
13 # along with this program; if not, write to the Free Software
14 # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
15 # MA 02110-1301, USA. A copy of the GNU General Public License is
16 # also available at http://www.gnu.org/copyleft/gpl.html.
18 OVIRT_CACHE_DIR ?= $(HOME)/ovirt-cache
19 OVIRT_LOCAL_REPO ?= file://$(OVIRT_CACHE_DIR)/ovirt
20 OVIRT_NODE_RECIPE ?= /usr/share/ovirt-node-tools/ovirt-node-recipe.ks
24 AUTH_KEYS ?= ~/.ssh/authorized_keys
26 ARCH = $(shell rpm --eval '%{_arch}')
28 NVR = $(PACKAGE)-$(VERSION)-$(ARCH)
36 DISTCLEANFILES = $(PACKAGE)-$(VERSION).tar.gz \
37 $(PACKAGE).$(PKG_FMT) \
39 $(NVR).$(PKG_FMT).$(SUM) \
42 # For Release: 0..., set _ovirt_dev=1 so that we get extra_release.GIT-
43 # annotated rpm version strings.
45 $(shell grep -q '^[[:space:]]*Release:[[:space:]]*0' \
46 $(srcdir)/*.spec.in && echo 1 || :)
48 git_head = $$(git log -1 --pretty=format:%h)
49 GIT_RELEASE = $(shell date --utc +%Y%m%d%H%M%S)git$(git_head)
50 RPMDIR = $$(rpm --eval '%{_rpmdir}')
51 RPM_FLAGS = --define "ovirt_cache_dir $(OVIRT_CACHE_DIR)"
52 RPM_FLAGS += $(if $(_ovirt_dev),--define "extra_release .$(GIT_RELEASE)")
53 NODE_TMP = $(OVIRT_CACHE_DIR)/$(PACKAGE)-$(ARCH)-tmp
54 SRC_KS = $(NODE_TMP)/src.ks
55 NODE_KS = $(NODE_TMP)/node.ks
59 if [ "$(_ovirt_dev)" = 1 -a -f $(AUTH_KEYS) ]; then \
60 cp -va $(AUTH_KEYS) ovirt-authorized_keys ;\
63 SELINUX_ENFORCING=$(shell /usr/sbin/getenforce)
64 $(NVR).$(PKG_FMT): no_nscd keys
66 mkdir -p $(OVIRT_CACHE_DIR)/yum-$(ARCH)
68 case $(SELINUX_ENFORCING) in \
69 Enforcing) sudo /usr/sbin/setenforce Permissive ;; \
71 *) if grep -q '^selinux --disabled' $(OVIRT_NODE_RECIPE); \
73 echo WARNING: SELinux disabled in kickstart ;\
75 echo ERROR: SELinux enabled in kickstart, \
76 but disabled on the build machine ;\
82 if [ "$(_ovirt_dev)" = 1 ]; then \
83 echo "repo --name=ovirt-local --baseurl=$(OVIRT_LOCAL_REPO)" > $(NODE_KS) ;\
85 cat $(OVIRT_NODE_RECIPE) >> $(NODE_KS)
86 sudo livecd-creator --skip-minimize -c $(NODE_KS)\
88 --tmpdir='$(NODE_TMP)' \
89 --cache='$(OVIRT_CACHE_DIR)/yum-$(ARCH)'
90 sudo chown $${USER} $(PACKAGE).$(PKG_FMT)
92 if [ $(SELINUX_ENFORCING) = Enforcing ]; then \
93 sudo /usr/sbin/setenforce Enforcing || exit 1 ;\
97 ln -nf $(PACKAGE).$(PKG_FMT) $(NVR).$(PKG_FMT)
99 $(NVR).$(PKG_FMT).$(SUM): $(NVR).$(PKG_FMT)
100 $(SUM) $(NVR).$(PKG_FMT) > $(NVR).$(PKG_FMT).$(SUM)
102 $(PACKAGE).$(PKG_FMT) node: $(NVR).$(PKG_FMT).$(SUM)
104 PUNGI = $(NODE_TMP)/tree/pungi
106 @sudo rm -Rf $(PUNGI)
110 sudo pungi -G --ver=$(PACKAGE) -c $(SRC_KS) \
111 --cachedir=$(OVIRT_CACHE_DIR)/yum-$(ARCH)
112 if [ "$(SRC_FMT)" == "iso" ]; then \
114 sudo pungi --sourceiso --ver=$(PACKAGE) -c $(SRC_KS) \
115 --cachedir=$(OVIRT_CACHE_DIR)/yum-$(ARCH) ;\
116 sudo mv $(PUNGI)/$(PACKAGE)/source/iso/Fedora-$(PACKAGE)-source.iso \
117 $(PWD)/$(PACKAGE)-source-$(VERSION).iso ;\
118 elif [ "$(SRC_FMT)" == "tar" ]; then \
119 cd $(PUNGI)/$(PACKAGE)/source && \
120 sudo tar cf ovirt-source.tar SRPMS ;\
121 sudo mv $(PUNGI)/$(PACKAGE)/source/ovirt-source.tar \
122 $(PWD)/$(PACKAGE)-source-$(VERSION).tar ;\
124 echo "Invalid src format: $(SRC_FMT)" ;\
127 sudo sudo chown -R $(USER) $(PWD)/$(PACKAGE)-source-$(VERSION).$(SRC_FMT)
128 sudo sudo chown -R $(USER) $(PUNGI)
129 $(SUM) $(PWD)/$(PACKAGE)-source-$(VERSION).$(SRC_FMT) \
130 > $(PACKAGE)-source-$(VERSION).$(SRC_FMT).$(SUM)
133 rpmbuild $(RPM_FLAGS) -ts $(distdir).tar.gz
134 rpmbuild $(RPM_FLAGS) --define "source_iso 1" -tb $(distdir).tar.gz
137 rpmbuild $(RPM_FLAGS) -ts $(distdir).tar.gz
141 rpmbuild $(RPM_FLAGS) --define "source_iso 1" -ts $(distdir).tar.gz
144 publish: rpms _publish
147 mkdir -p $(OVIRT_CACHE_DIR)
148 rsync -aq $(shell rpm --eval '%{_rpmdir}')/ $(OVIRT_CACHE_DIR)/ovirt/
149 rsync -aq $(shell rpm --eval '%{_srcrpmdir}')/ $(OVIRT_CACHE_DIR)/ovirt/src
150 createrepo $(OVIRT_CACHE_DIR)/ovirt
153 if pgrep -xl nscd; then \
154 echo "Please stop nscd" ;\
158 .PHONY: rpms publish srpms $(NVR).$(PKG_FMT).$(SUM) $(NVR).$(PKG_FMT) \
159 $(PACKAGE).$(PKG_FMT) keys src.ks source _publish iso_srpms \