- move node and appliance image creation to Makefiles - build-all.sh -u - upload new oVirt RPMs to the running appliance - build-all.sh -m URL - specify Fedora mirror instead of using mirrorlist Signed-off-by: Alan Pevec <apevec at redhat.com> --- build-all.sh | 179 +++++++++++++++++++++++--------- ovirt-host-creator/.gitignore | 4 +- ovirt-host-creator/Makefile | 15 ++-- ovirt-host-creator/iso-file | 1 + ovirt-host-creator/ovirt-cd | 31 ------ ovirt-host-creator/ovirt.ks | 4 +- ovirt-host-creator/repos.ks.in | 6 +- wui-appliance/.gitignore | 1 - wui-appliance/Makefile | 30 +++--- wui-appliance/create-wui-appliance.sh | 69 ++++--------- wui-appliance/repos.ks.in | 9 +- 11 files changed, 184 insertions(+), 165 deletions(-) create mode 100644 ovirt-host-creator/iso-file delete mode 100755 ovirt-host-creator/ovirt-cd diff --git a/build-all.sh b/build-all.sh index 6c0f252..d2d2c7e 100755 --- a/build-all.sh +++ b/build-all.sh @@ -2,9 +2,9 @@ # # build all oVirt components -# - create oVirt host image (livecd-creator) +# - create oVirt Node image (livecd-creator) # - create local YUM repository with ovirt-wui and ovirt-host-image-pxe RPMs -# - create oVirt admin appliance (appliance-creator) +# - create oVirt Server Suite appliance (appliance-creator) # Requires: createrepo kvm libvirt livecd-tools appliance-tools @@ -25,17 +25,22 @@ BUILD=$BASE/tmp COMMON=$BASE/common OVIRT=$BUILD/ovirt CACHE=$BUILD/cache +NAME=ovirt-appliance +IMGDIR=/var/lib/libvirt/images DEP_RPMS="createrepo kvm libvirt livecd-tools appliance-tools" usage() { case $# in 1) warn "$1"; try_h; exit 1;; esac cat <<EOF -Usage: $ME [-w] [-n] [-s] [-a] [-c] [-v git|release|none] [-e eth] +Usage: $ME [-w] [-n] [-s] [-a] [-c] [-u] [-m baseurl] [-v git|release|none] [-e eth] -w: update oVirt WUI RPMs - -n: update oVirt Managed Node RPMs - -s: include SRPMs and produce source ISO - -a: updates all (WUI, Node, Appliance) + -n: update oVirt Node RPMs + -s: download SRPMs and produce sources tarball + -a: updates all (WUI, Node, appliance) -c: cleanup local oVirt repo and YUM cache + -u: update running oVirt appliance + -m: baseurl of a Fedora mirror, default is to use mirrorlist + e.g. -m http://download.fedora.redhat.com/pub/fedora/linux -v: update version type (git, release, none) default is git -e: ethernet device to use as bridge (i.e. eth1) -h: display this help and exit @@ -52,20 +57,96 @@ bumpver() { fi } -update_wui=0 update_node=0 +# setup repository URLs +# setup_repos <kickstart include> <badpkg1> <badpkg2>... +# e.g. setup_repos $NODE/repos.ks ruby ruby-libs gtk-vnc\* +setup_repos() { + local ks_include=$1 + + # use Fedora + updates - those marked bad + currentbadupdates='' + for p in $@; do + currentbadupdates="$currentbadupdates --excludepkgs=$p" + done + fedora_mirror=http://mirrors.fedoraproject.org/mirrorlist + printf "repo --name=f$F_REL" > $ks_include + if [ -n "$fedora_url" ]; then + cat >> $ks_include << EOF + --baseurl=$fedora_url/releases/$F_REL/Everything/\$basearch/os +EOF + else + cat >> $ks_include << EOF + --mirrorlist=$fedora_mirror?repo=fedora-$F_REL&arch=\$basearch +EOF + fi + printf "repo --name=f$F_REL-updates" >> $ks_include + if [ -n "$fedora_url" ]; then + cat >> $ks_include << EOF + --baseurl=$fedora_url/updates/$F_REL/\$basearch \ + $currentbadupdates +EOF + else + cat >> $ks_include << EOF + --mirrorlist=$fedora_mirror?repo=updates-released-f$F_REL&arch=\$basearch \ + $currentbadupdates +EOF + fi + # + ovirt.org repo for updates not yet in Fedora + # + local ovirt repo with locally rebuilt ovirt* RPMs ( options -w and -n ) + # if not available, ovirt* RPMs from ovirt.org will be used + excludepkgs+ if [[ -f $OVIRT/repodata/repomd.xml ]]; then + excludepkgs='--excludepkgs=ovirt*' + cat >> $ks_include << EOF +repo --name=ovirt --baseurl=file://$OVIRT +EOF + fi + cat >> $ks_include << EOF +repo --name=ovirt-org \ + --baseurl=http://ovirt.org/repos/ovirt/$F_REL/\$basearch $excludepkgs +EOF +} + +update_running_appliance() { + local rpmfile=$1 + + local services_rpm=ovirt-wui + local services_list='ovirt-mongrel-rails ovirt-host-* ovirt-taskomatic' + + if [ $upload_rpms = 1 ]; then + pkg=$(basename $rpmfile) + cat $rpmfile | ssh root at 192.168.50.2 \ + "cat > $pkg; yum -y --nogpgcheck localupdate $pkg; + if [ $pkg != ${pkg#$services_rpm} ]; then + cd /etc/init.d + for s in $services_list; do + if service \$s status > /dev/null; then + service \$s restart + fi + done + fi" + fi +} + +update_wui=0 +update_node=0 update_app=0 +upload_rpms=0 include_src=0 +fedora_url cleanup=0 version_type=git bridge err=0 help=0 -while getopts wnsacv:e:h c; do +while getopts wnsacum:v:e:h c; do case $c in w) update_wui=1;; n) update_node=1;; s) include_src=1;; a) update_wui=1; update_node=1; update_app=1;; c) cleanup=1;; + u) upload_rpms=1;; + m) fedora_url=$OPTARG;; v) version_type=$OPTARG;; e) bridge=$OPTARG;; h) help=1;; @@ -81,11 +162,14 @@ test "$version_type" != "git" -a "$version_type" != "release" \ && usage "version type must be git, release or none" if [ $update_node = 1 -o $update_app = 1 ]; then - test $( id -u ) -ne 0 && die "Node or Application Update must run as root" + test $( id -u ) -ne 0 && die "Node or Appliance update must run as root" fi +test $upload_rpms = 1 && "$(virsh domstate $NAME 2> /dev/null)" != "running" \ + && die "oVirt appliance is not running" + # now make sure the packages we need are installed -rpm -q $DEP_RPMS >& /dev/null +rpm -q $DEP_RPMS > /dev/null 2>&1 if [ $? -ne 0 ]; then # one of the previous packages wasn't installed; bail out die "Must have $DEP_RPMS installed" @@ -132,52 +216,23 @@ if [ $cleanup = 1 ]; then rm -rf $CACHE/* fi - # stop execution on any error set -e # build ovirt-wui RPM if [ $update_wui = 1 ]; then - cd $BASE/wui rm -rf rpm-build bumpver make rpms rm -f $OVIRT/ovirt-wui*rpm cp rpm-build/ovirt-wui*rpm $OVIRT - cd $OVIRT createrepo . + update_running_appliance $OVIRT/ovirt-wui*.noarch.rpm fi -fedora_mirror=http://mirrors.fedoraproject.org/mirrorlist -# use Fedora + updates -currentbadupdates='' -cat > $NODE/repos.ks << EOF -repo --name=f$F_REL \ - --mirrorlist=$fedora_mirror?repo=fedora-$F_REL&arch=\$basearch -repo --name=f$F_REL-updates \ - --mirrorlist=$fedora_mirror?repo=updates-released-f$F_REL&arch=\$basearch \ - $currentbadupdates -EOF -# + ovirt.org repo for updates not yet in Fedora -# + local ovirt repo with locally rebuilt ovirt* RPMs ( options -w and -n ) -# if not available, ovirt* RPMs from ovirt.org will be used -excludepkgs-if [[ -f $OVIRT/repodata/repomd.xml ]]; then - excludepkgs='--excludepkgs=ovirt*' - cat >> $NODE/repos.ks << EOF -repo --name=ovirt --baseurl=file://$OVIRT -EOF -fi -cat >> $NODE/repos.ks << EOF -repo --name=ovirt-org \ - --baseurl=http://ovirt.org/repos/ovirt/$F_REL/\$basearch $excludepkgs -EOF - -# build oVirt host image; note that we unconditionally rebuild the -# ovirt-managed-node RPM, since it is now needed for the managed node -# NOTE: livecd-tools must run as root +# build oVirt Node image if [ $update_node = 1 ]; then cd $BASE/ovirt-managed-node rm -rf rpm-build @@ -191,21 +246,42 @@ if [ $update_node = 1 ]; then cd $NODE rm -rf rpm-build bumpver + make distclean + setup_repos $NODE/repos.ks make rpms YUMCACHE=$CACHE rm -f $OVIRT/ovirt-host-image*rpm cp rpm-build/ovirt-host-image*rpm $OVIRT cd $OVIRT createrepo . + update_running_appliance $OVIRT/ovirt-host-image-pxe*.$ARCH.rpm fi # build sources tarball if [ $include_src != 0 ]; then - cat $NODE/repos.ks - > $BUILD/src.ks << EOF -repo --name=f$F_REL-src \ + setup_repos $BUILD/src.ks + printf "repo --name=f$F_REL-src" >> $BUILD/src.ks + if [ -n "$fedora_url" ]; then + cat >> $BUILD/src.ks << EOF + --baseurl=$fedora_url/releases/$F_REL/Everything/source/SRPMS +EOF + else + cat >> $BUILD/src.ks << EOF --mirrorlist=$fedora_mirror?repo=fedora-source-$F_REL&arch=src -repo --name=f$F_REL-updates-src \ +EOF + fi + printf "repo --name=f$F_REL-updates-src" >> $BUILD/src.ks + if [ -n "$fedora_url" ]; then + cat >> $BUILD/src.ks << EOF + --baseurl=$fedora_url/updates/$F_REL/SRPMS + $currentbadupdates +EOF + else + cat >> $BUILD/src.ks << EOF --mirrorlist=$fedora_mirror?repo=updates-released-source-f$F_REL&arch=src \ $currentbadupdates +EOF + fi + cat >> $BUILD/src.ks << EOF repo --name=ovirt-org-src \ --baseurl=http://ovirt.org/repos/ovirt/$F_REL/src $excludepkgs @@ -221,20 +297,21 @@ EOF tar cf ovirt-source.tar SRPMS fi -# build oVirt admin appliance +# build oVirt Server Suite appliance if [ $update_app == 1 ]; then cd $WUI - make clean - cp $NODE/repos.ks $WUI/repos.ks - make + make distclean + setup_repos $WUI/repos.ks + make appliance YUMCACHE=$CACHE NAME=$NAME + printf "Moving the image..." + mv $NAME-sda.raw $IMGDIR + restorecon -v $IMGDIR/$NAME.img bridge_flag if [ -n "$bridge" ]; then bridge_flag="-e $bridge" fi - ./create-wui-appliance.sh -y $CACHE \ - -k wui-rel.ks \ - $bridge_flag + ./create-wui-appliance.sh -d $IMGDIR -n $NAME $bridge_flag fi diff --git a/ovirt-host-creator/.gitignore b/ovirt-host-creator/.gitignore index dee1a01..77f0929 100644 --- a/ovirt-host-creator/.gitignore +++ b/ovirt-host-creator/.gitignore @@ -1,6 +1,4 @@ -iso-file -*.iso +ovirt.iso tftpboot rpm-build -ovirt-cd.log repos.ks diff --git a/ovirt-host-creator/Makefile b/ovirt-host-creator/Makefile index b4c94d6..3a2d74a 100644 --- a/ovirt-host-creator/Makefile +++ b/ovirt-host-creator/Makefile @@ -1,3 +1,5 @@ +YUMCACHE=$$(pwd)/../tmp/cache + pkg_name = ovirt-host-image all: rpms @@ -7,17 +9,16 @@ clean: rm -rf ovirt-host-image-* ovirt-cd.log distclean: clean - rm -rf *.iso repos.ks rpm-build iso-file + rm -rf *.iso repos.ks rpm-build repos.ks: repos.ks.in - sed "s/@@ARCH@@/$(ARCH)/" repos.ks.in > repos.ks + cp repos.ks.in repos.ks -build: ovirt.ks common-install.ks common-pkgs.ks common-post.ks repos.ks +ovirt.iso: ovirt.ks common-install.ks common-pkgs.ks common-post.ks repos.ks ../common/rpm-compare.py GE 0 livecd-tools 017.1 1 - ./ovirt-cd $(YUMCACHE) + livecd-creator --cache=$(YUMCACHE) --skip-minimize -c ovirt.ks -f ovirt -tar: clean build - mv $$(cat iso-file) ovirt.iso +tar: clean ovirt.iso mkdir -p $(NV) cp -a ovirt-host-image.spec ovirt-pxe ovirt-flash ovirt-flash-static ovirt.iso $(NV) mkdir -p rpm-build @@ -25,4 +26,4 @@ tar: clean build cp version rpm-build/ rm -rf $(NV) -.PHONY: all clean build tar distclean +.PHONY: all clean tar distclean diff --git a/ovirt-host-creator/iso-file b/ovirt-host-creator/iso-file new file mode 100644 index 0000000..28b3530 --- /dev/null +++ b/ovirt-host-creator/iso-file @@ -0,0 +1 @@ +ovirt-200808152256.iso diff --git a/ovirt-host-creator/ovirt-cd b/ovirt-host-creator/ovirt-cd deleted file mode 100755 index 9a2ba8f..0000000 --- a/ovirt-host-creator/ovirt-cd +++ /dev/null @@ -1,31 +0,0 @@ -#!/bin/bash -# -# Create an Ovirt Host LiveCD -# Copyright 2008 Red Hat, Inc. -# Written by Chris Lalancette <clalance at redhat.com> -# -# This program is free software; you can redistribute it and/or modify -# it under the terms of the GNU General Public License as published by -# the Free Software Foundation; version 2 of the License. -# -# This program is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU Library General Public License for more details. -# -# You should have received a copy of the GNU General Public License -# along with this program; if not, write to the Free Software -# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. - -PATH=/sbin:/bin:/usr/bin - -KICKSTART=ovirt.ks -CACHE-if [ -n "$1" ]; then - CACHE=--cache=$1 -fi - -LABEL=ovirt-`date +%Y%m%d%H%M` -livecd-creator $CACHE --skip-minimize -c $KICKSTART -f $LABEL 1>&2 && - -echo $LABEL.iso > iso-file diff --git a/ovirt-host-creator/ovirt.ks b/ovirt-host-creator/ovirt.ks index e58176a..afa4d68 100644 --- a/ovirt-host-creator/ovirt.ks +++ b/ovirt-host-creator/ovirt.ks @@ -2,9 +2,11 @@ %include repos.ks -%packages --excludedocs +%packages --excludedocs --nobase %include common-pkgs.ks +%end + %post %include common-post.ks diff --git a/ovirt-host-creator/repos.ks.in b/ovirt-host-creator/repos.ks.in index 0a5cb52..79a8cef 100644 --- a/ovirt-host-creator/repos.ks.in +++ b/ovirt-host-creator/repos.ks.in @@ -1,3 +1,3 @@ -repo --name=f9 --mirrorlist=http://mirrors.fedoraproject.org/mirrorlist?repo=fedora-9&arch=@@ARCH@@ -repo --name=f9-updates --mirrorlist=http://mirrors.fedoraproject.org/mirrorlist?repo=updates-released-f9&arch=@@ARCH@@ -repo --name=ovirt --baseurl=http://ovirt.org/repos/ovirt/9/@@ARCH@@ +repo --name=f9 --mirrorlist=http://mirrors.fedoraproject.org/mirrorlist?repo=fedora-9&arch=$basearch +repo --name=f9-updates --mirrorlist=http://mirrors.fedoraproject.org/mirrorlist?repo=updates-released-f9&arch=$basearch +repo --name=ovirt --baseurl=http://ovirt.org/repos/ovirt/9/$basearch diff --git a/wui-appliance/.gitignore b/wui-appliance/.gitignore index 13842ee..4f7b1f4 100644 --- a/wui-appliance/.gitignore +++ b/wui-appliance/.gitignore @@ -1,3 +1,2 @@ -wui-rel.ks repos.ks ovirt-appliance.xml diff --git a/wui-appliance/Makefile b/wui-appliance/Makefile index b023622..d912105 100644 --- a/wui-appliance/Makefile +++ b/wui-appliance/Makefile @@ -1,21 +1,25 @@ -all: ks +NAME=ovirt-appliance +YUMCACHE=$$(pwd)/../tmp/cache -ARCH := $(shell uname -i) +appliance: $(NAME)-sda.raw -ks: wui-rel.ks +appliance-compressed: $(NAME)-sda.qcow -define ks-flatten - rm -f $@ $@-t - ksflatten $< > $@-t - chmod a=r $@-t - mv $@-t $@ -endef +$(NAME)-sda.raw: wui-devel.ks common-install.ks common-pkgs.ks common-post.ks repos.ks + appliance-creator --config wui-devel.ks --name $(NAME) \ + --tmpdir=$$(pwd)/tmp --cache=$(YUMCACHE) -wui-rel.ks: wui-devel.ks repos.ks - $(ks-flatten) +$(NAME)-sda.qcow: $(NAME)-sda.raw + # FIXME add --compress option to appliance-creator + qemu-img convert -c $(NAME)-sda.raw -O qcow2 $(NAME)-sda.qcow repos.ks: repos.ks.in - sed "s/@@ARCH@@/$(ARCH)/" repos.ks.in > repos.ks + cp repos.ks.in repos.ks clean: - rm -f repos.ks wui-rel.ks *~ + rm -f repos.ks + +distclean: clean + rm -rf $(NAME)-sda.raw $(NAME)-sda.qcow + +.PHONY: appliance appliance-compressed clean distclean diff --git a/wui-appliance/create-wui-appliance.sh b/wui-appliance/create-wui-appliance.sh index 1683237..2527675 100755 --- a/wui-appliance/create-wui-appliance.sh +++ b/wui-appliance/create-wui-appliance.sh @@ -6,54 +6,44 @@ try_h() { printf "Try \`$ME -h' for more information.\n" >&2; } die() { warn "$@"; try_h; exit 1; } RAM=768 -IMGSIZE=6000M IMGDIR_DEFAULT=/var/lib/libvirt/images +NAME_DEFAULT=ovirt-appliance NET_SCRIPTS=/etc/sysconfig/network-scripts -NAME=ovirt-appliance BRIDGENAME=ovirtbr imgdir=$IMGDIR_DEFAULT +name=$NAME_DEFAULT usage() { case $# in 1) warn "$1"; try_h; exit 1;; esac cat <<EOF -Usage: $ME [-c] [-d image_dir] [-y yumcachedir] [-k kickstart] [-e eth] - -c: compress the image (qcow2 compressed) +Usage: $ME [-d image_dir] [-n name] [-e eth] -d: directory to place virtual disk (default: $IMGDIR_DEFAULT) - -y: YUM cache directory to use - -k: appliance kickstart file + -n: appliance name (default: $NAME_DEFAULT) -e: ethernet device to use as bridge (i.e. eth1) -h: display this help and exit EOF } err=0 help=0 -compress=0 bridge-kickstart-yumcache-while getopts :cd:y:k:e:h c; do +while getopts :d:e:n:h c; do case $c in - c) compress=1;; d) imgdir=$OPTARG;; - y) yumcache=--cache=$OPTARG;; - k) kickstart=$OPTARG;; e) bridge=$OPTARG;; + n) name=$OPTARG;; h) help=1;; '?') err=1; warn "invalid option: \`-$OPTARG'";; :) err=1; warn "missing argument to \`-$OPTARG' option";; *) err=1; warn "internal error: \`-$OPTARG' not handled";; esac done -if [ -n "$1" ]; then - name=$1 -fi test $err = 1 && { try_h; exit 1; } test $help = 1 && { usage; exit 0; } gen_bridge() { - name=$1 + local name=$1 cat << EOF <network> <name>$name</name> @@ -64,8 +54,8 @@ EOF } gen_fake_managed_node() { - num=$1 - last_mac=$(( 54 + $num )) + local num=$1 + local last_mac=$(( 54 + $num )) cat <<EOF <domain type='kvm'> @@ -102,12 +92,13 @@ EOF } gen_app() { - local disk=$1 - local ram=$2 + local name=$1 + local disk=$2 + local ram=$3 cat<<EOF <domain type='kvm'> - <name>$NAME</name> + <name>$name</name> <memory>$(( $ram * 1024 ))</memory> <currentMemory>$(( $ram * 1024 ))</currentMemory> <vcpu>1</vcpu> @@ -273,36 +264,16 @@ fi virsh undefine bundled } > /dev/null 2>&1 -IMGNAME=$NAME.img mkdir -p $imgdir -virsh destroy $NAME > /dev/null 2>&1 -virsh undefine $NAME > /dev/null 2>&1 - -if [ -n "$kickstart" ]; then - mkdir -p tmp - set -e - appliance-creator --config $kickstart --name $NAME \ - --tmpdir=$(pwd)/tmp $yumcache - # FIXME add --compress option to appliance-creator - if [ $compress -ne 0 ]; then - printf "Compressing the image..." - qemu-img convert -c $NAME-sda.raw -O qcow2 "$imgdir/$IMGNAME" - rm $NAME-sda.raw - else - printf "Moving the image..." - mv $NAME-sda.raw "$imgdir/$IMGNAME" - restorecon -v "$imgdir/$IMGNAME" - fi - echo done - set +e -fi - -test ! -r $imgdir/$IMGNAME && die "Disk image not found at $imgdir/$IMGNAME" +imgname=$name.img +test ! -r $imgdir/$imgname && die "Disk image not found at $imgdir/$imgname" +virsh destroy $name > /dev/null 2>&1 +virsh undefine $name > /dev/null 2>&1 TMPXML=$(mktemp) || exit 1 # FIXME virt-image to define the appliance instance -gen_app $imgdir/$IMGNAME $RAM > $TMPXML +gen_app $name $imgdir/$imgname $RAM > $TMPXML virsh define $TMPXML rm $TMPXML -echo "Application defined using disk located at $imgdir/$IMGNAME." -echo "Run virsh start $NAME to start the appliance" +echo "Application defined using disk located at $imgdir/$imgname." +echo "Run virsh start $name to start the appliance" diff --git a/wui-appliance/repos.ks.in b/wui-appliance/repos.ks.in index 29fbbc6..79a8cef 100644 --- a/wui-appliance/repos.ks.in +++ b/wui-appliance/repos.ks.in @@ -1,6 +1,3 @@ -url --url http://download.fedora.redhat.com/pub/fedora/linux/releases/9/Fedora/@@ARCH@@/os/ - -repo --name=f9 --mirrorlist=http://mirrors.fedoraproject.org/mirrorlist?repo=fedora-9&arch=@@ARCH@@ -repo --name=f9-updates --mirrorlist=http://mirrors.fedoraproject.org/mirrorlist?repo=updates-released-f9&arch=@@ARCH@@ -repo --name=ovirt --baseurl=http://ovirt.org/repos/ovirt/9/@@ARCH@@ - +repo --name=f9 --mirrorlist=http://mirrors.fedoraproject.org/mirrorlist?repo=fedora-9&arch=$basearch +repo --name=f9-updates --mirrorlist=http://mirrors.fedoraproject.org/mirrorlist?repo=updates-released-f9&arch=$basearch +repo --name=ovirt --baseurl=http://ovirt.org/repos/ovirt/9/$basearch -- 1.5.5.1