diff --git a/TODO b/TODO index df97666..273c022 100644 --- a/TODO +++ b/TODO @@ -191,3 +191,24 @@ Axel's Break-Backwards-Compatibility Wishlist This would ease tab completion and CLI parameter reusage with "xm create" and friends. + +* Check if we can reduce MAKEDEV invocations in hooks/common/55-create-dev + + MAKEDEV std is called in any case. First comment says "Early + termination if we have a couple of common devices present should + speed up installs which use --copy/--tar" and then "We still need + to make sure the basic devices are present" and calls MAKEDEV more + often than otherwise. + + Additionally the 55-create-dev for CentOS/Fedora just created + console, zero and null. zero and null are part of "MAKEDEV std", + perhaps can we reduce it to that. console is part of "MAKEDEV + generic". + + Additionally the devices hda, sda and tty1 may not necessary in any + case, but instead hvc0 should be created for sure in many + cases. Nothing cares about $serial_device there either. + + Current MAKEDEV implementation support more than one device as + parameter. That could reduce the MAKEDEV calls from currently six + to two. diff --git a/hooks/common/55-create-dev b/hooks/common/55-create-dev index 89577ce..9b3006c 100755 --- a/hooks/common/55-create-dev +++ b/hooks/common/55-create-dev @@ -11,7 +11,6 @@ prefix=$1 - # # Source our common functions # @@ -27,13 +26,34 @@ fi # logMessage Script $0 starting +# +# Test where MAKEDEV is located, assuming /sbin/ as default +# +MAKEDEV='' +MAKEDEV_PATHS="/sbin/MAKEDEV /dev/MAKEDEV" +for MAKEDEV_PATH in ${MAKEDEV_PATHS}; do + if [ -x "${prefix}${MAKEDEV_PATH}" ]; then + MAKEDEV="${prefix}${MAKEDEV_PATH}" + break + fi +done +if [ -n "${MAKEDEV}" ]; then # # Early termination if we have a couple of common devices present # should speed up installs which use --copy/--tar # if ( test `ls -1 ${prefix}/dev | wc -l` -gt 10 ); then + # + # We still need to make sure the basic devices are present + # + cd ${prefix}/dev + ${MAKEDEV} std + ${MAKEDEV} hda + ${MAKEDEV} sda + ${MAKEDEV} tty1 + logMessage "Terminating because there appear to be files in /dev already" exit fi @@ -42,10 +62,11 @@ fi # # Make the device nodes. # -chroot ${prefix} /bin/sh -c 'cd /dev && ./MAKEDEV console' -chroot ${prefix} /bin/sh -c 'cd /dev && ./MAKEDEV null' -chroot ${prefix} /bin/sh -c 'cd /dev && ./MAKEDEV zero' +cd ${prefix}/dev +${MAKEDEV} generic +${MAKEDEV} std +fi # -n ${MAKEDEV} # # Log our finish diff --git a/hooks/dapper/55-create-dev b/hooks/dapper/55-create-dev deleted file mode 100755 index b692512..0000000 --- a/hooks/dapper/55-create-dev +++ /dev/null @@ -1,51 +0,0 @@ -#!/bin/sh -# -# This script ensures that the new guest images have a nicely -# populated /dev directory. -# -# Steve -# -- -# http://www.steve.org.uk/ - - -prefix=$1 - - -# -# Source our common functions -# -if [ -e /usr/lib/xen-tools/common.sh ]; then - . /usr/lib/xen-tools/common.sh -else - . ./hooks/common.sh -fi - - -# -# Log our start -# -logMessage Script $0 starting - - -# -# Early termination if we have a couple of common devices present -# should speed up installs which use --copy/--tar -# -if ( test `ls -1 ${prefix}/dev | wc -l` -gt 10 ); then - logMessage "Terminating because there appear to be files in /dev already" - exit -fi - - -# -# Make the device nodes. -# -cd ${prefix}/dev -./MAKEDEV generic -./MAKEDEV std - - -# -# Log our finish -# -logMessage Script $0 finished diff --git a/hooks/dapper/55-create-dev b/hooks/dapper/55-create-dev new file mode 120000 index 0000000..1f725c9 --- /dev/null +++ b/hooks/dapper/55-create-dev @@ -0,0 +1 @@ +../common/55-create-dev \ No newline at end of file diff --git a/hooks/debian/55-create-dev b/hooks/debian/55-create-dev deleted file mode 100755 index 9b3006c..0000000 --- a/hooks/debian/55-create-dev +++ /dev/null @@ -1,74 +0,0 @@ -#!/bin/sh -# -# This script ensures that the new guest images have a nicely -# populated /dev directory. -# -# Steve -# -- -# http://www.steve.org.uk/ - - -prefix=$1 - - -# -# Source our common functions -# -if [ -e /usr/lib/xen-tools/common.sh ]; then - . /usr/lib/xen-tools/common.sh -else - . ./hooks/common.sh -fi - - -# -# Log our start -# -logMessage Script $0 starting - -# -# Test where MAKEDEV is located, assuming /sbin/ as default -# -MAKEDEV='' -MAKEDEV_PATHS="/sbin/MAKEDEV /dev/MAKEDEV" -for MAKEDEV_PATH in ${MAKEDEV_PATHS}; do - if [ -x "${prefix}${MAKEDEV_PATH}" ]; then - MAKEDEV="${prefix}${MAKEDEV_PATH}" - break - fi -done - -if [ -n "${MAKEDEV}" ]; then - -# -# Early termination if we have a couple of common devices present -# should speed up installs which use --copy/--tar -# -if ( test `ls -1 ${prefix}/dev | wc -l` -gt 10 ); then - # - # We still need to make sure the basic devices are present - # - cd ${prefix}/dev - ${MAKEDEV} std - ${MAKEDEV} hda - ${MAKEDEV} sda - ${MAKEDEV} tty1 - - logMessage "Terminating because there appear to be files in /dev already" - exit -fi - - -# -# Make the device nodes. -# -cd ${prefix}/dev -${MAKEDEV} generic -${MAKEDEV} std - -fi # -n ${MAKEDEV} - -# -# Log our finish -# -logMessage Script $0 finished diff --git a/hooks/debian/55-create-dev b/hooks/debian/55-create-dev new file mode 120000 index 0000000..1f725c9 --- /dev/null +++ b/hooks/debian/55-create-dev @@ -0,0 +1 @@ +../common/55-create-dev \ No newline at end of file diff --git a/hooks/gentoo/55-create-dev b/hooks/gentoo/55-create-dev deleted file mode 100755 index 1b16a80..0000000 --- a/hooks/gentoo/55-create-dev +++ /dev/null @@ -1,51 +0,0 @@ -#!/bin/sh -# -# This script ensures that the new guest images have a nicely -# populated /dev directory. -# -# Steve -# -- -# http://www.steve.org.uk/ - - -prefix=$1 - - -# -# Source our common functions -# -if [ -e /usr/lib/xen-tools/common.sh ]; then - . /usr/lib/xen-tools/common.sh -else - . ./hooks/common.sh -fi - - -# -# Log our start -# -logMessage Script $0 starting - - - -# -# Early termination if we have a couple of common devices present -# should speed up installs which use --copy/--tar -# -if ( test `ls -1 ${prefix}/dev | wc -l` -gt 10 ); then - logMessage "Terminating because there appear to be files in /dev already" - exit -fi - - -# -# Make the device nodes. -# -cd ${prefix}/dev -./MAKEDEV generic - - -# -# Log our finish -# -logMessage Script $0 finished diff --git a/hooks/gentoo/55-create-dev b/hooks/gentoo/55-create-dev new file mode 120000 index 0000000..1f725c9 --- /dev/null +++ b/hooks/gentoo/55-create-dev @@ -0,0 +1 @@ +../common/55-create-dev \ No newline at end of file