Removed updates conditions for F9.
[ovirt-node-image.git] / Makefile.am
blobcb084e628c15a04b8b1a0b3ec46414011a38ae90
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                 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))" ;\
79             fi ;\
80             echo "repo --name=$${FEDORA_REPO} $${FEDORA_REPO_LOC}" > $@ ;\
81             echo "repo --name=ovirt-org --baseurl=$(OVIRT_URL)/$${OVIRT_DISTRO}/$(ARCH)" >> $@ ;\
82             echo "$${UPDATE_REPO_LINE}" >> $@ ;\
83             echo "repo --name=ovirt-local --baseurl=$(OVIRT_LOCAL_REPO)" >> $@ \
84         )
86 keys:
87         if [ "$(_ovirt_dev)" = 1 -a -f $(AUTH_KEYS) ]; then \
88             cp -va $(AUTH_KEYS) ovirt-authorized_keys ;\
89         fi
91 SELINUX_ENFORCING=$(shell /usr/sbin/getenforce)
92 $(NVR).$(PKG_FMT): repos.ks keys
93         mkdir -p $(OVIRT_CACHE_DIR)/$(PACKAGE)-tmp
94         mkdir -p $(OVIRT_CACHE_DIR)/yum
95         ( \
96             case $(SELINUX_ENFORCING) in \
97                 Enforcing) sudo /usr/sbin/setenforce Permissive ;; \
98                 Permissive) ;; \
99                 *) if ksflatten $(PACKAGE).ks 2>/dev/null \
100                        | grep -q '^selinux --disabled'; then \
101                        echo WARNING: SELinux disabled in kickstart ;\
102                    else \
103                        echo ERROR: SELinux enabled in kickstart, \
104                        but disabled on the build machine ;\
105                        exit 1 ;\
106                    fi ;; \
107             esac ;\
108         )
109         sudo livecd-creator --skip-minimize -c $(PACKAGE).ks \
110             -f $(PACKAGE) \
111             --tmpdir='$(OVIRT_CACHE_DIR)/$(PACKAGE)-tmp' \
112             --cache='$(OVIRT_CACHE_DIR)/yum'
113         sudo chown $${USER} $(PACKAGE).$(PKG_FMT)
114         ( \
115             if [ $(SELINUX_ENFORCING) = Enforcing ]; then \
116                 sudo /usr/sbin/setenforce Enforcing || exit 1 ;\
117             fi \
118         )
120         ln -nf $(PACKAGE).$(PKG_FMT) $(NVR).$(PKG_FMT)
122 $(NVR).$(PKG_FMT).$(SUM): $(NVR).$(PKG_FMT)
123         $(SUM) $(NVR).$(PKG_FMT) > $(NVR).$(PKG_FMT).$(SUM)
125 $(PACKAGE).$(PKG_FMT) node: $(NVR).$(PKG_FMT).$(SUM)
127 rpms: dist node
128         rpmbuild $(RPM_FLAGS) -ts $(distdir).tar.gz
129         rpmbuild $(RPM_FLAGS) --define "source_iso 1" -tb $(distdir).tar.gz
131 publish: rpms
132         mkdir -p $(OVIRT_CACHE_DIR)
133         rsync -aq $(shell rpm --eval '%{_rpmdir}')/ $(OVIRT_CACHE_DIR)/ovirt/
134         rsync -aq $(shell rpm --eval '%{_srcrpmdir}')/ $(OVIRT_CACHE_DIR)/ovirt/src
135         createrepo $(OVIRT_CACHE_DIR)/ovirt
137 .PHONY: rpms publish $(NVR).$(PKG_FMT).$(SUM) $(NVR).$(PKG_FMT) \
138   $(PACKAGE).$(PKG_FMT) keys repos.ks