[gentoo-portage-dev] [PATCH] glsa-check: add --reverse option (bug 235970)

2019-08-31 Thread Zac Medico
Add --reverse option which causes GLSAs to be listed in reverse order,
so that the most recent GLSAs are listed earlier.

Suggested-by: Pavel Sanda 
Bug: https://bugs.gentoo.org/235970
Signed-off-by: Zac Medico 
---
 bin/glsa-check | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)

diff --git a/bin/glsa-check b/bin/glsa-check
index 95ef16fde..6dbb7513c 100755
--- a/bin/glsa-check
+++ b/bin/glsa-check
@@ -67,6 +67,8 @@ parser.add_argument("-e", "--emergelike", 
action="store_false", dest="least_chan
help="Upgrade to latest version (not least-change)")
 parser.add_argument("-c", "--cve", action="store_true", dest="list_cve",
help="Show CVE IDs in listing mode")
+parser.add_argument("-r", "--reverse", action="store_true", dest="reverse",
+   help="List GLSAs in reverse order")
 
 options, params = parser.parse_known_args()
 
@@ -162,8 +164,7 @@ def summarylist(myglsalist, fd1=sys.stdout, fd2=sys.stderr, 
encoding="utf-8"):
fd2.write(green("[U]")+" means the system is not affected 
and\n")
fd2.write(red("[N]")+" indicates that the system might be 
affected.\n\n")
 
-   myglsalist.sort()
-   for myid in myglsalist:
+   for myid in sorted(myglsalist, reverse=options.reverse):
try:
myglsa = Glsa(myid, portage.settings, vardb, portdb)
except (GlsaTypeException, GlsaFormatException) as e:
-- 
2.21.0




[gentoo-portage-dev] [PATCH] glsa-check: fix truncated CVE ids in listmode (bug 692134)

2019-08-31 Thread Zac Medico
Use a regular expression to search for CVE ids in GLSA references.
Import unicode_literals from __future__ since portage's Glsa class
returns unicode strings for all python versions.

Reported-by: Georg Weiss 
Bug: https://bugs.gentoo.org/692134
Signed-off-by: Zac Medico 
---
 bin/glsa-check | 11 +--
 1 file changed, 9 insertions(+), 2 deletions(-)

diff --git a/bin/glsa-check b/bin/glsa-check
index 95ef16fde..6bb2ee21e 100755
--- a/bin/glsa-check
+++ b/bin/glsa-check
@@ -2,9 +2,10 @@
 # Copyright 1999-2019 Gentoo Authors
 # Distributed under the terms of the GNU General Public License v2
 
-from __future__ import print_function
+from __future__ import print_function, unicode_literals
 
 import argparse
+import re
 import sys
 import codecs
 from functools import reduce
@@ -204,7 +205,13 @@ def summarylist(myglsalist, fd1=sys.stdout, 
fd2=sys.stderr, encoding="utf-8"):
 
fd1.write(")")
if list_cve:
-   fd1.write(" "+(",".join([r[:13] for r in 
myglsa.references if r[:4] in ["CAN-", "CVE-"]])))
+   cve_ids = []
+   for r in myglsa.references:
+   m = re.search(r'(CAN|CVE)-[\d-]+', r)
+   if m is not None:
+   cve_ids.append(m.group(0))
+   if cve_ids:
+   fd1.write(" "+(",".join(cve_ids)))
fd1.write("\n")
return 0
 
-- 
2.21.0




[gentoo-portage-dev] [PATCH] _slot_confict_backtrack: consider masking a package matched by all parent atoms (bug 692746)

2019-08-31 Thread Zac Medico
When a slot conflict occurs involving a package that is matched by all
involved parent atoms, consider masking the package in order to avoid
a possible missed update. The included unit test demonstrates the case
fixed by this patch. There are 2 previously existing unit tests that
require larger backtracking values in order to succeed with this patch,
since more possible solutions are now considered.

Bug: https://bugs.gentoo.org/692746
Signed-off-by: Zac Medico 
---
 lib/_emerge/depgraph.py   |  5 ++
 lib/_emerge/resolver/backtracking.py  |  9 +++
 .../test_slot_conflict_update_virt.py | 79 +++
 .../test_slot_operator_complete_graph.py  |  2 +-
 .../test_slot_operator_runtime_pkg_mask.py|  2 +-
 5 files changed, 95 insertions(+), 2 deletions(-)
 create mode 100644 lib/portage/tests/resolver/test_slot_conflict_update_virt.py

diff --git a/lib/_emerge/depgraph.py b/lib/_emerge/depgraph.py
index 08240af67..6be1b3ec7 100644
--- a/lib/_emerge/depgraph.py
+++ b/lib/_emerge/depgraph.py
@@ -1768,6 +1768,11 @@ class depgraph(object):
debug = "--debug" in self._frozen_config.myopts
existing_node = 
next(self._dynamic_config._package_tracker.match(
root, slot_atom, installed=False))
+   if existing_node not in conflict_pkgs:
+   # Even though all parent atoms match existing_node,
+   # consider masking it in order to avoid a missed update
+   # as in bug 692746.
+   conflict_pkgs.append(existing_node)
# In order to avoid a missed update, first mask lower versions
# that conflict with higher versions (the backtracker visits
# these in reverse order).
diff --git a/lib/_emerge/resolver/backtracking.py 
b/lib/_emerge/resolver/backtracking.py
index c29b9d42a..99e4565c8 100644
--- a/lib/_emerge/resolver/backtracking.py
+++ b/lib/_emerge/resolver/backtracking.py
@@ -135,11 +135,20 @@ class Backtracker(object):
continue
 
entry_is_valid = False
+   any_conflict_parents = False
 
for ppkg, patom in runtime_pkg_mask[pkg].get("slot 
conflict", set()):
+   any_conflict_parents = True
if ppkg not in runtime_pkg_mask:
entry_is_valid = True
break
+   else:
+   if not any_conflict_parents:
+   # Even though pkg was involved in a 
slot conflict
+   # where it was matched by all involved 
parent atoms,
+   # consider masking it in order to avoid 
a missed
+   # update as in bug 692746.
+   entry_is_valid = True
 
if not entry_is_valid:
return False
diff --git a/lib/portage/tests/resolver/test_slot_conflict_update_virt.py 
b/lib/portage/tests/resolver/test_slot_conflict_update_virt.py
new file mode 100644
index 0..ce89925ba
--- /dev/null
+++ b/lib/portage/tests/resolver/test_slot_conflict_update_virt.py
@@ -0,0 +1,79 @@
+# Copyright 2019 Gentoo Authors
+# Distributed under the terms of the GNU General Public License v2
+
+from portage.tests import TestCase
+from portage.tests.resolver.ResolverPlayground import (ResolverPlayground,
+   ResolverPlaygroundTestCase)
+
+class SlotConflictUpdateVirtTestCase(TestCase):
+
+   def testSlotConflictUpdateVirt(self):
+
+   ebuilds = {
+   "dev-db/mysql-connector-c-6.1.11-r2" : {
+   "EAPI": "7",
+   "SLOT" : "0/18"
+   },
+
+   "dev-db/mysql-connector-c-8.0.17-r3" : {
+   "EAPI": "7",
+   "SLOT" : "0/21"
+   },
+
+   "virtual/libmysqlclient-18-r1" : {
+   "EAPI": "7",
+   "SLOT" : "0/18",
+   "RDEPEND": "dev-db/mysql-connector-c:0/18",
+   },
+
+   "virtual/libmysqlclient-21" : {
+   "EAPI": "7",
+   "SLOT" : "0/21",
+   "RDEPEND": "dev-db/mysql-connector-c:0/21",
+   },
+
+   "dev-perl/DBD-mysql-4.44.0" : {
+   "EAPI": "7",
+   "RDEPEND": "virtual/libmysqlclient:=",
+   },
+   }
+
+   installed = {
+   

[gentoo-portage-dev] [PATCH] _backtrack_depgraph: fix premature backtracking termination (bug 693242)

2019-08-31 Thread Zac Medico
Make backtracking continue as long as the backtracker has remaining
nodes to explore. This fixes a case where it would terminate prematurely
when the depgraph.need_restart() method returned False, even though the
backtracker had remaining nodes to explore.

Bug: https://bugs.gentoo.org/693242
Signed-off-by: Zac Medico 
---
 lib/_emerge/depgraph.py | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/lib/_emerge/depgraph.py b/lib/_emerge/depgraph.py
index 3e99ac077..08240af67 100644
--- a/lib/_emerge/depgraph.py
+++ b/lib/_emerge/depgraph.py
@@ -9794,8 +9794,8 @@ def _backtrack_depgraph(settings, trees, myopts, 
myparams, myaction, myfiles, sp
elif mydepgraph.need_restart():
backtracked += 1
backtracker.feedback(mydepgraph.get_backtrack_infos())
-   else:
-   break
+   elif backtracker:
+   backtracked += 1
 
if not (success or mydepgraph.need_config_change()) and backtracked:
 
-- 
2.21.0




Re: [gentoo-portage-dev] [PATCH] glsa-check: add exit code for affected GLSAs

2019-08-31 Thread Zac Medico
On 8/30/19 12:18 PM, Aaron Bauman wrote:
> Bug: https://bugs.gentoo.org/587930
> 
> Reported-by: Bandie Yip Kojote 
> Signed-off-by: Aaron Bauman 
> ---
>  bin/glsa-check | 1 +
>  1 file changed, 1 insertion(+)
> 
> diff --git a/bin/glsa-check b/bin/glsa-check
> index 83ea6b7c3..b3ddc532a 100755
> --- a/bin/glsa-check
> +++ b/bin/glsa-check
> @@ -282,6 +282,7 @@ if mode == "test":
>   summarylist(outputlist)
>   else:
>   sys.stdout.write("\n".join(outputlist)+"\n")
> + sys.exit(6)
>   else:
>   sys.stderr.write("This system is not affected by any of the 
> listed GLSAs\n")
>   sys.exit(0)
> 

Thanks, merged:

https://gitweb.gentoo.org/proj/portage.git/commit/?id=4d9c10704b2eaf6cd7467ff0929a94e64429bfa6
-- 
Thanks,
Zac



signature.asc
Description: OpenPGP digital signature


Re: [gentoo-portage-dev] [PATCH 1/2] Use RTNETLINK to configure the loopback interface

2019-08-31 Thread Zac Medico
On 8/30/19 11:24 AM, Mike Gilbert wrote:
> This eliminates the dependency on iproute2 on Linux.
> 
> Signed-off-by: Mike Gilbert 
> ---
>  lib/portage/process.py  | 26 --
>  lib/portage/util/netlink.py | 98 +
>  2 files changed, 108 insertions(+), 16 deletions(-)
>  create mode 100644 lib/portage/util/netlink.py

Thanks, merged:

https://gitweb.gentoo.org/proj/portage.git/commit/?id=70ec13029e5cc8a1decfab7134d3addea8612bd7
-- 
Thanks,
Zac



signature.asc
Description: OpenPGP digital signature