|
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [Xen-devel] [PATCH v2 3/4] raisin: improve output
Introduce an error_echo function that prints to stderr.
Call error_echo or verbose_echo, instead of echo, when possible and
appropriate.
Redirect build and tests output to /dev/null unless VERBOSE==1.
Redirect apt-get and yum output to /dev/null.
Fix echo arguments in check-package-deb.
Signed-off-by: Stefano Stabellini <stefano.stabellini@xxxxxxxxxxxxx>
---
Changes in v2:
- use "$@" instead of $* in error_echo and verbose_echo
---
components/grub | 4 +--
components/libvirt | 4 +--
components/linux | 2 +-
components/ovmf | 6 ++--
components/qemu | 2 +-
components/qemu_traditional | 2 +-
components/seabios | 6 ++--
components/xen | 8 ++---
lib/commands.sh | 18 +++++------
lib/common-functions.sh | 72 ++++++++++++++++++++++++++++++-------------
lib/common-tests.sh | 6 ++--
tests/busybox-hvm | 2 +-
12 files changed, 80 insertions(+), 52 deletions(-)
diff --git a/components/grub b/components/grub
index fa72b99..3bb5254 100644
--- a/components/grub
+++ b/components/grub
@@ -19,10 +19,10 @@ function grub_check_package() {
if [[ $RAISIN_ARCH != "x86_64" && $RAISIN_ARCH != "x86_32" ]]
then
- echo grub is only supported on x86_32 and x86_64
+ verbose_echo grub is only supported on x86_32 and x86_64
return
fi
- echo Checking Grub dependencies
+ verbose_echo Checking Grub dependencies
eval check-package \$DEP_"$DISTRO"_"$RAISIN_ARCH"
}
diff --git a/components/libvirt b/components/libvirt
index a554643..20405ae 100644
--- a/components/libvirt
+++ b/components/libvirt
@@ -22,7 +22,7 @@ function libvirt_check_package() {
local DEP_CentOS_x86_32="$DEP_Fedora_x86_32"
local DEP_CentOS_x86_64="$DEP_Fedora_x86_64"
- echo Checking Libvirt dependencies
+ verbose_echo Checking Libvirt dependencies
eval check-package \$DEP_"$DISTRO"_"$RAISIN_ARCH"
}
@@ -52,7 +52,7 @@ function libvirt_build() {
cp daemon/libvirtd.init "$INST_DIR"/etc/rc.d/init.d/libvirtd
chmod +x "$INST_DIR"/etc/rc.d/init.d/libvirtd
else
- echo "I don't know how write an init script for Libvirt on $DISTRO"
+ error_echo "I don't know how write an init script for Libvirt on
$DISTRO"
fi
cd ..
}
diff --git a/components/linux b/components/linux
index f90a894..9ae6955 100644
--- a/components/linux
+++ b/components/linux
@@ -15,7 +15,7 @@ function linux_check_package() {
local DEP_CentOS_x86_32="$DEP_Fedora_x86_32"
local DEP_CentOS_x86_64="$DEP_Fedora_x86_64"
- echo Checking Linux dependencies
+ verbose_echo Checking Linux dependencies
eval check-package \$DEP_"$DISTRO"_"$RAISIN_ARCH"
}
diff --git a/components/ovmf b/components/ovmf
index a59a771..387044a 100644
--- a/components/ovmf
+++ b/components/ovmf
@@ -14,10 +14,10 @@ function ovmf_check_package() {
if [[ $RAISIN_ARCH != "x86_64" ]]
then
- echo ovmf is only supported on x86_64
+ verbose_echo ovmf is only supported on x86_64
return
fi
- echo Checking OVMF dependencies
+ verbose_echo Checking OVMF dependencies
eval check-package \$DEP_"$DISTRO"_"$RAISIN_ARCH"
}
@@ -25,7 +25,7 @@ function ovmf_check_package() {
function ovmf_build() {
if [[ $RAISIN_ARCH != "x86_64" ]]
then
- echo ovmf is only supported on x86_64
+ verbose_echo ovmf is only supported on x86_64
return
fi
diff --git a/components/qemu b/components/qemu
index 72cfec1..dce4ce0 100644
--- a/components/qemu
+++ b/components/qemu
@@ -11,7 +11,7 @@ function qemu_check_package() {
local DEP_Fedora_x86_32="$DEP_Fedora_common"
local DEP_Fedora_x86_64="$DEP_Fedora_common"
- echo Checking QEMU dependencies
+ verbose_echo Checking QEMU dependencies
eval check-package \$DEP_"$DISTRO"_"$RAISIN_ARCH"
}
diff --git a/components/qemu_traditional b/components/qemu_traditional
index b338007..a9609b1 100644
--- a/components/qemu_traditional
+++ b/components/qemu_traditional
@@ -12,7 +12,7 @@ function qemu_traditional_check_package() {
local DEP_Fedora_x86_32="$DEP_Fedora_common"
local DEP_Fedora_x86_64="$DEP_Fedora_common"
- echo Checking QEMU dependencies
+ verbose_echo Checking QEMU dependencies
eval check-package \$DEP_"$DISTRO"_"$RAISIN_ARCH"
}
diff --git a/components/seabios b/components/seabios
index ed2c7d2..8fea193 100644
--- a/components/seabios
+++ b/components/seabios
@@ -14,10 +14,10 @@ function seabios_check_package() {
if [[ $RAISIN_ARCH != "x86_64" && $RAISIN_ARCH != "x86_32" ]]
then
- echo seabios is only supported on x86_32 and x86_64
+ verbose_echo seabios is only supported on x86_32 and x86_64
return
fi
- echo Checking SeaBIOS dependencies
+ verbose_echo Checking SeaBIOS dependencies
eval check-package \$DEP_"$DISTRO"_"$RAISIN_ARCH"
}
@@ -25,7 +25,7 @@ function seabios_check_package() {
function seabios_build() {
if [[ $RAISIN_ARCH != "x86_64" && $RAISIN_ARCH != "x86_32" ]]
then
- echo seabios is only supported on x86_32 and x86_64
+ verbose_echo seabios is only supported on x86_32 and x86_64
return
fi
diff --git a/components/xen b/components/xen
index add8136..6b700e5 100644
--- a/components/xen
+++ b/components/xen
@@ -19,7 +19,7 @@ function xen_check_package() {
local DEP_CentOS_x86_32="$DEP_CentOS_common dev86 texinfo iasl"
local DEP_CentOS_x86_64="$DEP_CentOS_x86_32 glibc-devel.i686"
- echo Checking Xen dependencies
+ verbose_echo Checking Xen dependencies
eval check-package \$DEP_"$DISTRO"_"$RAISIN_ARCH"
}
@@ -62,13 +62,13 @@ function _xen_create_bridge_Debian() {
if [[ -z "$IFACE" ]]
then
- echo "Please refer to the following page to setup networking:"
- echo
"http://wiki.xenproject.org/wiki/Network_Configuration_Examples_(Xen_4.1%2B)"
+ error_echo "Please refer to the following page to setup networking:"
+ error_echo
"http://wiki.xenproject.org/wiki/Network_Configuration_Examples_(Xen_4.1%2B)"
return 1
fi
if [[ "`grep $BRIDGE /etc/network/interfaces`" ]]
then
- echo "a network bridge seems to be already setup"
+ verbose_echo "a network bridge seems to be already setup"
return 0
fi
diff --git a/lib/commands.sh b/lib/commands.sh
index ffbadb4..a79611e 100755
--- a/lib/commands.sh
+++ b/lib/commands.sh
@@ -17,29 +17,29 @@ function check-builddep() {
if [[ -n "${missing[@]}" ]]
then
- echo "Missing packages: ${missing[@]}"
+ echo "$PREPEND Missing packages: ${missing[@]}"
if [[ "$YES" = "n" ]]
then
return
elif [[ "$YES" != "y" ]]
then
- echo "Do you want Raisin to automatically install them for you?
(y/n)"
+ echo "$PREPEND Do you want Raisin to automatically install them
for you? (y/n)"
while read answer
do
if [[ "$answer" = "n" ]]
then
- echo "Please install, or run ./raise install-builddep"
+ echo "$PREPEND Please install, or run ./raise
install-builddep"
exit 1
elif [[ "$answer" = "y" ]]
then
break
else
- echo "Reply y or n"
+ echo "$PREPEND Reply y or n"
fi
done
fi
- echo "Installing..."
+ echo "$PREPEND Installing..."
install-package "${missing[@]}"
fi
}
@@ -72,7 +72,7 @@ function install() {
# need single braces for filename matching expansion
if [ ! -f xen-sytem*rpm ] && [ ! -f xen-system*deb ]
then
- echo You need to raise build first.
+ error_echo You need to raise build first.
exit 1
fi
install_package xen-system
@@ -84,8 +84,8 @@ function configure() {
return
elif [[ "$YES" != "y" ]]
then
- echo "Proceeding we'll make changes to the running system,"
- echo "are you sure that you want to continue? (y/n)"
+ echo "$PREPEND Proceeding we'll make changes to the running system,"
+ echo "$PREPEND are you sure that you want to continue? (y/n)"
while read answer
do
if [[ "$answer" = "n" ]]
@@ -95,7 +95,7 @@ function configure() {
then
break
else
- echo "Reply y or n"
+ echo "$PREPEND Reply y or n"
fi
done
fi
diff --git a/lib/common-functions.sh b/lib/common-functions.sh
index 5b82c4c..cbb658e 100644
--- a/lib/common-functions.sh
+++ b/lib/common-functions.sh
@@ -3,10 +3,14 @@
function verbose_echo() {
if [[ $VERBOSE -eq 1 ]]
then
- echo $*
+ echo "$PREPEND" "$@"
fi
}
+function error_echo() {
+ echo "$PREPEND" "$@" >&2
+}
+
# Executed once at the beginning of the script
function common_init() {
export BASEDIR=`pwd`
@@ -15,6 +19,7 @@ function common_init() {
export RAISIN_MAKE=${MAKE-make}
export PREFIX=${PREFIX-/usr}
export INST_DIR=${DESTDIR-dist}
+ export PREPEND="[raisin]"
INST_DIR=`readlink -f $INST_DIR`
@@ -24,15 +29,15 @@ function common_init() {
export SUDO=""
elif [[ ! -f `which sudo 2>/dev/null` ]]
then
- echo "Raisin requires sudo to install build dependencies for you."
- echo "You can only build without it."
+ error_echo "Raisin requires sudo to install build dependencies for
you."
+ error_echo "You can only build without it."
export SUDO=""
fi
if [[ -z "$BASH_VERSINFO" || ${BASH_VERSINFO[0]} -lt 3 ||
(${BASH_VERSINFO[0]} -eq 3 && ${BASH_VERSINFO[1]} -lt 2) ]]
then
- echo "Raisin requires BASH 3.2 or newer."
+ error_echo "Raisin requires BASH 3.2 or newer."
exit 1
fi
@@ -186,7 +191,7 @@ function get_arch() {
}
function _check-package-deb() {
- verbose_echo "Checking for package ${args[0]}"
+ verbose_echo "Checking for package $1"
if dpkg -s "$1" 2>/dev/null | grep -q "Status:.*installed"
then
@@ -197,7 +202,7 @@ function _check-package-deb() {
}
function _install-package-deb() {
- $SUDO apt-get install -y $*
+ $SUDO apt-get install -y $* > /dev/null
}
function _check-package-rpm() {
@@ -212,7 +217,7 @@ function _check-package-rpm() {
}
function _install-package-rpm() {
- $SUDO yum install -y $*
+ $SUDO yum install -y $* > /dev/null
}
# Modifies inherited variable "missing"
@@ -236,13 +241,13 @@ function start_initscripts() {
do
case $DISTRO in
"Debian" )
- $SUDO update-rc.d $1 defaults || echo "Couldn't set $1 to start"
+ $SUDO update-rc.d $1 defaults || error_echo "Couldn't set $1 to
start"
;;
"Fedora" )
- $SUDO chkconfig --add $1 || echo "Couldn't set $1 to start"
+ $SUDO chkconfig --add $1 || error_echo "Couldn't set $1 to start"
;;
* )
- echo "I don't know how to start initscripts on $DISTRO"
+ error_echo "I don't know how to start initscripts on $DISTRO"
return 1
;;
esac
@@ -255,13 +260,13 @@ function stop_initscripts() {
do
case $DISTRO in
"Debian" )
- $SUDO update-rc.d $1 remove || echo "Couldn't remove $1 from init"
+ $SUDO update-rc.d $1 remove || error_echo "Couldn't remove $1 from
init"
;;
"Fedora" )
- $SUDO chkconfig --del $1 || echo "Couldn't remove $1 from init"
+ $SUDO chkconfig --del $1 || error_echo "Couldn't remove $1 from
init"
;;
* )
- echo "I don't know how to start initscripts on $DISTRO"
+ error_echo "I don't know how to start initscripts on $DISTRO"
return 1
;;
esac
@@ -291,9 +296,14 @@ function for_each_component () {
continue
fi
- verbose_echo calling "$component"_"$1"
- "$component"_"$1"
- verbose_echo "$component"_"$1" done
+ echo "$PREPEND" calling "$component"_"$1"
+ if [[ $VERBOSE -eq 0 ]]
+ then
+ "$component"_"$1" &> /dev/null
+ else
+ "$component"_"$1"
+ fi
+ echo "$PREPEND" "$component"_"$1" done
done
}
@@ -301,6 +311,7 @@ function run_tests() {
local t
local enabled
local found
+ local ret
for t in `cat "$BASEDIR"/tests/series`
do
@@ -319,9 +330,26 @@ function run_tests() {
continue
fi
- verbose_echo running test "$t"
- "$BASEDIR"/tests/$t
- verbose_echo "test "$t" done"
+ ret=0
+ if [[ $VERBOSE -eq 0 ]]
+ then
+ echo -n "$PREPEND test $t: "
+ "$BASEDIR"/tests/$t &>/dev/null || ret=1
+ if [[ $ret -eq 0 ]]
+ then
+ echo "success"
+ else
+ echo "fail"
+ fi
+ else
+ "$BASEDIR"/tests/$t || ret=1
+ if [[ $ret -eq 0 ]]
+ then
+ echo "$PREPEND test $t: success"
+ else
+ echo "$PREPEND test $t: fail"
+ fi
+ fi
done
}
@@ -336,7 +364,7 @@ function init_tests() {
then
check-package busybox grub2 which
else
- echo "I don't know distro $DISTRO. It might be missing packages."
+ error_echo "I don't know distro $DISTRO. It might be missing packages."
fi
if [[ -n "${missing[@]}" ]]
@@ -372,7 +400,7 @@ function install_package() {
then
$SUDO rpm -i --force "$1"-`git show --oneline | head -1 | cut -d " "
-f 1`-0.$RAISIN_ARCH.rpm
else
- echo "Don't know how to install packages on $DISTRO"
+ error_echo "Don't know how to install packages on $DISTRO"
fi
}
@@ -384,6 +412,6 @@ function uninstall_package() {
then
$SUDO rpm -e "$1"
else
- echo "Don't know how to uninstall packages on $DISTRO"
+ error_echo "Don't know how to uninstall packages on $DISTRO"
fi
}
diff --git a/lib/common-tests.sh b/lib/common-tests.sh
index abbc91a..0e51539 100644
--- a/lib/common-tests.sh
+++ b/lib/common-tests.sh
@@ -133,7 +133,7 @@ EOF
--grub-mkdevicemap=$tmpdir/boot/grub/device.map \
--root-directory=$tmpdir $dev
else
- echo "I don't know how to install grub on $DISTRO"
+ echo "$PREPEND I don't know how to install grub on $DISTRO"
fi
$SUDO umount $tmpdir
@@ -149,7 +149,7 @@ function check_guest_alive() {
i=$((i+1))
if [[ $i -gt 60 ]]
then
- echo Timeout connecting to guest
+ echo $PREPEND Timeout connecting to guest
return 1
fi
done
@@ -168,7 +168,7 @@ function get_host_initrd() {
then
echo "/boot/initramfs-`uname -r`".img
else
- echo "I don't know how to find the initrd" >&2
+ echo "$PREPEND I don't know how to find the initrd" >&2
exit 1
fi
}
diff --git a/tests/busybox-hvm b/tests/busybox-hvm
index b97ae34..c8024e5 100755
--- a/tests/busybox-hvm
+++ b/tests/busybox-hvm
@@ -14,7 +14,7 @@ function cleanup() {
if [[ $RAISIN_ARCH != "x86_64" && $RAISIN_ARCH != "x86_32" ]]
then
- echo busybox hvm test only valid on x86
+ echo $PREPEND busybox hvm test only valid on x86
exit 0
fi
--
1.7.10.4
_______________________________________________
Xen-devel mailing list
Xen-devel@xxxxxxxxxxxxx
http://lists.xen.org/xen-devel
|
![]() |
Lists.xenproject.org is hosted with RackSpace, monitoring our |