Skip to content

Commit

Permalink
linux-stable: Switch to fetching via git
Browse files Browse the repository at this point in the history
Signed-off-by: Paul Barker <[email protected]>
  • Loading branch information
pbrkr committed Oct 16, 2024
1 parent 4b54bde commit 2c8b826
Show file tree
Hide file tree
Showing 10 changed files with 30 additions and 78 deletions.
10 changes: 3 additions & 7 deletions recipes-kernel/linux/linux-stable.inc
Original file line number Diff line number Diff line change
Expand Up @@ -4,16 +4,12 @@
require linux-mainline-common.inc
SUMMARY += "(stable)"

LINUX_STABLE_BRANCH = "linux-${LINUX_VMAJOR}.${LINUX_VMINOR}.y"
LINUX_VERSION = "${LINUX_VMAJOR}.${LINUX_VMINOR}.${LINUX_VPATCH}"
PV = "${LINUX_VERSION}"

SRC_URI = " \
https://cdn.kernel.org/pub/linux/kernel/v${LINUX_VMAJOR}.x/linux-${LINUX_VMAJOR}.${LINUX_VMINOR}.tar.xz;name=tarball \
https://cdn.kernel.org/pub/linux/kernel/v${LINUX_VMAJOR}.x/patch-${LINUX_VMAJOR}.${LINUX_VMINOR}.${LINUX_VPATCH}.xz;downloadfilename=linux-${LINUX_VMAJOR}.${LINUX_VMINOR}.${LINUX_VPATCH}.patch.xz;name=patch \
"
SRC_URI[tarball.sha256sum] = "${LINUX_SHA256_TARBALL}"
SRC_URI[patch.sha256sum] = "${LINUX_SHA256_PATCH}"
S = "${WORKDIR}/linux-${LINUX_VMAJOR}.${LINUX_VMINOR}"
SRC_URI = "git://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git;protocol=https;branch=${LINUX_STABLE_BRANCH}"
S = "${WORKDIR}/git"

