yifengyou / rpms / yum

Forked from rpms/yum 3 years ago
Clone

Blame SOURCES/BZ-1510491-fixup-yumdb-validator.patch

5e9bef
commit 61cacc3c79c356a3c3a910b0c5ddd12cfaaa20e5
5e9bef
Author: Michal Domonkos <mdomonko@redhat.com>
5e9bef
Date:   Mon Nov 6 11:07:38 2017 +0100
5e9bef
5e9bef
    BZ 1510491
5e9bef
    
5e9bef
    Fix from_repo yumdb validator for local pkgs
5e9bef
5e9bef
diff --git a/yum/rpmsack.py b/yum/rpmsack.py
5e9bef
index e810e2f9..19b9ab35 100644
5e9bef
--- a/yum/rpmsack.py
5e9bef
+++ b/yum/rpmsack.py
5e9bef
@@ -1731,6 +1731,12 @@ class RPMDBAdditionalData(object):
5e9bef
 
5e9bef
         pass
5e9bef
 
5e9bef
+def _validate_from_repo(value):
5e9bef
+    if value and value[0] == '/':
5e9bef
+        # Local package; chop the slash as it's not a valid repoid char
5e9bef
+        value = value[1:]
5e9bef
+    return misc.validate_repoid(value) is None
5e9bef
+
5e9bef
 class RPMDBAdditionalDataPackage(object):
5e9bef
 
5e9bef
     # We do auto hardlink on these attributes
5e9bef
@@ -1744,7 +1750,7 @@ class RPMDBAdditionalDataPackage(object):
5e9bef
     # Validate these attributes when they are read from a file
5e9bef
     _validators = {
5e9bef
         # Fixes BZ 1234967
5e9bef
-        'from_repo': lambda repoid: misc.validate_repoid(repoid) is None,
5e9bef
+        'from_repo': _validate_from_repo,
5e9bef
     }
5e9bef
 
5e9bef
     def __init__(self, conf, pkgdir, yumdb_cache=None):