diff --git a/.github/workflows/create-archives.yml b/.github/workflows/create-archives.yml new file mode 100644 index 0000000..23af593 --- /dev/null +++ b/.github/workflows/create-archives.yml @@ -0,0 +1,37 @@ +name: "build archives" + +on: + workflow_dispatch: + push: + branches: [main] + paths: + - "src/**.lua" + - "cc/**" + - ".github/workflows/create-archives.yml" + +jobs: + build-archives: + runs-on: "ubuntu-latest" + steps: + - name: "checkout" + uses: "actions/checkout@v3" + - name: "minify" + uses: "walksanatora/lua-minify@main" + with: + find: "./src/ -name \"*.lua\"" + - name: "run cc" + uses: "walksanatora/craftos-action@v1.0.4" + with: + root: "cc" + timeout: "60" + - name: "upload-images" + uses: "actions/upload-artifact@v3" + with: + name: "archives" + path: "cc/computer/0/output/*" + - name: "upload-minified" + uses: "actions/upload-artifact@v3" + with: + name: "minified-src" + path: "src/" + \ No newline at end of file diff --git a/cc/computer/0/LD.lua b/cc/computer/0/LD.lua new file mode 100644 index 0000000..fd9389e --- /dev/null +++ b/cc/computer/0/LD.lua @@ -0,0 +1 @@ +local a,assert,error,pairs,b,c,d,e,f,g,h,tostring,type,i,j,k,l,m,n,o,p,q,r,s,t,u,v,w,x,y,z,A,C,D={},assert,error,pairs,string.byte,string.char,string.find,string.gsub,string.sub,table.concat,table.sort,tostring,type,{},{},{},{},{},{},{},{},{},{3,4,5,6,7,8,9,10,11,13,15,17,19,23,27,31,35,43,51,59,67,83,99,115,131,163,195,227,258},{0,0,0,0,0,0,0,0,1,1,1,1,2,2,2,2,3,3,3,3,4,4,4,4,5,5,5,5,0},{[0]=1,2,3,4,5,7,9,13,17,25,33,49,65,97,129,193,257,385,513,769,1025,1537,2049,3073,4097,6145,8193,12289,16385,24577},{[0]=0,0,0,0,1,1,2,2,3,3,4,4,5,5,6,6,7,7,8,8,9,9,10,10,11,11,12,12,13,13},{16,17,18,0,8,7,9,6,10,5,11,4,12,3,13,2,14,1,15},nil,nil,nil,nil,nil,nil,nil;for E=0,255 do j[E]=c(E)end;do local F=1;for E=0,32 do i[E]=F;F=F*2 end end;for E=1,9 do k[E]={}for G=0,i[E+1]-1 do local H=0;local I=G;for J=1,E do H=H-H%2+((H%2==1 or I%2==1)and 1 or 0)I=(I-I%2)/2;H=H*2 end;k[E][G]=(H-H%2)/2 end end;local K,L,M,J,N=bit.band,bit.bnot,bit.bxor,bit.blshift,bit.blogic_rshift;local O=0xEDB88320;local function P(Q)local R={}local S=setmetatable({},R)function R:__index(T)local U=Q(T)S[T]=U;return U end;return S end;local V=P(function(E)local W=E;for J=1,8 do local X=K(W,1)W=N(W,1)if X==1 then W=M(W,O)end end;return W end)local function Y(Z,W)W=L(W or 0)local _=N(W,8)local a0=V[M(W%256,Z)]return L(M(_,a0))end;local function a1(a2,W)W=W or 0;for E=1,#a2 do W=Y(a2:byte(E),W)end;return W end;function a:C(a2,W)if type(a2)=='string'then return a1(a2,W)else return Y(a2,W)end end;local a3={[0]={false,nil,0,0,0},[1]={false,nil,4,8,4},[2]={false,nil,5,18,8},[3]={false,nil,6,32,32},[4]={true,4,4,16,16},[5]={true,8,16,32,32},[6]={true,8,16,128,128},[7]={true,8,32,128,256},[8]={true,32,128,258,1024},[9]={true,32,258,258,4096}}local function a4(a5)local a6=a5;local a7=#a5;local a8=1;local a9=0;local aa=0;local function ab(ac)local ad=i[ac]local ae;if ac<=a9 then ae=aa%ad;aa=(aa-ae)/ad;a9=a9-ac else local af=i[a9]local ag,ah,ai,aj=b(a6,a8,a8+3)aa=aa+((ag or 0)+(ah or 0)*256+(ai or 0)*65536+(aj or 0)*16777216)*af;a8=a8+4;a9=a9+32-ac;ae=aa%ad;aa=(aa-ae)/ad end;return ae end;local function ak(al,am,an)assert(a9%8==0)local ao=a9/80 then if a9<15 and a6 then local af=i[a9]local ag,ah,ai,aj=b(a6,a8,a8+3)aa=aa+((ag or 0)+(ah or 0)*256+(ai or 0)*65536+(aj or 0)*16777216)*af;a8=a8+4;a9=a9+32 end;local ad=i[as]a9=a9-as;ae=aa%ad;aa=(aa-ae)/ad;ae=k[as][ae]av=aq[as]if ae0 and ac285 then return-10 elseif aI<256 then an=an+1;am[an]=j[aI]elseif aI>256 then aI=aI-256;local ac=r[aI]ac=aI>=8 and ac+ab(s[aI])or ac;aI=ap(aR,aS,aT)if aI<0 or aI>29 then return-10 end;local aY=t[aI]aY=aY>4 and aY+ab(u[aI])or aY;local aZ=an-aY+1;if aZ=-257 then for J=1,ac do an=an+1;am[an]=am[aZ]aZ=aZ+1 end else aZ=aW+aZ;for J=1,ac do an=an+1;local X=aV[aZ]am[an]=j[X]aZ=aZ+1 end end end;if ax()<0 then return 2 end;if an>=65536 then aU[#aU+1]=g(am,"",1,32768)for E=32769,an do am[E-32768]=am[E]end;an=an-32768;am[an+1]=nil end until aI==256;aD.buffer_size=an;return 0 end;local function a_(aD)local am,an,ab,ak,ax,ay,aU=aD.buffer,aD.buffer_size,aD.ReadBits,aD.ReadBytes,aD.ReaderBitlenLeft,aD.SkipToByteBoundary,aD.result_buffer;ay()local al=ab(16)if ax()<0 then return 2 end;local b0=ab(16)if ax()<0 then return 2 end;if al%256+b0%256~=255 then return-2 end;if(al-al%256)/256+(b0-b0%256)/256~=255 then return-2 end;an=ak(al,am,an)if an<0 then return 2 end;if an>=65536 then aU[#aU+1]=g(am,"",1,32768)for E=32769,an do am[E-32768]=am[E]end;an=an-32768;am[an+1]=nil end;aD.buffer_size=an;return 0 end;local function b1(aD)return aN(aD,z,x,7,D,B,5)end;local function b2(aD)local ab,ap=aD.ReadBits,aD.Decode;local b3=ab(5)+257;local b4=ab(5)+1;local b5=ab(4)+4;if b3>286 or b4>30 then return-3 end;local b6={}for E=1,b5 do local X=v[E]b6[X]=ab(3)end;local b7,b8,b9,ba=aE(b6,18,7)if b7~=0 then return-4 end;local aO={}local aR={}local au=0;while aub3+b4 then return-6 end;while aI>0 do aI=aI-1;if au 1 then print("[build] heading down to "..path.."/"..v) end + tree[v] = gen_disk(path.."/"..v) + else + if verbosity > 1 then print("[build] adding "..path.."/"..v) end + local chandle = fs.open(path.."/"..v,'rb') + tree[v] = chandle.readAll() + chandle.close() + end + end + return tree +end +--we require LibDeflate for this (since we make compressed images) +if not loaded_ld then error("Unnable to load LibDeflate"..ld) end +--make sure the minimised and stripped LibDeflate is also here +if not fs.exists(fs.combine(fs.getDir(shell.getRunningProgram()),"LD.lua")) then error("Unnable to locate minified LibDeflate") end +--make sure all paths are valid +print("[build] validating files") +for _,v in ipairs(files) do + local v = shell.resolve(v) + if not fs.exists(v) then error("File/Folder does not exist: "..v) end +end +--get the base name for the outputs +local output_base_name = shell.resolve(output) +local final = {} +--add files to the table +print("[build] starting tree gen") +for _,v in ipairs(files) do + local sr = shell.resolve(v) + print("[build] adding: "..v) + if fs.isDir(sr) then + final[fs.getName(v)] = gen_disk(sr) + else + local hand = fs.open(sr,'rb') + local con = hand.readAll() + final[fs.getName(v)] = con + hand.close() + end +end +--uncompressed serialize (and write) +print("[build] serialising") +local ser = textutils.serialise(final) +print("[build] writing VFS") +local handle = fs.open(output_base_name..".vfs",'wb') + handle.write(ser) + handle.close() +print("[build] compressing") +--compress it with Gzip +local compressed = ld:CompressGzip(ser) +print("[build] writing compressed") +local handle = fs.open(output_base_name..".vgz",'wb') + handle.write(compressed) + handle.close() +--now make a Self-Extracting-Archive +print("[build] creating Self Extracting Archive") +local output_file = fs.open(output_base_name..".lua",'wb') +output_file.write('local I,c,o,f,C,t,s,D = table.unpack({\nloadstring([=[') +local ldh = fs.open(fs.combine(fs.getDir(shell.getRunningProgram()),"LD.lua"),'rb') +local ldc = ldh.readAll() +output_file.write(ldc) +ldh.close() +output_file.write(']=])()\n,(function()local u,g = fs.open(shell.getRunningProgram(),"rb")g=u.readAll()u.close()return g:match("%[===%[(.+)%]===%]") end)(),shell.resolve(""),fs.open,fs.combine,type,shell.setDir,shell.dir()})\nfunction u(p,z)fs.makeDir(C(o,p))s(C(o,p))for k, v in pairs(z) do if t(v) == "table" then u(p.."/"..k,v)elseif t(v) == "string" then local h = f(fs.combine(o,C(p,k)),"wb")h.write(v)h.close()end end end u("') +output_file.write(extract_path..'",textutils.unserialise(I:d(c)))s(o)') +output_file.write('\n--[===[') +output_file.write(compressed) +output_file.write(']===]') +print("[build] done") \ No newline at end of file diff --git a/cc/computer/0/rerun.txt b/cc/computer/0/rerun.txt new file mode 100644 index 0000000..26fe3e5 --- /dev/null +++ b/cc/computer/0/rerun.txt @@ -0,0 +1,2 @@ +changeme to run-run img deploy +rerun counter 4 \ No newline at end of file diff --git a/cc/computer/0/startup.lua b/cc/computer/0/startup.lua new file mode 100644 index 0000000..4f341a2 --- /dev/null +++ b/cc/computer/0/startup.lua @@ -0,0 +1,2 @@ +shell.run("buildimgs output/yc '' yc/lib yc/youcube.lua") +os.shutdown() \ No newline at end of file diff --git a/cc/computer/0/yc b/cc/computer/0/yc new file mode 120000 index 0000000..a1d005e --- /dev/null +++ b/cc/computer/0/yc @@ -0,0 +1 @@ +../../../src/ \ No newline at end of file