-
Notifications
You must be signed in to change notification settings - Fork 0
/
f.lua
executable file
·105 lines (85 loc) · 3.66 KB
/
f.lua
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
#!/usr/bin/lua
-- SPDX-License-Identifier: GPL-2.0
-- Copyright 2022-2024 - Fábio Rodrigues Ribeiro and contributors
x = os.execute
local u = require "util"
local sai = require "sai"
local wd = "~/work/kernel_test"
local koji_build = ("cd %s ; koji download-build --arch=%s --rpm %s"):format(wd, "%s", "%s")
local kp_args, k_args = "kernel-%s%s-%d.fc%d.%s.rpm","kernel%s-%d.fc%d.%s.rpm"
Kp = {"modules-core", "core", "modules", "modules-extra" }
local function override() u.writecmd_x(("%s rpm-ostree override replace %s"):format(cd, table.concat(Kp, " "))) end
local function down_and_replace(version, dist)
x(("rm -rf %s && mkdir -p %s"):format(wd, wd))
for i, item in ipairs(Kp) do
Kp[i] = (kp_args):format(Kp[i], version, dist, u.sbversion(), u.arch())
u.writecmd_x(koji_build:format(u.arch(), Kp[i]))
end
u.writecmd_x(koji_build:format(u.arch(), k_args:format(version, dist, u.sbversion(), u.arch())))
table.insert(Kp, k_args:format(version, dist, u.sbversion(), u.arch()))
override()
end
local function dist(version)
return x(koji_build:format(u.arch(), k_args:format(version, 300, u.sbversion(), u.arch()))) and 300 or 200
end
local handlers = {
["off-selinux"] = function() x "semanage boolean -m --off selinuxuser_execheap" end,
["install-tools"] = function()
local list = { "make", "libtirpc-devel", "gcc", "python3-fedora", "koji", "fastfetch" }
local s = " \\\n--install="
x(("rpm-ostree upgrade %s%s && cd ~ ; git clone https://pagure.io/kernel-tests.git"):format(s, table.concat(list, s)))
end,
["check"] = function()
u.writecmd_x(([[koji list-builds --package=kernel --pattern "*fc%d*"]]):format(arg[2] and arg[2] or u.sbversion()))
io.write "\n\nLink para o koji: https://koji.fedoraproject.org/koji/packageinfo?packageID=8\n"
end,
["override-reset"] = function()
for i, item in ipairs(Kp) do Kp[i] = ("kernel-%s"):format(Kp[i]) end
table.insert(Kp, "kernel")
x(("rpm-ostree override reset %s"):format(table.concat(Kp, " ")))
end,
["force-override"] = function ()
arg[2] = u.getoutput "uname -r":match "(%d+)" -- Executa o comando uname -r para obter a versão do kernel e Divide a versão do kernel em partes usando o ponto como delimitador
override()
end,
["newer-patch"] = function()
local major, minor, patch = u.getoutput "uname -r":match "(%d+)%.(%d+)%.(%d+)" -- Executa o comando uname -r para obter a versão do kernel
local version = ("-%s.%s.%d"):format(major, minor, patch + 1) -- Converte o valor do Patch para número e incrementa 1 e constrói a nova versão do kernel
down_and_replace(version, dist(version))
end,
["newer"] = function() down_and_replace(("-%s"):format(arg[2]), dist(arg[2])) end,
["kernel-regressions"] = function()
x [[cd ~/kernel-tests;
sudo -s <<< "semanage boolean -m --on selinuxuser_execheap &&\
git pull &&\
./runtests.sh &&\
./runtests.sh -t performance &&\
semanage boolean -m --off selinuxuser_execheap"]]
end,
["help"] = function()
io.write
[[Options:
n, newer:
Download and Install a newer kernel (eg f.lua n 6.8.1-200)
np, newer-patch:
Download and Install a newer kernel patch (eg. f.lua np)
fo, force-override:
Force a kernel installation
or, override-reset:
Reset the installed kernel and goes to repo kernel
kr, kernel-regressions:
Performs test regressions
]]
end
}
-- Extra functions
handlers["c"] = handlers["check"]
handlers["fo"] = handlers["force-override"]
handlers["in"] = handlers["install-tools"]
handlers["kr"] = handlers["kernel-regressions"]
handlers["n"] = handlers["newer"]
handlers["np"] = handlers["newer-patch"]
handlers["off"] = handlers["off-selinux"]
handlers["or"] = handlers["override-reset"]
if sai.ca() then handlers["help"]() os.exit(1) end
handlers[arg[1]]()