Changeset 39229 in vbox for trunk/src/VBox/Installer/linux
- Timestamp:
- Nov 8, 2011 11:07:51 AM (13 years ago)
- Location:
- trunk/src/VBox/Installer/linux
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Installer/linux/installer-common.sh
r39223 r39229 38 38 } 39 39 40 generate_udev_rule() { 41 VBOXDRV_GRP="$1" # The group owning the vboxdrv device 42 VBOXDRV_MODE="$2" # The access mode for the vboxdrv device 43 INSTALLATION_DIR="$3" # The directory VirtualBox is installed in 44 USB_GROUP="$4" # The group that has permission to access USB devices 45 NO_INSTALL="$5" # Set this to "1" to remove but not re-install rules 46 UDEV_STRING="$6" # The output of the udev version command 47 48 # Extra space! 49 case "$USB_GROUP" in ?*) USB_GROUP=" $USB_GROUP" ;; esac 50 case "$NO_INSTALL" in 51 "1") ;; 52 *) 53 udev_ver=`expr "$UDEV_STRING" : '[^0-9]*\([0-9]*\)'` 54 udev_fix="" 55 test "$udev_ver" = "" -o "$udev_ver" -lt 55 && 56 udev_fix="1" 57 udev_do_usb="" 58 test "$udev_ver" -ge 59 && 59 udev_do_usb="1" 60 case "$udev_fix" in 61 "1") 62 udev_write_vboxdrv "$VBOXDRV_GRP" "$VBOXDRV_MODE" | 63 sed 's/\([^+=]*\)[+=]*\([^"]*"[^"]*"\)/\1=\2/g' 64 ;; 65 *) 66 udev_write_vboxdrv "$VBOXDRV_GRP" "$VBOXDRV_MODE" 67 case "$udev_do_usb" in "1") 68 udev_write_usb "$INSTALLATION_DIR" "$USB_GROUP" ;; 69 esac 70 ;; 71 esac 72 ;; 73 esac 74 } 75 40 76 install_udev() { 41 77 # install udev rule (disable with INSTALL_NO_UDEV=1 in /etc/default/virtualbox) for distribution packages 42 # To unit test, set $EXTERN to point to a function simulating external43 # commands: test; which; rm. See the code for usage.44 78 VBOXDRV_GRP="$1" # The group owning the vboxdrv device 45 79 VBOXDRV_MODE="$2" # The access mode for the vboxdrv device … … 48 82 NO_INSTALL="$5" # Set this to "1" to remove but not re-install rules 49 83 50 # Extra space! 51 case "$USB_GROUP" in ?*) USB_GROUP=" $USB_GROUP" ;; esac 52 case "$NO_INSTALL" in 53 "1") ;; 54 *) 55 if $EXTERN test -d /etc/udev/rules.d; then 56 udev_call="" 57 udev_app=`$EXTERN which udevadm 2> /dev/null` 58 if [ $? -eq 0 ]; then 59 udev_call="${udev_app} version 2> /dev/null" 60 else 61 udev_app=`$EXTERN which udevinfo 2> /dev/null` 62 if [ $? -eq 0 ]; then 63 udev_call="${udev_app} -V 2> /dev/null" 64 fi 65 fi 66 udev_fix="" 67 if [ "${udev_call}" != "" ]; then 68 udev_out=`${udev_call}` 69 udev_ver=`expr "$udev_out" : '[^0-9]*\([0-9]*\)'` 70 if [ "$udev_ver" = "" -o "$udev_ver" -lt 55 ]; then 71 udev_fix="1" 72 fi 73 udev_do_usb="" 74 if [ "$udev_ver" -ge 59 ]; then 75 udev_do_usb="1" 76 fi 77 fi 78 case "$udev_fix" in 79 "1") 80 udev_write_vboxdrv "$VBOXDRV_GRP" "$VBOXDRV_MODE" | 81 sed 's/\([^+=]*\)[+=]*\([^"]*"[^"]*"\)/\1=\2/g' 82 ;; 83 *) 84 udev_write_vboxdrv "$VBOXDRV_GRP" "$VBOXDRV_MODE" 85 case "$udev_do_usb" in "1") 86 udev_write_usb "$INSTALLATION_DIR" "$USB_GROUP" ;; 87 esac 88 ;; 89 esac 90 91 fi 92 ;; 93 esac 84 if test -d /etc/udev/rules.d; then 85 udev_out="`udevadm version 2>/dev/null || udevinfo -V 2>/dev/null`" 86 generate_udev_rule "$VBOXDRV_GRP" "$VBOXDRV_MODE" "$INSTALLATION_DIR" \ 87 "$USB_GROUP" "$NO_INSTALL" "$udev_out" 88 fi 94 89 # Remove old udev description file 95 if $EXTERN test -f /etc/udev/rules.d/60-vboxdrv.rules; then 96 $EXTERN rm -f /etc/udev/rules.d/60-vboxdrv.rules 2> /dev/null 97 fi 90 rm -f /etc/udev/rules.d/60-vboxdrv.rules 2> /dev/null 98 91 } 99 92 -
trunk/src/VBox/Installer/linux/testcase/tstInstallerLinux.sh
r39223 r39229 22 22 echo "Testing udev rule generation" 23 23 24 extern_test_input_install_udev() { 25 command="$1" 26 shift 27 case "$command" in 28 "which") my_which "$@";; 29 "test") my_test "$@";; 30 "rm") my_rm "$@";; 31 *) echo Unknown command $command >&2; exit 1;; 32 esac 24 check_udev_rule_generation() { 25 OUTPUT="$2" 26 EXPECTED="$4" 27 VERSION="$6" 28 case "$OUTPUT" in 29 "$EXPECTED") ;; 30 *) 31 echo "Bad output for udev version $VERSION. Expected:" 32 echo "$EXPECTED" 33 echo "Actual:" 34 echo "$OUTPUT" 35 CERRS="`expr "$CERRS" + 1`" 36 ;; 37 esac 33 38 } 34 35 setup_test_input_install_udev() {36 # Set up unit testing environment for the "install_udev" function below.37 TEST_NAME="$1" # used to identify the current test38 TEST_UDEV_VERSION="$2" # udev version to simulate39 EXTERN=extern_test_input_install_udev40 eval 'my_which() { echo test_udev ; }'41 eval 'my_test() { true ; }'42 eval 'my_rm() { case "$2" in "/etc/udev/rules.d/60-vboxdrv.rules") true ;; *) echo "rm: bad file name \"$2\"!"; false ;; esac ; }'43 eval 'test_udev() { echo "$TEST_UDEV_VERSION" ; }'44 DELETED_UDEV_FILE=""45 }46 47 setup_test_input_install_udev ".run, udev-59" 5948 39 49 40 udev_59_rules=`cat <<'UDEV_END' … … 55 46 UDEV_END` 56 47 57 install_udev_output="`install_udev vboxusers 0660 /opt/VirtualBox`" 58 case "$install_udev_output" in 59 "$udev_59_rules") ;; 60 *) 61 echo "Bad output for udev version 59. Expected:" 62 echo "$udev_59_rules" 63 echo "Actual:" 64 echo "$install_udev_output" 65 CERRS="`expr "$CERRS" + 1`" 66 ;; 67 esac 68 69 setup_test_input_install_udev ".run, udev-55" 55 48 install_udev_output="`generate_udev_rule vboxusers 0660 /opt/VirtualBox "" "" "udevinfo, version 059"`" 49 check_udev_rule_generation OUTPUT "$install_udev_output" \ 50 EXPECTED "$udev_59_rules" \ 51 VERSION 59 70 52 71 53 udev_55_rules=`cat <<'UDEV_END' … … 73 55 UDEV_END` 74 56 75 install_udev_output="`install_udev vboxusers 0660 /opt/VirtualBox`" 76 case "$install_udev_output" in 77 "$udev_55_rules") ;; 78 *) 79 echo "Bad output for udev version 55. Expected:" 80 echo "$udev_55_rules" 81 echo "Actual:" 82 echo "$install_udev_output" 83 CERRS="`expr "$CERRS" + 1`" 84 ;; 85 esac 86 87 setup_test_input_install_udev ".run, udev-54" 54 57 install_udev_output="`generate_udev_rule vboxusers 0660 /opt/VirtualBox "" "" "v 0055"`" 58 check_udev_rule_generation OUTPUT "$install_udev_output" \ 59 EXPECTED "$udev_55_rules" \ 60 VERSION 55 88 61 89 62 udev_54_rules=`cat <<'UDEV_END' … … 91 64 UDEV_END` 92 65 93 install_udev_output="`install_udev root 0600 /usr/lib/virtualbox`" 94 case "$install_udev_output" in 95 "$udev_54_rules") ;; 96 *) 97 echo "Bad output for udev version 54. Expected:" 98 echo "$udev_54_rules" 99 echo "Actual:" 100 echo "$install_udev_output" 101 CERRS="`expr "$CERRS" + 1`" 102 ;; 103 esac 66 install_udev_output="`generate_udev_rule root 0600 /usr/lib/virtualbox "" "" 54`" 67 check_udev_rule_generation OUTPUT "$install_udev_output" \ 68 EXPECTED "$udev_54_rules" \ 69 VERSION 54 104 70 105 71 echo "Testing device node setup"
Note:
See TracChangeset
for help on using the changeset viewer.