Author: waldi Date: Wed Aug 23 11:05:11 2006 New Revision: 272 Added: trunk/xen-common/scripts/xen-utils-root Modified: trunk/xen-common/scripts/Makefile trunk/xen-common/scripts/xen-utils-wrapper Log: * scripts/Makefile: Update. * scripts/xen-utils-root: Output root for version. * scripts/xen-utils-wrapper: Use xen-utils-root. Modified: trunk/xen-common/scripts/Makefile =============================================================================--- trunk/xen-common/scripts/Makefile (original) +++ trunk/xen-common/scripts/Makefile Wed Aug 23 11:05:11 2006 @@ -1,4 +1,4 @@ -SCRIPTS = \ +GLOBAL_SCRIPTS = \ cpuperf-perfcntr \ cpuperf-xen \ xend \ @@ -18,17 +18,20 @@ xentrace_setsize \ xm +PRIVATE_SCRIPTS = \ + xen-utils-root \ + $(WRAPPER) + WRAPPER = xen-utils-wrapper -SCRIPTS_DIR = /usr/sbin -WRAPPER_DIR = /usr/lib/xen-common/bin +GLOBAL_SCRIPTS_DIR = /usr/sbin +PRIVATE_SCRIPTS_DIR = /usr/lib/xen-common/bin install: - install -d $(DESTDIR)$(SCRIPTS_DIR) - install -d $(DESTDIR)$(WRAPPER_DIR) + install -d $(DESTDIR)$(GLOBAL_SCRIPTS_DIR) $(DESTDIR)$(PRIVATE_SCRIPTS_DIR) @for i in $(SCRIPTS); do \ - echo ln -s $(WRAPPER_DIR)/$(WRAPPER) $(DESTDIR)$(SCRIPTS_DIR)/$$i; \ - ln -s $(WRAPPER_DIR)/$(WRAPPER) $(DESTDIR)$(SCRIPTS_DIR)/$$i || exit 1; \ + echo ln -s $(PRIVATE_SCRIPTS_DIR)/$(WRAPPER) $(DESTDIR)$(GLOBAL_SCRIPTS_DIR)/$$i; \ + ln -s $(PRIVATE_SCRIPTA_DIR)/$(WRAPPER) $(DESTDIR)$(GLOBAL_SCRIPTS_DIR)/$$i || exit 1; \ done - install $(WRAPPER) $(DESTDIR)$(WRAPPER_DIR) + install $(PRIVATE_SCRIPTS) $(DESTDIR)$(PRIVATE_SCRIPTS_DIR) Added: trunk/xen-common/scripts/xen-utils-root =============================================================================--- (empty file) +++ trunk/xen-common/scripts/xen-utils-root Wed Aug 23 11:05:11 2006 @@ -0,0 +1,35 @@ +#!/bin/bash + +while getopts "qv:" OPT; do + case "$OPT" in + q) + QUIET=1 + ;; + v) + VERSION="$OPTARG" + ;; + esac +done + +# TODO: real version detection + +if [ -z "$VERSION" ]; then + VERSION="default" +fi + +root="/usr/lib/xen-$VERSION" +if [ -d "$root" ]; then + echo "$root" + exit 0 +fi + +root="/usr/lib/xen-default" +if [ -d "$root" ]; then + [ "$QUIET" ] || echo "WARING! Can''t find version $VERSION of xen utils, fallback to default version!" >&2 + echo "$root" + exit 0 +fi + +[ "$QUIET" ] || echo "ERROR! Can''t find default version of xen utils, bailing out!" >&2 +exit 1 + Modified: trunk/xen-common/scripts/xen-utils-wrapper =============================================================================--- trunk/xen-common/scripts/xen-utils-wrapper (original) +++ trunk/xen-common/scripts/xen-utils-wrapper Wed Aug 23 11:05:11 2006 @@ -1,16 +1,5 @@ #!/bin/bash -version="$XEN_VERSION" -# TODO: real version detection -if [ -z "$version" ]; then - version="default" -fi - -root="/usr/lib/xen-$version" -if ! [ -d "$root" ]; then - echo "WARING! Can''t find $version of xen utils, fallback to default version!" >2 - root="/usr/lib/xen-default" -fi - command="$(basename $0)" +root=$(/usr/lib/xen-common/bin/xen-utils-root -v "$XEN_VERSION") exec "$root/bin/$command" "$@"