def _downloadAndUnpackScriptZips(self): """ Downloads/copies the script ZIPs into TESTBOX_SCRIPT and unzips them to the same directory. Raises no exceptions, returns log + success indicator instead. """ sPathScript = self._oTestBoxScript.getPathScripts(); asArchives = self._sScriptZips.split(','); for sArchive in asArchives: sArchive = sArchive.strip(); if not sArchive: continue; # Figure the destination name (in scripts). sDstFile = webutils.getFilename(sArchive); if len(sDstFile) < 1 \ or re.search('[^a-zA-Z0-9 !#$%&\'()@^_`{}~.-]', sDstFile) is not None: # FAT charset sans 128-255 + '.'. self._log('Malformed script zip filename: %s' % (sArchive,)); return False; sDstFile = os.path.join(sPathScript, sDstFile); # Do the work. if webutils.downloadFile(sArchive, sDstFile, self._oTestBoxScript.getPathBuilds(), self._log, self._log) is not True: return False; asFiles = utils.unpackFile(sDstFile, sPathScript, self._log, self._log); if asFiles is None: return False; # Since zip files doesn't always include mode masks, set the X bit # of all of them so we can execute binaries and hash-bang scripts. for sFile in asFiles: utils.chmodPlusX(sFile); return True;
def _uninstallVBoxOnLinux(self): """ Uninstalls VBox on Linux.""" # Is VirtualBox installed? If not, don't try uninstall it. sVBox = self._getVBoxInstallPath(fFailIfNotFound=False) if sVBox is None: return True # Find the .run file and use it. sRun = self._findFile('^VirtualBox-.*\\.run$', fMandatory=False) if sRun is not None: utils.chmodPlusX(sRun) fRc, _ = self._sudoExecuteSync([sRun, 'uninstall']) return fRc # Try the installed uninstaller. for sUninstaller in [ os.path.join(sVBox, 'uninstall.sh'), '/opt/VirtualBox/uninstall.sh', ]: if os.path.isfile(sUninstaller): reporter.log('Invoking "%s"...' % (sUninstaller, )) fRc, _ = self._sudoExecuteSync([sUninstaller, 'uninstall']) return fRc reporter.log('Did not find any VirtualBox install to uninstall.') return True
def _installVBoxOnLinux(self): """ Installs VBox on Linux.""" sRun = self._findFile('^VirtualBox-.*\\.run$'); if sRun is None: return False; utils.chmodPlusX(sRun); # Install the new one. fRc, _ = self._sudoExecuteSync([sRun,]); return fRc;
def _uninstallVBoxOnLinux(self): """ Uninstalls VBox on Linux.""" # Is VirtualBox installed? If not, don't try uninstall it. sVBox = self._getVBoxInstallPath(fFailIfNotFound = False); if sVBox is None: return True; # Find the .run file and use it. sRun = self._findFile('^VirtualBox-.*\\.run$', fMandatory = False); if sRun is not None: utils.chmodPlusX(sRun); fRc, _ = self._sudoExecuteSync([sRun, 'uninstall']); return fRc; # Try the installed uninstaller. for sUninstaller in [os.path.join(sVBox, 'uninstall.sh'), '/opt/VirtualBox/uninstall.sh', ]: if os.path.isfile(sUninstaller): reporter.log('Invoking "%s"...' % (sUninstaller,)); fRc, _ = self._sudoExecuteSync([sUninstaller, 'uninstall']); return fRc; reporter.log('Did not find any VirtualBox install to uninstall.'); return True;