-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathdnf.lua
More file actions
55 lines (48 loc) · 1.13 KB
/
dnf.lua
File metadata and controls
55 lines (48 loc) · 1.13 KB
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
return {
install = function(packages)
local cmd = "dnf install -y"
for _, package in ipairs(packages) do
cmd = cmd .. " " .. package
end
os.execute(cmd)
return true
end,
remove = function(packages)
local cmd = "dnf remove -y"
for _, package in ipairs(packages) do
cmd = cmd .. " " .. package
end
os.execute(cmd)
return true
end,
update = function()
os.execute("dnf update -y")
return true
end,
list = function()
os.execute("dnf repoquery --userinstalled")
return true
end,
search = function(term)
local cmd = "dnf search " .. term
os.execute(cmd)
return true
end,
info = function(package)
local cmd = "dnf info " .. package
os.execute(cmd)
return true
end,
exists = function(package)
local handle = io.popen("dnf list installed " .. package .. " 2>/dev/null")
local output = handle:read("*a")
handle:close()
return output:match(package) ~= nil
end,
check = function(package)
local handle = io.popen("dnf check-update " .. package .. " 2>/dev/null")
local output = handle:read("*a")
handle:close()
return output ~= "" and not output:match("No packages marked for update")
end
}