Bumped the size of the node image to 700M.
[ovirt-node-image.git] / Makefile.am
blob2316e1e89ef69e94a9ef0a52935547ac0b87d019
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 SRC_FMT          ?= tar
24 AUTH_KEYS        ?= ~/.ssh/authorized_keys
26 FEDORA_MIRROR     = http://mirrors.fedoraproject.org/mirrorlist
27 CUR_RAWHIDE       = 13
29 FEDORA            = $(shell rpm --eval '%{fedora}')
30 ARCH              = $(shell rpm --eval '%{_arch}')
32 CUR_PREVIEW       = 12
33 PREVIEW_URL      ?= http://jforbes.fedorapeople.org/virt-preview/f$(CUR_PREVIEW)/$(ARCH)
35 NVR               = $(PACKAGE)-$(VERSION)-$(ARCH)
37 EXTRA_DIST =                            \
38   .gitignore                            \
39   $(PACKAGE).spec                       \
40   $(PACKAGE).spec.in                    \
41   common-blacklist.ks                   \
42   common-install.ks                     \
43   common-pkgs.ks                        \
44   common-post.ks                        \
45   $(PACKAGE).ks                         \
46   create-ovirt-iso-nodes                \
47   edit-livecd                           \
48   livecd-iso-to-iscsi                   \
49   livecd-setauth                        \
50   livecd-rpms                           \
51   README
53 DISTCLEANFILES = $(PACKAGE)-$(VERSION).tar.gz \
54   $(PACKAGE).$(PKG_FMT) \
55   $(NVR).$(PKG_FMT) \
56   $(NVR).$(PKG_FMT).$(SUM) \
57   repos.ks ovirt-authorized_keys
59 # For Release: 0..., set _ovirt_dev=1 so that we get extra_release.GIT-
60 # annotated rpm version strings.
61 _ovirt_dev = \
62  $(shell grep -q '^[[:space:]]*Release:[[:space:]]*0' \
63    $(srcdir)/*.spec.in && echo 1 || :)
65 git_head    = $$(git log -1 --pretty=format:%h)
66 GIT_RELEASE = $(shell date --utc +%Y%m%d%H%M%S)git$(git_head)
67 RPMDIR      = $$(rpm --eval '%{_rpmdir}')
68 RPM_FLAGS   = --define "ovirt_cache_dir $(OVIRT_CACHE_DIR)"
69 RPM_FLAGS  += $(if $(_ovirt_dev),--define "extra_release .$(GIT_RELEASE)")
70 NODE_TMP    = $(OVIRT_CACHE_DIR)/$(PACKAGE)-$(ARCH)-tmp
71 SRC_KS      = $(NODE_TMP)/src.ks
73 repos.ks:
74         ( \
75             if [ 0$(FEDORA) == 0$(CUR_RAWHIDE) ]; then \
76                 FEDORA_REPO=rawhide ;\
77                 FEDORA_REPO_LOC="$(if $(FEDORA_URL),--baseurl=$(FEDORA_URL)/development/$(ARCH)/os,--mirrorlist=$(FEDORA_MIRROR)?repo=rawhide&arch=$(ARCH))" ;\
78                 OVIRT_DISTRO=development ;\
79             else \
80                 FEDORA_REPO=f$(FEDORA) ;\
81                 FEDORA_REPO_LOC="$(if $(FEDORA_URL),--baseurl=$(FEDORA_URL)/releases/$(FEDORA)/Everything/${ARCH}/os,--mirrorlist=$(FEDORA_MIRROR)?repo=fedora-$(FEDORA)&arch=$(ARCH))" ;\
82                 OVIRT_DISTRO=$(FEDORA) ;\
83                 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))\n" ;\
84                 if [ 0$(FEDORA) == 0$(CUR_PREVIEW) ]; then \
85                     UPDATE_REPO_LINE="$${UPDATE_REPO_LINE}repo --name=preview --baseurl=$(PREVIEW_URL)\n" ;\
86                 fi ;\
87             fi ;\
88             echo "repo --name=$${FEDORA_REPO} $${FEDORA_REPO_LOC}" > $@ ;\
89             echo "repo --name=ovirt-org --baseurl=$(OVIRT_URL)/$${OVIRT_DISTRO}/$(ARCH)" >> $@ ;\
90             printf "$${UPDATE_REPO_LINE}" >> $@ ;\
91             echo "repo --name=ovirt-local --baseurl=$(OVIRT_LOCAL_REPO)" >> $@ \
92         )
94 src.ks: repos.ks
95         mkdir -p $(NODE_TMP)
96         ( \
97             cat repos.ks ;\
98             if [ 0$(FEDORA) == 0$(CUR_RAWHIDE) ]; then \
99                 FEDORA_REPO=rawhide ;\
100                 FEDORA_REPO_LOC="$(if $(FEDORA_URL),--baseurl=$(FEDORA_URL)/development/source/SRPMS,--mirrorlist=$(FEDORA_MIRROR)?repo=rawhide-source&arch=source)" ;\
101                 OVIRT_DISTRO=development ;\
102             else \
103                 FEDORA_REPO=f$(FEDORA) ;\
104                 FEDORA_REPO_LOC="$(if $(FEDORA_URL),--baseurl=$(FEDORA_URL)/releases/$(FEDORA)/Everything/source/SRPMS,--mirrorlist=$(FEDORA_MIRROR)?repo=fedora-source-$(FEDORA)&arch=source)" ;\
105                 OVIRT_DISTRO=$(FEDORA) ;\
106                 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)" ;\
107             fi ;\
108             echo "repo --name=$${FEDORA_REPO}-source $${FEDORA_REPO_LOC}" ;\
109             echo "repo --name=ovirt-org-source --baseurl=$(OVIRT_URL)/$${OVIRT_DISTRO}/src" ;\
110             echo "$${UPDATE_REPO_LINE}" ;\
111             echo "%packages --nobase" ;\
112             grep -v '^-' common-pkgs.ks ;\
113             echo "%end" ;\
114         ) > $(SRC_KS)
116 keys:
117         if [ "$(_ovirt_dev)" = 1 -a -f $(AUTH_KEYS) ]; then \
118             cp -va $(AUTH_KEYS) ovirt-authorized_keys ;\
119         fi
121 SELINUX_ENFORCING=$(shell /usr/sbin/getenforce)
122 $(NVR).$(PKG_FMT): no_nscd repos.ks keys
123         mkdir -p $(NODE_TMP)
124         mkdir -p $(OVIRT_CACHE_DIR)/yum-$(ARCH)
125         ( \
126             case $(SELINUX_ENFORCING) in \
127                 Enforcing) sudo /usr/sbin/setenforce Permissive ;; \
128                 Permissive) ;; \
129                 *) if ksflatten $(PACKAGE).ks 2>/dev/null \
130                        | grep -q '^selinux --disabled'; then \
131                        echo WARNING: SELinux disabled in kickstart ;\
132                    else \
133                        echo ERROR: SELinux enabled in kickstart, \
134                        but disabled on the build machine ;\
135                        exit 1 ;\
136                    fi ;; \
137             esac ;\
138         )
139         sudo livecd-creator --skip-minimize -c $(PACKAGE).ks \
140             -f $(PACKAGE) \
141             --tmpdir='$(NODE_TMP)' \
142             --cache='$(OVIRT_CACHE_DIR)/yum-$(ARCH)'
143         sudo chown $${USER} $(PACKAGE).$(PKG_FMT)
144         ( \
145             if [ $(SELINUX_ENFORCING) = Enforcing ]; then \
146                 sudo /usr/sbin/setenforce Enforcing || exit 1 ;\
147             fi \
148         )
150         ln -nf $(PACKAGE).$(PKG_FMT) $(NVR).$(PKG_FMT)
152 $(NVR).$(PKG_FMT).$(SUM): $(NVR).$(PKG_FMT)
153         $(SUM) $(NVR).$(PKG_FMT) > $(NVR).$(PKG_FMT).$(SUM)
155 $(PACKAGE).$(PKG_FMT) node: $(NVR).$(PKG_FMT).$(SUM)
157 PUNGI = $(NODE_TMP)/tree/pungi
158 source: src.ks
159         @sudo rm -Rf $(PUNGI)
160         @mkdir -p $(PUNGI)
162         cd $(PUNGI) && \
163             sudo pungi -G --ver=$(PACKAGE) -c $(SRC_KS) \
164             --cachedir=$(OVIRT_CACHE_DIR)/yum-$(ARCH)
165         if [ "$(SRC_FMT)" == "iso" ]; then \
166             cd $(PUNGI) && \
167                 sudo pungi --sourceiso --ver=$(PACKAGE) -c $(SRC_KS) \
168                 --cachedir=$(OVIRT_CACHE_DIR)/yum-$(ARCH) ;\
169             sudo mv $(PUNGI)/$(PACKAGE)/source/iso/Fedora-$(PACKAGE)-source.iso \
170                 $(PWD)/$(PACKAGE)-source-$(VERSION).iso ;\
171         elif [ "$(SRC_FMT)" == "tar" ]; then \
172             cd $(PUNGI)/$(PACKAGE)/source && \
173                 sudo tar cf ovirt-source.tar SRPMS ;\
174             sudo mv $(PUNGI)/$(PACKAGE)/source/ovirt-source.tar \
175                 $(PWD)/$(PACKAGE)-source-$(VERSION).tar ;\
176         else \
177             echo "Invalid src format: $(SRC_FMT)" ;\
178             exit 1 ;\
179         fi
180         sudo sudo chown -R $(USER) $(PWD)/$(PACKAGE)-source-$(VERSION).$(SRC_FMT)
181         sudo sudo chown -R $(USER) $(PUNGI)
182         $(SUM) $(PWD)/$(PACKAGE)-source-$(VERSION).$(SRC_FMT) \
183             > $(PACKAGE)-source-$(VERSION).$(SRC_FMT).$(SUM)
185 rpms: dist node
186         rpmbuild $(RPM_FLAGS) -ts $(distdir).tar.gz
187         rpmbuild $(RPM_FLAGS) --define "source_iso 1" -tb $(distdir).tar.gz
189 srpms: dist
190         rpmbuild $(RPM_FLAGS) -ts $(distdir).tar.gz
191         $(MAKE) _publish
193 iso_srpms: dist
194         rpmbuild $(RPM_FLAGS) --define "source_iso 1" -ts $(distdir).tar.gz
195         $(MAKE) _publish
197 publish: rpms _publish
199 _publish:
200         mkdir -p $(OVIRT_CACHE_DIR)
201         rsync -aq $(shell rpm --eval '%{_rpmdir}')/ $(OVIRT_CACHE_DIR)/ovirt/
202         rsync -aq $(shell rpm --eval '%{_srcrpmdir}')/ $(OVIRT_CACHE_DIR)/ovirt/src
203         createrepo $(OVIRT_CACHE_DIR)/ovirt
205 no_nscd:
206         if pgrep -xl nscd; then \
207             echo "Please stop nscd" ;\
208             exit 1 ;\
209         fi
211 .PHONY: rpms publish srpms $(NVR).$(PKG_FMT).$(SUM) $(NVR).$(PKG_FMT) \
212   $(PACKAGE).$(PKG_FMT) keys repos.ks src.ks source _publish iso_srpms \
213   no_nscd