Return-Path: Received: from mail-pa0-f47.google.com (mail-pa0-f47.google.com [209.85.220.47]) by mail.openembedded.org (Postfix) with ESMTP id 36BCC770AE for ; Fri, 2 Oct 2015 00:22:13 +0000 (UTC) Received: by padhy16 with SMTP id hy16so89476717pad.1 for ; Thu, 01 Oct 2015 17:22:13 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=from:to:cc:subject:date:message-id; bh=oKf2OLAfo1CD5cbj4rC0XxikKJogc7aG2Ks4+Y+3IfE=; b=y6eUlj0KySM+HXdmUijNzIybGnxmDoIFNq7z6TJ8BL/98wZ8tSR6DZSAgQAliPXmO5 GGe3a/Grrs1X1jyGR6iRCUo0Zi2mETVchWHa8biqvszZdsrntQD+01M4ZBhDw2z1O+As lfKeagzb6n4nfzJLBezW6Yv4xqjeIokPo1Yn7bt+JXk67zQ6CvYkx/aX+6wGoY6Dk2n8 j5ij+SWmaEfJ45VyrDzuXVyV20QhcxGvPu3zrX6CFvE9Pd07LjIhWQUmKIRkfRki/y7z mVgXxU7goLHgtvLC4lgo4MddYHThB/ttfvjp6zIJ2X8/Ha4vBnTYa9by+K4s/uvHCp4B qSWA== X-Received: by 10.66.102.7 with SMTP id fk7mr15850472pab.119.1443745333484; Thu, 01 Oct 2015 17:22:13 -0700 (PDT) Received: from e6520.cablelabs.com (50-204-102-64-static.hfc.comcastbusiness.net. [50.204.102.64]) by smtp.gmail.com with ESMTPSA id cs5sm8958703pbc.15.2015.10.01.17.22.11 (version=TLSv1.2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Thu, 01 Oct 2015 17:22:11 -0700 (PDT) From: Andre McCurdy To: openembedded-core@lists.openembedded.org Date: Thu, 1 Oct 2015 17:22:01 -0700 Message-Id: <1443745321-32158-1-git-send-email-armccurdy@gmail.com> X-Mailer: git-send-email 1.9.1 Subject: [PATCH] package_manager.py: sort output of OpkgPkgsList().list X-BeenThere: openembedded-core@lists.openembedded.org X-Mailman-Version: 2.1.12 Precedence: list List-Id: Patches and discussions about the oe-core layer List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 02 Oct 2015 00:22:14 -0000 Without explicit sorting, the output generated by OpkgPkgsList().list follows the order of packages in /var/lib/opkg/status, which appears to be "random". Add sorting to make OpkgPkgsList().list behaviour consistent with that of RpmPkgsList().list. Signed-off-by: Andre McCurdy --- meta/lib/oe/package_manager.py | 22 ++++++++++++++-------- 1 file changed, 14 insertions(+), 8 deletions(-) diff --git a/meta/lib/oe/package_manager.py b/meta/lib/oe/package_manager.py index 292ed44..83861ca 100644 --- a/meta/lib/oe/package_manager.py +++ b/meta/lib/oe/package_manager.py @@ -434,24 +434,30 @@ class OpkgPkgsList(PkgsList): (self.opkg_cmd, self.opkg_args) try: - output = subprocess.check_output(cmd, stderr=subprocess.STDOUT, shell=True).strip() + # bb.note(cmd) + tmp_output = subprocess.check_output(cmd, stderr=subprocess.STDOUT, shell=True).strip() + except subprocess.CalledProcessError as e: bb.fatal("Cannot get the installed packages list. Command '%s' " "returned %d:\n%s" % (cmd, e.returncode, e.output)) - if output and format == "file": - tmp_output = "" - for line in output.split('\n'): + output = list() + for line in tmp_output.split('\n'): + if len(line.strip()) == 0: + continue + if format == "file": pkg, pkg_file, pkg_arch = line.split() full_path = os.path.join(self.rootfs_dir, pkg_arch, pkg_file) if os.path.exists(full_path): - tmp_output += "%s %s %s\n" % (pkg, full_path, pkg_arch) + output.append('%s %s %s' % (pkg, full_path, pkg_arch)) else: - tmp_output += "%s %s %s\n" % (pkg, pkg_file, pkg_arch) + output.append('%s %s %s' % (pkg, pkg_file, pkg_arch)) + else: + output.append(line) - output = tmp_output + output.sort() - return output + return '\n'.join(output) class DpkgPkgsList(PkgsList): -- 1.9.1