python __anonymous() {
kver = (int(d.getVar("LINUX_VMAJOR")), int(d.getVar("LINUX_VMINOR")))
Expand Down
3 changes: 1 addition & 2 deletions recipes-kernel/linux/linux-stable_4.19.bb
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,5 @@
LINUX_VMAJOR = "4"
LINUX_VMINOR = "19"
LINUX_VPATCH = "322"
LINUX_SHA256_TARBALL = "0c68f5655528aed4f99dae71a5b259edc93239fa899e2df79c055275c21749a1"
LINUX_SHA256_PATCH = "20d6ccd160fc39ce2f6320727373d8b6eff84ad17f5fa184d75e38932d54f73b"
SRCREV = "de2cffe297563c815c840cfa14b77a0868b61e53"
require linux-stable.inc
3 changes: 1 addition & 2 deletions recipes-kernel/linux/linux-stable_5.10.bb
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,5 @@
LINUX_VMAJOR = "5"
LINUX_VMINOR = "10"
LINUX_VPATCH = "226"
LINUX_SHA256_TARBALL = "dcdf99e43e98330d925016985bfbc7b83c66d367b714b2de0cbbfcbf83d8ca43"
LINUX_SHA256_PATCH = "9f31e9db318054258407db3697003773bc27ecbe5d03ee6433d68a41277de7d1"
SRCREV = "ceb091e2c4ccf93b1ee0e0e8a202476a433784ff"
require linux-stable.inc
3 changes: 1 addition & 2 deletions recipes-kernel/linux/linux-stable_5.15.bb
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,5 @@
LINUX_VMAJOR = "5"
LINUX_VMINOR = "15"
LINUX_VPATCH = "167"
LINUX_SHA256_TARBALL = "57b2cf6991910e3b67a1b3490022e8a0674b6965c74c12da1e99d138d1991ee8"
LINUX_SHA256_PATCH = "7fe45d678d9df2d160ebf056baf903739710d6f45953a577ac858ddb8612249b"
SRCREV = "3a5928702e7120f83f703fd566082bfb59f1a57e"
require linux-stable.inc
3 changes: 1 addition & 2 deletions recipes-kernel/linux/linux-stable_5.4.bb
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,5 @@
LINUX_VMAJOR = "5"
LINUX_VMINOR = "4"
LINUX_VPATCH = "284"
LINUX_SHA256_TARBALL = "bf338980b1670bca287f9994b7441c2361907635879169c64ae78364efc5f491"
LINUX_SHA256_PATCH = "42288d989a67f771ac2f1454bdb25a25db7f7d51aa6db41b6fcefc22c3311399"
SRCREV = "661f109c057497c8baf507a2562ceb9f9fb3cbc2"
require linux-stable.inc
3 changes: 1 addition & 2 deletions recipes-kernel/linux/linux-stable_6.1.bb
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,5 @@
LINUX_VMAJOR = "6"
LINUX_VMINOR = "1"
LINUX_VPATCH = "112"
LINUX_SHA256_TARBALL = "2ca1f17051a430f6fed1196e4952717507171acfd97d96577212502703b25deb"
LINUX_SHA256_PATCH = "ca623b43f81fcc51fbb3fe63eb4fabf543444c21585171e2f1924cd5db1e249e"
SRCREV = "aa4cd140bba57b7064b4c7a7141bebd336d32087"
require linux-stable.inc
3 changes: 1 addition & 2 deletions recipes-kernel/linux/linux-stable_6.10.bb
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,5 @@
LINUX_VMAJOR = "6"
LINUX_VMINOR = "10"
LINUX_VPATCH = "14"
LINUX_SHA256_TARBALL = "774698422ee54c5f1e704456f37c65c06b51b4e9a8b0866f34580d86fef8e226"
LINUX_SHA256_PATCH = "28d575921f079cff449e50b6984c27dd341851342a9f00164c8ab8853f0a37ae"
SRCREV = "47c2f92131c47a37ea0e3d8e1a4e4c82a9b473d4"
require linux-stable.inc
3 changes: 1 addition & 2 deletions recipes-kernel/linux/linux-stable_6.11.bb
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,5 @@
LINUX_VMAJOR = "6"
LINUX_VMINOR = "11"
LINUX_VPATCH = "3"
LINUX_SHA256_TARBALL = "55d2c6c025ebc27810c748d66325dd5bc601e8d32f8581d9e77673529bdacb2e"
LINUX_SHA256_PATCH = "4c808f6dd8814ab55a343649a2e2b925895b7f97044d15fa3424e5cf69349c3e"
SRCREV = "8e24a758d14c0b1cd42ab0aea980a1030eea811f"
require linux-stable.inc
3 changes: 1 addition & 2 deletions recipes-kernel/linux/linux-stable_6.6.bb
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,5 @@
LINUX_VMAJOR = "6"
LINUX_VMINOR = "6"
LINUX_VPATCH = "56"
LINUX_SHA256_TARBALL = "d926a06c63dd8ac7df3f86ee1ffc2ce2a3b81a2d168484e76b5b389aba8e56d0"
LINUX_SHA256_PATCH = "391af9b4926f95fccc47eaf357bc80fe0b31e46179c3ab537141e08952d30e69"
SRCREV = "d4576c5670090297b903771726a526f81fdd8c7c"
require linux-stable.inc
74 changes: 19 additions & 55 deletions scripts/update-layer
Original file line number Diff line number Diff line change
Expand Up @@ -8,43 +8,27 @@ if sys.version_info < (3, 7):
print("ERROR: This script requires Python 3.7 or later!")
sys.exit(1)

import os
import re
import shutil
import subprocess
import tempfile
import textwrap
import urllib.request

TMPDIR = tempfile.TemporaryDirectory()


def load_sha256sums(vmajor, vminor, vpatch):
path = os.path.join(TMPDIR.name, f"sha256sums-v{vmajor}.asc")
if not os.path.exists(path):
f_in = urllib.request.urlopen(
f"https://cdn.kernel.org/pub/linux/kernel/v{vmajor}.x/sha256sums.asc"
)
f_out = open(path, "wb")
shutil.copyfileobj(f_in, f_out)
f_in.close()
f_out.close()

tarball_sha256sum = None
patch_sha256sum = None
tarball_pattern = re.compile(rf"([0-9a-f]*)\s+linux-{vmajor}.{vminor}.tar.xz")
patch_pattern = re.compile(rf"([0-9a-f]*)\s+patch-{vmajor}.{vminor}.{vpatch}.xz")
for line in open(path, "r"):
line = line.strip()
m = re.match(tarball_pattern, line)
if m:
tarball_sha256sum = m.group(1)
continue
m = re.match(patch_pattern, line)
if m:
patch_sha256sum = m.group(1)

return tarball_sha256sum, patch_sha256sum
def get_srcrev(version, upstream):
p = subprocess.run(
[
"git",
"ls-remote",
"--tags",
f"https://git.kernel.org/pub/scm/linux/kernel/git/{upstream}/linux.git",
f"v{version}^{{}}",
],
capture_output=True,
check=True,
)
srcrev = p.stdout.decode().split()[0]
# print(f"Got srcrev {srcrev} for version {version}")
return srcrev


def update_mainline_recipe(version):
Expand All @@ -53,20 +37,7 @@ def update_mainline_recipe(version):

print(f"mainline: {old_version} -> {version}")
if old_version != version:
# Get the srcrev
p = subprocess.run(
[
"git",
"ls-remote",
"--tags",
"https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git",
f"v{version}^{{}}",
],
capture_output=True,
check=True,
)
srcrev = p.stdout.decode().split()[0]
# print(f"mainline: Got srcrev {srcrev}")
srcrev = get_srcrev(version, "torvalds")

# Write the new recipe
open("recipes-kernel/linux/linux-mainline.bb", "w").write(
Expand Down Expand Up @@ -109,13 +80,9 @@ def update_stable_recipe(version):
f"{vmajor}.{vminor}.y: {vmajor}.{vminor}.{old_vpatch} -> {vmajor}.{vminor}.{vpatch}"
)
if old_vpatch != vpatch:
sha256_tarball, sha256_patch = load_sha256sums(vmajor, vminor, vpatch)
if not sha256_tarball or not sha256_patch:
print(f"Failed to get sha256sums for {version}")
return
srcrev = get_srcrev(version, "stable")

# print(f"{vmajor}.{vminor}.y: Got tarball sha256sum {sha256_tarball}")
# print(f"{vmajor}.{vminor}.y: Got patch sha256sum {sha256_patch}")
# Write the new recipe
open(fname, "w").write(
textwrap.dedent(
f"""\
Expand All @@ -124,17 +91,14 @@ def update_stable_recipe(version):
LINUX_VMAJOR = "{vmajor}"
LINUX_VMINOR = "{vminor}"
LINUX_VPATCH = "{vpatch}"
LINUX_SHA256_TARBALL = "{sha256_tarball}"
LINUX_SHA256_PATCH = "{sha256_patch}"
SRCREV = "{srcrev}"
require linux-stable.inc
"""
)
)

if old_vpatch:
msg = f"linux-stable: Uprev {vmajor}.{vminor} recipe to v{vmajor}.{vminor}.{vpatch}"
elif not vpatch:
msg = f"linux-stable: Add {vmajor}.{vminor} recipe"
else:
msg = f"linux-stable: Add {vmajor}.{vminor} recipe at v{vmajor}.{vminor}.{vpatch}"
subprocess.run(
Expand Down

0 comments on commit 2c8b826

Please sign in to comment.