[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]

[Ovirt-devel] [PATCH node] refactor node image recipe



top-level kickstart file contains only includes,
example custom-template.ks is provided with documented customization
points.

Signed-off-by: Alan Pevec <apevec redhat com>
---
 recipe/Makefile.am             |   29 +++++++----
 recipe/common-manifest-post.ks |   31 +++++++++++
 recipe/common-manifest-pre.ks  |   11 ++++
 recipe/common-post-nochroot.ks |   46 ++++++++++++++++
 recipe/common-post.ks          |   24 +++++++++
 recipe/custom-template.ks      |   33 ++++++++++++
 recipe/ovirt-node-image.ks     |  111 ++--------------------------------------
 7 files changed, 168 insertions(+), 117 deletions(-)
 create mode 100644 recipe/common-manifest-post.ks
 create mode 100644 recipe/common-manifest-pre.ks
 create mode 100644 recipe/common-post-nochroot.ks
 create mode 100644 recipe/custom-template.ks

diff --git a/recipe/Makefile.am b/recipe/Makefile.am
index d09905a..fe116f6 100644
--- a/recipe/Makefile.am
+++ b/recipe/Makefile.am
@@ -36,21 +36,28 @@ SUM               ?= sha1sum
 AUTH_KEYS         ?= $(HOME)/.ssh/authorized_keys
 
 OVIRT_NODE_TOOLSdir = $(datadir)/ovirt-node-tools
-OVIRT_NODE_TOOLS_DATA = 	\
-        repos.ks        	\
+OVIRT_NODE_TOOLS_DATA =         \
+        repos.ks                \
+        common-manifest-pre.ks  \
         common-blacklist.ks     \
+        common-manifest-post.ks \
         common-install.ks       \
-        common-pkgs.ks  	\
-        common-post.ks  	\
-        ovirt-node-image.ks	\
+        common-pkgs.ks          \
+        common-post.ks          \
+        common-post-nochroot.ks \
+        ovirt-node-image.ks     \
         ovirt-node-recipe.ks
 
