Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
39 changes: 26 additions & 13 deletions testing/litevm/rpm.py
Original file line number Diff line number Diff line change
Expand Up @@ -123,6 +123,7 @@ def __init__(
cache_dir: Optional[Path] = None,
pkgbase: str = "kernel-uek",
yum_fmt: Optional[str] = None,
frozen_release: Optional[str] = None,
) -> None:
self.ol_ver = ol_ver
self.uek_ver = uek_ver
Expand All @@ -131,7 +132,7 @@ def __init__(
self.yum_fmt = yum_fmt
self.pkgbase = pkgbase

self._release: str = ""
self._release: str = frozen_release or ""
self._rpm_urls: List[str] = []
self._dbinfo_url: str = ""

Expand Down Expand Up @@ -188,17 +189,26 @@ def _getlatest(self) -> None:
)
db_path = db_path_dec

# Finally, search for the latest version in the DB. We always search for
# kernel-uek since even if the package is split, that's the
# meta-package.
conn = sqlite3.connect(str(db_path))
rows = conn.execute(
"""
SELECT version, release, location_href FROM packages
WHERE name=? AND arch=?;
""",
(self.pkgbase, self.arch),
).fetchall()
if self._release:
# If a release was specified, we'll search for just that version in
# the sqlite db.
rows = conn.execute(
"""
SELECT version, release, location_href FROM packages
WHERE name=? AND (version || '-' || release || '.' || arch)=?;
""",
(self.pkgbase, self._release),
).fetchall()
else:
# Otherwise, fetch all versions so we can find the latest.
rows = conn.execute(
"""
SELECT version, release, location_href FROM packages
WHERE name=? AND arch=?;
""",
(self.pkgbase, self.arch),
).fetchall()
conn.close()

# Sqlite can't sort versions correctly, so we load them all and sort
Expand All @@ -211,7 +221,10 @@ def key(t):
)
rows.sort(key=key, reverse=True)
versions_tried = []
for ver, rel, href in rows[:2]:
# We will try a maximum of the 5 most recent kernel to see whether
# debuginfo is available. This adds a bit of wiggle room in case of
# situations where debuginfo is not up-to-date online.
for ver, rel, href in rows[:5]:
# Check whether all RPMs are either cached or available via HTTP
rpm_urls: List[str] = []
rpm_url = yumbase + href
Expand Down Expand Up @@ -260,7 +273,7 @@ def key(t):
)

def _get_rpms(self) -> None:
if not self._release:
if not self._rpm_urls:
self._getlatest()

self._rpm_paths = []
Expand Down
Loading