From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from lists.gentoo.org (pigeon.gentoo.org [208.92.234.80]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits)) (No client certificate requested) by finch.gentoo.org (Postfix) with ESMTPS id AF7B6158089 for ; Sun, 8 Oct 2023 03:28:43 +0000 (UTC) Received: from pigeon.gentoo.org (localhost [127.0.0.1]) by pigeon.gentoo.org (Postfix) with SMTP id F31522BC018; Sun, 8 Oct 2023 03:28:42 +0000 (UTC) Received: from smtp.gentoo.org (dev.gentoo.org [IPv6:2001:470:ea4a:1:5054:ff:fec7:86e4]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by pigeon.gentoo.org (Postfix) with ESMTPS id D8A382BC018 for ; Sun, 8 Oct 2023 03:28:42 +0000 (UTC) Received: from oystercatcher.gentoo.org (oystercatcher.gentoo.org [148.251.78.52]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by smtp.gentoo.org (Postfix) with ESMTPS id B59E8335C67 for ; Sun, 8 Oct 2023 03:28:41 +0000 (UTC) Received: from localhost.localdomain (localhost [IPv6:::1]) by oystercatcher.gentoo.org (Postfix) with ESMTP id 32D8D9EE for ; Sun, 8 Oct 2023 03:28:40 +0000 (UTC) From: "Sam James" To: gentoo-commits@lists.gentoo.org Content-Transfer-Encoding: 8bit Content-type: text/plain; charset=UTF-8 Reply-To: gentoo-dev@lists.gentoo.org, "Sam James" Message-ID: <1696735655.c846c08c046588a98f2b40a45ac74b84cda21a89.sam@gentoo> Subject: [gentoo-commits] proj/gentoolkit:master commit in: pym/gentoolkit/eclean/ X-VCS-Repository: proj/gentoolkit X-VCS-Files: pym/gentoolkit/eclean/clean.py pym/gentoolkit/eclean/pkgindex.py X-VCS-Directories: pym/gentoolkit/eclean/ X-VCS-Committer: sam X-VCS-Committer-Name: Sam James X-VCS-Revision: c846c08c046588a98f2b40a45ac74b84cda21a89 X-VCS-Branch: master Date: Sun, 8 Oct 2023 03:28:40 +0000 (UTC) Precedence: bulk List-Post: List-Help: List-Unsubscribe: List-Subscribe: List-Id: Gentoo Linux mail X-BeenThere: gentoo-commits@lists.gentoo.org X-Auto-Response-Suppress: DR, RN, NRN, OOF, AutoReply X-Archives-Salt: 79416b27-6277-46b5-8e12-366cb87092da X-Archives-Hash: 4f270c0dae5a440161b964b3d0dade72 commit: c846c08c046588a98f2b40a45ac74b84cda21a89 Author: Siddhanth Rathod gmail com> AuthorDate: Thu Oct 5 13:29:32 2023 +0000 Commit: Sam James gentoo org> CommitDate: Sun Oct 8 03:27:35 2023 +0000 URL: https://gitweb.gentoo.org/proj/gentoolkit.git/commit/?id=c846c08c eclean: pkg: fix pkgindex handling Last implemention was importing binhost module incorrectly: calling Modules() from portage.module which sets binhost var to the BinhostHandler class which would always fail as it needs name and namepath, leading to always call emaint via a subprocess call. Signed-off-by: Siddhanth Rathod gmail.com> Signed-off-by: Sam James gentoo.org> pym/gentoolkit/eclean/clean.py | 17 +++++--- pym/gentoolkit/eclean/pkgindex.py | 86 --------------------------------------- 2 files changed, 11 insertions(+), 92 deletions(-) diff --git a/pym/gentoolkit/eclean/clean.py b/pym/gentoolkit/eclean/clean.py index 87d7aac..92449b4 100644 --- a/pym/gentoolkit/eclean/clean.py +++ b/pym/gentoolkit/eclean/clean.py @@ -8,7 +8,9 @@ import os import sys import gentoolkit.pprinter as pp -from gentoolkit.eclean.pkgindex import PkgIndex +import portage +from portage.emaint.main import TaskHandler +from portage.emaint.modules.binhost import binhost class CleanUp: @@ -61,11 +63,14 @@ class CleanUp: # run 'emaint --fix' here if clean_size: - index_control = PkgIndex(self.controller) - # emaint is not yet importable so call it - # print a blank line here for separation - print() - clean_size += index_control.clean_pkgs_index(self.quiet) + file = os.path.join(portage.settings["PKGDIR"], "Packages") + size1 = os.stat(file).st_size + TaskHandler(show_progress_bar=self.quiet).run_tasks( + [binhost.BinhostHandler], "fix" + ) + size = size1 - os.stat(file).st_size + self.controller(size, "Packages Index", file, "Index") + clean_size += size # return total size of deleted or to delete files return clean_size diff --git a/pym/gentoolkit/eclean/pkgindex.py b/pym/gentoolkit/eclean/pkgindex.py deleted file mode 100644 index 7d6fade..0000000 --- a/pym/gentoolkit/eclean/pkgindex.py +++ /dev/null @@ -1,86 +0,0 @@ -#!/usr/bin/python - -# Copyright 2003-2010 Gentoo Foundation -# Distributed under the terms of the GNU General Public License v2 - -import subprocess -import os -import sys - -import gentoolkit.pprinter as pp -from gentoolkit.eprefix import EPREFIX - -import portage -from portage.module import ( - InvalidModuleName, - Modules, -) -from portage.emaint.main import TaskHandler - - -class PkgIndex: - """Handle the cleaning of the binpkg Package - Index file - - @type output: class - @param output: optional output class for printing - """ - - def __init__(self, controller=None): - self.controller = controller - # backup command line call - self.emaint_cmd = "%s/usr/sbin/emaint --fix binhost" % EPREFIX - - def _get_emaint_binhost(self): - """Obtain a reference to the binhost module class - - @sets: self.binhost to BinhostHandler class - @rtype: boolean - """ - try: - self.emaint_control = Modules() - self.binhost = self.emaint_control._get_class("binhost") - except InvalidModuleName as er: - print(pp.error("Error importing emaint binhost module"), file=sys.stderr) - print(pp.error("Original error: " + er), file=sys.stderr) - except: - return False - return True - - def clean_pkgs_index(self, quiet): - """This will clean the binpkgs packages index file - - @param quiet: boolean - @return: the difference in file size - """ - file_ = os.path.join(portage.settings["PKGDIR"], "Packages") - statinfo = os.stat(file_) - size1 = statinfo.st_size - show_progress = not quiet - if self._get_emaint_binhost(): - self.taskmaster = TaskHandler(show_progress_bar=show_progress) - tasks = [self.binhost] - self.taskmaster.run_tasks(tasks) - else: - self.call_emaint() - statinfo = os.stat(file_) - clean_size = size1 - statinfo.st_size - self.controller(clean_size, "Packages Index", file_, "Index") - return clean_size - - def call_emaint(self): - """Run the stand alone emaint script from - a subprocess call. - - @rtype: integer - @return: the difference in file size - """ - try: - retcode = subprocess.call(self.emaint_cmd, shell=True) - if retcode < 0: - print( - pp.error("Child was terminated by signal" + str(-retcode)), - file=sys.stderr, - ) - except OSError as e: - print(pp.error("Execution failed:" + e), file=sys.stderr)