From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from pigeon.gentoo.org ([208.92.234.80] helo=lists.gentoo.org) by finch.gentoo.org with esmtp (Exim 4.60) (envelope-from ) id 1QaHtG-0007zO-G8 for garchives@archives.gentoo.org; Sat, 25 Jun 2011 01:42:30 +0000 Received: from pigeon.gentoo.org (localhost [127.0.0.1]) by pigeon.gentoo.org (Postfix) with SMTP id D7A3B1C013; Sat, 25 Jun 2011 01:42:16 +0000 (UTC) Received: from smtp.gentoo.org (smtp.gentoo.org [140.211.166.183]) by pigeon.gentoo.org (Postfix) with ESMTP id 7A1BF1C013 for ; Sat, 25 Jun 2011 01:42:16 +0000 (UTC) Received: from pelican.gentoo.org (unknown [66.219.59.40]) (using TLSv1 with cipher ADH-AES256-SHA (256/256 bits)) (No client certificate requested) by smtp.gentoo.org (Postfix) with ESMTPS id 8548B2AC039 for ; Sat, 25 Jun 2011 01:42:15 +0000 (UTC) Received: from localhost.localdomain (localhost [127.0.0.1]) by pelican.gentoo.org (Postfix) with ESMTP id D77C78003C for ; Sat, 25 Jun 2011 01:42:14 +0000 (UTC) From: "Wiktor W Brodlo" To: gentoo-commits@lists.gentoo.org Content-type: text/plain; charset=UTF-8 Reply-To: gentoo-dev@lists.gentoo.org, "Wiktor W Brodlo" Message-ID: <607de627ad6a60288f14dd89f38458d701d738e3.wiktor@gentoo> Subject: [gentoo-commits] proj/anaconda:master commit in: gentoo/ X-VCS-Repository: proj/anaconda X-VCS-Files: gentoo/__init__.py X-VCS-Directories: gentoo/ X-VCS-Committer: wiktor X-VCS-Committer-Name: Wiktor W Brodlo X-VCS-Revision: 607de627ad6a60288f14dd89f38458d701d738e3 Date: Sat, 25 Jun 2011 01:42:14 +0000 (UTC) Precedence: bulk List-Post: List-Help: List-Unsubscribe: List-Subscribe: List-Id: Gentoo Linux mail X-BeenThere: gentoo-commits@lists.gentoo.org Content-Transfer-Encoding: quoted-printable X-Archives-Salt: X-Archives-Hash: 8532214bc4cd6a4230c2821a2abbccf6 commit: 607de627ad6a60288f14dd89f38458d701d738e3 Author: wiktor w brodlo brodlo net> AuthorDate: Sat Jun 25 01:40:54 2011 +0000 Commit: Wiktor W Brodlo brodlo net> CommitDate: Sat Jun 25 01:40:54 2011 +0000 URL: http://git.overlays.gentoo.org/gitweb/?p=3Dproj/anaconda.git;= a=3Dcommit;h=3D607de627 Portage install method version 1 ;-) --- gentoo/__init__.py | 126 +++++++---------------------------------------= ----- 1 files changed, 18 insertions(+), 108 deletions(-) diff --git a/gentoo/__init__.py b/gentoo/__init__.py index 629cba8..1cb23d9 100644 --- a/gentoo/__init__.py +++ b/gentoo/__init__.py @@ -1,8 +1,9 @@ # -# gentoo.py: Gentoo Linux Anaconda install method backend +# gentoo/__init__.py: Gentoo Portage Anaconda install method backend # # -# Copyright (C) 2010 Fabio Erculiani +# Copyright (C) 2011 wiktor w brodlo +# Copyright (C) 2011 Gentoo Foundation # # This program is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by @@ -21,113 +22,22 @@ import os import sys =20 -# add Entropy module path to PYTHONPATH -sys.path.insert(0, '/usr/lib/entropy/libraries') +class Portage: =20 -# Entropy Interface -from entropy.client.interfaces import Client -from entropy.output import nocolor -from entropy.fetchers import UrlFetcher -import entropy.tools + def __init__(self, terminal): + self.term =3D terminal + # chroot into the new installation if not already there + self.term.run_command("chroot "+os.environ["ANACONDA_PRODUCTPATH"]+" 2= > /dev/null") =20 -class Entropy(Client): + # Syncs the Portage tree and updates Portage if an update is available + def sync(self): + self.term.run_command("emerge --sync") + self.term.run_command("emerge --update portage") =20 - def init_singleton(self): - self._progress =3D None - self.oldcount =3D [] - Client.init_singleton(self, xcache =3D False, - url_fetcher =3D InstallerUrlFetcher) - nocolor() + # Installs a package atom + def install(self, atom): + terminal.run_command("emerge "+atom) =20 - def connect_progress(self, progress): - self._progress =3D progress - - def output(self, text, header =3D "", footer =3D "", back =3D False, - importance =3D 0, level =3D "info", count =3D None, percent =3D = False): - - if not self._progress: - return - - if not self.oldcount: - self.oldcount =3D [0,100] - - progress_text =3D text - if count: - try: - self.oldcount =3D int(count[0]),int(count[1]) - except: - self.oldcount =3D [0,100] - if not percent: - count_str =3D "(%s/%s) " % (str(count[0]),str(count[1]),= ) - progress_text =3D count_str+progress_text - - percentage =3D float(self.oldcount[0])/self.oldcount[1] * 100 - percentage =3D round(percentage, 2) - self._progress.set_fraction(percentage) - self._progress.set_text(progress_text) - - def is_installed(self, package_name): - match =3D self.installed_repository().atomMatch(package_name) - if match[0] !=3D -1: - return True - return False - - @staticmethod - def is_corecd(): - if os.path.isfile("/etc/gentoo-edition"): - f =3D open("/etc/gentoo-edition","r") - cnt =3D f.readline().strip() - f.close() - if cnt.lower().find("core") !=3D -1: - return True - return False - - @staticmethod - def is_gentoo_mce(): - with open("/proc/cmdline", "r") as cmd_f: - args =3D cmd_f.readline().strip().split() - for tstr in ("mceinstall", "gentoomce"): - if tstr in args: - return True - return False - -# in this way, any singleton class that tries to directly load Client -# gets Entropy in change -Client.__singleton_class__ =3D Entropy - -class InstallerUrlFetcher(UrlFetcher): - - gui_last_avg =3D 0 - - def handle_statistics(self, th_id, downloaded_size, total_size, - average, old_average, update_step, show_speed, data_transfer= , - time_remaining, time_remaining_secs): - self.__average =3D average - self.__downloadedsize =3D downloaded_size - self.__remotesize =3D total_size - self.__datatransfer =3D data_transfer - - def output(self): - """ backward compatibility """ - return self.update() - - def update(self): - - myavg =3D abs(int(round(float(self.__average), 1))) - if abs((myavg - InstallerUrlFetcher.gui_last_avg)) < 1: - return - - if (myavg > InstallerUrlFetcher.gui_last_avg) or (myavg < 2) or = \ - (myavg > 97): - - cur_prog =3D float(self.__average)/100 - cur_prog_str =3D str(int(self.__average)) - - human_dt =3D entropy.tools.bytes_into_human(self.__datatrans= fer) - prog_str =3D "%s/%s kB @ %s" % ( - str(round(float(self.__downloadedsize)/1024, 1)), - str(round(self.__remotesize, 1)), - str(human_dt) + "/sec", - ) - Entropy().output(prog_str) - InstallerUrlFetcher.gui_last_avg =3D myavg + # Updates world + def update_world(self): + terminal.run_command("emerge --deep --newuse --update world")