top-level kickstart file contains only includes, example custom-template.ks is provided with documented customization points. Signed-off-by: Alan Pevec <apevec at redhat.com> --- recipe/common-manifest-post.ks | 31 +++++++++++ recipe/common-manifest-pre.ks | 11 ++++ recipe/common-post-chroot.ks | 46 ++++++++++++++++ recipe/common-post.ks | 24 +++++++++ recipe/custom-template.ks | 33 ++++++++++++ recipe/ovirt-node-image.ks | 111 ++-------------------------------------- 6 files changed, 150 insertions(+), 106 deletions(-) create mode 100644 recipe/common-manifest-post.ks create mode 100644 recipe/common-manifest-pre.ks create mode 100644 recipe/common-post-chroot.ks create mode 100644 recipe/custom-template.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-chroot.ks b/recipe/common-post-chroot.ks new file mode 100644 index 0000000..a3f5071 --- /dev/null +++ b/recipe/common-post-chroot.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 at 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 at 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
Darryl L. Pierce
2010-Apr-13 14:44 UTC
[Ovirt-devel] [PATCH node] refactor node image recipe
On Tue, Apr 13, 2010 at 02:26:50PM +0200, Alan Pevec wrote:> top-level kickstart file contains only includes, > example custom-template.ks is provided with documented customization > points. > > Signed-off-by: Alan Pevec <apevec at redhat.com> > ---The patch works but after a few fixes were made locally. * need to add common-manifest-post.ks to recipes/Makefile.am * need to add common-manifest-pre.ks to recipes/Makefile.am * need to add common-post-chroot.ks to recipes/Makefile.am [1] * need to fix recipe/ovirt-node-image.ks to use common-post-chroot.ks [1] - I went on the assumptiong that common-post-chroot.ks and common-post-nochroot.ks are the same file. NAK until an update with the above changes is sent. -- Darryl L. Pierce, Sr. Software Engineer @ Red Hat, Inc. Delivering value year after year. Red Hat ranks #1 in value among software vendors. redhat.com/promo/vendor -------------- next part -------------- A non-text attachment was scrubbed... Name: not available Type: application/pgp-signature Size: 198 bytes Desc: not available URL: <listman.redhat.com/archives/ovirt-devel/attachments/20100413/d7e728e1/attachment.sig>
Seemingly Similar Threads
- [PATCH node 1/3] add reinstall and uninstall options to boot menu
- [PATCH node-image] kdump support
- Refactor ovirt-node-image code base for inclusion in Fedora
- Refactor ovirt-node code base for inclusion in Fedora
- [PATCH] move dracut config and patching to spec