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 _installVBox(self): """ Download / copy the build files into the scratch area and install them. """ reporter.testStart('Installing VirtualBox'); reporter.log('CWD=%s' % (os.getcwd(),)); # curious # # Download the build files. # for i in range(len(self._asBuildUrls)): if webutils.downloadFile(self._asBuildUrls[i], self._asBuildFiles[i], self.sBuildPath, reporter.log, reporter.log) is not True: reporter.testDone(fSkipped = True); return None; # Failed to get binaries, probably deleted. Skip the test run. # # Unpack anything we know what is and append it to the build files # list. This allows us to use VBoxAll*.tar.gz files. # for sFile in list(self._asBuildFiles): if self._maybeUnpackArchive(sFile, fNonFatal = True) is not True: reporter.testDone(fSkipped = True); return None; # Failed to unpack. Probably local error, like busy # DLLs on windows, no reason for failing the build. # # Go to system specific installation code. # sHost = utils.getHostOs() if sHost == 'darwin': fRc = self._installVBoxOnDarwin(); elif sHost == 'linux': fRc = self._installVBoxOnLinux(); elif sHost == 'solaris': fRc = self._installVBoxOnSolaris(); elif sHost == 'win': fRc = self._installVBoxOnWindows(); else: reporter.error('Unsupported host "%s".' % (sHost,)); if fRc is False: reporter.testFailure('Installation error.'); elif fRc is not True: reporter.log('Seems installation was skipped. Old version lurking behind? Not the fault of this build/test run!'); # # Install the extension pack. # if fRc is True and self._fAutoInstallPuelExtPack: fRc = self._installExtPack(); if fRc is False: reporter.testFailure('Extension pack installation error.'); # Some debugging... try: cMbFreeSpace = utils.getDiskUsage(self.sScratchPath); reporter.log('Disk usage after VBox install: %d MB available at %s' % (cMbFreeSpace, self.sScratchPath,)); except: reporter.logXcpt('Unable to get disk free space. Ignored. Continuing.'); reporter.testDone(fRc is None); return fRc;
def _doUpgrade(self, oResponse, oConnection, fReboot): """ Common worker for _cmdUpgrade and _cmdUpgradeAndReboot. Will sys.exit on success! """ # # The server specifies a ZIP archive with the new scripts. It's ASSUMED # that the zip is of selected files at g_ksValidationKitDir in SVN. It's # further ASSUMED that we're executing from # sZipUrl = oResponse.getStringChecked( constants.tbresp.UPGRADE_PARAM_URL) oResponse.checkParameterCount(2) if utils.isRunningFromCheckout(): raise TestBoxException( 'Cannot upgrade when running from the tree!') oConnection.sendAckAndClose(constants.tbresp.CMD_UPGRADE_AND_REBOOT if fReboot else constants.tbresp.CMD_UPGRADE) testboxcommons.log('Upgrading...') # # Download the file and install it. # sDstFile = os.path.join(g_ksTestScriptDir, 'VBoxTestBoxScript.zip') if os.path.exists(sDstFile): os.unlink(sDstFile) fRc = webutils.downloadFile(sZipUrl, sDstFile, self._oTestBoxScript.getPathBuilds(), testboxcommons.log) if fRc is not True: return False if upgradeFromZip(sDstFile) is not True: return False # # Restart the system or the script (we have a parent script which # respawns us when we quit). # if fReboot: self.doReboot() sys.exit(TBS_EXITCODE_NEED_UPGRADE) return False
def _doUpgrade(self, oResponse, oConnection, fReboot): """ Common worker for _cmdUpgrade and _cmdUpgradeAndReboot. Will sys.exit on success! """ # # The server specifies a ZIP archive with the new scripts. It's ASSUMED # that the zip is of selected files at g_ksValidationKitDir in SVN. It's # further ASSUMED that we're executing from # sZipUrl = oResponse.getStringChecked(constants.tbresp.UPGRADE_PARAM_URL) oResponse.checkParameterCount(2); if utils.isRunningFromCheckout(): raise TestBoxException('Cannot upgrade when running from the tree!'); oConnection.sendAckAndClose(constants.tbresp.CMD_UPGRADE_AND_REBOOT if fReboot else constants.tbresp.CMD_UPGRADE); testboxcommons.log('Upgrading...'); # # Download the file and install it. # sDstFile = os.path.join(g_ksTestScriptDir, 'VBoxTestBoxScript.zip'); if os.path.exists(sDstFile): os.unlink(sDstFile); fRc = webutils.downloadFile(sZipUrl, sDstFile, self._oTestBoxScript.getPathBuilds(), testboxcommons.log); if fRc is not True: return False; if upgradeFromZip(sDstFile) is not True: return False; # # Restart the system or the script (we have a parent script which # respawns us when we quit). # if fReboot: self.doReboot(); sys.exit(TBS_EXITCODE_NEED_UPGRADE); return False; # shuts up pylint (it will probably complain later when it learns DECL_NO_RETURN).