From df253243cae48a16d761b02f099409013e1bb7d7 Mon Sep 17 00:00:00 2001 From: Arunava Das Date: Wed, 22 Jan 2025 14:08:58 +0530 Subject: [PATCH] update kernel version parser --- .github/workflows/kernel.yaml | 6 +++--- ruler/package.py | 27 +++++++++++++-------------- 2 files changed, 16 insertions(+), 17 deletions(-) diff --git a/.github/workflows/kernel.yaml b/.github/workflows/kernel.yaml index e86523b..d165e28 100644 --- a/.github/workflows/kernel.yaml +++ b/.github/workflows/kernel.yaml @@ -36,11 +36,11 @@ jobs: .kernelcfg=(.version | sub("(?\\d+\\.\\d+)(.*)"; "kernel-\(.x)_arm64.cfg")) | .release=( if (.version | test("^\\d+\\.\\d+$")) then - (.version | sub("(?\\d+\\.\\d+)"; "\(.x).0+nobara-1kernel\(0)")) + (.version | sub("(?\\d+\\.\\d+)"; "\(.x).0+nobara-\(1000)")) elif(.version | test("^\\d+\\.\\d+\\.\\d+$")) then - (.version | sub("(?\\d+\\.\\d+)\\.(?\\d+)"; "\(.x).\(.y)+nobara-1kernel\(.y | tonumber + 0)")) + (.version | sub("(?\\d+\\.\\d+)\\.(?\\d+)"; "\(.x).\(.y)+nobara-\(.y | tonumber + 1000)")) else - (.version | sub("(?\\d+\\.\\d+)-rc(?\\d+)"; "\(.x).0+nobara-0kernel\(.y | tonumber + 0)")) + (.version | sub("(?\\d+\\.\\d+)-rc(?\\d+)"; "\(.x).0+nobara-\(.y | tonumber + 1000)")) end ) ) diff --git a/ruler/package.py b/ruler/package.py index 2d15bcd..0f71481 100644 --- a/ruler/package.py +++ b/ruler/package.py @@ -265,10 +265,13 @@ def parse_args(): parse_args() -exit() +# exit() -def encode_array(array, xlen=4, ylen=25): - array = [k for k in map(lambda x: (len(max(x, key=lambda y: len(y))), x), batched(array, ylen))] +def encode_array(array, xlen=4): + + ylen = 1+(len(array) // xlen) + + array = [k for k in map(lambda x: [ len(max(x, key=lambda y: len(y))), x ], batched(array, ylen))] dump = "" for y in range(ylen): for x in range(xlen): @@ -283,7 +286,7 @@ def encode_array(array, xlen=4, ylen=25): def decode_array(dump, xlen=4): - array = findall(r"\S+", dump) + array = findall('"(.+)"', dump) darray = [] @@ -295,24 +298,20 @@ def decode_array(dump, xlen=4): for x in range(xlen): for y in range(ylen): try: - if y > rlen: - r = 1 - else: - r = 0 - darray.append( array[x+y*(xlen-r)] ) + + darray.append( array[x+y*xlen] ) except IndexError: pass return darray -print(encode_array(debootstrap_package_array, xlen=4, ylen=1+(len(debootstrap_package_array)//4))) -print(encode_array(pipewire_server_package_array, xlen=4, ylen=1+(len(pipewire_server_package_array)//4))) -print(encode_array(cross_compiler_packages, xlen=4, ylen=1+(len(cross_compiler_packages)//4))) -print(dump:=encode_array(server_package_array, xlen=4, ylen=1+(len(server_package_array)//4))) +print(encode_array(debootstrap_package_array, xlen=4)) +print(encode_array(pipewire_server_package_array, xlen=4)) +print(encode_array(cross_compiler_packages, xlen=4)) +print(dump:=encode_array(server_package_array, xlen=4)) -print(decode_array(dump, xlen=4)) # xz --decompress --stdout < ubuntu-image/ubuntu-24.10-preinstalled-server-arm64.img.xz | sudo dd of=/dev/nvme0n1 bs=8M iflag=fullblock oflag=direct status=progress