This repository was archived by the owner on Jan 17, 2026. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathrepos.lua
More file actions
112 lines (96 loc) · 3.15 KB
/
repos.lua
File metadata and controls
112 lines (96 loc) · 3.15 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
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
pcall(require, "luarocks.loader")
local system = require("system")
local lfs = require "lfs"
local tools = require "tools"
local config = require "neld.config"
local CWD = lfs.currentdir()
local BASE = CWD .. "/neld/"
local STAGE_DIRECTORY = ".stage" .. stage
local self = { available_packages = {}, ROOTFS_CACHE = BASE .. ".rootfs/", BUILD_CACHE = BASE .. ".build/" }
function self.fetch()
self.available_packages = {}
for line in system.capture("curl -sL " .. config.binhost .. "/packages/available.txt"):gmatch("[^\r\n]+") do
local i, name, version = 1
for part in line:gmatch("([^,]+)") do
if i == 3 then
break
end
if i == 1 then
name = part
else
version = part
end
i = i + 1
end
local available_versions = self.available_packages[name]
if not available_versions then
available_versions = {}
self.available_packages[name] = available_versions
end
table.insert(available_versions, version)
end
end
local installed_packages = {}
function self.download(name, directory)
if installed_packages[name] then
return
end
print("INSTALLING: " .. name)
local versions = self.available_packages[name]
if versions then
local file_name = tools.get_file(name, versions[1])
if not lfs.attributes(file_name) then
local success = os.execute("curl -sSLo " .. file_name .. " " .. config.binhost .. "/packages/" .. file_name)
if not success then
print("ERROR: Package `" .. name .. "` isn't available!")
return
end
end
if directory then
os.execute("unsquashfs -d " .. directory .. " -f " .. file_name)
end
installed_packages[name] = true
local package, i = name:find("%.")
if i then
package = pkg(name:sub(1, i - 1))
else
package = pkg(name)
end
if package.dependencies then
for _, dep in ipairs(package.dependencies) do
self.download(dep.name, directory)
end
end
else
print("ERROR: Package `" .. name .. "` isn't available!")
end
end
function self.extract(path, name, variant)
return os.execute("unsquashfs -d " ..
path ..
" -f " .. CWD .. "/" .. config.repository .. "/" ..
name .. "/" .. STAGE_DIRECTORY .. "/" .. tools.get_file(name, pkg(name).version, variant))
end
local copied_packages = {}
function self.copy(name, path)
local package
local i = name:find("%.")
if i then
package = pkg(name:sub(1, i - 1))
else
package = pkg(name)
end
if copied_packages[name] then
return
else
copied_packages[name] = true
end
os.execute("cp " .. config.repository .. "/" ..
package.name .. "/.stage" .. stage .. "/" .. tools.get_file(name, package.version) .. " " .. path)
if package.dependencies then
for _, dep in ipairs(package.dependencies) do
self.copy(dep.name, path)
end
end
end
return self