build procedure change: include image ISO in SRPM
[ovirt-node-image.git] / Makefile.am
blob6020609fb64c0d33483d5b1e1f28ad08a02a6299
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        ?= $(OVIRT_CACHE_DIR)/ovirt
20 OVIRT_URL               ?= http://ovirt.org/repos/ovirt
22 EXTRA_DIST =                            \
23   .gitignore                            \
24   ovirt-node-image.spec         \
25   ovirt-node-image.spec.in      \
26   README.krb5                           \
27   common-blacklist.ks                   \
28   common-install.ks                     \
29   common-pkgs.ks                        \
30   common-post.ks                        \
31   ovirt-flash                           \
32   ovirt-flash-static            \
33   ovirt-node-image.ks           \
34   ovirt-pxe
36 # For Release: 0..., set _ovirt_dev=1 so that we get extra_release.GIT-
37 # annotated rpm version strings.
38 _ovirt_dev = \
39  $(shell grep -q '^[[:space:]]*Release:[[:space:]]*0' \
40    $(srcdir)/*.spec.in && echo 1 || :)
42 git_head        = $$(git log -1 --pretty=format:%h)
43 GIT_RELEASE     = $$(date --utc +%Y%m%d%H%M%S)git$(git_head)
44 RPMDIR          = $$(rpm --eval '%{_rpmdir}')
45 RPM_FLAGS       = --define "ovirt_cache_dir $(OVIRT_CACHE_DIR)"
46 RPM_FLAGS       += $(if $(_ovirt_dev),--define "extra_release .$(GIT_RELEASE)")
48 FEDORA=$(shell rpm --eval '%{fedora}')
49 ARCH=$(shell rpm --eval '%{_arch}')
50 FEDORA_MIRROR=http://mirrors.fedoraproject.org/mirrorlist
51 CUR_RAWHIDE=10
53 repos.ks:
54         ( \
55             if [ 0$(FEDORA) == 0$(CUR_RAWHIDE) ]; then \
56                 FEDORA_REPO=rawhide ;\
57                 FEDORA_REPO_LOC="$(if $(FEDORA_URL),--baseurl=$(FEDORA_URL)/development/$(ARCH)/os,--mirrorlist=$(FEDORA_MIRROR)?repo=rawhide&arch=$(ARCH))" ;\
58                 OVIRT_DISTRO=development ;\
59             else \
60                 FEDORA_REPO=f$(FEDORA) ;\
61                 FEDORA_REPO_LOC="$(if $(FEDORA_URL),--baseurl=$(FEDORA_URL)/releases/$(FEDORA)/Everything/${ARCH}/os,--mirrorlist=$(FEDORA_MIRROR)?repo=fedora-$(FEDORA)&arch=$(ARCH))" ;\
62                 OVIRT_DISTRO=$(FEDORA) ;\
63                 UPDATE_REPO_LINE="repo --name=$${FEDORA_REPO}-updates-newkey $(if $(FEDORA_URL),--baseurl=$(FEDORA_URL)/updates/$(FEDORA)/${ARCH}.newkey,--mirrorlist=$(FEDORA_MIRROR)?repo=updates-released-f$(FEDORA).newkey&arch=$(ARCH))" ;\
64             fi ;\
65             echo "repo --name=$${FEDORA_REPO} $${FEDORA_REPO_LOC}" > $@ ;\
66             echo "repo --name=ovirt-org --baseurl=$(OVIRT_URL)/$${OVIRT_DISTRO}/$(ARCH)" >> $@ ;\
67             echo "$${UPDATE_REPO_LINE}" >> $@ ;\
68             echo "repo --name=ovirt-local --baseurl=file://$(OVIRT_CACHE_DIR)/ovirt" >> $@ \
69         )
71 SELINUX_ENFORCING=$(shell /usr/sbin/getenforce)
72 ovirt-node-image.iso: repos.ks
73         mkdir -p $(OVIRT_CACHE_DIR)/node-image-tmp
74         mkdir -p $(OVIRT_CACHE_DIR)/yum
75         ( \
76             case $(SELINUX_ENFORCING) in \
77                 Enforcing) sudo /usr/sbin/setenforce Permissive ;; \
78                 Permissive) ;; \
79                  *) if ksflatten ovirt-image-node.ks 2>/dev/null \
80                       | grep -q '^selinux --disabled'; then \
81                       echo WARNING: SELinux disabled in kickstart ;\
82                     else \
83                       echo ERROR: SELinux enabled in kickstart, \
84                            but disabled on the build machine ;\
85                       exit 1 ;\
86                     fi ;; \
87             esac ;\
88         )
89         sudo livecd-creator --skip-minimize -c ovirt-node-image.ks \
90                -f ovirt-node-image \
91                --tmpdir='$(OVIRT_CACHE_DIR)/node-image-tmp' \
92                --cache='$(OVIRT_CACHE_DIR)/yum'
93         sudo chown $${USER} ovirt-node-image.iso
94         ( \
95             if [ $(SELINUX_ENFORCING) = Enforcing ]; then \
96               sudo /usr/sbin/setenforce Enforcing || exit 1 ;\
97             fi \
98         )
100 rpms: ovirt-node-image.iso dist
101         rpmbuild $(RPM_FLAGS) -ta $(distdir).tar.gz
103 publish: rpms
104         mkdir -p $(OVIRT_CACHE_DIR)
105         rsync -aq $(shell rpm --eval '%{_rpmdir}')/ $(OVIRT_CACHE_DIR)/ovirt/
106         rsync -aq $(shell rpm --eval '%{_srcrpmdir}')/ $(OVIRT_CACHE_DIR)/ovirt/src
107         createrepo $(OVIRT_CACHE_DIR)/ovirt
109 .PHONY: rpms publish ovirt-node-image.iso