Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- local resp = true
- args = {...}
- local function add_ons_toInt(number_of_addOns)
- if number_of_addOns == "0" then
- add_ons = 0
- elseif number_of_addOns == "1" then
- add_ons = 1
- elseif number_of_addOns == "2" then
- add_ons = 2
- elseif number_of_addOns == "3" then
- add_ons = 3
- elseif number_of_addOns == "4" then
- add_ons = 4
- elseif number_of_addOns == "5" then
- add_ons = 5
- elseif number_of_addOns == "6" then
- add_ons = 6
- elseif number_of_addOns == "7" then
- add_ons = 7
- elseif number_of_addOns == "8" then
- add_ons = 8
- elseif number_of_addOns == "9" then
- add_ons = 9
- elseif number_of_addOns == "10" then
- add_ons = 10
- elseif number_of_addOns == "11" then
- add_ons = 11
- else
- add_ons = 0
- end
- end
- if (args[1] == nil) or (args[1] == "") then
- print("tget initialized!")
- print("scanning for repository...")
- print("What you want to install?")
- write(">")
- program = read()
- print("searching for package...")
- else
- program = args[1]
- if args[2] == "--force" then
- force = true
- end
- progargs = true
- end
- informationFile = http.get("http://192.168.1.130/trepo/"..program.."/pkg_info")
- if informationFile then
- cache = informationFile.readLine()
- name2 = informationFile.readLine()
- if progargs ~= true then
- print("Full package name:")
- end
- if term.isColor() then
- term.setTextColor(colors.yellow) end
- print(name2)
- if term.isColor() then
- term.setTextColor(colors.white) end
- cache = informationFile.readLine()
- version = informationFile.readLine()
- if progargs ~= true then
- if fs.exists("."..program.."."..version) then
- error("You have nevest version", 0)
- end
- end
- cache = informationFile.readLine()
- add_ons_toInt(informationFile.readLine())
- if add_ons == 0 then
- os.sleep(0)
- else
- print("resolving dependens...")
- i = 1
- d = {}
- while i <= add_ons do
- d[i] = informationFile.readLine()
- dlist = i
- i = i + 1
- end
- i = 1
- print("dependences is:")
- while i <= add_ons do
- os.sleep(0.8)
- if term.isColor() then
- term.setTextColor(colors.red) end
- print(d[i])
- term.setTextColor(colors.white)
- i = i + 1
- end
- end
- informationFile.close()
- if force ~= true then
- print("would you like to install this package?")
- write("[Y/n]?")
- a = read()
- else
- a = "Y"
- end
- if (a == "") or (a == "Y") or (a == "y") then
- a = true
- if add_ons == 0 then
- print("installing...")
- programd = "http://192.168.1.130/trepo/"..program.."/program/"..version.."/"..program
- file = http.get(programd)
- program_code = file.readAll()
- file.close()
- file = fs.open(program, "w")
- file.write(program_code)
- file.close()
- else
- i = 1
- while i <= dlist do
- print("Installing "..d[i].."...")
- file = http.get("http://192.168.1.130/trepo/"..program.."/add-ons/"..d[i])
- add_on_code = file.readAll()
- file.close()
- file = fs.open(d[i], "w")
- file.write(add_on_code)
- file.close()
- print("OK.")
- i = i + 1
- end
- file = http.get("http://192.168.1.130/trepo/"..program.."/program/"..version.."/"..program)
- print("installing "..program.."...")
- program_code = file.readAll()
- file.close()
- file = fs.open(program, "w")
- file.write(program_code)
- file.close()
- print("Ok.")
- print("Setting up the package...")
- file = fs.open("."..program.."."..version, "w")
- file.writeLine("installed")
- file.close()
- print("Done!")
- end
- end
- else
- print("tget have some errors:")
- print("error IO Read: 404 page not found!")
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement