Guest User

pkg tiny

a guest
Nov 26th, 2016
206
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 1.15 KB | None | 0 0
  1. local a=[[
  2. --pkg, a packaging program.
  3. --(c) Haddock, 2016
  4. --Run me to extract.
  5.  
  6. ]]local b={...}local c={}local function d(e,f)for g,h in ipairs(fs.list(e))do local i=e..'/'..h;if h=='.DS_Store'or h=='.gitignore'or h=='.git'or i=='/rom'or i=='/'..shell.getRunningProgram()or h=='/'..shell.getRunningProgram()or h=="pkg"or h=="pkg.lua"or i=="pkg"or i=="pkg.lua"then print("Not including "..h)elseif fs.isDir(i)then f[h]={}d(i,f[h])else local j=fs.open(i,'r')if j then f[h]=j.readAll()j.close()end end end end;d(shell.dir(),c)print("Packing...")a=a..'local files = '..textutils.serialize(c)..'\n'a=a..[[
  7. local function extract()
  8.     local function node(path, tree)
  9.         if type(tree) == 'table' then
  10.             fs.makeDir(path)
  11.             for k, v in pairs(tree) do
  12.                 node(path .. '/' .. k, v)
  13.             end
  14.         else
  15.             local f = fs.open(path, 'w')
  16.             if f then
  17.                 f.write(tree)
  18.                 f.close()
  19.             end
  20.         end
  21.     end
  22.     node(shell.dir(), files)
  23. end
  24.  
  25. extract()
  26.  
  27. ]]local j=fs.open(shell.dir()..'/out.pkg','w')j.write(a)j.close()print("Package wrote to "..shell.dir().."/out.pkg")
Advertisement
Add Comment
Please, Sign In to add comment