-
Notifications
You must be signed in to change notification settings - Fork 0
/
sb.lua
executable file
·130 lines (117 loc) · 4.93 KB
/
sb.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
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
#!/usr/bin/lua
-- SPDX-License-Identifier: GPL-2.0
-- Copyright 2022-2023 - Fábio Rodrigues Ribeiro and contributors
x = os.execute
local u = require "util"
local s = require "sai"
local ro = "rpm-ostree"
local roc = ("%s cancel && "):format(ro)
local function kv () io.write (("Versão do kernel: %s\n"):format(u.getoutput "uname -r" )) end
local function lastdeploy () io.write(("Data do último deploy: %s\n"):format(u.openfile_match("/etc/os-release",[[VERSION="(.-)"]]))) end
local function rebasesb(plus,testing) x(("%s rebase fedora:fedora/%d/%s%s/silverblue"):format(ro,u.sbversion()+plus,u.arch(),testing)) end
local function pin() u.writemsg_x("sudo ostree admin pin 0","\n*** Pinning: \n") end
--[[
function open_override()
local pct = {}
local file = assert(io.open("override.txt","r"))
for line in file:lines() do pct = table.insert(pct,line) end
file:close()
return table.concat(pct," ")
end
]]--
local function rpmostree_upgrade(opts)
kv() lastdeploy() io.write "\n"
if os.getenv("DESKTOP_SESSION") == "gnome" then u.x_writemsg("gnome-software --quit","*** Parado gnome-software ***\n\n") end
x(("%s %s upgrade %s"):format(roc,ro,opts))
end
local function up()
rpmostree_upgrade ""
u.x_writemsg("flatpak update -y","\n*** Termiado atualizar flatpak ***\n*** Atualizando toolbox ***\n")
u.x_writemsg("toolbox run sudo dnf update -y", "\n*** Termiado atualizar toolbox ***\n\n")
end
local function clean() x(("sudo -s <<< \"%s cleanup -b -m && ostree admin cleanup\" && toolbox run dnf clean all"):format(ro)) end
local function oua() for i = 2,5 do x(("sudo ostree admin pin --unpin %d"):format(i)) end end
local handlers = {
-- ["reinstall"] = function() x "rpm-ostree upgrade --install=flatpak-builder" end
-- ["mesa-drm-freeworld"] = function() x "rpm-ostree override remove mesa-va-drivers --install=mesa-va-drivers-freeworld --install=mesa-vdpau-drivers-freeworld --install=ffmpeg" end,
-- --uninstall=rpmfusion-free-release-",self.__sbversion,"-1.noarch --uninstall=rpmfusion-nonfree-release-",self.__sbversion,"-1.noarch --install=https://mirrors.rpmfusion.org/nonfree/fedora/rpmfusion-nonfree-release-",self.__sbversion+1,".noarch.rpm --install=https://mirrors.rpmfusion.org/free/fedora/rpmfusion-free-release-",self.__sbversion+1,".noarch.rpm")
-- ["bulk-override-replace"] = function() print(("rpm-ostree override replace%s"):format(open_override())) end,
-- ["preview"] = function() x "rpm-ostree upgrade --preview" end,-- obsoleto
["c-up"] = function() clean() up() end,-- Funciona mas precisa fazer funções fora da tabela, solucionado
["check-branch"] = function() x(("ostree remote refs fedora | grep -E %d | grep -E \"%s/silverblue$\""):format(util.sbversion()+1,util.arch())) end,
["in"] = function() x(("%s%s upgrade --install=%s"):format(roc,ro,u.xargs())) end,
["lastchange"] = function() x(("%s db diff"):format(ro)) end,
["nextsb"] = function() rebasesb(1,"") end,
["nexttest"] = function() rebasesb(1,"/testing") end,
["poweroff"] = function () x "systemctl poweroff" end,
["reboot"] = function () x "systemctl reboot" end,
["ro"] = function() x(("%s%s%s"):format(roc,ro,u.xargs())) end,
["search"] = function() x(("%s search %s"):format(ro,u.xargs())) end,
["search-inrpm"] = function() x(("rpm -qa | grep -E %s"):format(u.xargs())) end,
["testsb"] = function() rebasesb(0,"/testing") end,
["up-r"] = function() rpmostree_upgrade "-r" end,
clean = clean,
lastdeploy = lastdeploy,
pin = pin,
up = up,
oua = oua,
["ostree-unpinall-pin"] = function()
oua()
pin()
end,
["help"] = function()
io.write
[[
Options:
cb, check-branch:
Check new branch
testsb:
Rebase to testing branch
nt, nexttest:
Upgrade to next testing version of silverblue
nsb, nextsb:
Upgrade to next version of silverblue
up:
Upgrade the role system to latest commit
in:
Install a layered package
c, clean:
Cleanup ostree based metadatas and cache
c-up:
Cleanup ostree based metadatas, cache and upgrade the role system to latest commit
pw, preview:
Dry-run of rpmostree upgrade
pin:
Pin the Ostree Deployment
mesa-drm-freeworld:
Install RPMFusion's mesa-drm freeworld (need configure rpmfusion repo)
search-inrpm:
Search for installed package
s, search:
Search for package
lc, lastchage:
Show last changes in rpm-ostree
ld, lastdeploy:
Show the last deploy in Silverblue
oua, ostree-unpinall:
Unpin all pinned commits
ouap, ostree-unpinall-pin:
Unpin all pinned commits and pin
]]
end
}
-- Extra functions
handlers['cb'] = handlers["check-branch"]
handlers["ouap"] = handlers["ostree-unpinall-pin"]
handlers["c"] = handlers["clean"]
handlers["s"] = handlers["search"]
handlers["pw"] = handlers["preview"]
handlers["nt"] = handlers["nexttest"]
handlers["ld"] = handlers["lastdeploy"]
handlers["lc"] = handlers["lastchange"]
handlers["nsb"] = handlers["nextsb"]
handlers["p"] = handlers["poweroff"]
handlers["r"] = handlers["reboot"]
handlers["ostree-unpinall"] = handlers["oua"]
if s.ca() then handlers["help"]() os.exit(1) end
handlers[arg[1]]()