def checking_pyqt(self): logging.debug("Checking PyQt") if gui.backend != "PyQt": gui.wait_command( self.run_as_root.get_prefix() + ["apt-get", "-y", "install", "python-qt4"], **self.get_generic_installation_messages("Qt4 for Python")) reload(gui) if gui.backend != "PyQt": logging.debug("Could not enable PyQt")
def create_run_as_root(self): version = float(self.version) if (self.dist == "Fedora" and version >= 10) or \ (self.dist == "U.F.O" and version >= 1.0): if not os.path.exists("/usr/bin/beesu"): # if os.path.exists("/usr/bin/gpk-install-package-name"): # print (["/usr/bin/gpk-install-package-name", "beesu"], msg)' #else: gui.wait_command( ["/usr/bin/pkcon", "install", "beesu"], **self.get_generic_installation_messages("beesu")) return LinuxBackend.create_run_as_root(self)
def look_for_virtualbox(self): logging.debug("Checking VirtualBox binaries") vbox_path = utils.call(["which", "VirtualBox"], output=True)[1].strip() if not os.path.lexists(vbox_path): open("/etc/apt/sources.list", "a").write( "deb http://download.virtualbox.org/virtualbox/debian %s non-free\n" % (self.codename.lower(), )) os.system( "wget -q http://download.virtualbox.org/virtualbox/debian/oracle_vbox.asc -O- | sudo apt-key add -" ) gui.wait_command( ["apt-get", "update"], msg="Votre système est en train d'être mis à jour") gui.wait_command( ["apt-get", "-y", "install", "virtualbox-3.1"], **self.get_generic_installation_messages("VirtualBox 3.1")) lsmod = self.call([["lsmod"], ["grep", "vboxdrv"]], output=True)[1] if not lsmod: gui.wait_command(["/etc/init.d/vboxdrv", "setup"], msg="Configuration en cours de \"VirtualBox 3\".") LinuxBackend.look_for_virtualbox(self)
def self_update(ufo_dir, relaunch): try: latest_version, x, x = get_latest_version() latest_version = ".".join(map(str, latest_version)) try: if sys.platform == "darwin": mount = utils.grep( utils.call(["mount"], output=True)[1], ufo_dir) if mount: dev = mount.split()[0] utils.call(["diskutil", "unmount", dev]) utils.call(["diskutil", "mount", dev]) except: pass url = conf.UPDATEURL + "/launcher-" + latest_version + ".tar.bz2" filename = tempfile.mkstemp()[1] logging.debug("Downloading " + url + " to " + filename) retcode = gui.download_file( url, filename, title=_("Downloading update"), msg=_("Please wait while the update is being downloaded"), success_msg=_( "Your key will now be updated.<br>" "This operation can take a few minutes<br><br>\n" "<b>The USB key absolutely must not be unplugged during this process.</b>" )) if retcode: raise Exception("Download was canceled") logging.debug("Extracting update " + filename + " to " + ufo_dir) import tarfile tar = tarfile.open(filename) filelist = path.join(ufo_dir, ".data", "launcher.filelist") gui.wait_command( cmd=[ remove_deprecated_files, tar, filelist, os.path.normcase(ufo_dir) ], title=_("Removing old files"), msg=_("Please wait while the old files are being removed")) if sys.platform == "darwin": gui.wait_command( cmd=["tar", "-C", ufo_dir, "-xjf", filename], title=_("Installing update"), msg=_( "Please wait while the update is being installed.<br><br>" "<b>The USB key absolutely must not be unplugged.</b>")) mount = utils.grep(utils.call(["mount"], output=True)[1], ufo_dir) if mount: dev = mount.split()[0] utils.call(["diskutil", "unmount", dev]) utils.call(["diskutil", "mount", dev]) # At this point we consider that update terminated successfully, # as tar command return higher than 0 when all files has been copied. success = True else: success = gui.extract_tar( tgz=tar, dest=os.path.normcase(ufo_dir), title=_("Installing update"), msg=_( "Please wait while the update is being installed.<br><br>" "<b>The USB key absolutely must not be unplugged.</b>")) tar.close() if not success: raise Exception("Installation has failed") logging.debug("Updating settings.conf") cp = ConfigParser() cp.read([conf.conf_file]) cp.set("launcher", "VERSION", latest_version) cp.write(open(conf.conf_file, "w")) gui.dialog_info(title=_("Information"), msg=_("Your %s launcher is up to date (v") % (conf.PRODUCTNAME, ) + latest_version + ") !") try: os.remove(filename) except: pass except: gui.dialog_info( title=_("Error"), msg=_("An error occurred. You key could not be updated.")) import traceback info = sys.exc_info() logging.debug("Unexpected error: " + str(info[1])) logging.debug("".join(traceback.format_tb(info[2]))) logging.debug("Exception while updating") logging.debug("Restarting UFO launcher : " + relaunch) logging.shutdown() os.execv(relaunch, [relaunch, "--respawn"])
def look_for_virtualbox(self): logging.debug("Checking VirtualBox binaries") kernel = "kernel" if os.uname()[2].endswith("PAE"): kernel += "-PAE" if not path.exists(path.join(conf.BIN, self.VIRTUALBOX_EXECUTABLE)): logging.debug("Installing Agorabox repository for VirtualBox") gui.wait_command( ["yum", "-y", "install", "yum-priorities"], **self.get_generic_installation_messages("yum-priorities")) gui.wait_command([ "rpm", "-ivf", self.AGORABOX_VBOX_REPO + "agorabox-virtualbox-yum-repository-1.0.noarch.rpm" ], msg=_("Setting Yum Agorabox repository")) logging.debug("Kernel is: " + kernel) logging.debug("Installing VirtualBox") gui.wait_command( [ "yum", "-y", "install", "VirtualBox-OSE", "VirtualBox-OSE-kmodsrc", kernel, kernel + "-devel", "gcc", "make", "lzma", "xz" ], msg= _("Installing VirtualBox Open Source edition. This can take a few minutes" )) version = self.call( ["rpm", "-q", "--queryformat", "%{VERSION}", "VirtualBox-OSE"], output=True)[1] kmod_name = "VirtualBox-OSE-kmod-" + str(version) lsmod = self.call([["lsmod"], ["grep", "vboxdrv"]], output=True)[1] if not lsmod: cant_compile = False need_reboot = False import yum yumbase = yum.YumBase() yumbase.doConfigSetup() pkglist = yumbase.doPackageLists('installed') devel_exactmatch, devel_matched, devel_unmatched = yum.packages.parsePackages( pkglist.installed, [kernel + "-devel"]) devel_exactmatch.sort(key=lambda x: x.version) kern_exactmatch, kern_matched, kern_unmatched = yum.packages.parsePackages( pkglist.installed, [kernel]) kern_exactmatch.sort(key=lambda x: x.version) yumbase.close() yumbase.closeRpmDB() if devel_exactmatch: latest = devel_exactmatch[-1] if not os.uname()[2].startswith( "%s-%s" % (devel_exactmatch[-1].version, devel_exactmatch[-1].release)): cant_compile = True if kern_exactmatch: latest = kern_exactmatch[-1] if not os.uname()[2].startswith("%s-%s" % (kern_exactmatch[-1].version, kern_exactmatch[-1].release)): need_reboot = True if cant_compile: if need_reboot: msg = _( "You are not running the latest installed version of the kernel.\nA reboot is required for %s to work." ) % (conf.PRODUCTNAME, ) else: msg = _( "An error has occurred during the installation of VirtualBox.\nPlease install the latest %s and %s-devel packages." ) % (kernel, kernel) gui.dialog_info(title=_("Warning"), msg=msg, error=False) sys.exit(0) logging.debug( "Decompressing drivers source code from /usr/share/%s/%s.tar" % ( kmod_name, kmod_name, )) tarfile = glob.glob("/usr/share/%s/%s.tar.*" % ( kmod_name, kmod_name, ))[0] tarext = os.path.splitext(tarfile)[1][1:] utils.call([ "tar", "--use-compress-program", tarext, "-xf", "/usr/share/%s/%s.tar.%s" % ( kmod_name, kmod_name, tarext, ) ], cwd=tempfile.gettempdir()) compdir = os.path.join(tempfile.gettempdir(), kmod_name, "vboxdrv") logging.debug("Compiling vboxdrv source code in %s" % (compdir, )) gui.wait_command(["make", "install", "-C", compdir], msg=_("Compiling VirtualBox drivers")) logging.debug("Loading vboxdrv module") self.call(["/etc/sysconfig/modules/VirtualBox-OSE.modules"]) LinuxBackend.look_for_virtualbox(self)