Skip to content

Commit 8078633

Browse files
committed
Be a bit more aggressive about expiring old soversions
Allow the source package responsible for the old soversion to be completely expired if it wouldn't normally be kept, and all of it's install packages have no external rdepends.
1 parent f4dd6de commit 8078633

File tree

1 file changed

+31
-9
lines changed

1 file changed

+31
-9
lines changed

calm/package.py

Lines changed: 31 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1660,7 +1660,7 @@ def mark_fn(packages, po, v, certain_age, vault_requests):
16601660
# shouldn't retain anything.
16611661
#
16621662
if pn.endswith('-debuginfo'):
1663-
return Freshness.conditional
1663+
return (Freshness.conditional, False)
16641664

16651665
# - shared library packages which don't come from the current version of
16661666
# source (i.e. is superseded or removed), have no packages from a
@@ -1674,25 +1674,25 @@ def mark_fn(packages, po, v, certain_age, vault_requests):
16741674
mtime = po.tar(v).mtime
16751675
if mtime < certain_age:
16761676
logging.debug("deprecated soversion package '%s' version '%s' mtime '%s' is over cut-off age" % (pn, v, time.strftime("%F %T %Z", time.localtime(mtime))))
1677-
return Freshness.conditional
1677+
return (Freshness.conditional, True)
16781678

16791679
# - if package depends on anything in expired_provides
16801680
#
16811681
requires = po.version_hints[v].get('depends', [])
16821682
if any(ep in requires for ep in past_mistakes.expired_provides):
16831683
logging.debug("package '%s' version '%s' not retained as it requires a provide known to be expired" % (pn, v))
1684-
return Freshness.conditional
1684+
return (Freshness.conditional, False)
16851685

16861686
# - marked via 'calm-tool vault'
16871687
#
16881688
es = po.srcpackage(v, suffix=False)
16891689
if es in vault_requests:
16901690
if v in vault_requests[es]:
16911691
logging.info("package '%s' version '%s' not retained due vault request" % (pn, v))
1692-
return Freshness.conditional
1692+
return (Freshness.conditional, False)
16931693

16941694
# otherwise, make no change
1695-
return Freshness.fresh
1695+
return (Freshness.fresh, False)
16961696

16971697

16981698
#
@@ -1708,9 +1708,6 @@ def stale_packages(packages, vault_requests):
17081708

17091709
# mark install packages for freshness
17101710
for pn, po in packages.items():
1711-
if po.kind != Kind.binary:
1712-
continue
1713-
17141711
# mark as fresh any versions explicitly listed in the keep: override
17151712
# hint (unconditionally)
17161713
for v in po.override_hints.get('keep', '').split():
@@ -1759,13 +1756,38 @@ def stale_packages(packages, vault_requests):
17591756
if newer:
17601757
mark_package_fresh(packages, pn, v)
17611758

1759+
for pn, po in packages.items():
1760+
if po.kind != Kind.binary:
1761+
continue
1762+
17621763
# overwrite with 'conditional' package retention mark if it meets
17631764
# various criteria
17641765
for v in sorted(po.versions(), key=lambda v: SetupVersion(v)):
1765-
mark = mark_fn(packages, po, v, certain_age, vault_requests)
1766+
(mark, others) = mark_fn(packages, po, v, certain_age, vault_requests)
17661767
if mark != Freshness.fresh:
17671768
mark_package_fresh(packages, pn, v, mark)
17681769

1770+
# also look over the other install packages generated by the
1771+
# source...
1772+
if others:
1773+
es = po.version_hints[v].get('external-source', None)
1774+
if es:
1775+
es_po = packages[es]
1776+
# ... if the source package version doesn't count as kept ...
1777+
#
1778+
# (set above using same critera as for install package
1779+
# e.g. we have an excess number of packages)
1780+
logging.warning("considering other packages from source package '%s' version '%s'" % (es, v))
1781+
if getattr(es_po.tar(v), 'fresh', Freshness.stale) != Freshness.fresh:
1782+
# ... additionally mark anything with no other-source
1783+
# rdepends
1784+
for opn in sorted(es_po.is_used_by):
1785+
if v in packages[opn].versions():
1786+
if not any(packages[p].srcpackage(v) != es for p in packages[opn].rdepends):
1787+
mark_package_fresh(packages, opn, v, mark)
1788+
else:
1789+
logging.warning("package '%s' version '%s' retained due to being used" % (opn, v))
1790+
17691791
# mark source packages as fresh if any install package which uses it is fresh
17701792
for po in packages.values():
17711793
if po.kind == Kind.source:

0 commit comments

Comments
 (0)