-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathpastebin.lua
57 lines (48 loc) · 1.37 KB
/
pastebin.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
local internet = require('internet')
local shell = require('shell')
local filesystem = require('filesystem')
local args = { ... }
local package = args[1]
print("Welcome, to the package installer")
if not args[1] then
print(
[[
Usage:
pastebin run kydcWA2y <package>
]]
)
return
end
local repo = "NeOzay/open-computer-project"
local branch = "master"
local url = string.format('https://raw.githubusercontent.com/%s/%s', repo, branch)
local function install(name)
shell.execute(string.format('wget -fq %s/%s/%s %s', url, name, ".package.lua", "_package.lua"))
if not filesystem.exists(shell.resolve("_package.lua")) then
error()
end
local filesList = loadfile("_package.lua")()
-- INSTALL
for index, file in ipairs(filesList) do
local dir = file
if not string.find(dir, "usr") then
dir = filesystem.concat("usr", dir)
end
local overwrite = true
if not filesystem.exists(filesystem.path(dir)) then
filesystem.makeDirectory(filesystem.path(dir))
elseif filesystem.exists(dir) then
io.write(dir)
io.write("do you want to overwrite the following element?[y/N]:")
overwrite = string.lower(io.read()) == "y"
end
if overwrite then
shell.execute(string.format('wget -f %s/%s/%s /%s', url, name, file, dir))
end
end
filesystem.remove("_package")
for index, dep in ipairs(filesList.dependencies or {}) do
install(dep)
end
end
install(package)