Makes $dist-updates-newkey only available on Fedora 9.
[ovirt-node-image.git] / Makefile.am
blob8d20ac47e4c6939dd6f03971c84dde85291666bd
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
21 SUM              ?= sha1sum
22 PKG_FMT           = iso
23 AUTH_KEYS        ?= ~/.ssh/authorized_keys
25 FEDORA_MIRROR     = http://mirrors.fedoraproject.org/mirrorlist
26 CUR_RAWHIDE       = 11
28 FEDORA            = $(shell rpm --eval '%{fedora}')
29 ARCH              = $(shell rpm --eval '%{_arch}')
31 NVR               = $(PACKAGE)-$(VERSION)-$(ARCH)
33 EXTRA_DIST =                            \
34   .gitignore                            \
35   $(PACKAGE).spec                       \
36   $(PACKAGE).spec.in            \
37   README.krb5                           \
38   common-blacklist.ks           \
39   common-install.ks                     \
40   common-pkgs.ks                        \
41   common-post.ks                        \
42   ovirt-flash                           \
43   ovirt-flash-static            \
44   $(PACKAGE).ks                         \
45   ovirt-pxe                                     \
46   create-ovirt-iso-nodes        \
47   edit-livecd                           \
48   livecd-setauth
50 DISTCLEANFILES = $(PACKAGE)-$(VERSION).tar.gz \
51   $(PACKAGE).$(PKG_FMT) \
52   $(NVR).$(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.
58 _ovirt_dev = \
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)")
68 repos.ks:
69         ( \
70             if [ 0$(FEDORA) == 0$(CUR_RAWHIDE) ]; then \
71                 FEDORA_REPO=rawhide ;\
72                 FEDORA_REPO_LOC="$(if $(FEDORA_URL),--baseurl=$(FEDORA_URL)/development/$(ARCH)/os,--mirrorlist=$(FEDORA_MIRROR)?repo=rawhide&arch=$(ARCH))" ;\
73                 OVIRT_DISTRO=development ;\
74             else \
75                 FEDORA_REPO=f$(FEDORA) ;\
76                 FEDORA_REPO_LOC="$(if $(FEDORA_URL),--baseurl=$(FEDORA_URL)/releases/$(FEDORA)/Everything/${ARCH}/os,--mirrorlist=$(FEDORA_MIRROR)?repo=fedora-$(FEDORA)&arch=$(ARCH))" ;\
77                 OVIRT_DISTRO=$(FEDORA) ;\
78                 if [ FEDORA_REPO == f9 ]; then \
79                   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))" ;\
80                 else
81                   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                 fi ;\
83             fi ;\
84             echo "repo --name=$${FEDORA_REPO} $${FEDORA_REPO_LOC}" > $@ ;\
85             echo "repo --name=ovirt-org --baseurl=$(OVIRT_URL)/$${OVIRT_DISTRO}/$(ARCH)" >> $@ ;\
86             echo "$${UPDATE_REPO_LINE}" >> $@ ;\
87             echo "repo --name=ovirt-local --baseurl=$(OVIRT_LOCAL_REPO)" >> $@ \
88         )
90 keys:
91         if [ "$(_ovirt_dev)" = 1 -a -f $(AUTH_KEYS) ]; then \
92             cp -va $(AUTH_KEYS) ovirt-authorized_keys ;\
93         fi
95 SELINUX_ENFORCING=$(shell /usr/sbin/getenforce)
96 $(NVR).$(PKG_FMT): repos.ks keys
97         mkdir -p $(OVIRT_CACHE_DIR)/$(PACKAGE)-tmp
98         mkdir -p $(OVIRT_CACHE_DIR)/yum
99         ( \
100             case $(SELINUX_ENFORCING) in \
101                 Enforcing) sudo /usr/sbin/setenforce Permissive ;; \
102                 Permissive) ;; \
103                 *) if ksflatten $(PACKAGE).ks 2>/dev/null \
104                        | grep -q '^selinux --disabled'; then \
105                        echo WARNING: SELinux disabled in kickstart ;\
106                    else \
107                        echo ERROR: SELinux enabled in kickstart, \
108                        but disabled on the build machine ;\
109                        exit 1 ;\
110                    fi ;; \
111             esac ;\
112         )
113         sudo livecd-creator --skip-minimize -c $(PACKAGE).ks \
114             -f $(PACKAGE) \
115             --tmpdir='$(OVIRT_CACHE_DIR)/$(PACKAGE)-tmp' \
116             --cache='$(OVIRT_CACHE_DIR)/yum'
117         sudo chown $${USER} $(PACKAGE).$(PKG_FMT)
118         ( \
119             if [ $(SELINUX_ENFORCING) = Enforcing ]; then \
120                 sudo /usr/sbin/setenforce Enforcing || exit 1 ;\
121             fi \
122         )
124         ln -nf $(PACKAGE).$(PKG_FMT) $(NVR).$(PKG_FMT)
126 $(NVR).$(PKG_FMT).$(SUM): $(NVR).$(PKG_FMT)
127         $(SUM) $(NVR).$(PKG_FMT) > $(NVR).$(PKG_FMT).$(SUM)
129 $(PACKAGE).$(PKG_FMT) node: $(NVR).$(PKG_FMT).$(SUM)
131 rpms: dist node
132         rpmbuild $(RPM_FLAGS) -ts $(distdir).tar.gz
133         rpmbuild $(RPM_FLAGS) --define "source_iso 1" -tb $(distdir).tar.gz
135 publish: rpms
136         mkdir -p $(OVIRT_CACHE_DIR)
137         rsync -aq $(shell rpm --eval '%{_rpmdir}')/ $(OVIRT_CACHE_DIR)/ovirt/
138         rsync -aq $(shell rpm --eval '%{_srcrpmdir}')/ $(OVIRT_CACHE_DIR)/ovirt/src
139         createrepo $(OVIRT_CACHE_DIR)/ovirt
141 .PHONY: rpms publish $(NVR).$(PKG_FMT).$(SUM) $(NVR).$(PKG_FMT) \
142   $(PACKAGE).$(PKG_FMT) keys