Merge remote-tracking branch 'origin/main' into deps/poetry-update

This commit is contained in:
GitHub Actions 2023-04-16 20:22:02 +00:00
commit 61a6ab2fce
5 changed files with 119 additions and 11 deletions

View file

@ -24,6 +24,10 @@ information about the usage of `repo-autoindex`.
## Changelog
### v1.1.1 - 2023-04-12
- Fix handling of kickstart repositories with no checksums in treeinfo.
### v1.1.0 - 2023-04-04
- Added limited support for kickstart repositories.

View file

@ -9,7 +9,7 @@
project = "repo-autoindex"
copyright = "2023, Red Hat"
author = "Rohan McGovern <rmcgover@redhat.com>"
release = "1.1.0"
release = "1.1.1"
# -- General configuration ---------------------------------------------------
# https://www.sphinx-doc.org/en/master/usage/configuration.html#general-configuration

View file

@ -1,6 +1,6 @@
[tool.poetry]
name = "repo-autoindex"
version = "1.1.0"
version = "1.1.1"
description = "Generic static HTML indexes of various repository types"
authors = ["Rohan McGovern <rmcgover@redhat.com>"]
license = "GPL-3.0-or-later"

View file

@ -132,15 +132,15 @@ class KickstartRepo(YumRepo):
treeinfo = configparser.ConfigParser()
treeinfo.read_string(self.treeinfo_content)
for image in treeinfo["checksums"]:
entry = IndexEntry(
href=image,
text=os.path.basename(image),
)
if entry.href.endswith(".iso") or entry.href.endswith(".img"):
entry.icon = ICON_OPTICAL
out.append(entry)
if "checksums" in treeinfo:
for image in treeinfo["checksums"]:
entry = IndexEntry(
href=image,
text=os.path.basename(image),
)
if entry.href.endswith(".iso") or entry.href.endswith(".img"):
entry.icon = ICON_OPTICAL
out.append(entry)
return out
async def _extra_files_entries(self) -> list[IndexEntry]:

View file

@ -445,6 +445,43 @@ repository = .
type = variant
uid = BaseOS"""
TREEINFO_APPSTREAM="""[general]
; WARNING.0 = This section provides compatibility with pre-productmd treeinfos.
; WARNING.1 = Read productmd documentation for details about new format.
arch = x86_64
family = Red Hat Enterprise Linux
name = Red Hat Enterprise Linux 8.3
packagedir = Packages
platforms = x86_64
repository = .
timestamp = 1601410486
variant = AppStream
variants = AppStream
version = 8.3
[header]
type = productmd.treeinfo
version = 1.2
[release]
name = Red Hat Enterprise Linux
short = RHEL
version = 8.3
[tree]
arch = x86_64
build_timestamp = 1601410486
platforms = x86_64
variants = AppStream
[variant-AppStream]
id = AppStream
name = AppStream
packages = Packages
repository = .
type = variant
uid = AppStream"""
EXTRA_FILES_JSON = """{
"data": [
{
@ -574,3 +611,70 @@ async def test_typical_index():
assert '<a href="install.img">' in by_relative_dir["images"].content
assert '<a href="vmlinuz">' in by_relative_dir["images/pxeboot"].content
async def test_typical_appstream_index():
fetcher = StaticFetcher()
fetcher.content["https://example.com/repodata/repomd.xml"] = REPOMD_XML
fetcher.content[
"https://example.com/repodata/d4888f04f95ac067af4d997d35c6d345cbe398563d777d017a3634c9ed6148cf-primary.xml.gz"
] = PRIMARY_XML
fetcher.content["https://example.com/treeinfo"] = TREEINFO_APPSTREAM
fetcher.content["https://example.com/extra_files.json"] = EXTRA_FILES_JSON
entries: list[GeneratedIndex] = []
async for entry in autoindex("https://example.com", fetcher=fetcher):
print(f"Found one entry: {entry.relative_dir}")
entries.append(entry)
# It should generate some entries
assert entries
entries.sort(key=lambda e: e.relative_dir)
# First check that the directory structure was reproduced.
assert [e.relative_dir for e in entries] == [
"",
"packages",
"packages/w",
"packages/x",
"repodata",
]
by_relative_dir: dict[str, GeneratedIndex] = {}
for entry in entries:
by_relative_dir[entry.relative_dir] = entry
# Sanity check a few links expected to appear in each.
assert '<a href="repodata/">' in by_relative_dir[""].content
assert '<a href="packages/">' in by_relative_dir[""].content
assert '<a href="w/">' in by_relative_dir["packages"].content
assert '<a href="x/">' in by_relative_dir["packages"].content
assert (
'<a href="284769ec79daa9e0a3b0129bb6260cc6271c90c4fe02b43dfa7cdf7635fb803f-filelists.xml.gz">'
in by_relative_dir["repodata"].content
)
assert (
'<a href="wireplumber-libs-0.4.10-1.fc36.x86_64.rpm">'
in by_relative_dir["packages/w"].content
)
assert (
'<a href="xfce4-terminal-1.0.3-1.fc36.x86_64.rpm">'
in by_relative_dir["packages/x"].content
)
assert '<a href="treeinfo">' in by_relative_dir[""].content
assert '<a href="extra_files.json">' in by_relative_dir[""].content
assert '<a href="EULA">' in by_relative_dir[""].content
assert '<a href="GPL">' in by_relative_dir[""].content
assert '<a href="RPM-GPG-KEY-redhat-beta">' in by_relative_dir[""].content
assert '<a href="RPM-GPG-KEY-redhat-release">' in by_relative_dir[""].content