@@ -1660,7 +1660,7 @@ def mark_fn(packages, po, v, certain_age, vault_requests):
1660
1660
# shouldn't retain anything.
1661
1661
#
1662
1662
if pn .endswith ('-debuginfo' ):
1663
- return Freshness .conditional
1663
+ return ( Freshness .conditional , False )
1664
1664
1665
1665
# - shared library packages which don't come from the current version of
1666
1666
# 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):
1674
1674
mtime = po .tar (v ).mtime
1675
1675
if mtime < certain_age :
1676
1676
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 )
1678
1678
1679
1679
# - if package depends on anything in expired_provides
1680
1680
#
1681
1681
requires = po .version_hints [v ].get ('depends' , [])
1682
1682
if any (ep in requires for ep in past_mistakes .expired_provides ):
1683
1683
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 )
1685
1685
1686
1686
# - marked via 'calm-tool vault'
1687
1687
#
1688
1688
es = po .srcpackage (v , suffix = False )
1689
1689
if es in vault_requests :
1690
1690
if v in vault_requests [es ]:
1691
1691
logging .info ("package '%s' version '%s' not retained due vault request" % (pn , v ))
1692
- return Freshness .conditional
1692
+ return ( Freshness .conditional , False )
1693
1693
1694
1694
# otherwise, make no change
1695
- return Freshness .fresh
1695
+ return ( Freshness .fresh , False )
1696
1696
1697
1697
1698
1698
#
@@ -1708,9 +1708,6 @@ def stale_packages(packages, vault_requests):
1708
1708
1709
1709
# mark install packages for freshness
1710
1710
for pn , po in packages .items ():
1711
- if po .kind != Kind .binary :
1712
- continue
1713
-
1714
1711
# mark as fresh any versions explicitly listed in the keep: override
1715
1712
# hint (unconditionally)
1716
1713
for v in po .override_hints .get ('keep' , '' ).split ():
@@ -1759,13 +1756,38 @@ def stale_packages(packages, vault_requests):
1759
1756
if newer :
1760
1757
mark_package_fresh (packages , pn , v )
1761
1758
1759
+ for pn , po in packages .items ():
1760
+ if po .kind != Kind .binary :
1761
+ continue
1762
+
1762
1763
# overwrite with 'conditional' package retention mark if it meets
1763
1764
# various criteria
1764
1765
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 )
1766
1767
if mark != Freshness .fresh :
1767
1768
mark_package_fresh (packages , pn , v , mark )
1768
1769
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
+
1769
1791
# mark source packages as fresh if any install package which uses it is fresh
1770
1792
for po in packages .values ():
1771
1793
if po .kind == Kind .source :
0 commit comments