From 268dd7ffc933b0e8358afa8815787226f8aded5c Mon Sep 17 00:00:00 2001 From: Thierry Parmentelat Date: Tue, 12 Jun 2012 10:49:59 +0200 Subject: [PATCH] pkgs.py accepts new option -u to avoid sorting - used when loading .mirrors --- build.common | 3 ++- pkgs.py | 8 ++++++-- 2 files changed, 8 insertions(+), 3 deletions(-) diff --git a/build.common b/build.common index a21d7093..20cfb7ca 100644 --- a/build.common +++ b/build.common @@ -248,7 +248,8 @@ function pl_root_mkfedora () { # get mirrors if not specified with -l if [ -z "$mirrors" ] ; then mirrorsfile=$(pl_locateDistroFile ../build/ $pldistro "$pldistro.mirrors") - mirrors=$(pl_parsePkgs mirror $fcdistro $pldistro $mirrorsfile) + # do not sort mirrors, keep order from input + mirrors=$(pl_parsePkgs -u mirror $fcdistro $pldistro $mirrorsfile) fi yumexclude_line="" diff --git a/pkgs.py b/pkgs.py index 5a35e135..220eb748 100755 --- a/pkgs.py +++ b/pkgs.py @@ -165,12 +165,14 @@ class PkgsParser: included += i excluded += e ok = ok and o - results = list (set(included).difference(set(excluded))) + # avoid set operations that would not preserve order + results = [ x for x in included if x not in excluded ] results = [ x.replace('@arch@',self.arch).\ replace('@fcdistro@',self.fcdistro).\ replace('@pldistro@',self.pldistro) for x in results] - results.sort() + if self.options.sort_results: + results.sort() # default is space-separated if not self.options.new_line: print " ".join(results) @@ -192,6 +194,8 @@ def main (): help='verbose when using qualifiers') parser.add_option ('-n', '--new-line',dest='new_line',action='store_true',default=False, help='print outputs separated with newlines rather than with a space') + parser.add_option ('-u', '--no-sort',dest='sort_results',default=True,action='store_false', + help='keep results in the same order as in the inputs') (options,args) = parser.parse_args() if len(args) <=1 : -- 2.43.0