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_URL ?= http://ovirt.org/repos/ovirt
24 AUTH_KEYS ?= ~/.ssh/authorized_keys
26 FEDORA_MIRROR = http://mirrors.fedoraproject.org/mirrorlist
29 FEDORA = $(shell rpm --eval '%{fedora}')
30 ARCH = $(shell rpm --eval '%{_arch}')
32 NVR = $(PACKAGE)-$(VERSION)-$(ARCH)
46 create-ovirt-iso-nodes \
50 DISTCLEANFILES = $(PACKAGE)-$(VERSION).tar.gz \
51 $(PACKAGE).$(PKG_FMT) \
53 $(NVR).$(PKG_FMT).$(SUM) \
54 repos.ks ovirt-authorized_keys
56 # For Release: 0..., set _ovirt_dev=1 so that we get extra_release.GIT-
57 # annotated rpm version strings.
59 $(shell grep -q '^[[:space:]]*Release:[[:space:]]*0' \
60 $(srcdir)/*.spec.in && echo 1 || :)
62 git_head = $$(git log -1 --pretty=format:%h)
63 GIT_RELEASE = $(shell date --utc +%Y%m%d%H%M%S)git$(git_head)
64 RPMDIR = $$(rpm --eval '%{_rpmdir}')
65 RPM_FLAGS = --define "ovirt_cache_dir $(OVIRT_CACHE_DIR)"
66 RPM_FLAGS += $(if $(_ovirt_dev),--define "extra_release .$(GIT_RELEASE)")
67 NODE_TMP = $(OVIRT_CACHE_DIR)/$(PACKAGE)-$(ARCH)-tmp
68 SRC_KS = $(NODE_TMP)/src.ks
72 if [ 0$(FEDORA) == 0$(CUR_RAWHIDE) ]; then \
73 FEDORA_REPO=rawhide ;\
74 FEDORA_REPO_LOC="$(if $(FEDORA_URL),--baseurl=$(FEDORA_URL)/development/$(ARCH)/os,--mirrorlist=$(FEDORA_MIRROR)?repo=rawhide&arch=$(ARCH))" ;\
75 OVIRT_DISTRO=development ;\
77 FEDORA_REPO=f$(FEDORA) ;\
78 FEDORA_REPO_LOC="$(if $(FEDORA_URL),--baseurl=$(FEDORA_URL)/releases/$(FEDORA)/Everything/${ARCH}/os,--mirrorlist=$(FEDORA_MIRROR)?repo=fedora-$(FEDORA)&arch=$(ARCH))" ;\
79 OVIRT_DISTRO=$(FEDORA) ;\
80 UPDATE_REPO_LINE="repo --name=$${FEDORA_REPO}-updates $(if $(FEDORA_URL),--baseurl=$(FEDORA_URL)/updates/$(FEDORA)/${ARCH},--mirrorlist=$(FEDORA_MIRROR)?repo=updates-released-f$(FEDORA)&arch=$(ARCH))" ;\
82 echo "repo --name=$${FEDORA_REPO} $${FEDORA_REPO_LOC}" > $@ ;\
83 echo "repo --name=ovirt-org --baseurl=$(OVIRT_URL)/$${OVIRT_DISTRO}/$(ARCH)" >> $@ ;\
84 echo "$${UPDATE_REPO_LINE}" >> $@ ;\
85 echo "repo --name=ovirt-local --baseurl=$(OVIRT_LOCAL_REPO)" >> $@ \
92 if [ 0$(FEDORA) == 0$(CUR_RAWHIDE) ]; then \
93 FEDORA_REPO=rawhide ;\
94 FEDORA_REPO_LOC="$(if $(FEDORA_URL),--baseurl=$(FEDORA_URL)/development/source/SRPMS,--mirrorlist=$(FEDORA_MIRROR)?repo=rawhide-source&arch=source)" ;\
95 OVIRT_DISTRO=development ;\
97 FEDORA_REPO=f$(FEDORA) ;\
98 FEDORA_REPO_LOC="$(if $(FEDORA_URL),--baseurl=$(FEDORA_URL)/releases/$(FEDORA)/Everything/source/SRPMS,--mirrorlist=$(FEDORA_MIRROR)?repo=fedora-source-$(FEDORA)&arch=source)" ;\
99 OVIRT_DISTRO=$(FEDORA) ;\
100 UPDATE_REPO_LINE="repo --name=$${FEDORA_REPO}-updates-source $(if $(FEDORA_URL),--baseurl=$(FEDORA_URL)/updates/$(FEDORA)/SRPMS,--mirrorlist=$(FEDORA_MIRROR)?repo=updates-released-source-f$(FEDORA)&arch=source)" ;\
102 echo "repo --name=$${FEDORA_REPO}-source $${FEDORA_REPO_LOC}" ;\
103 echo "repo --name=ovirt-org-source --baseurl=$(OVIRT_URL)/$${OVIRT_DISTRO}/src" ;\
104 echo "$${UPDATE_REPO_LINE}" ;\
105 echo "%packages --nobase" ;\
106 grep -v '^-' common-pkgs.ks ;\
111 if [ "$(_ovirt_dev)" = 1 -a -f $(AUTH_KEYS) ]; then \
112 cp -va $(AUTH_KEYS) ovirt-authorized_keys ;\
115 SELINUX_ENFORCING=$(shell /usr/sbin/getenforce)
116 $(NVR).$(PKG_FMT): repos.ks keys
118 mkdir -p $(OVIRT_CACHE_DIR)/yum-$(ARCH)
120 case $(SELINUX_ENFORCING) in \
121 Enforcing) sudo /usr/sbin/setenforce Permissive ;; \
123 *) if ksflatten $(PACKAGE).ks 2>/dev/null \
124 | grep -q '^selinux --disabled'; then \
125 echo WARNING: SELinux disabled in kickstart ;\
127 echo ERROR: SELinux enabled in kickstart, \
128 but disabled on the build machine ;\
133 sudo livecd-creator --skip-minimize -c $(PACKAGE).ks \
135 --tmpdir='$(NODE_TMP)' \
136 --cache='$(OVIRT_CACHE_DIR)/yum-$(ARCH)'
137 sudo chown $${USER} $(PACKAGE).$(PKG_FMT)
139 if [ $(SELINUX_ENFORCING) = Enforcing ]; then \
140 sudo /usr/sbin/setenforce Enforcing || exit 1 ;\
144 ln -nf $(PACKAGE).$(PKG_FMT) $(NVR).$(PKG_FMT)
146 $(NVR).$(PKG_FMT).$(SUM): $(NVR).$(PKG_FMT)
147 $(SUM) $(NVR).$(PKG_FMT) > $(NVR).$(PKG_FMT).$(SUM)
149 $(PACKAGE).$(PKG_FMT) node: $(NVR).$(PKG_FMT).$(SUM)
151 PUNGI = $(NODE_TMP)/tree/pungi
153 @sudo rm -Rf $(PUNGI)
157 sudo pungi -G --ver=$(PACKAGE) -c $(SRC_KS) \
158 --cachedir=$(OVIRT_CACHE_DIR)/yum-$(ARCH)
159 if [ "$(SRC_FMT)" == "iso" ]; then \
161 sudo pungi --sourceiso --ver=$(PACKAGE) -c $(SRC_KS) \
162 --cachedir=$(OVIRT_CACHE_DIR)/yum-$(ARCH) ;\
163 sudo mv $(PUNGI)/$(PACKAGE)/source/iso/Fedora-$(PACKAGE)-source.iso \
164 $(PWD)/$(PACKAGE)-source-$(VERSION).iso ;\
165 elif [ "$(SRC_FMT)" == "tar" ]; then \
166 cd $(PUNGI)/$(PACKAGE)/source && \
167 sudo tar cf ovirt-source.tar SRPMS ;\
168 sudo mv $(PUNGI)/$(PACKAGE)/source/ovirt-source.tar \
169 $(PWD)/$(PACKAGE)-source-$(VERSION).tar ;\
171 echo "Invalid src format: $(SRC_FMT)" ;\
174 sudo sudo chown -R $(USER) $(PWD)/$(PACKAGE)-source-$(VERSION).$(SRC_FMT)
175 sudo sudo chown -R $(USER) $(PUNGI)
176 $(SUM) $(PWD)/$(PACKAGE)-source-$(VERSION).$(SRC_FMT) \
177 > $(PACKAGE)-source-$(VERSION).$(SRC_FMT).$(SUM)
180 rpmbuild $(RPM_FLAGS) -ts $(distdir).tar.gz
181 rpmbuild $(RPM_FLAGS) --define "source_iso 1" -tb $(distdir).tar.gz
184 rpmbuild $(RPM_FLAGS) -ts $(distdir).tar.gz
188 rpmbuild $(RPM_FLAGS) --define "source_iso 1" -ts $(distdir).tar.gz
191 publish: rpms _publish
194 mkdir -p $(OVIRT_CACHE_DIR)
195 rsync -aq $(shell rpm --eval '%{_rpmdir}')/ $(OVIRT_CACHE_DIR)/ovirt/
196 rsync -aq $(shell rpm --eval '%{_srcrpmdir}')/ $(OVIRT_CACHE_DIR)/ovirt/src
197 createrepo $(OVIRT_CACHE_DIR)/ovirt
199 .PHONY: rpms publish srpms $(NVR).$(PKG_FMT).$(SUM) $(NVR).$(PKG_FMT) \
200 $(PACKAGE).$(PKG_FMT) keys repos.ks src.ks source _publish iso_srpms