Hi, I would like to create ovirt-node-image.iso and mount it; wrapping it within an rpm is unhelpful for our needs. Also, moving logic from .spec to Makefile is generally a good thing that shortens dev cycles. Please review the following patch and consider applying something on these lines. I hope this is the place for such requests. Regrads, Dan. commit 5f1ada4cde747eb09714d38067d3f9d20eaaf607 Author: Dan Kenigsberg <danken at qumranet.com> Date: Mon Oct 20 16:40:55 2008 +0200 Move iso-making code from spec to Makefile Signed-off-by: Dan Kenigsberg <danken at rehat.com> diff --git a/Makefile.am b/Makefile.am index 17b26c0..13421af 100644 --- a/Makefile.am +++ b/Makefile.am @@ -47,6 +47,59 @@ RPM_FLAGS += $(if $(FEDORA_URL),--define "fedora_url $(FEDORA_URL)") # OVIRT_URL env var can be set to the root of an ovirt.org mirror RPM_FLAGS += $(if $(OVIRT_URL),--define "ovirt_url $(OVIRT_URL)") +FEDORA=$(shell rpm --eval '%{fedora}') +ARCH=$(shell rpm --eval '%{_arch}') +FEDORA_MIRROR=http://mirrors.fedoraproject.org/mirrorlist +CUR_RAWHIDE=10 +OVIRT_URL=http://ovirt.org/repos/ovirt + +repos.ks: + ( \ + if [ 0$(FEDORA) == 0$(CUR_RAWHIDE) ]; then \ + FEDORA_REPO=rawhide ;\ + FEDORA_REPO_LOC="$(if $(FEDORA_URL),--baseurl=$(FEDORA_URL)/development/$(ARCH)/os,--mirrorlist=$(FEDORA_MIRROR)?repo=rawhide&arch=$(ARCH))" ;\ + OVIRT_DISTRO=development ;\ + else \ + FEDORA_REPO=f$(FEDORA) ;\ + FEDORA_REPO_LOC="$(if $(FEDORA_URL),--baseurl=$(FEDORA_URL)/releases/$(FEDORA)/Everything/${ARCH}/os,--mirrorlist=$(FEDORA_MIRROR)?repo=fedora-$(FEDORA)&arch=$(ARCH))" ;\ + OVIRT_DISTRO=$(FEDORA) ;\ + 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)&arch=$(ARCH))" ;\ + fi ;\ + echo "repo --name=$${FEDORA_REPO} $${FEDORA_REPO_LOC}" > $@ ;\ + echo "repo --name=ovirt-org --baseurl=$(OVIRT_URL)/$${OVIRT_DISTRO}/$(ARCH)" >> $@ ;\ + echo "$${UPDATE_REPO_LINE}" >> $@ ;\ + echo "repo --name=ovirt-local --baseurl=file://$(OVIRT_CACHE_DIR)/ovirt" >> $@ \ + ) + +SELINUX_ENFORCING=$(shell getenforce) +iso: repos.ks + mkdir -p $(OVIRT_CACHE_DIR)/node-image-tmp + mkdir -p $(OVIRT_CACHE_DIR)/yum + ( \ + case $(SELINUX_ENFORCING) in \ + Enforcing) setenforce Permissive ;; \ + Permissive) ;; \ + *) if ksflatten ovirt-image-node.ks 2>/dev/null \ + | grep -q '^selinux --disabled'; then \ + echo WARNING: SELinux disabled in kickstart ;\ + else \ + echo ERROR: SELinux enabled in kickstart, \ + but disabled on the build machine ;\ + exit 1 ;\ + fi ;; \ + esac ;\ + ) + sudo livecd-creator --skip-minimize -c ovirt-node-image.ks \ + -f ovirt-node-image \ + --tmpdir='$(OVIRT_CACHE_DIR)/node-image-tmp' \ + --cache='$(OVIRT_CACHE_DIR)/yum' + sudo chown $${USER} ovirt-node-image.iso + ( \ + if [ $(SELINUX_ENFORCING) = Enforcing ]; then \ + setenforce Enforcing || exit 1 ;\ + fi \ + ) + rpms: dist rpmbuild $(RPM_FLAGS) -ta $(distdir).tar.gz diff --git a/ovirt-node-image.spec.in b/ovirt-node-image.spec.in index 6f9ddac..7184c77 100644 --- a/ovirt-node-image.spec.in +++ b/ovirt-node-image.spec.in @@ -1,8 +1,3 @@ -%{!?ovirt_cache_dir: %define ovirt_cache_dir /var/tmp/ovirt-cache} -%{!?ovirt_local_repo: %define ovirt_local_repo file://%{ovirt_cache_dir}/ovirt} -%{!?ovirt_url: %define ovirt_url http://ovirt.org/repos/ovirt} -%define fedora_mirror http://mirrors.fedoraproject.org/mirrorlist - Summary: oVirt Node ISO image Name: ovirt-node-image Version: @VERSION@ @@ -35,66 +30,10 @@ The PXE boot image for oVirt Node network boot from oVirt Server. %prep %setup -q +./configure %build -%if 0%{?fedora} == 010 - # XXX current rawhide - %if "%{?fedora_url}" == "" -cat > repos.ks << EOF -repo --name=rawhide --mirrorlist=%{fedora_mirror}?repo=rawhide&arch=%{_arch} -EOF - %else -cat > repos.ks << EOF -repo --name=rawhide --baseurl=%{fedora_url}/development/%{_arch}/os -EOF - %endif -cat >> repos.ks << EOF -repo --name=ovirt-org --baseurl=%{ovirt_url}/development/%{_arch} -EOF -%else - %if "%{?fedora_url}" == "" -cat > repos.ks << EOF -repo --name=f%{fedora} --mirrorlist=%{fedora_mirror}?repo=fedora-%{fedora}&arch=%{_arch} -repo --name=f%{fedora}-updates-newkey --mirrorlist=%{fedora_mirror}?repo=updates-released-f%{fedora}.newkey&arch=%{_arch} -EOF - %else -cat > repos.ks << EOF -repo --name=f%{fedora} --baseurl=%{fedora_url}/releases/%{fedora}/Everything/%{_arch}/os -repo --name=f%{fedora}-updates-newkey --baseurl=%{fedora_url}/updates/%{fedora}/%{_arch}.newkey -EOF - %endif -cat >> repos.ks << EOF -repo --name=ovirt-org --baseurl=%{ovirt_url}/%{fedora}/%{_arch} -EOF -%endif - -cat >> repos.ks << EOF -repo --name=ovirt-local --baseurl=%{ovirt_local_repo} -EOF - -mkdir -p %{ovirt_cache_dir}/node-image-tmp -mkdir -p %{ovirt_cache_dir}/yum - -sudo su - -c "cd $(pwd) && - enforcing=\$(getenforce) - case \$enforcing in - Enforcing) setenforce Permissive ;; - Permissive) ;; - *) if ksflatten %{name}.ks 2>/dev/null \ - | grep -q '^selinux --disabled$'; then - echo WARNING: SELinux disabled in kickstart - else - echo ERROR: SELinux enabled in kickstart, \ - but disabled on the build machine - exit 1 - fi ;; - esac - livecd-creator --skip-minimize -c %{name}.ks -f %{name} \ - --tmpdir='%{ovirt_cache_dir}/node-image-tmp' \ - --cache='%{ovirt_cache_dir}/yum' - if [ \$enforcing = Enforcing ]; then - setenforce Enforcing || exit 1 - fi" +make iso sudo su - -c "cd $(pwd) && ./ovirt-pxe %{name}.iso" sudo su - -c "cd $(pwd) && chown -R $USER ."
Dan Kenigsberg wrote:> Also, moving logic from .spec to Makefile is generally a good thing that > shortens dev cycles. > Please review the following patch and consider applying something on > these lines. I hope this is the place for such requests.yes, that was on our TechnicalDebt TODO, thanks for doing it :)> +SELINUX_ENFORCING=$(shell getenforce)since we run build as non-root account, we need full path /usr/sbin/getenforce> +iso: repos.ks+ovirt-node-image.iso: repos.ks since we have known file output, it's better to use real target otherwise, iso should be listed in .PHONY> + Enforcing) setenforce Permissive ;; \need sudo /usr/sbin/setenforce Permissive I'll git-send-email your patch now with those changes.
Alan Pevec
2008-Oct-20 20:05 UTC
[Ovirt-devel] [PATCH ovirt-node-image] Move iso-making code from spec to Makefile
From: Dan Kenigsberg <danken at qumranet.com> Signed-off-by: Dan Kenigsberg <danken at redhat.com> --- Makefile.am | 53 +++++++++++++++++++++++++++++++++++++ ovirt-node-image.spec.in | 65 +-------------------------------------------- 2 files changed, 55 insertions(+), 63 deletions(-) diff --git a/Makefile.am b/Makefile.am index 17b26c0..37e52c6 100644 --- a/Makefile.am +++ b/Makefile.am @@ -47,6 +47,59 @@ RPM_FLAGS += $(if $(FEDORA_URL),--define "fedora_url $(FEDORA_URL)") # OVIRT_URL env var can be set to the root of an ovirt.org mirror RPM_FLAGS += $(if $(OVIRT_URL),--define "ovirt_url $(OVIRT_URL)") +FEDORA=$(shell rpm --eval '%{fedora}') +ARCH=$(shell rpm --eval '%{_arch}') +FEDORA_MIRROR=http://mirrors.fedoraproject.org/mirrorlist +CUR_RAWHIDE=10 +OVIRT_URL=http://ovirt.org/repos/ovirt + +repos.ks: + ( \ + if [ 0$(FEDORA) == 0$(CUR_RAWHIDE) ]; then \ + FEDORA_REPO=rawhide ;\ + FEDORA_REPO_LOC="$(if $(FEDORA_URL),--baseurl=$(FEDORA_URL)/development/$(ARCH)/os,--mirrorlist=$(FEDORA_MIRROR)?repo=rawhide&arch=$(ARCH))" ;\ + OVIRT_DISTRO=development ;\ + else \ + FEDORA_REPO=f$(FEDORA) ;\ + FEDORA_REPO_LOC="$(if $(FEDORA_URL),--baseurl=$(FEDORA_URL)/releases/$(FEDORA)/Everything/${ARCH}/os,--mirrorlist=$(FEDORA_MIRROR)?repo=fedora-$(FEDORA)&arch=$(ARCH))" ;\ + OVIRT_DISTRO=$(FEDORA) ;\ + 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)&arch=$(ARCH))" ;\ + fi ;\ + echo "repo --name=$${FEDORA_REPO} $${FEDORA_REPO_LOC}" > $@ ;\ + echo "repo --name=ovirt-org --baseurl=$(OVIRT_URL)/$${OVIRT_DISTRO}/$(ARCH)" >> $@ ;\ + echo "$${UPDATE_REPO_LINE}" >> $@ ;\ + echo "repo --name=ovirt-local --baseurl=file://$(OVIRT_CACHE_DIR)/ovirt" >> $@ \ + ) + +SELINUX_ENFORCING=$(shell /usr/sbin/getenforce) +ovirt-node-image.iso: repos.ks + mkdir -p $(OVIRT_CACHE_DIR)/node-image-tmp + mkdir -p $(OVIRT_CACHE_DIR)/yum + ( \ + case $(SELINUX_ENFORCING) in \ + Enforcing) sudo /usr/sbin/setenforce Permissive ;; \ + Permissive) ;; \ + *) if ksflatten ovirt-image-node.ks 2>/dev/null \ + | grep -q '^selinux --disabled'; then \ + echo WARNING: SELinux disabled in kickstart ;\ + else \ + echo ERROR: SELinux enabled in kickstart, \ + but disabled on the build machine ;\ + exit 1 ;\ + fi ;; \ + esac ;\ + ) + sudo livecd-creator --skip-minimize -c ovirt-node-image.ks \ + -f ovirt-node-image \ + --tmpdir='$(OVIRT_CACHE_DIR)/node-image-tmp' \ + --cache='$(OVIRT_CACHE_DIR)/yum' + sudo chown $${USER} ovirt-node-image.iso + ( \ + if [ $(SELINUX_ENFORCING) = Enforcing ]; then \ + sudo /usr/sbin/setenforce Enforcing || exit 1 ;\ + fi \ + ) + rpms: dist rpmbuild $(RPM_FLAGS) -ta $(distdir).tar.gz diff --git a/ovirt-node-image.spec.in b/ovirt-node-image.spec.in index 6f9ddac..6fb968f 100644 --- a/ovirt-node-image.spec.in +++ b/ovirt-node-image.spec.in @@ -1,8 +1,3 @@ -%{!?ovirt_cache_dir: %define ovirt_cache_dir /var/tmp/ovirt-cache} -%{!?ovirt_local_repo: %define ovirt_local_repo file://%{ovirt_cache_dir}/ovirt} -%{!?ovirt_url: %define ovirt_url http://ovirt.org/repos/ovirt} -%define fedora_mirror http://mirrors.fedoraproject.org/mirrorlist - Summary: oVirt Node ISO image Name: ovirt-node-image Version: @VERSION@ @@ -35,66 +30,10 @@ The PXE boot image for oVirt Node network boot from oVirt Server. %prep %setup -q +./configure %build -%if 0%{?fedora} == 010 - # XXX current rawhide - %if "%{?fedora_url}" == "" -cat > repos.ks << EOF -repo --name=rawhide --mirrorlist=%{fedora_mirror}?repo=rawhide&arch=%{_arch} -EOF - %else -cat > repos.ks << EOF -repo --name=rawhide --baseurl=%{fedora_url}/development/%{_arch}/os -EOF - %endif -cat >> repos.ks << EOF -repo --name=ovirt-org --baseurl=%{ovirt_url}/development/%{_arch} -EOF -%else - %if "%{?fedora_url}" == "" -cat > repos.ks << EOF -repo --name=f%{fedora} --mirrorlist=%{fedora_mirror}?repo=fedora-%{fedora}&arch=%{_arch} -repo --name=f%{fedora}-updates-newkey --mirrorlist=%{fedora_mirror}?repo=updates-released-f%{fedora}.newkey&arch=%{_arch} -EOF - %else -cat > repos.ks << EOF -repo --name=f%{fedora} --baseurl=%{fedora_url}/releases/%{fedora}/Everything/%{_arch}/os -repo --name=f%{fedora}-updates-newkey --baseurl=%{fedora_url}/updates/%{fedora}/%{_arch}.newkey -EOF - %endif -cat >> repos.ks << EOF -repo --name=ovirt-org --baseurl=%{ovirt_url}/%{fedora}/%{_arch} -EOF -%endif - -cat >> repos.ks << EOF -repo --name=ovirt-local --baseurl=%{ovirt_local_repo} -EOF - -mkdir -p %{ovirt_cache_dir}/node-image-tmp -mkdir -p %{ovirt_cache_dir}/yum - -sudo su - -c "cd $(pwd) && - enforcing=\$(getenforce) - case \$enforcing in - Enforcing) setenforce Permissive ;; - Permissive) ;; - *) if ksflatten %{name}.ks 2>/dev/null \ - | grep -q '^selinux --disabled$'; then - echo WARNING: SELinux disabled in kickstart - else - echo ERROR: SELinux enabled in kickstart, \ - but disabled on the build machine - exit 1 - fi ;; - esac - livecd-creator --skip-minimize -c %{name}.ks -f %{name} \ - --tmpdir='%{ovirt_cache_dir}/node-image-tmp' \ - --cache='%{ovirt_cache_dir}/yum' - if [ \$enforcing = Enforcing ]; then - setenforce Enforcing || exit 1 - fi" +make ovirt-node-image.iso sudo su - -c "cd $(pwd) && ./ovirt-pxe %{name}.iso" sudo su - -c "cd $(pwd) && chown -R $USER ." -- 1.5.5.1