[Ovirt-devel] [PATCH appliance] Support for multiple package formats for the appliance packaging
Perry Myers
pmyers at redhat.com
Wed Nov 19 23:32:33 UTC 2008
PKG_FMT environment variable allows:
tar, tar.gz and tar.bz2
Default is tar.bz2
get-ovirt-appliance allows -p to specify package format, default
is tar.bz2
Developers will want to use .tar since it makes builds quicker.
But tar.bz2 decreases appliance size for download by about 2/3s
Support for multiple disk image formats:
raw, qcow2
DISK_FMT environment variable specifies this for Makefile, -f
parameter for get-ovirt-appliance and create-ovirt-appliance
NOTE: use of raw for DISK_FMT is not reccommend at the present
time since appliance-tools (due to python restriction) do not
support tarfile with --sparse option.
Signed-off-by: Perry Myers <pmyers at redhat.com>
---
.gitignore | 3 ++-
Makefile.am | 6 +++---
create-ovirt-appliance | 6 ++++--
get-ovirt-appliance | 25 ++++++++++++++++++++-----
ovirt-appliance-functions | 14 ++++++++++++--
5 files changed, 41 insertions(+), 13 deletions(-)
diff --git a/.gitignore b/.gitignore
index f6f68fa..7a8fd8f 100644
--- a/.gitignore
+++ b/.gitignore
@@ -11,10 +11,11 @@ config.status
configure
install-sh
missing
-ovirt-appliance-*-*.tar
+ovirt-appliance-*-*.tar*
ovirt-appliance-*-*.tar.sha1sum
ovirt-appliance-*.tar.gz
ovirt-appliance.spec
ovirt-authorized_keys
repos.ks
stamp-h1
+tmp
diff --git a/Makefile.am b/Makefile.am
index adace7c..6bcb0bf 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -19,7 +19,7 @@ OVIRT_CACHE_DIR ?= $(HOME)/ovirt-cache
OVIRT_LOCAL_REPO ?= file://$(OVIRT_CACHE_DIR)/ovirt
OVIRT_URL ?= http://ovirt.org/repos/ovirt
THINCRUST_URL ?= http://thincrust.org/repo
-PKG_FMT = tar
+PKG_FMT ?= tar.bz2
DISK_FMT ?= qcow2
SUM ?= sha1sum
APP_RAM ?= 768
@@ -43,8 +43,8 @@ EXTRA_DIST = \
$(PACKAGE).spec.in
DISTCLEANFILES = $(PACKAGE)-$(VERSION).tar.gz \
- $(NVR).$(PKG_FMT) \
- $(NVR).$(PKG_FMT).$(SUM) \
+ $(NVR).* \
+ $(NVR).*.$(SUM) \
repos.ks ovirt-authorized_keys
# For Release: 0..., set _ovirt_dev=1 so that we get extra_release.GIT-
diff --git a/create-ovirt-appliance b/create-ovirt-appliance
index b31bc21..860aaf9 100755
--- a/create-ovirt-appliance
+++ b/create-ovirt-appliance
@@ -22,21 +22,23 @@
usage() {
case $# in 1) warn "$1"; try_h; exit 1;; esac
cat <<EOF
-Usage: $ME [-d image_dir] [-n name] [-c]
+Usage: $ME [-d image_dir] [-n name] [-c] [-f disk_fmt]
-d: directory to place virtual disk (default: $IMGDIR_DEFAULT)
-n: appliance name (default: $NAME_DEFAULT)
-c: open console when appliance is started
+ -f: disk image format for appliance (default: DISK_FMT_DEFAULT)
-h: display this help and exit
EOF
}
err=0 help=0
console=0
-while getopts :d:n:ch c; do
+while getopts :d:n:cf:h c; do
case $c in
d) imgdir=$OPTARG;;
n) name=$OPTARG;;
c) console=1;;
+ f) DISK_FMT=$OPTARG;;
h) help=1;;
'?') err=1; warn "invalid option: \`-$OPTARG'";;
:) err=1; warn "missing argument to \`-$OPTARG' option";;
diff --git a/get-ovirt-appliance b/get-ovirt-appliance
index 88b4a49..46fc614 100755
--- a/get-ovirt-appliance
+++ b/get-ovirt-appliance
@@ -23,22 +23,26 @@
usage() {
case $# in 1) warn "$1"; try_h; exit 1;; esac
cat <<EOF
-Usage: $ME [-d image_dir] [-n name] [-l appliance location]
+Usage: $ME [-d image_dir] [-n name] [-l appliance location] [-p pkg_fmt] [-f disk_fmt]
-d: directory to place virtual disk (default: $IMGDIR_DEFAULT)
-n: appliance name (default: $NAME_DEFAULT)
-l: directory or url to get appliance archive and checksum files (default: $OVIRT_URL)
this can either be http:// url or relative/absolute path
+ -p: package format for appliance (default: $PKG_FMT_DEFAULT)
+ -f: disk image format for appliance (default: DISK_FMT_DEFAULT)
-h: display this help and exit
EOF
}
err=0 help=0
app_loc=$OVIRT_URL
-while getopts :d:n:l:h c; do
+while getopts :d:n:l:p:f:h c; do
case $c in
d) imgdir=$OPTARG;;
n) name=$OPTARG;;
l) app_loc=$OPTARG;;
+ p) PKG_FMT=$OPTARG;;
+ f) DISK_FMT=$OPTARG;;
h) help=1;;
'?') err=1; warn "invalid option: \`-$OPTARG'";;
:) err=1; warn "missing argument to \`-$OPTARG' option";;
@@ -86,9 +90,20 @@ mkdir -p $imgdir
appdisk=$name/$name-sda.$DISK_FMT
datadisk=$name/$name-sdb.$DISK_FMT
-# This is the only bit of PKG_FMT that is hardcoded. If we really want to support
-# multiple formats for distribution we should have a case statement here
-tar -xvf $app_loc/$pkgfile -C $imgdir
+case $PKG_FMT in
+ tar.bz2)
+ tar -jSxvf $app_loc/$pkgfile -C $imgdir
+ ;;
+ tar.gz)
+ tar -zSxvf $app_loc/$pkgfile -C $imgdir
+ ;;
+ tar)
+ tar -xSvf $app_loc/$pkgfile -C $imgdir
+ ;;
+ *)
+ die "$PKG_FMT is unsupported"
+ ;;
+esac
test ! -r $imgdir/$appdisk && die "Disk image not found at $imgdir/$appdisk"
test ! -r $imgdir/$datadisk && die "Disk image not found at $imgdir/$datadisk"
diff --git a/ovirt-appliance-functions b/ovirt-appliance-functions
index de28caa..a4eef52 100644
--- a/ovirt-appliance-functions
+++ b/ovirt-appliance-functions
@@ -32,10 +32,12 @@ BRIDGENAME=ovirtbr0
NETWORK=192.168.50.0
NETMASK=255.255.255.0
-PKG_FMT=tar
+PKG_FMT_DEFAULT=tar.bz2
+PKG_FMT=$PKG_FMT_DEFAULT
SUM=sha1sum
-DISK_FMT=qcow2
+DISK_FMT_DEFAULT=qcow2
+DISK_FMT=$DISK_FMT_DEFAULT
OVIRT_URL=http://ovirt.org/download
NODE_DISK_FMT=qcow2
@@ -52,6 +54,13 @@ do_checks() {
die "Must run as root"
fi
+ test "$PKG_FMT" = "tar" -o "$PKG_FMT" = "tar.gz" \
+ -o "$PKG_FMT" = "tar.bz2" \
+ || die "$PKG_FMT is not a supported package format"
+
+ test "$DISK_FMT" = "qcow2" -o "$DISK_FMT" = "raw" \
+ || die "$DISK_FMT is not a supported disk format"
+
# now make sure the packages we need are installed
if [ -e /etc/redhat-release ]; then
# We rely on RPM deps for this in Red Hat/Fedora systems
@@ -178,6 +187,7 @@ verify_sum() {
test ! -f $sumfile && { echo "$sumfile not found" ; return 1 ; }
test ! -f $pkgfile && { echo "$pkgfile not found" ; return 1 ; }
+ echo "performing checksum of $pkgfile"
local actual_sum=$($SUM $pkgfile | awk '{print $1}')
local expect_sum=$(awk '{print $1}' $sumfile)
--
1.6.0.3
More information about the ovirt-devel
mailing list