FrostyX / tracer

Tracer finds outdated running applications in your system
GNU General Public License v2.0
82 stars 24 forks source link

Recognize packages updated through rpm #214

Open FrostyX opened 2 weeks ago

FrostyX commented 2 weeks ago

See https://issues.redhat.com/browse/RHEL-58663

Tracer doesn't recognize packages updated through rpm, e.g.

rpm -Uvh --noscripts chrony-4.5-1.el9.x86_64.rpm

It's not as simple as editing System.package_manager function and adding:

"fedora":  [
    ("tracer.packageManagers.dnf", "Dnf"),
    ("tracer.packageManagers.yum", "Yum"),
    ("tracer.packageManagers.rpm", "Rpm"),
],

because the Rpm class doesn't know where the RPM database is:

class Rpm(IPackageManager):
    @property
    def history_path(self): return NotImplemented

I am not sure if this is enough to fix this, or the SQL queries in the class won't work anyway.

FrostyX commented 2 weeks ago

I am not sure if this is enough to fix this, or the SQL queries in the class won't work anyway.

Nope, they won't work, they are both written for Yum and Dnf. Even when using /var/lib/rpm/rpmdb.sqlite database and applying some tweaks, neither of these is compatible with the database:

if self.opts.get('modern_swdb'):
    sql = """
        SELECT DISTINCT rpm.name, trans.dt_end AS end

        FROM trans JOIN trans_item JOIN rpm
        ON trans.id=trans_item.trans_id
        AND trans_item.item_id=rpm.item_id

        WHERE trans.dt_begin > ?
        ORDER BY rpm.name
    """
else:
    sql = """
        SELECT DISTINCT pkgtups.name, trans_end.timestamp AS end

        FROM trans_beg JOIN trans_end JOIN trans_data_pkgs JOIN pkgtups
        ON trans_beg.tid=trans_end.tid
        AND trans_data_pkgs.tid=trans_beg.tid
        AND trans_data_pkgs.pkgtupid=pkgtups.pkgtupid

        WHERE trans_beg.timestamp > ?
        ORDER BY pkgtups.name
    """