Skip to content

Commit

Permalink
Switch Upstream 4.14 to use the OpenELA branch (closes #9)
Browse files Browse the repository at this point in the history
Signed-off-by: Stephen Brennan <[email protected]>
  • Loading branch information
brenns10 committed May 24, 2024
1 parent 527a9f3 commit 7dce199
Show file tree
Hide file tree
Showing 3 changed files with 62 additions and 11 deletions.
18 changes: 8 additions & 10 deletions config.ini
Original file line number Diff line number Diff line change
Expand Up @@ -626,14 +626,13 @@ key = gregkh

[upstream_4.14_x86_64]
name = Upstream Default
version = 4.14
do_update = false
version = 4.14 (OpenELA)
arch = x86_64
package = linux
fetcher = kconfigs.upstream.UpstreamFetcher
fetcher = kconfigs.github.GithubFetcher
extractor = kconfigs.upstream.DefconfigExtractor
index = https://www.kernel.org/feeds/kdist.xml
key = gregkh
index = https://github.com/openela/kernel-lts
key = NOVERIFY-GITHUB

[upstream_6.9_aarch64]
name = Upstream Default
Expand Down Expand Up @@ -707,14 +706,13 @@ key = gregkh

[upstream_4.14_aarch64]
name = Upstream Default
version = 4.14
do_update = false
version = 4.14 (OpenELA)
arch = aarch64
package = linux
fetcher = kconfigs.upstream.UpstreamFetcher
fetcher = kconfigs.github.GithubFetcher
extractor = kconfigs.upstream.DefconfigExtractor
index = https://www.kernel.org/feeds/kdist.xml
key = gregkh
index = https://github.com/openela/kernel-lts
key = NOVERIFY-GITHUB

[arch_linux_x86_64]
# btw
Expand Down
49 changes: 49 additions & 0 deletions kconfigs/github.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
# Copyright (c) 2024, Oracle and/or/ its affiliates.
# Licensed under the terms of the GNU General Public License.
import json
import urllib.parse
from pathlib import Path
from typing import Any

from kconfigs.fetcher import DistroConfig
from kconfigs.fetcher import Fetcher
from kconfigs.util import download_file_mem


class GithubFetcher(Fetcher):
"""
Fetcher for Github releases.
Uses the Github API to fetch the latest release tarball asset. From there,
you can then use the DefconfigExtractor to generate the default config for
various architectures.
To use this, the DistroConfig should set the "index" configuration to be the
repository URL. You'll also want to set the "key" to "NOVERIFY-GITHUB" so
that the DefconfigExtractor will not try to verify a non-existing GPG
signature.
"""

def __init__(
self, saved_state: dict[str, Any], dc: DistroConfig, savedir: Path
):
self.user, self.repo = (
urllib.parse.urlparse(dc.index).path.strip("/").split("/")
)

def save_data(self) -> dict[str, Any]:
return {}

@classmethod
def uid(cls, dc: DistroConfig) -> str:
user, repo = urllib.parse.urlparse(dc.index).path.strip("/").split("/")
return f"github-{user}-{repo}"

async def is_updated(self) -> bool:
return True # there's no extra index to check

async def latest_version_url(self, package: str) -> tuple[str, None]:
url = f"https://api.github.com/repos/{self.user}/{self.repo}/releases"
data = await download_file_mem(url)
resp = json.loads(data.decode("utf-8"))
return resp[0]["tarball_url"], None
6 changes: 5 additions & 1 deletion kconfigs/upstream.py
Original file line number Diff line number Diff line change
Expand Up @@ -106,6 +106,8 @@ class DefconfigExtractor(Extractor):
async def verify_signature(
self, package: Path, sig: Path, dc: DistroConfig
) -> None:
if dc.key == "NOVERIFY-GITHUB":
return
assert dc.key is not None
decompressed_tar = await maybe_decompress(package)
if await gpg_verify(decompressed_tar, sig, dc.key):
Expand All @@ -125,13 +127,15 @@ async def extract_kconfig(
tdpath = Path(td)
arch = UPSTREAM_ARCH.get(dc.arch, dc.arch)

extract_dir = tdpath / package.stem.split(".tar")[0]
await check_call(
["tar", "xf", package],
cwd=tdpath,
stdout=DEVNULL,
stderr=DEVNULL,
)
subdirs = list(tdpath.iterdir())
assert len(subdirs) == 1
extract_dir = subdirs[0]
await check_call(
["make", f"ARCH={arch}", "defconfig"],
cwd=extract_dir,
Expand Down

0 comments on commit 7dce199

Please sign in to comment.