Changeset 75839 in vbox for trunk/src/VBox/Additions/linux/installer
- Timestamp:
- Nov 30, 2018 11:07:51 AM (6 years ago)
- Location:
- trunk/src/VBox/Additions/linux/installer
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Additions/linux/installer/install.sh.in
r70930 r75839 60 60 usage() 61 61 { 62 info "" 63 info "Usage: $SELF install [<installation directory>]" 64 info " [--with-<module>] |" 65 info " uninstall" 66 info " [--force] [--no-setup]" 67 info "" 68 info "Example:" 69 info "$SELF install" 62 catinfo << EOF 63 64 Usage: $SELF install [<installation directory>] 65 [--with-<module>] 66 [--package-base <base> | 67 uninstall 68 [--force] [--no-setup] 69 70 Options: 71 --package-base <base> For use when building distribution packages. 72 Installs relative to <base> instead of to "/", 73 does not run setup, installs to "<base>/usr/lib" 74 instead of to "/opt" and does not create uninstall. 75 76 Example: 77 $SELF install 78 EOF 70 79 exit 1 71 80 } … … 159 168 fi 160 169 fi 170 # Inhibit rebuilding of any installed kernels. 171 for i in /lib/modules/*; do 172 ver="${i##*/}" 173 test ! -d "$i"/build || touch /var/lib/VBoxGuestAdditions/skip-"$ver" 174 done 161 175 # Stop what we can in the way of services and remove them from the 162 176 # system … … 195 209 info "$PACKAGE_NAME installer" 196 210 197 # Check architecture198 cpu=`uname -m`;199 case "$cpu" in200 i[3456789]86|x86)201 cpu="x86"202 lib_candidates="/usr/lib/i386-linux-gnu /usr/lib /lib"203 ;;204 x86_64|amd64)205 cpu="amd64"206 lib_candidates="/usr/lib/x86_64-linux-gnu /usr/lib64 /usr/lib /lib64 /lib"207 ;;208 *)209 cpu="unknown"210 esac211 ARCH_PACKAGE="$PACKAGE-$cpu.tar.bz2"212 if [ ! -r "$ARCH_PACKAGE" ]; then213 info "Detected unsupported $cpu machine type."214 exit 1215 fi216 # Find the most appropriate libary folder by seeing which of the candidate paths217 # are actually in the shared linker path list and choosing the first. We look218 # for Debian-specific paths first, then LSB ones, then the new RedHat ones.219 libs=`ldconfig -v 2>/dev/null | grep -v ^$'\t'`220 for i in $lib_candidates; do221 if echo $libs | grep -q $i; then222 lib_path=$i223 break224 fi225 done226 if [ ! -x "$lib_path" ]; then227 info "Unable to determine correct library path."228 exit 1229 fi230 231 211 # Sensible default actions 232 212 ACTION="install" … … 234 214 NO_CLEANUP="" 235 215 FORCE_UPGRADE="" 216 PACKAGE_BASE="" 236 217 237 218 while [ $# -ge 2 ]; … … 249 230 uninstall) 250 231 ACTION="uninstall" 232 ;; 233 234 package) 235 ACTION="package" 236 INSTALLATION_DIR=/usr/lib 237 PACKAGE_BASE="$2" 238 DO_SETUP="" 239 shift 240 if test ! -d "${PACKAGE_BASE}"; then 241 info "Package base directory not found." 242 usage 243 fi 251 244 ;; 252 245 … … 315 308 done 316 309 310 # Check architecture 311 cpu=`uname -m`; 312 case "$cpu" in 313 i[3456789]86|x86) 314 cpu="x86" 315 lib_candidates="/usr/lib/i386-linux-gnu /usr/lib /lib" 316 ;; 317 x86_64|amd64) 318 cpu="amd64" 319 lib_candidates="/usr/lib/x86_64-linux-gnu /usr/lib64 /usr/lib /lib64 /lib" 320 ;; 321 *) 322 cpu="unknown" 323 esac 324 ARCH_PACKAGE="$PACKAGE-$cpu.tar.bz2" 325 if [ ! -r "$ARCH_PACKAGE" ]; then 326 info "Detected unsupported $cpu machine type." 327 exit 1 328 fi 329 # Find the most appropriate libary folder by seeing which of the candidate paths 330 # are actually in the shared linker path list and choosing the first. We look 331 # for Debian-specific paths first, then LSB ones, then the new RedHat ones. 332 libs=`ldconfig -v 2>/dev/null | grep -v ^$'\t'` 333 for i in $lib_candidates; do 334 if echo $libs | grep -q $i; then 335 lib_path=$i 336 break 337 fi 338 done 339 if [ ! -x "$lib_path" ]; then 340 info "Unable to determine correct library path." 341 exit 1 342 fi 343 317 344 # uninstall any previous installation 318 345 # If the currently installed Additions have provided an uninstallation hook, try … … 387 414 388 415 # Set symlinks into /usr and /sbin 389 link_into_fs "bin" " /usr/bin"390 link_into_fs "sbin" " /usr/sbin"416 link_into_fs "bin" "${PACKAGE_BASE}/usr/bin" 417 link_into_fs "sbin" "${PACKAGE_BASE}/usr/sbin" 391 418 link_into_fs "lib" "$lib_path" 392 add_symlink "$INSTALLATION_DIR/lib/$PACKAGE" /usr/lib/"$PACKAGE" 393 link_into_fs "src" "/usr/src" 419 link_into_fs "src" "${PACKAGE_BASE}/usr/src" 394 420 395 421 if [ -d "$INSTALLATION_MODULES_DIR" ]; then -
trunk/src/VBox/Additions/linux/installer/vboxadd.sh
r75428 r75839 60 60 ## systemd logs information about service status, otherwise do that ourselves. 61 61 QUIET= 62 test -z "${KERN_VER}" && KERN_VER=`uname -r` 62 test -z "${TARGET_VER}" && TARGET_VER=`uname -r` 63 # Marker to ignore a particular kernel version which was already installed. 64 SKIPFILE_BASE=/var/lib/VBoxGuestAdditions/skip 63 65 64 66 setup_log() 65 67 { 66 test - n "${LOG}" &&return 068 test -z "${LOG}" || return 0 67 69 # Rotate log files 68 70 LOG="/var/log/vboxadd-setup.log" … … 105 107 begin() 106 108 { 107 test - z "${QUIET}" &&echo "${SERVICE}: ${1}"109 test -n "${QUIET}" || echo "${SERVICE}: ${1}" 108 110 } 109 111 … … 184 186 fi 185 187 fi 186 test - z "$maj" &&{188 test -n "$maj" || { 187 189 rmmod vboxguest 2>/dev/null 188 190 fail "Cannot locate the VirtualBox device" … … 223 225 { 224 226 begin "Starting." 225 # If we got this far assume that the slow set-up has been done.226 QUICKSETUP=start227 227 if test -z "${INSTALL_NO_MODULE_BUILDS}"; then 228 uname -r | grep -q -E '^2\.6|^3|^4' 2>/dev/null && 228 setup --quick 229 test -d /sys && 229 230 ps -A -o comm | grep -q '/*udevd$' 2>/dev/null || 230 231 no_udev=1 … … 233 234 fail "Cannot remove $dev" 234 235 } 235 236 236 rm -f $userdev || { 237 237 fail "Cannot remove $userdev" 238 238 } 239 240 $MODPROBE vboxguest >/dev/null 2>&1 || { 241 setup 242 $MODPROBE vboxguest >/dev/null 2>&1 || 243 fail "modprobe vboxguest failed" 244 } 239 $MODPROBE vboxguest >/dev/null 2>&1 || 240 fail "modprobe vboxguest failed" 245 241 case "$no_udev" in 1) 246 242 sleep .5;; … … 252 248 253 249 running_vboxsf || { 254 $MODPROBE vboxsf > /dev/null 2>&1 || { 255 if dmesg | grep "VbglR0SfConnect failed" > /dev/null 2>&1; then 256 info "Unable to start shared folders support. Make sure that your VirtualBox build supports this feature." 257 else 258 info "modprobe vboxsf failed" 259 fi 260 } 250 $MODPROBE vboxsf > /dev/null 2>&1 || 251 info "modprobe vboxsf failed" 261 252 } 262 253 fi # INSTALL_NO_MODULE_BUILDS … … 278 269 { 279 270 begin "Stopping." 271 test -n "${INSTALL_NO_MODULE_BUILDS}" || setup --quick 280 272 if test -r /etc/ld.so.conf.d/00vboxvideo.conf; then 281 273 rm /etc/ld.so.conf.d/00vboxvideo.conf … … 308 300 depmod "${version}" 309 301 rm -f "/lib/modules/${version}/initrd/vboxvideo" 310 test -d "/lib/modules/${version}/initrd" &&311 test -f "/lib/modules/${version}/misc/vboxvideo.ko" &&302 test ! -d "/lib/modules/${version}/initrd" || 303 test ! -f "/lib/modules/${version}/misc/vboxvideo.ko" || 312 304 touch "/lib/modules/${version}/initrd/vboxvideo" 313 305 … … 328 320 cleanup_modules() 329 321 { 330 test "x${1}" = x--skip && skip_ver="${2}"331 322 # Needed for Ubuntu and Debian, see update_initramfs 332 323 rm -f /lib/modules/*/initrd/vboxvideo 333 324 for i in /lib/modules/*/misc; do 334 kern_ver="${i%/misc}"335 kern_ver="${kern_ver#/lib/modules/}"325 KERN_VER="${i%/misc}" 326 KERN_VER="${KERN_VER#/lib/modules/}" 336 327 unset do_update 337 328 for j in ${OLDMODULES}; do 338 329 test -f "${i}/${j}.ko" && do_update=1 && rm -f "${i}/${j}.ko" 339 330 done 340 test -n "${do_update}" && test "x${kern_ver}" != "x${skip_ver}" && 341 update_initramfs "${kern_ver}" 331 test -z "$do_update" || update_initramfs "$KERN_VER" 342 332 # Remove empty /lib/modules folders which may have been kept around 343 333 rmdir -p "${i}" 2>/dev/null || true 344 334 unset keep 345 for j in /lib/modules/"${ kern_ver}"/*; do335 for j in /lib/modules/"${KERN_VER}"/*; do 346 336 name="${j##*/}" 347 337 test -d "${name}" || test "${name%%.*}" != modules && keep=1 348 338 done 349 339 if test -z "${keep}"; then 350 rm -rf /lib/modules/"${ kern_ver}"351 rm -f /boot/initrd.img-"${ kern_ver}"340 rm -rf /lib/modules/"${KERN_VER}" 341 rm -f /boot/initrd.img-"${KERN_VER}" 352 342 fi 353 343 done … … 357 347 done 358 348 rm -f /etc/depmod.d/vboxvideo-upstream.conf 349 rm -f "$SKIPFILE_BASE"-* 359 350 } 360 351 … … 362 353 setup_modules() 363 354 { 364 # don't stop the old modules here -- they might be in use 365 test -z "${QUICKSETUP}" && cleanup_modules --skip "${KERN_VER}" 366 # This does not work for 2.4 series kernels. How sad. 367 test -n "${QUICKSETUP}" && test -f "${MODULE_DIR}/vboxguest.ko" && return 0 368 info "Building the VirtualBox Guest Additions kernel modules. This may take a while." 369 370 # If the kernel headers are not there, wait at bit in case they get 371 # installed. Package managers have been known to trigger module rebuilds 372 # before actually installing the headers. 373 for delay in 60 60 60 60 60 300 30 300 300; do 374 test "x${QUICKSETUP}" = xyes || break 375 test -d "/lib/modules/${KERN_VER}/build" && break 376 printf "Kernel modules not yet installed, waiting %s seconds." "${delay}" 377 sleep "${delay}" 378 done 379 380 # Inhibit shutdown for up to ten minutes if possible. 381 systemd-inhibit 600 2>/dev/null & 382 log "Building the main Guest Additions module." 355 KERN_VER="$1" 356 test -n "$KERN_VER" || return 1 357 test ! -f /lib/modules/"$KERN_VER"/misc/vboxguest.ko || return 0 358 test ! -f /lib/modules/"$KERN_VER"/misc/vboxguest.o || return 0 359 test -d /lib/modules/"$KERN_VER"/build || return 0 360 test ! -f "$SKIPFILE_BASE"-"$KERN_VER" || return 0 361 export KERN_VER 362 info "Building the modules for kernel $KERN_VER." 363 364 log "Building the main Guest Additions module for kernel $KERN_VER." 383 365 if ! myerr=`$BUILDINTMP \ 384 366 --save-module-symvers /tmp/vboxguest-Module.symvers \ … … 389 371 "${INSTALL_DIR}"/other/check_module_dependencies.sh 2>&1 && 390 372 info "Look at $LOG to find out what went wrong" 391 kill $! 2>/dev/null392 373 return 0 393 374 fi … … 399 380 module_build_log "$myerr" 400 381 info "Look at $LOG to find out what went wrong" 401 kill $! 2>/dev/null402 382 return 0 403 383 fi … … 415 395 echo "override vboxvideo * misc" >> /etc/depmod.d/vboxvideo-upstream.conf 416 396 update_initramfs "${KERN_VER}" 417 depmod418 kill $! 2>/dev/null419 397 return 0 420 398 } … … 458 436 } 459 437 460 create_module_rebuild_script()461 {462 # And a post-installation script for rebuilding modules when a new kernel463 # is installed.464 mkdir -p /etc/kernel/postinst.d /etc/kernel/prerm.d465 cat << EOF > /etc/kernel/postinst.d/vboxadd466 #!/bin/sh467 # Run in the background so that we can wait in case the package installer has468 # not yet installed the kernel headers we need.469 KERN_VER="\${1}" /sbin/rcvboxadd quicksetup &470 exit 0471 EOF472 cat << EOF > /etc/kernel/prerm.d/vboxadd473 #!/bin/sh474 for i in ${OLDMODULES}; do rm -f /lib/modules/"\${1}"/misc/"\${i}".ko; done475 rmdir -p /lib/modules/"\$1"/misc 2>/dev/null476 exit 0477 EOF478 chmod 0755 /etc/kernel/postinst.d/vboxadd /etc/kernel/prerm.d/vboxadd479 }480 481 438 shared_folder_setup() 482 439 { … … 507 464 export USERNAME 508 465 466 test x"$1" != x--quick || QUICKSETUP=true 467 test -n "$QUICKSETUP" || cleanup 509 468 MODULE_SRC="$INSTALL_DIR/src/vboxguest-$INSTALL_VER" 510 469 BUILDINTMP="$MODULE_SRC/build_in_tmp" 511 test -e /etc/selinux/config &&470 test ! -e /etc/selinux/config || 512 471 chcon -t bin_t "$BUILDINTMP" 513 472 514 test -z "${INSTALL_NO_MODULE_BUILDS}" && setup_modules 473 if test -z "$INSTALL_NO_MODULE_BUILDS"; then 474 if test -z "$QUICKSETUP"; then 475 info "Building the VirtualBox Guest Additions kernel modules. This may take a while." 476 info "To build modules for other installed kernels, run" 477 info " /sbin/rcvboxadd quicksetup <version>" 478 for setupi in /lib/modules/*; do 479 KERN_VER="${setupi##*/}" 480 # For a full setup, mark kernels we do not want to build. 481 touch "$SKIPFILE_BASE"-"$KERN_VER" 482 done 483 fi 484 # That is, we mark all but the requested kernel. 485 rm -f "$SKIPFILE_BASE"-"$TARGET_VER" 486 for setupi in /lib/modules/*; do 487 KERN_VER="${setupi##*/}" 488 setup_modules "$KERN_VER" 489 done 490 depmod 491 fi 515 492 create_vbox_user 516 493 create_udev_rule 517 test -z "${INSTALL_NO_MODULE_BUILDS}" && create_module_rebuild_script 518 test -n "${QUICKSETUP}" && return 0 494 test -z "$QUICKSETUP" || return 0 519 495 shared_folder_setup 520 496 if running_vboxguest || running_vboxadd; then … … 543 519 # Remove other files 544 520 rm /sbin/mount.vboxsf 2>/dev/null 545 if test -z "${INSTALL_NO_MODULE_BUILDS}"; then546 rm -f /etc/kernel/postinst.d/vboxadd /etc/kernel/prerm.d/vboxadd547 rmdir -p /etc/kernel/postinst.d /etc/kernel/prerm.d 2>/dev/null548 fi549 521 rm /etc/udev/rules.d/60-vboxadd.rules 2>/dev/null 550 522 } … … 577 549 ;; 578 550 quicksetup) 579 QUICKSETUP=yes580 setup 551 test -z "$2" || test ! -d /lib/modules/"$2"/build || TARGET_VER="$2" 552 setup --quick 581 553 ;; 582 554 cleanup)
Note:
See TracChangeset
for help on using the changeset viewer.