Download and install from live repo
authorOlav Bakke Svendsen <mail@olavbs.no>
Fri, 24 May 2024 18:45:51 +0000 (20:45 +0200)
committerOlav Bakke Svendsen <mail@olavbs.no>
Fri, 24 May 2024 18:45:51 +0000 (20:45 +0200)
common/dl.lua
common/install.lua

index e6b7f9f413f2880c69b6282cce8dabaa75f560c2..93040ba946bd7db74c0871bca638c8c1b8146d1f 100644 (file)
@@ -1,7 +1,8 @@
 -- dl.lua
 -- download from git repo
 -- usage:
--- dl repo[:tag] remote/path:local/path[:o] [remote/path:local/path[:o] ...]
+-- dl repo[:tag] remote/path:local/path[:o] [remote/path:local/path[:o] ...]      -- downloads from git repo
+-- dl live remote/path:local/path[:o] [remote/path:local/path[:o] ...]            -- downloads from live repo
 
 local args = {...}
 local repo = ""
@@ -20,7 +21,11 @@ do
 end
 
 for _, file in pairs(files) do
-  local url = "https://git.olavbs.no/?p="..repo..".git;a=blob_plain;f="..file.from..";hb="..tag
+  if repo = "live" then
+    local url = "https://cc.olavbs.no/live/"..file.from
+  else
+    local url = "https://git.olavbs.no/?p="..repo..".git;a=blob_plain;f="..file.from..";hb="..tag
+  end
   if fs.exists(file.to) and file.overwrite then
     local tmp = textutils.serialize(math.random(100000,999999))
     local ok = shell.run("wget "..url.." "..tmp)
index 08934f1047b551b0ba16c89191607c5a5f52a46f..0e0af5904d9a58500bb6138738775afecbcc5c10 100644 (file)
@@ -1,12 +1,24 @@
 -- install.lua
--- looks for package-file in git repo and runs dl.lua on every line
+-- looks for package-file in repo and runs dl.lua on every line
 -- usage:
--- install repo:[tag] remote/path
+-- install repo:[tag] remote/path     install package from git repo
+-- install live remote/path           install package from live repo
+
 local args = {...}
+
+local repo = args[1]
+local path = args[2]
+
+local live = repo == "live"
+
 local tmp = textutils.serialize(math.random(100000,999999))
-shell.run("dl "..args[1].." "..args[2].."/package:"..tmp)
+shell.run("dl "..repo.." "..path.."/package:"..tmp)
 local file = fs.open(tmp, "r")
 for line in file.readLine do
-  shell.run("dl "..line)
+  if live then 
+    shell.run("dl "..string.gsub(line, "^.-%s+", "live "))
+  else
+    shell.run("dl "..line)
+  end
 end
 fs.delete(tmp)