Advertisement
briannovius

Pydo Package Manager

Jul 24th, 2018
188
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 6.08 KB | None | 0 0
  1. local debounce = true
  2. local repoFiles = fs.list("/pydo/repos/")
  3. local repos = {}
  4. local repolist = fs.open("/pydo/repos/repolist", "r")
  5. local tArgs = {...}
  6.  
  7. --check update
  8. pydo = fs.open("pydo.lua", "r")
  9. readall = pydo.readAll()
  10. pydo.close()
  11. lib1 = fs.open("libs/puplib", "r")
  12. readall2 = lib1.readAll()
  13. lib1.close()
  14.  
  15.  
  16. if _G.checkupdated == nil then
  17. print("Checking for updates..")
  18. if readall == http.get("https://pastebin.com/raw/qJtuxiwF").readAll() then
  19. if readall2 == http.get("https://pastebin.com/raw/8CNB4w6u").readAll() then
  20. print("Pydo is up to date!")
  21. _G.checkupdated = 1
  22. else
  23. _G.checkupdated = 1
  24. printError("puplib is not up to date! please run pydo update! You can continue if you want")
  25. end
  26. else
  27. _G.checkupdated = 1
  28. printError("Pydo itself has an update! Please use pydo update! You can continue without updating")
  29. end
  30. else
  31. end
  32.  
  33.  
  34.  
  35. if fs.exists("libs/puplib") then
  36. library1 = fs.open("libs/puplib", "r")
  37. pup = loadstring(library1.readAll())()
  38. library1.close()
  39. else
  40. printError("Puplib could not be found! Please run pydo.lua update!")
  41. end
  42.  
  43. local function printhelp()
  44. print("Following functions")
  45. print(" ")
  46. print("help --prints help")
  47. print("install (reponame) (packagename) --installs a package from the repo given")
  48. print("installfile (file) --installs a package from file")
  49. print("list (reponame) --for a list of packages in that repo")
  50. print("uninstall (packagename) --to uninstall a package")
  51. print("installed --to view installed packages")
  52. print("update --updates pydo")
  53. print("repolist --shows all repo's")
  54. print("download (reponame) (packagename)")
  55. print("info (reponame OR 'file') (packagename OR filename)")
  56. end
  57. loadstring(repolist.readAll())()
  58. if tArgs[1] == "repolist" then
  59. print(textutils.serialize(repotable))
  60. elseif tArgs[1] == "help" then
  61. printhelp()
  62. elseif tArgs[1] == "info" then
  63. if tArgs[2] == "file" then
  64. if fs.exists(tArgs[3]) then
  65. print("Checking file..")
  66. metatable = pup.getMeta(tArgs[3])
  67. sleep(1)
  68. print("info:")
  69. print(metatable["info"])
  70. print(" ")
  71. print("dependencies:")
  72. print(" ")
  73. print(metatable["dependencies"])
  74. else
  75. printError("File doesnt exist!")
  76. end
  77. else
  78. if tArgs[3] then
  79. local site = http.get(repotable[tArgs[2]].."files/"..tArgs[3])
  80. print(site)
  81. if site then
  82. print("Connected to repo")
  83. local file = site.readAll()
  84. if file then
  85. temporary = fs.open(".temporary", "w")
  86. temporary.write(file)
  87. temporary.close()
  88. print("Grabbed file..")
  89. sleep(1)
  90. print("Checking file..")
  91. metatable = pup.getMeta(".temporary")
  92. print("info:")
  93. print(metatable["info"])
  94. print(" ")
  95. print("dependancies:")
  96. print(" ")
  97. print(metatable["dependancies"])
  98. else
  99. error("The file contains nothing! Or was never fetched!")
  100. end
  101. end
  102. else
  103. printError("Invalid Input! Use pydo.lua info (reponame) (packagename)")
  104. end
  105. end
  106.  
  107. elseif tArgs[1] == "update" then
  108. fs.delete("pydo.lua")
  109. fs.delete("libs/puplib")
  110. shell.run("wget https://pastebin.com/raw/qJtuxiwF pydo.lua")
  111. print("Installing libraries..")
  112. shell.run("wget https://pastebin.com/raw/8CNB4w6u /libs/puplib")
  113. elseif tArgs[1] == "installed" then
  114. local packagelist = fs.list("/.installed/")
  115. for _, file in ipairs(packagelist) do
  116. sleep(0.5)
  117. print(file)
  118. end
  119. elseif tArgs[1] == nil then
  120. printhelp()
  121. elseif tArgs[1] == "uninstall" then
  122. if fs.exists("/.installed/"..tArgs[2]) then
  123. print("Uninstalling")
  124. pup.uninstall("/.installed/"..tArgs[2], "/")
  125. shell.run("delete /.installed/"..tArgs[2])
  126. else
  127. error("Package does not exist!")
  128. end
  129. elseif tArgs[1] == "installfile" then
  130. if fs.exists(tArgs[2]) then
  131. shell.run("copy tArgs[2] /.installed/")
  132. print("Installing..")
  133. pup.unpack(tArgs[2], "/")
  134. print("Done..!")
  135. print("Checking for installer file..")
  136. if fs.exists("installer") then
  137. print("Found.. Running...")
  138. sleep(1)
  139. shell.run("installer")
  140. sleep(3)
  141. print("Deleting installer..")
  142. fs.delete("/installer")
  143. sleep(1)
  144. print("Done!")
  145. else
  146. print("Is not there. Most likely not required!")
  147. end
  148. else
  149. print("File does not exist!")
  150. end
  151. elseif tArgs[1] == "download" then
  152. if tArgs[2] then
  153. if tArgs[3] then
  154. local site = http.get(repotable[tArgs[2]].."files/"..tArgs[3])
  155. print(site)
  156. if site then
  157. print("Connected to repo")
  158. local file = site.readAll()
  159. if file then
  160. temporary = fs.open(".temporary", "w")
  161. temporary.write(file)
  162. temporary.close()
  163. print("Grabbed file..")
  164. sleep(1)
  165. shell.run("copy .temporary /pydo/downloads/"..tArgs[3]..".pyd")
  166. sleep(1)
  167. print("...Done! The file is downloaded in /pydo/downloads/ !")
  168. else
  169. error("The file contains nothing! Or was never fetched!")
  170. end
  171. end
  172. else
  173. error("I was not able to fetch the file! Did you spell it correctly?")
  174. end
  175. end
  176. elseif tArgs[1] == "install" then
  177. if tArgs[2] then
  178. if tArgs[3] then
  179. local site = http.get(repotable[tArgs[2]].."files/"..tArgs[3])
  180. print(site)
  181. if site then
  182. print("Connected to repo")
  183. local file = site.readAll()
  184. if file then
  185. temporary = fs.open(".temporary", "w")
  186. temporary.write(file)
  187. temporary.close()
  188. print("Grabbed file..")
  189. sleep(1)
  190. shell.run("copy .temporary /.installed/"..tArgs[3])
  191. pup.unpack(".temporary", "/")
  192. print("Installing..")
  193. sleep(1)
  194. print("...Done!")
  195. print("Checking for installer file..")
  196. if fs.exists("installer") then
  197. print("Found.. Running...")
  198. sleep(1)
  199. shell.run("installer")
  200. sleep(3)
  201. print("Deleting installer..")
  202. fs.delete("/installer")
  203. sleep(1)
  204. print("Done!")
  205. else
  206. print("Is not there. Most likely not required!")
  207. end
  208. else
  209. error("The file contains nothing! Or was never fetched!")
  210. end
  211. end
  212. else
  213. error("I was not able to fetch the file! Did you spell it correctly?")
  214. end
  215. end
  216. else
  217. if tArgs[1] == "list" then
  218. if tArgs[2] then
  219. sitelist = print(http.get(repotable[tArgs[2]].."list").readAll())
  220. print(repotable[tArgs[2]])
  221. print(sitelist)
  222. else
  223. print("Invalid input!")
  224. end
  225. end
  226. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement