Changeset 38385 in vbox for trunk/src/VBox/Installer/linux
- Timestamp:
- Aug 9, 2011 4:22:56 PM (13 years ago)
- Location:
- trunk/src/VBox/Installer/linux
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Installer/linux/install.sh
r37124 r38385 442 442 fi 443 443 444 # Create udev description file 445 install_udev "$VBOXDRV_GRP" "$VBOXDRV_MODE" "$INSTALLATION_DIR" \ 446 > /etc/udev/rules.d/10-vboxdrv.rules 447 448 # Build our device tree 449 for i in /sys/bus/usb/devices/*; do 450 if test -r "$i/dev"; then 451 dev="`cat "$i/dev" 2> /dev/null`" 452 major="`expr "$dev" : '\(.*\):' 2> /dev/null`" 453 minor="`expr "$dev" : '.*:\(.*\)' 2> /dev/null`" 454 class="`cat $i/bDeviceClass 2> /dev/null`" 455 sh "$INSTALLATION_DIR/VBoxCreateUSBNode.sh" "$major" "$minor" "$class" 2>/dev/null 456 fi 457 done 444 install_device_node_setup "$VBOXDRV_GRP" "$VBOXDRV_MODE" "$INSTALLATION_DIR" 458 445 459 446 # Write the configuration. Do this before we call /etc/init.d/vboxdrv setup! -
trunk/src/VBox/Installer/linux/installer-utils.sh
r37423 r38385 15 15 16 16 setup_normal_input_install_udev() { 17 TEST_UDEV_VERSION="$1" # udev version to simulate 17 # The udev rule setup functions contain some aliases which are used for unit 18 # testing purposes. This function sets up the aliases to point to the real 19 # commands for "normal" use. 18 20 eval 'my_which() { which "$@" ; }' 19 21 eval 'my_test() { test "$@" ; }' … … 21 23 } 22 24 25 # Needs to be done before the udev setup functions are called "normally" (i.e. 26 # not in a unit testing context). Will be overridden later in a unit test. 23 27 setup_normal_input_install_udev 24 28 25 29 setup_test_input_install_udev() { 30 # Set up unit testing environment for the "install_udev" function below. 26 31 TEST_NAME="$1" # used to identify the current test 27 32 TEST_UDEV_VERSION="$2" # udev version to simulate … … 30 35 eval 'my_rm() { case "$2" in "/etc/udev/rules.d/60-vboxdrv.rules") true ;; *) echo "rm: bad file name \"$2\"!"; false ;; esac ; }' 31 36 eval 'test_udev() { echo "$TEST_UDEV_VERSION" ; }' 37 DELETED_UDEV_FILE="" 38 } 39 40 cleanup_test_input_install_udev() { 41 # Clean up after unit testing install_udev for a given input 42 setup_normal_input_install_udev 43 unset test_udev 32 44 DELETED_UDEV_FILE="" 33 45 } … … 108 120 } 109 121 110 cleanup_test_input_install_udev() { 111 setup_normal_input_install_udev 112 unset test_udev 113 DELETED_UDEV_FILE="" 114 } 122 setup_normal_input_install_create_usb_node() { 123 # install_create_usb_node_for_sysfs contain some aliases for unit testing 124 # purposes. This function sets up the aliases to point to the real 125 # commands for "normal" use. 126 eval 'my_test() { test "$@" ; }' 127 eval 'my_cat() { cat "$@" ; }' 128 eval 'my_sh() { sh "$@" ; }' 129 } 130 131 # Assume we will be calling the function normally, not for unit testing 132 setup_normal_input_install_create_usb_node 133 134 # Add a unit test here if/when needed following the same pattern as 135 # setup_test_input_install_udev. 136 137 install_create_usb_node_for_sysfs() { 138 # Create a usb device node for a given sysfs path 139 path="$1" # sysfs path for the device 140 usb_createnode="$2" # Path to the USB device node creation script 141 usb_group="$3" # The group to give ownership of the node to 142 if my_test -r "${path}/dev"; then 143 dev="`my_cat "${path}/dev" 2> /dev/null`" 144 major="`expr "$dev" : '\(.*\):' 2> /dev/null`" 145 minor="`expr "$dev" : '.*:\(.*\)' 2> /dev/null`" 146 class="`my_cat ${path}/bDeviceClass 2> /dev/null`" 147 my_sh "${usb_createnode}" "$major" "$minor" "$class" "${usb_group}" \ 148 2>/dev/null 149 fi 150 } 151 152 setup_normal_input_install_device_node_setup() { 153 # install_device_node_setup contain some aliases for unit testing 154 # purposes. This function sets up the aliases to point to the real 155 # values for "normal" use. 156 udev_rule_file=/etc/udev/rules.d/10-vboxdrv.rules # Set this to /dev/null 157 # for unit testing 158 sysfs_usb_devices="/sys/bus/usb/devices/*" 159 eval 'do_install_udev() { install_udev "$@"; }' 160 eval 'do_install_create_usb_node_for_sysfs() { \ 161 install_create_usb_node_for_sysfs "$@" ; }' 162 } 163 164 # Assume we will be calling the function normally, not for unit testing 165 setup_normal_input_install_device_node_setup 166 167 setup_test_input_install_device_node_setup() { 168 # Set up unit testing environment for the "install_udev" function below. 169 test_drv_grp="$1" # The expected vboxdrv group 170 test_drv_mode="$2" # The expected vboxdrv mode 171 test_inst_dir="$3" # The expected installation directory 172 test_usb_grp="$4" # The expected USB node group 173 udev_rule_file=/dev/null 174 sysfs_usb_devices=test_sysfs_path 175 eval 'do_install_udev() { test "$1" = "${test_drv_grp}" \ 176 -a "$2" = "${test_drv_mode}" \ 177 -a "$3" = "${test_inst_dir}" \ 178 -a "$4" = "${test_usb_grp}" \ 179 -a "$5" = "${INSTALL_NO_UDEV}" \ 180 || echo "do_install_udev: bad parameters: $@" >&2 ; }' 181 eval 'do_install_create_usb_node_for_sysfs() { \ 182 test "$1" = "${sysfs_usb_devices}" \ 183 -a "$2" = "${test_inst_dir}/VBoxCreateUSBNode.sh" \ 184 -a "$3" = "${test_usb_grp}" \ 185 || echo "do_install_create_usb_node_for_sysfs: \ 186 bad parameters: $@" >&2 ; }' 187 } 188 189 cleanup_test_input_install_device_node_setup() { 190 # Clean up unit testing environment for the "install_udev" function below. 191 # Nothing to do. 192 true 193 } 194 195 install_device_node_setup() { 196 # Install udev rules and create device nodes for usb access 197 VBOXDRV_GRP="$1" # The group that should own /dev/vboxdrv 198 VBOXDRV_MODE="$2" # The mode to be used for /dev/vboxdrv 199 INSTALLATION_DIR="$3" # The directory VirtualBox is installed in 200 USB_GROUP="$4" # The group that should own the /dev/vboxusb device 201 # nodes unless INSTALL_NO_GROUP=1 in 202 # /etc/default/virtualbox. Optional. 203 usb_createnode="$INSTALLATION_DIR/VBoxCreateUSBNode.sh" 204 # install udev rule (disable with INSTALL_NO_UDEV=1 in 205 # /etc/default/virtualbox) 206 if [ "$INSTALL_NO_GROUP" != "1" ]; then 207 usb_group=$USB_GROUP 208 vboxdrv_group=$VBOXDRV_GRP 209 else 210 usb_group=root 211 vboxdrv_group=root 212 fi 213 do_install_udev "${vboxdrv_group}" "$VBOXDRV_MODE" "$INSTALLATION_DIR" \ 214 "${usb_group}" "$INSTALL_NO_UDEV" > ${udev_rule_file} 215 # Build our device tree 216 for i in ${sysfs_usb_devices}; do # This line intentionally without quotes. 217 do_install_create_usb_node_for_sysfs "$i" "${usb_createnode}" \ 218 "${usb_group}" 219 done 220 } -
trunk/src/VBox/Installer/linux/testcase/tstInstallerLinux.sh
r37124 r38385 86 86 cleanup_test_input_install_udev 87 87 88 echo "Testing device node setup" 89 90 unset INSTALL_NO_GROUP 91 unset INSTALL_NO_UDEV 92 setup_test_input_install_device_node_setup vboxusers 0660 /opt/VirtualBox \ 93 vboxusb 94 95 command="install_device_node_setup vboxusers 0660 /opt/VirtualBox vboxusb" 96 err="`${command} 2>&1`" 97 test -n "${err}" && { 98 echo "${command} failed." 99 echo "Error: ${err}" 100 CERRS="`expr "$CERRS" + 1`" 101 } 102 103 cleanup_test_input_install_device_node_setup 104 105 INSTALL_NO_GROUP=1 106 unset INSTALL_NO_UDEV 107 setup_test_input_install_device_node_setup root 0660 /opt/VirtualBox root 108 109 command="install_device_node_setup vboxusers 0660 /opt/VirtualBox vboxusb" 110 err="`${command} 2>&1`" 111 test -n "${err}" && { 112 echo "${command} failed." 113 echo "Error: ${err}" 114 CERRS="`expr "$CERRS" + 1`" 115 } 116 117 cleanup_test_input_install_device_node_setup 118 119 unset INSTALL_NO_GROUP 120 INSTALL_NO_UDEV=1 121 setup_test_input_install_device_node_setup vboxusers 0660 /opt/VirtualBox \ 122 vboxusb 123 124 command="install_device_node_setup vboxusers 0660 /opt/VirtualBox vboxusb" 125 err="`${command} 2>&1`" 126 test -n "${err}" && { 127 echo "${command} failed." 128 echo "Error: ${err}" 129 CERRS="`expr "$CERRS" + 1`" 130 } 131 132 cleanup_test_input_install_device_node_setup 133 88 134 echo "Done. Error count $CERRS."
Note:
See TracChangeset
for help on using the changeset viewer.