-EXTRA_DIST= 			\
-	common-blacklist.ks	\
-	common-install.ks	\
-	common-pkgs.ks		\
-	common-post.ks		\
-	ovirt-node-image.ks
+
+EXTRA_DIST =                    \
+        common-manifest-pre.ks  \
+        common-blacklist.ks     \
+        common-manifest-post.ks \
+        common-install.ks       \
+        common-pkgs.ks          \
+        common-post.ks          \
+        common-post-nochroot.ks \
+        ovirt-node-image.ks
 
 repos.ks:
 	( \
diff --git a/recipe/common-manifest-post.ks b/recipe/common-manifest-post.ks
new file mode 100644
index 0000000..020f3a0
--- /dev/null
+++ b/recipe/common-manifest-post.ks
@@ -0,0 +1,31 @@
+%post
+# Create post-image processing manifests
+manifests=/tmp/manifests
+mkdir -p $manifests
+rpm -qa --qf '%{name}-%{version}-%{release}.%{arch}\n' | sort \
+    > $manifests/rpm-manifest-post.txt
+rpm -qa --qf '%{sourcerpm}\n' | sort -u > $manifests/srpm-manifest-post.txt
+du -akx --exclude=/var/cache/yum / > $manifests/file-manifest-post.txt
+du -x --exclude=/var/cache/yum / > $manifests/dir-manifest-post.txt
+
+ver=$(rpm -q --qf '%{version}' ovirt-node)
+rel=$(rpm -q --qf '%{release}' ovirt-node)
+arch=$(rpm -q --qf '%{arch}' ovirt-node)
+echo "oVirt Node release $ver-$rel-$arch" > $manifests/ovirt-release
+tar -cvf ovirt-node-image-manifests-$ver-$rel.$arch.tar -C /tmp manifests
+ln -nf ovirt-node-image-manifests-$ver-$rel.$arch.tar ovirt-node-image-manifests.tar
+rm -Rf $manifests
+%end
+
+%post --nochroot
+# Move manifest tar to build directory
+mv $INSTALL_ROOT/ovirt-node-image-manifests*.tar .
+
+# only works on x86, x86_64
+if [ "$(uname -i)" = "i386" -o "$(uname -i)" = "x86_64" ]; then
+    if [ ! -d $LIVE_ROOT/LiveOS ]; then mkdir -p $LIVE_ROOT/LiveOS ; fi
+    cp /usr/bin/livecd-iso-to-disk $LIVE_ROOT/LiveOS
+    cp /usr/bin/livecd-iso-to-pxeboot $LIVE_ROOT/LiveOS
+fi
+%end
+
diff --git a/recipe/common-manifest-pre.ks b/recipe/common-manifest-pre.ks
new file mode 100644
index 0000000..c88f0cc
--- /dev/null
+++ b/recipe/common-manifest-pre.ks
@@ -0,0 +1,11 @@
+%post
+# Create initial manifests
+manifests=/tmp/manifests
+mkdir -p $manifests
+rpm -qa --qf '%{name}-%{version}-%{release}.%{arch}\n' | sort \
+    > $manifests/rpm-manifest.txt
+rpm -qa --qf '%{sourcerpm}\n' | sort -u > $manifests/srpm-manifest.txt
+du -akx --exclude=/var/cache/yum / > $manifests/file-manifest.txt
+du -x --exclude=/var/cache/yum / > $manifests/dir-manifest.txt
+%end
+
diff --git a/recipe/common-post-nochroot.ks b/recipe/common-post-nochroot.ks
new file mode 100644
index 0000000..a3f5071
--- /dev/null
+++ b/recipe/common-post-nochroot.ks
@@ -0,0 +1,46 @@
+if [ -f "ovirt-authorized_keys" ]; then
+  echo "Adding authorized_keys to Image"
+  mkdir -p $INSTALL_ROOT/root/.ssh
+  cp -v ovirt-authorized_keys $INSTALL_ROOT/root/.ssh/authorized_keys
+  chown -R root:root $INSTALL_ROOT/root/.ssh
+  chmod 755 $INSTALL_ROOT/root/.ssh
+  chmod 644 $INSTALL_ROOT/root/.ssh/authorized_keys
+fi
+
+echo "Fixing boot menu"
+# remove quiet from Node bootparams, added by livecd-creator
+sed -i -e 's/ quiet//' $LIVE_ROOT/isolinux/isolinux.cfg
+
+# add stand-alone boot entry
+awk '
+BEGIN {
+  # append additional default boot parameters
+  add_boot_params="check"
+}
+/^label linux0/ { linux0=1 }
+linux0==1 && $1=="append" {
+  $0=$0 " " add_boot_params
+  append0=$0
+}
+linux0==1 && $1=="label" && $2!="linux0" {
+  linux0=2
+  print "label stand-alone"
+  print "  menu label Boot in stand-alone mode"
+  print "  kernel vmlinuz0"
+  gsub("console=tty0", "", append0)
+  print append0" ovirt_standalone console=tty0"
+}
+{ print }
+' $LIVE_ROOT/isolinux/isolinux.cfg > $LIVE_ROOT/isolinux/isolinux.cfg.standalone
+mv $LIVE_ROOT/isolinux/isolinux.cfg.standalone $LIVE_ROOT/isolinux/isolinux.cfg
+
+cp $INSTALL_ROOT/usr/share/ovirt-node/syslinux-vesa-splash.jpg $LIVE_ROOT/isolinux/splash.jpg
+
+# overwrite user visible banners with the image versioning info
+PACKAGE=ovirt
+ln -snf $PACKAGE-release $INSTALL_ROOT/etc/redhat-release
+ln -snf $PACKAGE-release $INSTALL_ROOT/etc/system-release
+cp $INSTALL_ROOT/etc/$PACKAGE-release $INSTALL_ROOT/etc/issue
+echo "Kernel \r on an \m (\l)" >> $INSTALL_ROOT/etc/issue
+cp $INSTALL_ROOT/etc/issue $INSTALL_ROOT/etc/issue.net
+
diff --git a/recipe/common-post.ks b/recipe/common-post.ks
index 411e565..fed5b6b 100644
--- a/recipe/common-post.ks
+++ b/recipe/common-post.ks
@@ -3,6 +3,9 @@ echo "Starting Kickstart Post"
 PATH=/sbin:/usr/sbin:/bin:/usr/bin
 export PATH
 
+# cleanup rpmdb to allow non-matching host and chroot RPM versions
+rm -f /var/lib/rpm/__db*
+
 # Import SELinux Modules
 echo "Enabling selinux modules"
 SEMODULES="base automount avahi consolekit cyrus dhcp dnsmasq guest hal ipsec \
@@ -196,3 +199,24 @@ EOF
 # Need this for F12 findfs calls
 # Otherwise, findfs returns /dev/sdX instead of /dev/mapper/<wwid>
 echo "EVALUATE=scan" > /etc/blkid.conf
+
+touch /.autorelabel
+
+# prepare for STATE_MOUNT in rc.sysinit
+augtool <<\EOF
+set /files/etc/sysconfig/readonly-root/TEMPORARY_STATE NOT_OVIRT_FIRSTBOOT
+set /files/etc/sysconfig/readonly-root/STATE_LABEL CONFIG
+set /files/etc/sysconfig/readonly-root/STATE_MOUNT /config
+set /files/etc/sysconfig/readonly-root/READONLY yes
+save
+EOF
+# use persistent state unless firstboot is forced
+# XXX auges shellvars lens does not accept this value
+sed -i 's NOT_OVIRT_FIRSTBOOT@$(if cat /proc/cmdline|grep -qv ovirt_firstboot; then printf "yes"; else printf "no"; fi)@' /etc/sysconfig/readonly-root
+# prepare mount points for local storage
+mkdir -p /boot
+mkdir -p /config
+mkdir -p /data
+mkdir -p /liveos
+echo "/dev/HostVG/Config /config ext3 defaults,noauto,noatime 0 0" >> /etc/fstab
+
diff --git a/recipe/custom-template.ks b/recipe/custom-template.ks
new file mode 100644
index 0000000..70d084b
--- /dev/null
+++ b/recipe/custom-template.ks
@@ -0,0 +1,33 @@
+# oVirt Node image recipe
+# This an example TEMPLATE for customizations.
+
+%include common-install.ks
+# add custom installation directives here
+
+%include repos.ks
+# add custom repos here
+
+%packages --excludedocs --nobase
+%include common-pkgs.ks
+# add custom package list here
+
+%end
+
+%post
+%include common-post.ks
+# add custom post-scripts here
+
+%end
+
+%include common-manifest-pre.ks
+
+%include common-blacklist.ks
+
+%post --nochroot
+%include common-post-nochroot.ks
+# add custom post-scripts running outside image chroot here
+
+%end
+
+%include common-manifest-post.ks
+
diff --git a/recipe/ovirt-node-image.ks b/recipe/ovirt-node-image.ks
index 7c9361c..6fad5cd 100644
--- a/recipe/ovirt-node-image.ks
+++ b/recipe/ovirt-node-image.ks
@@ -1,3 +1,5 @@
+# oVirt Node image recipe
+
 %include common-install.ks
 
 %include repos.ks
@@ -8,121 +10,18 @@
 %end
 
 %post
-# cleanup rpmdb to allow non-matching host and chroot RPM versions
-rm -f /var/lib/rpm/__db*
 %include common-post.ks
 
-touch /.autorelabel
-
-# prepare for STATE_MOUNT in rc.sysinit
-augtool <<\EOF
-set /files/etc/sysconfig/readonly-root/TEMPORARY_STATE NOT_OVIRT_FIRSTBOOT
-set /files/etc/sysconfig/readonly-root/STATE_LABEL CONFIG
-set /files/etc/sysconfig/readonly-root/STATE_MOUNT /config
-set /files/etc/sysconfig/readonly-root/READONLY yes
-save
-EOF
-# use persistent state unless firstboot is forced
-# XXX auges shellvars lens does not accept this value
-sed -i 's NOT_OVIRT_FIRSTBOOT@$(if cat /proc/cmdline|grep -qv ovirt_firstboot; then printf "yes"; else printf "no"; fi)@' /etc/sysconfig/readonly-root
-# prepare mount points for local storage
-mkdir -p /boot
-mkdir -p /config
-mkdir -p /data
-mkdir -p /liveos
-echo "/dev/HostVG/Config /config ext3 defaults,noauto,noatime 0 0" >> /etc/fstab
 %end
 
-%post
-# Create initial manifests
-manifests=/tmp/manifests
-mkdir -p $manifests
-rpm -qa --qf '%{name}-%{version}-%{release}.%{arch}\n' | sort \
-    > $manifests/rpm-manifest.txt
-rpm -qa --qf '%{sourcerpm}\n' | sort -u > $manifests/srpm-manifest.txt
-du -akx --exclude=/var/cache/yum / > $manifests/file-manifest.txt
-du -x --exclude=/var/cache/yum / > $manifests/dir-manifest.txt
-%end
+%include common-manifest-pre.ks
 
 %include common-blacklist.ks
 
 %post --nochroot
-if [ -f "ovirt-authorized_keys" ]; then
-  echo "Adding authorized_keys to Image"
-  mkdir -p $INSTALL_ROOT/root/.ssh
-  cp -v ovirt-authorized_keys $INSTALL_ROOT/root/.ssh/authorized_keys
-  chown -R root:root $INSTALL_ROOT/root/.ssh
-  chmod 755 $INSTALL_ROOT/root/.ssh
-  chmod 644 $INSTALL_ROOT/root/.ssh/authorized_keys
-fi
-
-echo "Fixing boot menu"
-# remove quiet from Node bootparams, added by livecd-creator
-sed -i -e 's/ quiet//' $LIVE_ROOT/isolinux/isolinux.cfg
-
-# add stand-alone boot entry
-awk '
-BEGIN {
-  # append additional default boot parameters
-  add_boot_params="check"
-}
-/^label linux0/ { linux0=1 }
-linux0==1 && $1=="append" {
-  $0=$0 " " add_boot_params
-  append0=$0
-}
-linux0==1 && $1=="label" && $2!="linux0" {
-  linux0=2
-  print "label stand-alone"
-  print "  menu label Boot in stand-alone mode"
-  print "  kernel vmlinuz0"
-  gsub("console=tty0", "", append0)
-  print append0" ovirt_standalone console=tty0"
-}
-{ print }
-' $LIVE_ROOT/isolinux/isolinux.cfg > $LIVE_ROOT/isolinux/isolinux.cfg.standalone
-mv $LIVE_ROOT/isolinux/isolinux.cfg.standalone $LIVE_ROOT/isolinux/isolinux.cfg
-
-cp $INSTALL_ROOT/usr/share/ovirt-node/syslinux-vesa-splash.jpg $LIVE_ROOT/isolinux/splash.jpg
-
-# overwrite user visible banners with the image versioning info
-PACKAGE=ovirt
-ln -snf $PACKAGE-release $INSTALL_ROOT/etc/redhat-release
-ln -snf $PACKAGE-release $INSTALL_ROOT/etc/system-release
-cp $INSTALL_ROOT/etc/$PACKAGE-release $INSTALL_ROOT/etc/issue
-echo "Kernel \r on an \m (\l)" >> $INSTALL_ROOT/etc/issue
-cp $INSTALL_ROOT/etc/issue $INSTALL_ROOT/etc/issue.net
+%include common-post-nochroot.ks
 
 %end
 
-%post
-# Create post-image processing manifests
-manifests=/tmp/manifests
-mkdir -p $manifests
-rpm -qa --qf '%{name}-%{version}-%{release}.%{arch}\n' | sort \
-    > $manifests/rpm-manifest-post.txt
-rpm -qa --qf '%{sourcerpm}\n' | sort -u > $manifests/srpm-manifest-post.txt
-du -akx --exclude=/var/cache/yum / > $manifests/file-manifest-post.txt
-du -x --exclude=/var/cache/yum / > $manifests/dir-manifest-post.txt
-
-ver=$(rpm -q --qf '%{version}' ovirt-node)
-rel=$(rpm -q --qf '%{release}' ovirt-node)
-arch=$(rpm -q --qf '%{arch}' ovirt-node)
-echo "oVirt Node release $ver-$rel-$arch" > $manifests/ovirt-release
-tar -cvf ovirt-node-image-manifests-$ver-$rel.$arch.tar -C /tmp manifests
-ln -nf ovirt-node-image-manifests-$ver-$rel.$arch.tar ovirt-node-image-manifests.tar
-rm -Rf $manifests
-%end
-
-%post --nochroot
-# Move manifest tar to build directory
-mv $INSTALL_ROOT/ovirt-node-image-manifests*.tar .
-
-# only works on x86, x86_64
-if [ "$(uname -i)" = "i386" -o "$(uname -i)" = "x86_64" ]; then
-    if [ ! -d $LIVE_ROOT/LiveOS ]; then mkdir -p $LIVE_ROOT/LiveOS ; fi
-    cp /usr/bin/livecd-iso-to-disk $LIVE_ROOT/LiveOS
-    cp /usr/bin/livecd-iso-to-pxeboot $LIVE_ROOT/LiveOS
-fi
-%end
+%include common-manifest-post.ks
 
-- 
1.6.0.6


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]