diff options
author | Sam James <sam@gentoo.org> | 2021-02-17 03:04:51 +0000 |
---|---|---|
committer | Sam James <sam@gentoo.org> | 2021-02-17 03:04:51 +0000 |
commit | d023294af12750f1c9ff4d97b4d449eae6f57dcb (patch) | |
tree | da6779db1867386876746006838f663b4bba2efc | |
parent | scripts/tatt: drop invalid ~ prefix to arch (diff) | |
download | tatt-d023294af12750f1c9ff4d97b4d449eae6f57dcb.tar.gz tatt-d023294af12750f1c9ff4d97b4d449eae6f57dcb.tar.bz2 tatt-d023294af12750f1c9ff4d97b4d449eae6f57dcb.zip |
tatt/usecombis.py: Give up after too many USE-generation attempts
Closes: #40
Signed-off-by: Sam James <sam@gentoo.org>
-rw-r--r-- | tatt/usecombis.py | 21 |
1 files changed, 21 insertions, 0 deletions
diff --git a/tatt/usecombis.py b/tatt/usecombis.py index fb67be7..c24a82c 100644 --- a/tatt/usecombis.py +++ b/tatt/usecombis.py @@ -46,11 +46,31 @@ def findUseFlagCombis (package, config, port): swlist.append(2**len(uselist) - 1) # Test if we can exhaust all USE-combis by computing the binary logarithm. elif len(uselist) > math.log(config['usecombis'],2): + # Generate a sample of USE combis s = 2**(len (uselist)) rnds = set() random.seed() + + attempts = 0 + ignore_use_expand = False + while len(swlist) < config['usecombis'] and len(rnds) < s: + if attempts >= 10000 and not ignore_use_expand: + # After 10000 attempts, let's give up on USE_EXPAND. + ignore_use_expand = True + attempts = 0 + + print("Giving up on USE_EXPAND after {0} tries to find valid USE combinations".format(attempts)) + print("We've found {0} USE combinations so far".format(len(swlist))) + uselist = [use for use in uselist if not "_" in use] + + if attempts >= 10000 and ignore_use_expand: + # Let's give up entirely and use what we have. + print("Giving up on finding more USE combinations after {0} further attempts".format(attempts)) + print("We've found {0} USE combinations".format(len(swlist))) + break + r = random.randint(0, s-1) if r in rnds: # already checked @@ -58,6 +78,7 @@ def findUseFlagCombis (package, config, port): rnds.add(r) if not check_uses(ruse, uselist, r, package): + attempts += 1 # invalid combination continue |