Minor fixes for non-Linux platforms
PATCH 1/1 Minor fixes for non-Linux platforms
Hello!
The attached patch makes the stuff in tools/check/ work for *BSD systems. Consider this as a start to make xen buildable on non-Linux platforms.
I don't expect to get this into xen 3.0.3, but I hope this can go into -unstable.
tools/check/check_brctl +16 -2
@@ -1,4 +1,4 @@ -#!/bin/bash +#!/bin/sh # CHECK-INSTALL function error {
@@ -7,4 +7,18 @@ function error { exit 1 } -which brctl 1>/dev/null 2>&1 || error + +case ${OS} in +OpenBSD|NetBSD|FreeBSD) + # These systems have a bridge builtin + which brconfig 1>/dev/null 2>&1 || error + ;; +Linux) + which brctl 1>/dev/null 2>&1 || error + ;; +*) + echo "Unknown OS" && error + ;; +esac + +exit 0
tools/check/check_iproute +13 -2
@@ -1,4 +1,4 @@ -#!/bin/bash +#!/bin/sh # CHECK-INSTALL function error {
@@ -7,5 +7,16 @@ function error { exit 1 } -ip addr list 1>/dev/null 2>&1 || error +case ${OS} in +OpenBSD|NetBSD|FreeBSD) + ifconfig -a 1>/dev/null 2>&1 || error + ;; +Linux) + ip addr list 1>/dev/null 2>&1 || error + ;; +*) + echo "Unknown OS" && error + ;; +esac +exit 0
tools/check/check_python +1 -1
@@ -1,4 +1,4 @@ -#!/bin/bash +#!/bin/sh # CHECK-BUILD CHECK-INSTALL function error {
tools/check/check_zlib_devel +1 -1
@@ -1,4 +1,4 @@ -#!/bin/bash +#!/bin/sh # CHECK-BUILD function error {
tools/check/check_zlib_lib +2 -2
@@ -1,4 +1,4 @@ -#!/bin/bash +#!/bin/sh # CHECK-BUILD CHECK-INSTALL function error {
@@ -8,4 +8,4 @@ function error { } set -e -ldconfig -p | grep -q libz.so || error +ldconfig -v 2>&1 | grep -q libz.so || error
tools/check/chk +2 -1
@@ -1,4 +1,4 @@ -#!/bin/bash +#!/bin/sh function usage { echo "Usage:"
@@ -13,6 +13,7 @@ function usage { } export PATH=${PATH}:/sbin:/usr/sbin +export OS=`uname -s` case $1 in build)
_______________________________________________
Xen-devel mailing list
[email protected]
http://lists.xensource.com/xen-devel
tools/check/check_brctl line 1
Quoted 6 lines · Christoph Egger
diff -r
f14a67a35bectools/check/check_brctltools/check/check_brctl +1
-1@@ -1,4 +1,4 @@ -#!/bin/bash +#!/bin/sh
Thats a bad idea. Some of the scripts uses non-POSIX extensions and /bin/sh is normaly only defined as POSIX compilant.
Bastian
Signature · 2 lines
Men will always be men -- no matter where they are. -- Harry Mudd, "Mudd's Women", stardate 1329.8
Quoted 9 lines · Bastian Blank
tools/check/check_brctl Thu Oct 12 10:17:33 2006 +0200 line 1
Quoted 6 lines
diff -r
f14a67a35bectools/check/check_brctltools/check/check_brctl Thu Oct 12 10:17:33 2006 +0200 renamed from tools/check/check_brctl Thu Oct 12 17:53:51 2006 +0100 +1
-1@@ -1,4 +1,4 @@ -#!/bin/bash +#!/bin/shThats a bad idea. Some of the scripts uses non-POSIX extensions and
/bin/shis normaly only defined as POSIX compilant.
The scripts are tiny. We should stop them using those non-compliant extensions. We use /bin/sh in just about all our other scripts (and some of those are *way* more complex).
-- Keir
Quoted 11 lines · Keir Fraser
Quoted 9 lines · Bastian Blank
tools/check/check_brctl Thu Oct 12 10:17:33 2006 +0200 line 1
Quoted 6 lines
diff -r
f14a67a35bectools/check/check_brctltools/check/check_brctl Thu Oct 12 10:17:33 2006 +0200 renamed from tools/check/check_brctl Thu Oct 12 17:53:51 2006 +0100 +1
-1@@ -1,4 +1,4 @@ -#!/bin/bash +#!/bin/shThats a bad idea. Some of the scripts uses non-POSIX extensions and
/bin/shis normaly only defined as POSIX compilant.
Quoted 3 lines
The scripts are tiny. We should stop them using those non-compliant extensions. We use
/bin/shin just about all our other scripts (and some of those are *way* more complex).
One more try. Patch attached.
tools/check/check_brctl +22 -7
@@ -1,10 +1,25 @@ -#!/bin/bash +#!/bin/sh # CHECK-INSTALL -function error { - echo - echo ' *** Check for the bridge control utils (brctl) FAILED' - exit 1 -} +RC=0 -which brctl 1>/dev/null 2>&1 || error +case ${OS} in +OpenBSD|NetBSD|FreeBSD) + # These systems have a bridge builtin + which brconfig 1>/dev/null 2>&1 || RC=1 + ;; +Linux) + which brctl 1>/dev/null 2>&1 || RC=1 + ;; +*) + echo "Unknown OS" && error + ;; +esac + + +if test ${RC} -ne 0; then + echo + echo ' *** Check for the bridge control utils (brctl) FAILED' +fi + +exit ${RC}
tools/check/check_iproute +19 -7
@@ -1,11 +1,23 @@ -#!/bin/bash +#!/bin/sh # CHECK-INSTALL -function error { - echo - echo ' *** Check for iproute (ip addr) FAILED' - exit 1 -} +RC=0 -ip addr list 1>/dev/null 2>&1 || error +case ${OS} in +OpenBSD|NetBSD|FreeBSD) + ifconfig -a 1>/dev/null 2>&1 || RC=1 + ;; +Linux) + ip addr list 1>/dev/null 2>&1 || RC=1 + ;; +*) + echo "Unknown OS" && RC=1 + ;; +esac +if test ${RC} -ne 0; then + echo + echo ' *** Check for iproute (ip addr) FAILED' +fi + +exit ${RC}
tools/check/check_python +10 -7
@@ -1,10 +1,13 @@ -#!/bin/bash +#!/bin/sh # CHECK-BUILD CHECK-INSTALL -function error { - echo - echo " *** Check for Python version >= 2.2 FAILED" - exit 1 -} +RC=0 -python -V 2>&1 | cut -d ' ' -f 2 | grep -q '^2.[2345]' || error +python -V 2>&1 | cut -d ' ' -f 2 | grep -q '^2.[2345]' || RC=1 + +if test ${RC} -ne 0; then + echo + echo " *** Check for Python version >= 2.2 FAILED" +fi + +exit ${RC}
tools/check/check_zlib_devel +10 -7
@@ -1,11 +1,14 @@ -#!/bin/bash +#!/bin/sh # CHECK-BUILD -function error { - echo - echo " *** Check for zlib headers FAILED" - exit 1 -} +RC=0 set -e -[ -e /usr/include/zlib.h ] || error +test -r /usr/include/zlib.h || RC=1 + +if test ${RC} -ne 0; then + echo + echo " *** Check for zlib headers FAILED" +fi + +exit ${RC}
tools/check/check_zlib_lib +10 -7
@@ -1,11 +1,14 @@ -#!/bin/bash +#!/bin/sh # CHECK-BUILD CHECK-INSTALL -function error { - echo - echo " *** Check for zlib library FAILED" - exit 1 -} +RC=0 set -e -ldconfig -p | grep -q libz.so || error +ldconfig -v 2>&1 | grep -q libz.so || RC=1 + +if test ${RC} -ne 0; then + echo + echo " *** Check for zlib library FAILED" +fi + +exit ${RC}
tools/check/chk +12 -15
@@ -1,18 +1,7 @@ -#!/bin/bash - -function usage { - echo "Usage:" - echo "\t$0 [build|install|clean]" - echo - echo "Check suitability for Xen build or install." - echo "Exit with 0 if OK, 1 if not." - echo "Prints only failed tests." - echo - echo "Calling with 'clean' removes generated files." - exit 1 -} +#!/bin/sh export PATH=${PATH}:/sbin:/usr/sbin +export OS=`uname -s` case $1 in build)
@@ -25,7 +14,15 @@ case $1 in exit 0 ;; *) - usage + echo "Usage:" + echo "\t$0 [build|install|clean]" + echo + echo "Check suitability for Xen build or install." + echo "Exit with 0 if OK, 1 if not." + echo "Prints only failed tests." + echo + echo "Calling with 'clean' removes generated files." + exit 1 ;; esac
@@ -54,4 +51,4 @@ for f in check_* ; do fi done -exit $failed +exit ${failed}
_______________________________________________
Xen-devel mailing list
[email protected]
http://lists.xensource.com/xen-devel
Quoted 1 line · Christoph Egger
One more try. Patch attached.
In check_brctl, you remove the error function but you don't remove all users of it.
christian
Christoph Egger wrote: [Thu Oct 12 2006, 08:33:22AM EDT]
Quoted 11 lines
diff -r
49d096ef3d76tools/check/chktools/check/chk +0
-7@@ -1,18 +1,7 @@ -#!/bin/bash - -function usage { - echo "Usage:" - echo "\t$0 [build|install|clean]" - echo - echo "Check suitability for Xen build or install."
tools/check/chk line 4
Quoted 10 lines
tools/check/chk +2
-6- echo "Exit with 0 if OK, 1 if not." - echo "Prints only failed tests." - echo - echo "Calling with 'clean' removes generated files." - exit 1 -} +#!/bin/sh export PATH=${PATH}:/sbin:/usr/sbin +export OS=`uname -s`
export with variable assignment doesn't work on most Bourne shells. These need to be split up:
PATH=${PATH}:/sbin:/usr/sbin
OS=uname -s
export PATH OS
tools/check/chk case $1 in · line 18
Quoted 9 lines
tools/check/chk +2
-1case $1 in build)@@ -25,7 +14,15 @@ case $1 in exit 0 ;; *) - usage + echo "Usage:" + echo "\t$0 [build|install|clean]"
\t isn't standard (it doesn't even work on Linux without -e). You should insert a real tab there instead.
Aron
Quoted 2 lines · Aron Griffis
Christoph Egger wrote: [Thu Oct 12 2006, 08:33:22AM EDT]
[...]
Quoted 8 lines
Review
Quoted 4 lines
(quoted diff) +2
-0+#!/bin/sh export PATH=${PATH}:/sbin:/usr/sbin +export OS=`uname -s`export with variable assignment doesn't work on most Bourne shells. These need to be split up:
Quoted 4 lines
PATH=${PATH}:/sbin:/usr/sbin
OS=uname -s
export PATH OS
Fixed.
[...]
Quoted 6 lines
Review
Quoted 3 lines
(quoted diff) +2
-1- usage + echo "Usage:" + echo "\t$0 [build|install|clean]"\t isn't standard (it doesn't even work on Linux without -e). You should insert a real tab there instead.
Fixed.
Quoted 7 lines
Just wondering, why did you get rid of all the functions from these scripts? AFAIK, every Bourne shell ever made supports functions, though they might need to be declared with the older syntax:
func() { asdfasdf }
The scripts are so small, you gain nothing with functions - not even just for readability.
One exception: The usage function in the chk script actually improves readability. So I converted it to the old and portable Bourne Shell syntax.
Quoted 2 lines · Christian Limpach
In
check_brctl, you remove the error function but you don't remove all users of it.
Fixed.
New Patch attached.
tools/check/check_brctl +24 -7
@@ -1,10 +1,27 @@ -#!/bin/bash +#!/bin/sh # CHECK-INSTALL -function error { - echo - echo ' *** Check for the bridge control utils (brctl) FAILED' - exit 1 -} +RC=0 -which brctl 1>/dev/null 2>&1 || error +case ${OS} in +OpenBSD|NetBSD|FreeBSD) + # These systems have a bridge builtin + TOOL="brconfig" + which ${TOOL} 1>/dev/null 2>&1 || RC=1 + ;; +Linux) + TOOL="brctl" + which ${TOOL} 1>/dev/null 2>&1 || RC=1 + ;; +*) + TOOL="" + echo "Unknown OS" && RC=1 + ;; +esac + +if test ${RC} -ne 0; then + echo + echo " *** Check for the bridge control utils (${TOOL}) FAILED" +fi + +exit ${RC}
tools/check/check_iproute +22 -7
@@ -1,11 +1,26 @@ -#!/bin/bash +#!/bin/sh # CHECK-INSTALL -function error { - echo - echo ' *** Check for iproute (ip addr) FAILED' - exit 1 -} +RC=0 -ip addr list 1>/dev/null 2>&1 || error +case ${OS} in +OpenBSD|NetBSD|FreeBSD) + TOOL="ifconfig" + eval ${TOOL} -a 1>/dev/null 2>&1 || RC=1 + ;; +Linux) + TOOL="ip addr" + eval ${TOOL} list 1>/dev/null 2>&1 || RC=1 + ;; +*) + TOOL="" + echo "Unknown OS" && RC=1 + ;; +esac +if test ${RC} -ne 0; then + echo + echo " *** Check for iproute (${TOOL}) FAILED" +fi + +exit ${RC}
tools/check/check_python +10 -7
@@ -1,10 +1,13 @@ -#!/bin/bash +#!/bin/sh # CHECK-BUILD CHECK-INSTALL -function error { - echo - echo " *** Check for Python version >= 2.2 FAILED" - exit 1 -} +RC=0 -python -V 2>&1 | cut -d ' ' -f 2 | grep -q '^2.[2345]' || error +python -V 2>&1 | cut -d ' ' -f 2 | grep -q '^2.[2345]' || RC=1 + +if test ${RC} -ne 0; then + echo + echo " *** Check for Python version >= 2.2 FAILED" +fi + +exit ${RC}
tools/check/check_zlib_devel +10 -7
@@ -1,11 +1,14 @@ -#!/bin/bash +#!/bin/sh # CHECK-BUILD -function error { - echo - echo " *** Check for zlib headers FAILED" - exit 1 -} +RC=0 set -e -[ -e /usr/include/zlib.h ] || error +test -r /usr/include/zlib.h || RC=1 + +if test ${RC} -ne 0; then + echo + echo " *** Check for zlib headers FAILED" +fi + +exit ${RC}
tools/check/check_zlib_lib +10 -7
@@ -1,11 +1,14 @@ -#!/bin/bash +#!/bin/sh # CHECK-BUILD CHECK-INSTALL -function error { - echo - echo " *** Check for zlib library FAILED" - exit 1 -} +RC=0 set -e -ldconfig -p | grep -q libz.so || error +ldconfig -v 2>&1 | grep -q libz.so || RC=1 + +if test ${RC} -ne 0; then + echo + echo " *** Check for zlib library FAILED" +fi + +exit ${RC}
tools/check/chk +9 -6
@@ -1,8 +1,9 @@ -#!/bin/bash +#!/bin/sh -function usage { +func_usage () +{ echo "Usage:" - echo "\t$0 [build|install|clean]" + echo " $0 [build|install|clean]" echo echo "Check suitability for Xen build or install." echo "Exit with 0 if OK, 1 if not."
@@ -12,7 +13,9 @@ function usage { exit 1 } -export PATH=${PATH}:/sbin:/usr/sbin +PATH=${PATH}:/sbin:/usr/sbin +OS=`uname -s` +export PATH OS case $1 in build)
@@ -25,7 +28,7 @@ case $1 in exit 0 ;; *) - usage + func_usage ;; esac
@@ -54,4 +57,4 @@ for f in check_* ; do fi done -exit $failed +exit ${failed}
_______________________________________________
Xen-devel mailing list
[email protected]
http://lists.xensource.com/xen-devel
This is a resend of the patch with a minor adaption for the Solaris patches. The patch is against C/S 11791.
Please apply to xen-unstable.
tools/check/check_brctl +24 -7
@@ -1,10 +1,27 @@ -#!/bin/bash +#!/bin/sh # CHECK-INSTALL -function error { - echo - echo ' *** Check for the bridge control utils (brctl) FAILED' - exit 1 -} +RC=0 -which brctl 1>/dev/null 2>&1 || error +case ${OS} in +OpenBSD|NetBSD|FreeBSD) + # These systems have a bridge builtin + TOOL="brconfig" + which ${TOOL} 1>/dev/null 2>&1 || RC=1 + ;; +Linux) + TOOL="brctl" + which ${TOOL} 1>/dev/null 2>&1 || RC=1 + ;; +*) + TOOL="" + echo "Unknown OS" && RC=1 + ;; +esac + +if test ${RC} -ne 0; then + echo + echo " *** Check for the bridge control utils (${TOOL}) FAILED" +fi + +exit ${RC}
tools/check/check_iproute +22 -7
@@ -1,11 +1,26 @@ -#!/bin/bash +#!/bin/sh # CHECK-INSTALL -function error { - echo - echo ' *** Check for iproute (ip addr) FAILED' - exit 1 -} +RC=0 -ip addr list 1>/dev/null 2>&1 || error +case ${OS} in +OpenBSD|NetBSD|FreeBSD) + TOOL="ifconfig" + eval ${TOOL} -a 1>/dev/null 2>&1 || RC=1 + ;; +Linux) + TOOL="ip addr" + eval ${TOOL} list 1>/dev/null 2>&1 || RC=1 + ;; +*) + TOOL="" + echo "Unknown OS" && RC=1 + ;; +esac +if test ${RC} -ne 0; then + echo + echo " *** Check for iproute (${TOOL}) FAILED" +fi + +exit ${RC}
tools/check/check_python +10 -7
@@ -1,10 +1,13 @@ -#!/bin/bash +#!/bin/sh # CHECK-BUILD CHECK-INSTALL -function error { - echo - echo " *** Check for Python version >= 2.2 FAILED" - exit 1 -} +RC=0 -python -V 2>&1 | cut -d ' ' -f 2 | grep -q '^2.[2345]' || error +python -V 2>&1 | cut -d ' ' -f 2 | grep -q '^2.[2345]' || RC=1 + +if test ${RC} -ne 0; then + echo + echo " *** Check for Python version >= 2.2 FAILED" +fi + +exit ${RC}
tools/check/check_zlib_devel +10 -7
@@ -1,11 +1,14 @@ -#!/bin/bash +#!/bin/sh # CHECK-BUILD -function error { - echo - echo " *** Check for zlib headers FAILED" - exit 1 -} +RC=0 set -e -[ -e /usr/include/zlib.h ] || error +test -r /usr/include/zlib.h || RC=1 + +if test ${RC} -ne 0; then + echo + echo " *** Check for zlib headers FAILED" +fi + +exit ${RC}
tools/check/check_zlib_lib +10 -7
@@ -1,11 +1,14 @@ -#!/bin/bash +#!/bin/sh # CHECK-BUILD CHECK-INSTALL -function error { - echo - echo " *** Check for zlib library FAILED" - exit 1 -} +RC=0 set -e -ldconfig -p | grep -q libz.so || error +ldconfig -v 2>&1 | grep -q libz.so || RC=1 + +if test ${RC} -ne 0; then + echo + echo " *** Check for zlib library FAILED" +fi + +exit ${RC}
tools/check/chk +12 -7
@@ -1,8 +1,9 @@ -#!/bin/bash +#!/bin/sh -function usage { +func_usage () +{ echo "Usage:" - echo "\t$0 [build|install|clean]" + echo " $0 [build|install|clean]" echo echo "Check suitability for Xen build or install." echo "Exit with 0 if OK, 1 if not."
@@ -12,9 +13,13 @@ function usage { exit 1 } -export PATH=${PATH}:/sbin:/usr/sbin +PATH=${PATH}:/sbin:/usr/sbin +OS=`uname -s` +export PATH OS -[ `uname -s` = SunOS ] && exit 0 +if test "${OS}" = "SunOS"; then + exit 0 +fi case $1 in build)
@@ -27,7 +32,7 @@ case $1 in exit 0 ;; *) - usage + func_usage ;; esac
@@ -56,4 +61,4 @@ for f in check_* ; do fi done -exit $failed +exit ${failed}
_______________________________________________
Xen-devel mailing list
[email protected]
http://lists.xensource.com/xen-devel
Christoph,
Just wondering, why did you get rid of all the functions from these scripts? AFAIK, every Bourne shell ever made supports functions, though they might need to be declared with the older syntax:
func() {
asdfasdf
}Aron
Quoted 9 lines · Aron Griffis
Christoph,
Just wondering, why did you get rid of all the functions from these scripts? AFAIK, every Bourne shell ever made supports functions, though they might need to be declared with the older syntax:
func() { asdfasdf }
IEEE 1003.1 section 2.9.5 seems to be appropriate:
http://www.opengroup.org/onlinepubs/009695399/utilities/xcu_chap02.html#tag_02_09_05
And that indeed shows functions being supported as above. Surely we can work to this spec on this matter?
Ewan.