Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Hpm builds
local UlikV=load([===[
local rA5U=20160728.17
local Uc06="-[ JSON.lua package by Jeffrey Friedl (http://regex.info/blog/lua/json) version 20160728.17 ]-"local lcBL={VERSION=rA5U,AUTHOR_NOTE=Uc06}local DHPxI=" "
local dx={pretty=true,align_keys=false,indent=DHPxI}
local RRuSHnxf={__tostring=function()return"JSON array"end}RRuSHnxf.__index=RRuSHnxf
local mcYOuT={__tostring=function()return"JSON object"end}mcYOuT.__index=mcYOuT;function lcBL:newArray(iXxD6s)
return setmetatable(iXxD6s or{},RRuSHnxf)end;function lcBL:newObject(oiY)return
setmetatable(oiY or{},mcYOuT)end;local function Rr(FsYIVlkf)
return
type(FsYIVlkf)=='number'and FsYIVlkf or FsYIVlkf.N end
local scRP0={__index=isNumber,__tostring=function(HLXS0Q_)return HLXS0Q_.S end,__unm=function(Kw)return
Rr(Kw)end,__concat=function(nvaIsNv7,vDnoL55)
return tostring(nvaIsNv7)..tostring(vDnoL55)end,__add=function(xlAK,zr1y)return Rr(xlAK)+Rr(zr1y)end,__sub=function(Hs,jk)return
Rr(Hs)-Rr(jk)end,__mul=function(qzSFyIO,Z65)
return Rr(qzSFyIO)*Rr(Z65)end,__div=function(umyCNfj,FT)return Rr(umyCNfj)/Rr(FT)end,__mod=function(YVLXYq,bJfct)return
Rr(YVLXYq)%Rr(bJfct)end,__pow=function(OhuFpq_N,Dzg)return
Rr(OhuFpq_N)^Rr(Dzg)end,__lt=function(_4O,C)return Rr(_4O)<Rr(C)end,__eq=function(fLI2zRe,_Fr2YU)return
Rr(fLI2zRe)==Rr(_Fr2YU)end,__le=function(Xfn,U)return
Rr(Xfn)<=Rr(U)end}
function lcBL:asNumber(Ebsw)
if getmetatable(Ebsw)==scRP0 then return Ebsw elseif
type(Ebsw)=='table'and
type(Ebsw.S)=='string'and type(Ebsw.N)=='number'then return setmetatable(Ebsw,scRP0)else
local UlikV={S=tostring(Ebsw),N=tonumber(Ebsw)}return setmetatable(UlikV,scRP0)end end
local function AI0R2TQ6(JtAjijkG)
if JtAjijkG<=127 then return string.char(JtAjijkG)elseif JtAjijkG<=2047 then
local s=math.floor(JtAjijkG/0x40)local YAtG_LV3=JtAjijkG- (0x40*s)return
string.char(0xC0+s,0x80+YAtG_LV3)elseif JtAjijkG<=65535 then
local LfEJbh_=math.floor(JtAjijkG/0x1000)local JD=JtAjijkG-0x1000*LfEJbh_
local u=math.floor(JD/0x40)local pzDMZwG=JD-0x40*u;LfEJbh_=0xE0+LfEJbh_;u=0x80+u
pzDMZwG=0x80+pzDMZwG
if
(LfEJbh_==0xE0 and u<0xA0)or
(LfEJbh_==0xED and u>0x9F)or(LfEJbh_==0xF0 and u<0x90)or(LfEJbh_==0xF4 and u>0x8F)then return"?"else return string.char(LfEJbh_,u,pzDMZwG)end else local XPoQB=math.floor(JtAjijkG/0x40000)
local XxJ=JtAjijkG-0x40000*XPoQB;local o5sms=math.floor(XxJ/0x1000)
XxJ=XxJ-0x1000*o5sms;local JQi1jg=math.floor(XxJ/0x40)local wVzn=XxJ-0x40*JQi1jg
return string.char(
0xF0+XPoQB,0x80+o5sms,0x80+JQi1jg,0x80+wVzn)end end
function lcBL:onDecodeError(pE,RSjapQ,QJf,zC)if RSjapQ then
if QJf then
pE=string.format("%s at char %d of: %s",pE,QJf,RSjapQ)else pE=string.format("%s: %s",pE,RSjapQ)end end
if zC~=nil then pE=pE.." ("..
lcBL:encode(zC)..")"end
if self.assert then self.assert(false,pE)else assert(false,pE)end end;lcBL.onDecodeOfNilError=lcBL.onDecodeError
lcBL.onDecodeOfHTMLError=lcBL.onDecodeError
function lcBL:onEncodeError(pfZ3SPy_,pDNa2ox6)
if pDNa2ox6 ~=nil then pfZ3SPy_=pfZ3SPy_..
" ("..lcBL:encode(pDNa2ox6)..")"end;if self.assert then self.assert(false,pfZ3SPy_)else
assert(false,pfZ3SPy_)end end
local function yA(Do6yo7nm,y06X3k,ivnJjrA,d3fMjkg)
local el=y06X3k:match('^-?[1-9]%d*',ivnJjrA)or y06X3k:match("^-?0",ivnJjrA)if not el then
Do6yo7nm:onDecodeError("expected number",y06X3k,ivnJjrA,d3fMjkg.etc)end
local Wu_uIt=ivnJjrA+el:len()local w=y06X3k:match('^%.%d+',Wu_uIt)or""Wu_uIt=Wu_uIt+
w:len()
local sgeP=y06X3k:match('^[eE][-+]?%d+',Wu_uIt)or""Wu_uIt=Wu_uIt+sgeP:len()local CM=el..w..sgeP;if
d3fMjkg.decodeNumbersAsObjects then return lcBL:asNumber(CM),Wu_uIt end
if
(
d3fMjkg.decodeIntegerStringificationLength and(el:len()>=d3fMjkg.decodeIntegerStringificationLength or
sgeP:len()>0))or
(d3fMjkg.decodeDecimalStringificationLength and
(
w:len()>=d3fMjkg.decodeDecimalStringificationLength or sgeP:len()>0))then return CM,Wu_uIt end;local Qlmlet=tonumber(CM)if not Qlmlet then
Do6yo7nm:onDecodeError("bad number",y06X3k,ivnJjrA,d3fMjkg.etc)end;return Qlmlet,Wu_uIt end
local function XmVolesU(_,RkGFh6,hw18,nvCiFt7r)if RkGFh6:sub(hw18,hw18)~='"'then
_:onDecodeError("expected string's opening quote",RkGFh6,hw18,nvCiFt7r.etc)end;local xSebv5Jc=hw18+1
local mMp=RkGFh6:len()local rDtVf=""
while xSebv5Jc<=mMp do local vj=RkGFh6:sub(xSebv5Jc,xSebv5Jc)if
vj=='"'then return rDtVf,xSebv5Jc+1 end
if vj~='\\'then rDtVf=rDtVf..vj;xSebv5Jc=
xSebv5Jc+1 elseif RkGFh6:match('^\\b',xSebv5Jc)then rDtVf=rDtVf.."\b"xSebv5Jc=
xSebv5Jc+2 elseif RkGFh6:match('^\\f',xSebv5Jc)then rDtVf=rDtVf.."\f"xSebv5Jc=
xSebv5Jc+2 elseif RkGFh6:match('^\\n',xSebv5Jc)then rDtVf=rDtVf.."\n"xSebv5Jc=
xSebv5Jc+2 elseif RkGFh6:match('^\\r',xSebv5Jc)then rDtVf=rDtVf.."\r"xSebv5Jc=
xSebv5Jc+2 elseif RkGFh6:match('^\\t',xSebv5Jc)then rDtVf=rDtVf.."\t"xSebv5Jc=
xSebv5Jc+2 else
local z=RkGFh6:match('^\\u([0123456789aAbBcCdDeEfF][0123456789aAbBcCdDeEfF][0123456789aAbBcCdDeEfF][0123456789aAbBcCdDeEfF])',xSebv5Jc)
if z then xSebv5Jc=xSebv5Jc+6;local Zg=tonumber(z,16)
if
Zg>=0xD800 and Zg<=0xDBFF then
local ykRppH=RkGFh6:match('^\\u([dD][cdefCDEF][0123456789aAbBcCdDeEfF][0123456789aAbBcCdDeEfF])',xSebv5Jc)
if ykRppH then xSebv5Jc=xSebv5Jc+6;Zg=0x2400+ (Zg-0xD800)*0x400+
tonumber(ykRppH,16)else end end;rDtVf=rDtVf..AI0R2TQ6(Zg)else rDtVf=rDtVf..
RkGFh6:match('^\\(.)',xSebv5Jc)xSebv5Jc=xSebv5Jc+2 end end end
_:onDecodeError("unclosed string",RkGFh6,hw18,nvCiFt7r.etc)end
local function eZ0l3ch(WQ6,y36Aetn)local iPL3B4cr,GI2hz6SK=WQ6:find("^[ \n\r\t]+",y36Aetn)if GI2hz6SK then
return GI2hz6SK+1 else return y36Aetn end end;local W_63_9
local function h9dyA_4T(Oh,PG,n,O)if PG:sub(n,n)~='{'then
Oh:onDecodeError("expected '{'",PG,n,O.etc)end;local N5UjTN=eZ0l3ch(PG,n+1)local qLH5=Oh.strictTypes and
Oh:newObject{}or{}if
PG:sub(N5UjTN,N5UjTN)=='}'then return qLH5,N5UjTN+1 end
local tE=PG:len()
while N5UjTN<=tE do local VcV0EuD,pX4gCR=XmVolesU(Oh,PG,N5UjTN,O)
N5UjTN=eZ0l3ch(PG,pX4gCR)if PG:sub(N5UjTN,N5UjTN)~=':'then
Oh:onDecodeError("expected colon",PG,N5UjTN,O.etc)end
N5UjTN=eZ0l3ch(PG,N5UjTN+1)local gad4ZcL,pX4gCR=W_63_9(Oh,PG,N5UjTN,O)qLH5[VcV0EuD]=gad4ZcL
N5UjTN=eZ0l3ch(PG,pX4gCR)local dk=PG:sub(N5UjTN,N5UjTN)
if dk=='}'then return qLH5,N5UjTN+1 end;if PG:sub(N5UjTN,N5UjTN)~=','then
Oh:onDecodeError("expected comma or '}'",PG,N5UjTN,O.etc)end
N5UjTN=eZ0l3ch(PG,N5UjTN+1)end;Oh:onDecodeError("unclosed '{'",PG,n,O.etc)end
local function oh(E,OO,y,cR6rJlAl)if OO:sub(y,y)~='['then
E:onDecodeError("expected '['",OO,y,cR6rJlAl.etc)end;local M6ilzGJ=eZ0l3ch(OO,y+1)local iW6CD=E.strictTypes and
E:newArray{}or{}if
OO:sub(M6ilzGJ,M6ilzGJ)==']'then return iW6CD,M6ilzGJ+1 end
local wZdg=1;local BaX=OO:len()
while M6ilzGJ<=BaX do
local SJsW11k,Ki1HJT=W_63_9(E,OO,M6ilzGJ,cR6rJlAl)iW6CD[wZdg]=SJsW11k;wZdg=wZdg+1;M6ilzGJ=eZ0l3ch(OO,Ki1HJT)
local wjim8xCV=OO:sub(M6ilzGJ,M6ilzGJ)if wjim8xCV==']'then return iW6CD,M6ilzGJ+1 end;if
OO:sub(M6ilzGJ,M6ilzGJ)~=','then
E:onDecodeError("expected comma or '['",OO,M6ilzGJ,cR6rJlAl.etc)end
M6ilzGJ=eZ0l3ch(OO,M6ilzGJ+1)end
E:onDecodeError("unclosed '['",OO,y,cR6rJlAl.etc)end
W_63_9=function(E,QLam,qTDt,v)qTDt=eZ0l3ch(QLam,qTDt)
if qTDt>QLam:len()then E:onDecodeError("unexpected end of string",QLam,
nil,v.etc)end
if QLam:find('^"',qTDt)then return XmVolesU(E,QLam,qTDt,v.etc)elseif
QLam:find('^[-0123456789 ]',qTDt)then return yA(E,QLam,qTDt,v)elseif QLam:find('^%{',qTDt)then
return h9dyA_4T(E,QLam,qTDt,v)elseif QLam:find('^%[',qTDt)then return oh(E,QLam,qTDt,v)elseif QLam:find('^true',qTDt)then return true,
qTDt+4 elseif QLam:find('^false',qTDt)then return false,qTDt+5 elseif
QLam:find('^null',qTDt)then return nil,qTDt+4 else
E:onDecodeError("can't parse JSON",QLam,qTDt,v.etc)end end
function lcBL:decode(Ta,u,nArcvQl)if type(nArcvQl)~='table'then nArcvQl={}end;if u~=nil then
nArcvQl.etc=u end;if
type(self)~='table'or self.__index~=lcBL then
lcBL:onDecodeError("JSON:decode must be called in method format",nil,nil,nArcvQl.etc)end
if Ta==nil then
self:onDecodeOfNilError(string.format("nil passed to JSON:decode()"),
nil,nil,nArcvQl.etc)elseif type(Ta)~='string'then
self:onDecodeError(string.format("expected string argument to JSON:decode(), got %s",type(Ta)),
nil,nil,nArcvQl.etc)end;if Ta:match('^%s*$')then return nil end;if Ta:match('^%s*<')then
self:onDecodeOfHTMLError(string.format("html passed to JSON:decode()"),Ta,
nil,nArcvQl.etc)end
if
Ta:sub(1,1):byte()==0 or
(Ta:len()>=2 and Ta:sub(2,2):byte()==0)then
self:onDecodeError("JSON package groks only UTF-8, sorry",Ta,nil,nArcvQl.etc)end;if nArcvQl.decodeNumbersAsObjects==nil then
nArcvQl.decodeNumbersAsObjects=self.decodeNumbersAsObjects end;if
nArcvQl.decodeIntegerStringificationLength==nil then
nArcvQl.decodeIntegerStringificationLength=self.decodeIntegerStringificationLength end;if
nArcvQl.decodeDecimalStringificationLength==nil then
nArcvQl.decodeDecimalStringificationLength=self.decodeDecimalStringificationLength end
local h6Ub7U,Gm=pcall(W_63_9,self,Ta,1,nArcvQl)if h6Ub7U then return Gm else
if self.assert then self.assert(false,Gm)else assert(false,Gm)end;return nil,Gm end end
local function DZXGTh(YKA7cU)
if YKA7cU=="\n"then return"\\n"elseif YKA7cU=="\r"then return"\\r"elseif YKA7cU=="\t"then return"\\t"elseif YKA7cU=="\b"then
return"\\b"elseif YKA7cU=="\f"then return"\\f"elseif YKA7cU=='"'then return'\\"'elseif YKA7cU=='\\'then return'\\\\'else return
string.format("\\u%04x",YKA7cU:byte())end end
local Su9Koz='['..'"'..
'%\\'..'%z'..'\001'..'-'..'\031'..']'local Uk7e=AI0R2TQ6(0x2028)local KwQCk_G=AI0R2TQ6(0x2029)
local function ptZa(mCsewfX,yY)
local Xf=mCsewfX:gsub(Su9Koz,DZXGTh)if yY.stringsAreUtf8 then
Xf=Xf:gsub(Uk7e,'\\u2028'):gsub(KwQCk_G,'\\u2029')end;return'"'..Xf..'"'end
local function PEqsd(UlFdiZ7v,U,wFeA)local JQgI={}local N={}local fs52REi=false;local PUNkgaiM
for X in pairs(U)do
if type(X)=='string'then
table.insert(JQgI,X)elseif type(X)=='number'then table.insert(N,X)
if X<=0 or X>=math.huge then
fs52REi=true elseif not PUNkgaiM or X>PUNkgaiM then PUNkgaiM=X end else
UlFdiZ7v:onEncodeError("can't encode table with a key of type "..type(X),wFeA)end end
if#JQgI==0 and not fs52REi then
if#N>0 then return nil,PUNkgaiM elseif
tostring(U)=="JSON array"then return nil elseif tostring(U)=="JSON object"then return{}else return nil end end;table.sort(JQgI)local s6FbB
if#N>0 then if UlFdiZ7v.noKeyConversion then
UlFdiZ7v:onEncodeError("a table with both numeric and string keys could be an object or array; aborting",wFeA)end
s6FbB={}for dc61,aguhyl in pairs(U)do s6FbB[dc61]=aguhyl end
table.sort(N)
for p,gOPDv in ipairs(N)do local aSdZU3=tostring(gOPDv)
if s6FbB[aSdZU3]==nil then
table.insert(JQgI,aSdZU3)s6FbB[aSdZU3]=U[gOPDv]else
UlFdiZ7v:onEncodeError(
"conflict converting table with mixed-type keys into a JSON object: key "..gOPDv.." exists both as a string and a number.",wFeA)end end end;return JQgI,nil,s6FbB end;local iSj
function iSj(YKDL,oFyb6OLp,oGdh_mv,WjvvK,TASVwBgU,KjUncMB,XkT)
if oFyb6OLp==nil or
(not XkT and TASVwBgU and TASVwBgU.null and oFyb6OLp==
TASVwBgU.null)then return'null'elseif
type(oFyb6OLp)=='string'then return ptZa(oFyb6OLp,TASVwBgU)elseif type(oFyb6OLp)=='number'then
if
oFyb6OLp~=oFyb6OLp then return"null"elseif oFyb6OLp>=math.huge then return"1e+9999"elseif oFyb6OLp<=-math.huge then
return"-1e+9999"else return tostring(oFyb6OLp)end elseif type(oFyb6OLp)=='boolean'then return tostring(oFyb6OLp)elseif type(oFyb6OLp)~=
'table'then
YKDL:onEncodeError("can't convert "..type(oFyb6OLp).." to JSON",WjvvK)elseif getmetatable(oFyb6OLp)==scRP0 then return tostring(oFyb6OLp)else
local c3dr=oFyb6OLp;if type(TASVwBgU)~='table'then TASVwBgU={}end;if type(KjUncMB)~=
'string'then KjUncMB=""end
if oGdh_mv[c3dr]then
YKDL:onEncodeError("table "..
tostring(c3dr).." is a child of itself",WjvvK)else oGdh_mv[c3dr]=true end;local NGH;local tIc,MD2O,HQ=PEqsd(YKDL,c3dr,WjvvK)
if MD2O then local cng={}for lE=1,MD2O do
table.insert(cng,iSj(YKDL,c3dr[lE],oGdh_mv,WjvvK,TASVwBgU,KjUncMB))end
if TASVwBgU.pretty then NGH="[ "..
table.concat(cng,", ").." ]"else NGH="["..
table.concat(cng,",").."]"end elseif tIc then local nI2F0id=HQ or c3dr
if TASVwBgU.pretty then local N4aMD_P={}local pCi=0
for lNOqUk8,YAnZNei in ipairs(tIc)do
local h8YWR44E=iSj(YKDL,tostring(YAnZNei),oGdh_mv,WjvvK,TASVwBgU,KjUncMB,true)
if TASVwBgU.align_keys then pCi=math.max(pCi,#h8YWR44E)end;table.insert(N4aMD_P,h8YWR44E)end
local NzeoQJ=KjUncMB..tostring(TASVwBgU.indent or"")
local AwGfFV=NzeoQJ..string.rep(" ",pCi)..
(TASVwBgU.align_keys and" "or"")
local wCRY="%s%"..string.format("%d",pCi).."s: %s"local d0uKSVw1={}
for VF,fTrMe in ipairs(tIc)do
local ypDndT8=iSj(YKDL,nI2F0id[fTrMe],oGdh_mv,WjvvK,TASVwBgU,AwGfFV)
table.insert(d0uKSVw1,string.format(wCRY,NzeoQJ,N4aMD_P[VF],ypDndT8))end;NGH="{\n"..
table.concat(d0uKSVw1,",\n").."\n"..KjUncMB.."}"else local MV65={}
for Y3D66Ym9,q in
ipairs(tIc)do
local PhJ=iSj(YKDL,nI2F0id[q],oGdh_mv,WjvvK,TASVwBgU,KjUncMB)
local h=iSj(YKDL,tostring(q),oGdh_mv,WjvvK,TASVwBgU,KjUncMB,true)
table.insert(MV65,string.format("%s:%s",h,PhJ))end;NGH="{"..table.concat(MV65,",").."}"end else NGH="[]"end;oGdh_mv[c3dr]=false;return NGH end end
function lcBL:encode(j2K,r8hgwQ,_6U)if type(self)~='table'or self.__index~=lcBL then
lcBL:onEncodeError("JSON:encode must be called in method format",r8hgwQ)end;if
type(_6U)~='table'then _6U={}end;return iSj(self,j2K,{},r8hgwQ,_6U)end
function lcBL:encode_pretty(GLSzBQs,c,xg)if type(self)~='table'or self.__index~=lcBL then
lcBL:onEncodeError("JSON:encode_pretty must be called in method format",c)end;if
type(xg)~='table'then xg=dx end;return iSj(self,GLSzBQs,{},c,xg)end;function lcBL.__tostring()return"JSON encode/decode package"end
lcBL.__index=lcBL
function lcBL:new(Id2KoP_G)local Y2or={}if Id2KoP_G then
for zN8ASHV5,iju in pairs(Id2KoP_G)do Y2or[zN8ASHV5]=iju end end
return setmetatable(Y2or,lcBL)end;return lcBL:new()
]===])()
local JtAjijkG=(function()
local h6Ub7U=[[ Copyright (c) The python-semanticversion project
All rights reserved.
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are met:
1. Redistributions of source code must retain the above copyright notice, this
list of conditions and the following disclaimer.
2. Redistributions in binary form must reproduce the above copyright notice,
this list of conditions and the following disclaimer in the documentation
and/or other materials provided with the distribution.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR
ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
]]
h6Ub7U=[[ The use of the library is similar to the original one,
check the documentation here: https://python-semanticversion.readthedocs.io/en/latest/
]]local Gm,YKA7cU,mCsewfX;do local dc61=table
Gm,YKA7cU,mCsewfX=dc61.concat,dc61.insert,dc61.unpack end;local yY
yY=function(aguhyl)
do local p=tonumber(aguhyl)if p then
return p,true else return aguhyl,false end end end;local Xf
Xf=function(gOPDv)return
gOPDv and gOPDv[1]=='0'and tonumber(gOPDv and gOPDv~='0')end;local UlFdiZ7v
UlFdiZ7v=function(aSdZU3,YKDL)if aSdZU3 ==YKDL then return 0 end
if aSdZU3 >YKDL then return 1 end;if aSdZU3 <YKDL then return-1 end end;local U
U=function(oFyb6OLp,oGdh_mv)local WjvvK,TASVwBgU=yY(oFyb6OLp)local KjUncMB,XkT=yY(oGdh_mv)
if TASVwBgU and XkT then return
UlFdiZ7v(WjvvK,KjUncMB)elseif TASVwBgU then return-1 elseif XkT then return 1 else return UlFdiZ7v(WjvvK,KjUncMB)end end;local wFeA
wFeA=function(c3dr,NGH)local tIc
do local MD2O={}for HQ=1,#c3dr do
if NGH[HQ]then MD2O[c3dr[HQ]]=NGH[HQ]end end;tIc=MD2O end
for cng,lE in pairs(tIc)do local nI2F0id=U(cng,lE)if nI2F0id~=0 then return nI2F0id end end;return UlFdiZ7v(#c3dr,#NGH)end;local JQgI
do local N4aMD_P
local pCi={_coerce=function(AwGfFV,wCRY,d0uKSVw1)if d0uKSVw1 ==nil then d0uKSVw1=false end;if
wCRY==nil and d0uKSVw1 then return wCRY end;return tonumber(wCRY)end,next_major=function(lNOqUk8)
if
lNOqUk8.prerelease and lNOqUk8.minor==0 and lNOqUk8.patch==0 then
return
JQgI(Gm((function()local YAnZNei={}local h8YWR44E=1
local VF={lNOqUk8.major,lNOqUk8.minor,lNOqUk8.patch}for fTrMe=1,#VF do local ypDndT8=VF[fTrMe]YAnZNei[h8YWR44E]=tostring(ypDndT8)h8YWR44E=
h8YWR44E+1 end
return YAnZNei end)(),'.'))else
return
JQgI(Gm((function()local MV65={}local Y3D66Ym9=1;local q={lNOqUk8.major+1,0,0}
for PhJ=1,#q do
local h=q[PhJ]MV65[Y3D66Ym9]=tostring(h)Y3D66Ym9=Y3D66Ym9+1 end;return MV65 end)(),'.'))end end,next_minor=function(j2K)if
not(j2K.minor)then
error("Partial version doesn't contain the minor component!")end
if
j2K.prerelease and j2K.patch==0 then
return
JQgI(Gm((function()local r8hgwQ={}local _6U=1;local GLSzBQs={j2K.major,j2K.minor,j2K.patch}
for c=1,#
GLSzBQs do local xg=GLSzBQs[c]r8hgwQ[_6U]=tostring(xg)_6U=_6U+1 end;return r8hgwQ end)(),'.'))else
return
JQgI(Gm((function()local Id2KoP_G={}local Y2or=1;local zN8ASHV5={j2K.major,j2K.minor+1,0}for iju=1,#zN8ASHV5
do local XsWgh=zN8ASHV5[iju]Id2KoP_G[Y2or]=tostring(XsWgh)
Y2or=Y2or+1 end;return Id2KoP_G end)(),'.'))end end,next_patch=function(l4Hdz)if
not(l4Hdz.patch)then
error("Partial version doesn't contain the patch component!")end
if l4Hdz.prerelease then
return
JQgI(Gm((function()local NSXCgSH={}local Wq=1
local SbOQ={l4Hdz.major,l4Hdz.minor,l4Hdz.patch}for IiuHGo=1,#SbOQ do local cGqxtYr=SbOQ[IiuHGo]NSXCgSH[Wq]=tostring(cGqxtYr)
Wq=Wq+1 end;return NSXCgSH end)(),'.'))else
return
JQgI(Gm((function()local bgJFKeeZ={}local yu9fg0nN=1
local wgx={l4Hdz.major,l4Hdz.minor,l4Hdz.patch+1}for zlU7X=1,#wgx do local t=wgx[zlU7X]bgJFKeeZ[yu9fg0nN]=tostring(t)
yu9fg0nN=yu9fg0nN+1 end;return bgJFKeeZ end)(),'.'))end end,coerce=function(f6qbO,kk,QrubIAv)if
QrubIAv==nil then QrubIAv=false end;local bLHDW
bLHDW=function(JYrf2)
local KHDOUlRY,I0JvPpn=JYrf2:match('^(%d+)(.*)$')if not(KHDOUlRY)then return nil end;local Ce4ZE=KHDOUlRY
local OVx_mN,lB=I0JvPpn:match('^%.(%d+)(.*)$')
if OVx_mN then I0JvPpn=lB;Ce4ZE=Ce4ZE.. ('.'..OVx_mN)end;local byE;byE,lB=I0JvPpn:match('^%.(%d+)(.*)$')if byE then I0JvPpn=lB;Ce4ZE=Ce4ZE.. (
'.'..byE)end;return JYrf2,Ce4ZE end;local YjFd7b,jZgPYb=bLHDW(kk)if not(YjFd7b)then
error("Version string lacks a numerical component: "..tostring(kk))end
local zN2=kk:sub(1,#jZgPYb)if not QrubIAv then while({zN2:gsub('.','')})[2]<2 do
zN2=zN2 ..'.0'end end;if
#jZgPYb==#kk then return JQgI(zN2,QrubIAv)end
local IN69pa5=kk:sub(#jZgPYb+1)IN69pa5=IN69pa5:gsub('[^a-zA-Z0-9+.-]','-')
local UOWJ,WtalJw=nil,nil
if IN69pa5:sub(1,1)=='+'then UOWJ=''WtalJw=IN69pa5:sub(2)elseif
IN69pa5:sub(1,1)=='.'then UOWJ=''WtalJw=IN69pa5:sub(2)elseif
IN69pa5:sub(1,1)=='-'then IN69pa5=IN69pa5:sub(2)
do local bITCI=IN69pa5:find('+')if bITCI then UOWJ,WtalJw=IN69pa5:sub(1,
bITCI-1),IN69pa5:sub(bITCI+1,-1)else
UOWJ,WtalJw=IN69pa5,''end end else
do local K=IN69pa5:find('+')if K then
UOWJ,WtalJw=IN69pa5:sub(1,K-1),IN69pa5:sub(K+1,-1)else UOWJ,WtalJw=IN69pa5,''end end end;WtalJw=WtalJw:gsub('+','.')if UOWJ and UOWJ~=''then
zN2=zN2 .. ('-'..UOWJ)end;if WtalJw and WtalJw~=''then
zN2=zN2 .. ('+'..WtalJw)end;return f6qbO.__class(zN2,QrubIAv)end,parse=function(F5dtVpnN,kxeBp,a,kQ)if
a==nil then a=false end;if kQ==nil then kQ=false end;if not kxeBp or
type(kxeBp)~='string'or kxeBp==''then
error("Invalid empty version string: "..
tostring(tostring(kxeBp)))end;local EE9LAE
if a then
EE9LAE=F5dtVpnN.__class.partialVersionRe else EE9LAE=F5dtVpnN.__class.versionRe end;local iVx,eg,AQviNt,T6,NviN0i=EE9LAE(F5dtVpnN.__class,kxeBp)if not iVx then
error(
"Invalid version string: "..tostring(kxeBp))end;if Xf(iVx)then
error("Invalid leading zero in major: "..tostring(kxeBp))end;if Xf(eg)then
error("Invalid leading zero in minor: "..
tostring(kxeBp))end;if Xf(AQviNt)then
error("Invalid leading zero in patch: "..
tostring(kxeBp))end;iVx=tonumber(iVx)
eg=F5dtVpnN:_coerce(eg,a)AQviNt=F5dtVpnN:_coerce(AQviNt,a)
if T6 ==nil then if a and NviN0i==nil then return{iVx,eg,AQviNt,
nil,nil}else T6={}end elseif T6 ==''then
T6={}else do local BlMQce={}local o=1
for dpRE in T6:gmatch('[^.]+')do BlMQce[o]=dpRE;o=o+1 end;T6=BlMQce end
F5dtVpnN:_validateIdentifiers(T6,false)end
if NviN0i==nil then if a then NviN0i=nil else NviN0i={}end elseif NviN0i==''then NviN0i={}else
do local fEiXwWq={}
local r3JzMga6=1;for Tuyw in NviN0i:gmatch('[^.]+')do fEiXwWq[r3JzMga6]=Tuyw
r3JzMga6=r3JzMga6+1 end;NviN0i=fEiXwWq end;F5dtVpnN:_validateIdentifiers(NviN0i,true)end;return{iVx,eg,AQviNt,T6,NviN0i}end,_validateIdentifiers=function(FYLcr2nu,ioS69,AiP)if
AiP==nil then AiP=false end
for S2jwpoi=1,#ioS69 do local _WX9u=ioS69[S2jwpoi]if not _WX9u then
error(
"Invalid empty identifier "..
tostring(_WX9u).." in "..tostring(Gm(ioS69,'.')))end;if
_WX9u:sub(1,1)=='0'and tonumber(_WX9u)and _WX9u~='0'and not AiP then
error("Invalid leading zero in identifier "..tostring(_WX9u))end end end,__pairs=function(u0riyU)return
pairs({u0riyU.major,u0riyU.minor,u0riyU.patch,u0riyU.prerelease,u0riyU.build})end,__ipairs=function(UH)return
ipairs({UH.major,UH.minor,UH.patch,UH.prerelease,UH.build})end,__tostring=function(WNph)
local ytF=tostring(WNph.major)
if WNph.minor~=nil then ytF=ytF.. ('.'..WNph.minor)end
if WNph.patch~=nil then ytF=ytF.. ('.'..WNph.patch)end
if WNph.prerelease and#WNph.prerelease>0 or
WNph.partial and WNph.prerelease and#WNph.prerelease==0 and WNph.build==nil then ytF=ytF.. ('-'..
Gm(WNph.prerelease,'.'))end;if
WNph.build and#WNph.build>0 or WNph.partial and WNph.build and#
WNph.build==0 then
ytF=ytF.. ('+'..Gm(WNph.build,'.'))end;return ytF end,_comparsionFunctions=function(d,gRm)if
gRm==nil then gRm=false end;local LPX0
LPX0=function(qao,ipUPIzc)
if qao and ipUPIzc then
return wFeA(qao,ipUPIzc)elseif qao then return-1 elseif ipUPIzc then return 1 else return 0 end end;local g
g=function(N8,Gzk)if N8 ==Gzk then return 0 else return'not implemented'end end;local _l
_l=function(J7nsK)local dXbd
dXbd=function(vQj,sVBxyy)
if vQj==nil or sVBxyy==nil then return 0 else return J7nsK(vQj,sVBxyy)end end;return dXbd end
if gRm then
return{UlFdiZ7v,_l(UlFdiZ7v),_l(UlFdiZ7v),_l(LPX0),_l(g)}else return{UlFdiZ7v,UlFdiZ7v,UlFdiZ7v,LPX0,g}end end,__compare=function(N9d,S7)
local bJtvRSR=N9d:_comparsionFunctions(
N9d.partial or S7.partial)
local aBhZK5={{bJtvRSR[1],N9d.major,S7.major},{bJtvRSR[2],N9d.minor,S7.minor},{bJtvRSR[3],N9d.patch,S7.patch},{bJtvRSR[4],N9d.prerelease,S7.prerelease},{bJtvRSR[5],N9d.build,S7.build}}
for Jz8JUscj=1,#aBhZK5 do local OtGmbAgE=aBhZK5[Jz8JUscj]local oU_r,n_lv,UYQF=mCsewfX(OtGmbAgE)
local WXx=oU_r(n_lv,UYQF)if WXx~=0 then return WXx end end;return 0 end,__compareHelper=function(W4EuxJXi,BlYNd61h,XDPndG,sJYFQIP4)
local Ogq0S2=W4EuxJXi:__compare(BlYNd61h)if Ogq0S2 =='not implemented'then return sJYFQIP4 end;return
XDPndG(Ogq0S2)end,__eq=function(n8Cw3SR,GJqd7gt)
local slE5aDm2;slE5aDm2=function(aL_g)return aL_g==0 end;return
n8Cw3SR:__compareHelper(GJqd7gt,slE5aDm2,false)end,__lt=function(IMUI10L,vPA)
local pUXZ6G4;pUXZ6G4=function(mk)return mk<0 end;return
IMUI10L:__compareHelper(vPA,pUXZ6G4,false)end,__le=function(OeQex1U4,i0cV9)
local EGD;EGD=function(VWiGCreH)return VWiGCreH<=0 end;return
OeQex1U4:__compareHelper(i0cV9,EGD,false)end}pCi.__index=pCi
N4aMD_P=setmetatable({__init=function(B_kkL,uEO6Y,i_053JPY)if i_053JPY==nil then i_053JPY=false end
local l,UK,NzaICo,k1X83nYm,xxzxfj=mCsewfX(B_kkL:parse(uEO6Y,i_053JPY))
B_kkL.major,B_kkL.minor,B_kkL.patch,B_kkL.prerelease,B_kkL.build,B_kkL.partial=l,UK,NzaICo,k1X83nYm,xxzxfj,i_053JPY end,__base=pCi,__name="Version"},{__index=pCi,__call=function(_ad1m4I,...)
local H1QsS=setmetatable({},pCi)_ad1m4I.__init(H1QsS,...)return H1QsS end})pCi.__class=N4aMD_P;local NzeoQJ=N4aMD_P
NzeoQJ.versionRe=function(NzeoQJ,rIMx)
local TiA,Y51P,ichL,NOK=rIMx:match('^(%d+)%.(%d+)%.(%d+)(.*)$')if not(TiA)then return nil end
local Alv,YeLO2=NOK:match('^%-([0-9a-zA-z.-]+)(.*)$')if Alv then NOK=YeLO2 end;local CkrmO
CkrmO,YeLO2=NOK:match('^%+([0-9a-zA-Z.-]+)(.*)$')if CkrmO then NOK=YeLO2 end;if#NOK>0 then return nil end
return TiA,Y51P,ichL,Alv,CkrmO end
NzeoQJ.partialVersionRe=function(NzeoQJ,ooovsSJe)local s5IsD,KvYEVoXt=ooovsSJe:match('^(%d+)(.*)$')if not
(s5IsD)then return nil end
local VWWD_P,zsMuNkv=KvYEVoXt:match('^%.(%d+)(.*)$')if VWWD_P then KvYEVoXt=zsMuNkv end;local aXxi
aXxi,zsMuNkv=KvYEVoXt:match('^%.(%d+)(.*)$')if aXxi then KvYEVoXt=zsMuNkv end;local Q18a7QTy
Q18a7QTy,zsMuNkv=KvYEVoXt:match('^%-([0-9a-zA-Z.-]*)(.*)$')if Q18a7QTy then KvYEVoXt=zsMuNkv end;local K5Rp6
K5Rp6,zsMuNkv=KvYEVoXt:match('^%+([0-9a-zA-Z.-]*)(.*)$')if K5Rp6 then KvYEVoXt=zsMuNkv end;if#KvYEVoXt>0 then return nil end;return s5IsD,
VWWD_P,aXxi,Q18a7QTy,K5Rp6 end;JQgI=N4aMD_P end;local N
do local GTIA
local gdPUe={parse=function(pcN_ceXY,_P)if not _P or type(_P)~='string'or _P==''then
error(
"Invalid empty requirement specification: "..tostring(tostring(_P)))end;if _P=='*'then return
{pcN_ceXY.__class.KIND_ANY,''}end
local rq,mo=pcN_ceXY.__class:reSpec(_P)if not rq then
error("Invalid requirement specification: "..tostring(_P))end;rq=
pcN_ceXY.__class.KIND_ALIASES[rq]or rq;local I=JQgI(mo,true)
if I.build~=nil and
rq~=pcN_ceXY.__class.KIND_EQUAL and rq~=
pcN_ceXY.__class.KIND_NEQ then
error(
"Invalid requirement specification "..tostring(_P)..": build numbers have no ordering")end;return{rq,I}end,match=function(RAAJAsR,c1pjj7)
local BMv=RAAJAsR.kind
if RAAJAsR.__class.KIND_ANY==BMv then return true elseif
RAAJAsR.__class.KIND_LT==BMv then return c1pjj7 <RAAJAsR.spec elseif RAAJAsR.__class.KIND_LTE==BMv then return
c1pjj7 <=RAAJAsR.spec elseif
RAAJAsR.__class.KIND_EQUAL==BMv then return c1pjj7 ==RAAJAsR.spec elseif
RAAJAsR.__class.KIND_GTE==BMv then return c1pjj7 >=RAAJAsR.spec elseif RAAJAsR.__class.KIND_GT==BMv then return
c1pjj7 >RAAJAsR.spec elseif RAAJAsR.__class.KIND_NEQ==BMv then return
c1pjj7 ~=RAAJAsR.spec elseif
RAAJAsR.__class.KIND_CARET==BMv then return RAAJAsR.spec<=c1pjj7 and
c1pjj7 <RAAJAsR.spec:next_major()elseif
RAAJAsR.__class.KIND_TILDE==BMv then
return RAAJAsR.spec<=c1pjj7 and c1pjj7 <
RAAJAsR.spec:next_minor()else return
error("Unexpected match kind: "..tostring(RAAJAsR.kind))end end,__tostring=function(NQh8)return
tostring(NQh8.kind)..tostring(NQh8.spec)end,__eq=function(P,bkTe)
return
P.kind==bkTe.kind and P.spec==bkTe.spec end}gdPUe.__index=gdPUe
GTIA=setmetatable({__init=function(ohmPbyDd,D)
ohmPbyDd.kind,ohmPbyDd.spec=mCsewfX(ohmPbyDd:parse(D))end,__base=gdPUe,__name="SpecItem"},{__index=gdPUe,__call=function(DfDLWkT,...)
local MTU8HP4d=setmetatable({},gdPUe)DfDLWkT.__init(MTU8HP4d,...)return MTU8HP4d end})gdPUe.__class=GTIA;local _bxEn=GTIA;_bxEn.KIND_ANY='*'_bxEn.KIND_LT='<'
_bxEn.KIND_LTE='<='_bxEn.KIND_EQUAL='=='_bxEn.KIND_SHORTEQ='='_bxEn.KIND_EMPTY=''
_bxEn.KIND_GTE='>='_bxEn.KIND_GT='>'_bxEn.KIND_NEQ='!='_bxEn.KIND_CARET='^'
_bxEn.KIND_TILDE='~'
_bxEn.KIND_ALIASES={[_bxEn.__class.KIND_SHORTEQ]=_bxEn.__class.KIND_EQUAL,[_bxEn.__class.KIND_EMPTY]=_bxEn.__class.KIND_EQUAL}
_bxEn.reSpec=function(_bxEn,hIM_cG0i)local jD,me=hIM_cG0i:match('^(.-)(%d.*)$')
if not
(
jD=='<'or
jD=='<='or jD==''or jD=='='or jD=='=='or jD=='>='or jD=='>'or jD=='!='or jD=='^'or jD=='~')then return nil else return jD,me end end;N=GTIA end;local fs52REi
do local sgU5HAMG
local FDydY={parse=function(PEZ_,c)local ElbTbcZG={}local r3=1;for p in c:gmatch('[^,]+')do ElbTbcZG[r3]=N(p)
r3=r3+1 end;return ElbTbcZG end,match=function(UiVYRok,jvPsY9)
local tEBmuypm=UiVYRok.specs;for hW=1,#tEBmuypm do local iOcgdUx=tEBmuypm[hW]if not iOcgdUx:match(jvPsY9)then
return false end end;return
true end,filter=function(kCwLIk,_l)
local rjQ=0
return function()
while true do rjQ=rjQ+1;local Euo0=_l[rjQ]if not(Euo0)then return nil end;if
kCwLIk:match(Euo0)then return Euo0 end end end end,select=function(LIV,vydlAbZ3)
local BXxv5z;do local mKLU={}local Him=1
for cPDhu in LIV:filter(vydlAbZ3)do mKLU[Him]=cPDhu;Him=Him+1 end;BXxv5z=mKLU end
if
#BXxv5z>0 then local UQnOS=BXxv5z[1]for tRWU=1,#BXxv5z do local X2Zy_nb=BXxv5z[tRWU]
if UQnOS<X2Zy_nb then UQnOS=X2Zy_nb end end;return UQnOS else return nil end end,__index=function(ITtw3N7E,yozOp)if
ITtw3N7E:match(yozOp)then return true else return nil end end,__pairs=function(wxU)return
pairs(wxU.specs)end,__ipairs=function(kOmS5sy)return ipairs(kOmS5sy.specs)end,__tostring=function(CLSdD)
return
Gm((function()
local Fh={}local IlAPA=1;local jLKMpQuK=CLSdD.specs;for sUQpby=1,#jLKMpQuK do local mbA=jLKMpQuK[sUQpby]
Fh[IlAPA]=tostring(mbA)IlAPA=IlAPA+1 end;return Fh end)(),',')end,__eq=function(_qPhpaFx,zex)
local pPGcdu=_qPhpaFx.specs
for rjp=1,#pPGcdu do local cT2z=pPGcdu[rjp]local zke1tWps=false;local gRFA=zex.specs
for jX9a0tJX=1,#gRFA do
local YFy4TGc=gRFA[jX9a0tJX]if cT2z==YFy4TGc then zke1tWps=true;break end end;if not zke1tWps then return false end end;return true end}FDydY.__index=FDydY
sgU5HAMG=setmetatable({__init=function(YjpbYkCb,L1p7luJ)if type(L1p7luJ)=='string'then
L1p7luJ={L1p7luJ}end;local eH
do local WpOZ={}local fD2289=1
for folfO=1,#L1p7luJ do
local vtsK=L1p7luJ[folfO]WpOZ[fD2289]=YjpbYkCb:parse(vtsK)fD2289=fD2289+1 end;eH=WpOZ end;YjpbYkCb.specs={}
for E1p4Mv=1,#eH do local IHap=eH[E1p4Mv]for rDvV=1,#IHap do local RX1L2q=IHap[rDvV]
YKA7cU(YjpbYkCb.specs,RX1L2q)end end end,__base=FDydY,__name="Spec"},{__index=FDydY,__call=function(bCBtWguf,...)
local q=setmetatable({},FDydY)bCBtWguf.__init(q,...)return q end})FDydY.__class=sgU5HAMG;fs52REi=sgU5HAMG end;local PUNkgaiM
PUNkgaiM=function(e1sXUN4f,x)return UlFdiZ7v(JQgI(e1sXUN4f,JQgI(x)))end;local s6FbB
s6FbB=function(VP,IQwqq)return fs52REi(VP):match(JQgI(IQwqq))end;local X
X=function(Xcc4)return({JQgI:parse(Xcc4)})[1]end
return{Spec=fs52REi,SpecItem=N,Version=JQgI,compare=PUNkgaiM,match=s6FbB,validate=X}end)()local s;s=require("component").isAvailable;local YAtG_LV3,LfEJbh_
do
local fqw5=require("shell")YAtG_LV3,LfEJbh_=fqw5.parse,fqw5.getWorkingDirectory end;local JD=require("shell")local u,pzDMZwG,XPoQB,XxJ,o5sms
do
local qnVfOeRE=require("filesystem")
u,pzDMZwG,XPoQB,XxJ,o5sms=qnVfOeRE.isDirectory,qnVfOeRE.exists,qnVfOeRE.makeDirectory,qnVfOeRE.concat,qnVfOeRE.copy end;local JQi1jg=require("filesystem")local wVzn,pE
do
local YIiSKsxK=require("serialization")wVzn,pE=YIiSKsxK.serialize,YIiSKsxK.unserialize end;local RSjapQ;RSjapQ=require("event").pull;local QJf,zC;do
local Ua=require("term")QJf,zC=Ua.clearLine,Ua.getCursor end;local pfZ3SPy_
pfZ3SPy_=os.exit;local pDNa2ox6,Do6yo7nm
do local qeJtG=io;pDNa2ox6,Do6yo7nm=qeJtG.write,qeJtG.stderr end;local y06X3k,ivnJjrA
do local pdpNgBcZ=table;y06X3k,ivnJjrA=pdpNgBcZ.insert,pdpNgBcZ.unpack end;local d3fMjkg=JQi1jg.list;local el,Wu_uIt={},{}local w=nil;local sgeP={}local CM={}
local Qlmlet="/etc/hpm/module/"local _="/var/lib/hpm/dist/"local RkGFh6=0;local hw18="/etc/hpm/hpm.cfg"
local nvCiFt7r=[[Usage: hpm OPTIONS COMMAND
See `man hpm` for more info.]]
local xSebv5Jc=[[-- << Global settings >> -------------------------------------------------------
-- A directory where package manifests will be placed.
-- It will be created if it doesn't exist.
dist = "/var/lib/hpm/dist"
-- A place where to search for custom hpm modules.
-- It will be created if it doesn't exist.
modules = "/etc/hpm/module"
-- << Settings related to the hel module >> ------------------------------------
hel = {}
-- If set to `false`, hpm will *only* remove a package that hpm is told to
-- remove. Otherwise, all of its dependants will be also removed.
hel.remove_dependants = true
-- << Settings related to the oppm module >> -----------------------------------
oppm = {}
-- A directory where package manifests will be stored for faster access.
oppm.cache_directory = "/var/cache/hpm/oppm"
-- See hel.remove_dependants above.
oppm.remove_dependants = true]]
local mMp={info=function(...)
if el.v then
return
print(table.concat((function(...)local wV={}local rLd=1;local z8oF={...}for DB6A7N=1,#z8oF do local VhYX=z8oF[DB6A7N]
wV[rLd]=tostring(VhYX)rLd=rLd+1 end;return wV end)(...),"\t"))end end,print=function(...)
if
not(el.q)then
return
print(table.concat((function(...)local Ha7ErH={}local rjU95v=1;local sxBl={...}for m=1,#sxBl do local nD4LhX6z=sxBl[m]
Ha7ErH[rjU95v]=tostring(nD4LhX6z)rjU95v=rjU95v+1 end;return Ha7ErH end)(...),"\t"))end end,error=function(...)
if
not(el.q)then
return
Do6yo7nm:write(
table.concat((function(...)local iN={}local Lq=1;local s9tW={...}
for R61K=1,#s9tW do
local Jf4os=s9tW[R61K]iN[Lq]=tostring(Jf4os)Lq=Lq+1 end;return iN end)(...),"\t")..'\n')end end,fatal=function(...)
if
not(el.q)then
Do6yo7nm:write(
table.concat((function(...)local a4xc={}local e=1;local la5={...}for i=1,#la5 do local R=la5[i]
a4xc[e]=tostring(R)e=e+1 end;return a4xc end)(...),"\t")..'\n')end;return pfZ3SPy_(1)end}local rDtVf
rDtVf=function(xWVu,Yw8Yxix)if not(xWVu)then return mMp.fatal(Yw8Yxix)end end;local vj
vj=function(i)return
mMp.fatal((tostring(i))..": Not implemented yet!")end;local z
z=function()pDNa2ox6(nvCiFt7r)return pfZ3SPy_(0)end;local Zg
Zg=function(VoXG,JL0I04c)if not(VoXG)then mMp.fatal(JL0I04c)end;return VoXG end;local ykRppH
ykRppH=function(En6r_K97,T4AA,VnuCKTdu)
if not(type(En6r_K97 ==T4AA))then
mMp.fatal("Value '"..
tostring(En6r_K97)..
"' is "..tostring(type(VnuCKTdu))..", however, a "..
tostring(T4AA).." is expected.")end;return VnuCKTdu end;local WQ6
WQ6=function(XnNgn)return ykRppH(XnNgn,"number",tonumber(XnNgn))end;local y36Aetn
y36Aetn=function(H1JD)return ykRppH(H1JD,"string",tostring(H1JD))end;local iPL3B4cr
iPL3B4cr=function(gEEa9I,ULLLDUm)
for e4F3,GsfNt7 in pairs(ULLLDUm)do if GsfNt7 ==gEEa9I then return true,e4F3 end end;return false end;local GI2hz6SK
GI2hz6SK=function(fF0)local YWPfQKb2=0
for r,OS0Zp3i in pairs(fF0)do YWPfQKb2=YWPfQKb2+1 end;return YWPfQKb2 end;local Oh
Oh=function(BK)
if type(BK)=="nil"then return true elseif type(BK)=="string"then
return not BK or#BK<1 elseif type(BK)=="table"then return not BK or GI2hz6SK(BK)<1 else
return true end end;local PG
PG=function(Idjbe70)
for B=1,#Idjbe70 do local nDjt=Idjbe70[B]if not nDjt then return false end end;return true end;local n
n=function(NVWt)return pzDMZwG(NVWt)and u(NVWt)end;local O
O=function(efuUGMh)return pzDMZwG(efuUGMh)and not u(efuUGMh)end;local N5UjTN
N5UjTN=function(p4nNp)return p4nNp==1 and""or"s"end;local qLH5
qLH5=function(VW)return VW~=1 and""or"s"end;local tE
tE=function(Zt)return Zt==1 and"is"or"are"end;local VcV0EuD
VcV0EuD=function(V)return V:match("^([^:]-):?([^:@]+)@?([^:@]*)$")end;local pX4gCR
pX4gCR=function(mzeTI)
if
JQi1jg.get(JD.resolve(mzeTI)).isReadOnly()then return false,"the path is readonly!"elseif not pzDMZwG(mzeTI)then
return false,"the filesystem node doesn't exist."else
if
not(u(mzeTI)or JQi1jg.isLink(mzeTI))then return JQi1jg.remove(mzeTI)else for sy4J in Zg(d3fMjkg(mzeTI))do
pX4gCR(XxJ(mzeTI,sy4J))end;return JQi1jg.remove(mzeTI)end end end;local gad4ZcL
gad4ZcL=function()local ztJhP_u8=el.c or el.config or hw18
if
not O(ztJhP_u8)then local ys=JQi1jg.path(ztJhP_u8)
if not n(ys)then local X,zLtWO09=XPoQB(ys)if not X then
return false,
"Failed to create '"..
tostring(ys).."' directory for the config file: "..tostring(zLtWO09)end end;local rMQ1um8,U2=io.open(ztJhP_u8,"w")
if rMQ1um8 then
rMQ1um8:write(xSebv5Jc)rMQ1um8:close()else return false,
"Failed to open config file for writing: "..tostring(U2)end end;local D,XIcl=io.open(ztJhP_u8,"r")
if D then local Z=D:read("*all")
D:close()local ZDICnKE={}
(load(Z,"config","t",ZDICnKE))()local L
L=function(B58)if B58 ==nil then B58={}end
return
setmetatable(B58,{__index={get=function(PYVzrNl,KTVmRC,Pa)
if type(B58[PYVzrNl])~="nil"then
if
type(B58[PYVzrNl])=="table"then return L(B58[PYVzrNl])end;return B58[PYVzrNl]end
mMp.error("Attempt to access undeclared config field '"..tostring(PYVzrNl).."'!")if not Pa then return KTVmRC else return L(KTVmRC)end end}})end;CM=L(ZDICnKE)Qlmlet=CM.get("modules",Qlmlet)
_=CM.get("dist",_)return CM else
return false,"Failed to open config file for reading: "..tostring(XIcl)end end;local dk
dk=function()if not(s("internet"))then
mMp.fatal("This command requires an internet card to run!")end;w=w or
require("internet").request end;local E;E=function(bmK)dk()return pcall(w,bmK)end;local OO
OO=function()
if not
n(Qlmlet)then local j,vMgKnGj=XPoQB(Qlmlet)if not j then
return false,"Failed to create '"..
tostring(Qlmlet)..
"' directory for custom modules: "..tostring(vMgKnGj)end end;local OJPc3R=Zg(d3fMjkg(Qlmlet))
for M9K in OJPc3R do
local Zeu=M9K:match("^(.+)%..+$")
local Q2_d=(loadfile(XxJ(Qlmlet,M9K),"t",_ENV))()if Q2_d then sgeP[Zeu]=Q2_d end end;return true end;local y
y=function(W0iTcMIt)local N=W0iTcMIt;local Hald6SO
do local Dq=W0iTcMIt:find(':')if Dq then
N=W0iTcMIt:sub(Dq+1)Hald6SO=W0iTcMIt:sub(1,Dq-1)end end
if not Hald6SO then local y3Ur={}
for GL70F7uL,Hald6SO in pairs(sgeP)do
if Hald6SO[N]then if type(Hald6SO[N])=="table"and
Hald6SO[N].__public==true then
y06X3k(y3Ur,{class=Hald6SO,module=GL70F7uL,method=Hald6SO[N]})end end end
if#y3Ur>1 then local lqANrrJA=nil;for WUFTXBy6,Hald6SO in pairs(y3Ur)do
if Hald6SO.module=="hel"then lqANrrJA=WUFTXBy6;break end end;if lqANrrJA then
y3Ur={y3Ur[lqANrrJA]}end end
if#y3Ur>1 then
mMp.print("Ambiguous choice: method "..
tostring(N).." is implemented in the following modules:")for aEZf=1,#y3Ur do local Hald6SO=y3Ur[aEZf]
mMp.print(" * "..tostring(Hald6SO.module))end
mMp.print(
"Choose a specific module by prepending its name with a colon, e.g., "..
tostring(y3Ur[1].module)..":"..tostring(N)..".")return false elseif#y3Ur==0 then
mMp.error("Unknown command: "..tostring(N))return false else Hald6SO=y3Ur[1].module
mMp.info("Note, using "..tostring(Hald6SO)..":"..
tostring(N)..".")return
function(...)return y3Ur[1].method(y3Ur[1].class,...)end end else
if sgeP[Hald6SO]and Oh(N)then local QjQ_o={}
for wDiq_,QYA5WJOY in pairs(sgeP[Hald6SO])do if type(QYA5WJOY)==
"table"and QYA5WJOY.__public==true then
y06X3k(QjQ_o,tostring(wDiq_))end end
mMp.print("Available module-specific commands: "..tostring(table.concat(QjQ_o,", ")))return false end
if
not sgeP[Hald6SO]or not sgeP[Hald6SO][N]or
sgeP[Hald6SO][N]and
(type(sgeP[Hald6SO][N])~="table"or
sgeP[Hald6SO][N].__public~=true)then
mMp.error("Unknown command: "..tostring(Hald6SO)..":"..tostring(N))return false else return function(...)
return sgeP[Hald6SO][N](sgeP[Hald6SO],...)end end end end;local cR6rJlAl
cR6rJlAl=function(yliV8)
if not yliV8 or yliV8 ==""then yliV8="hel"else yliV8=yliV8 end;return sgeP[yliV8]or sgeP.default end;local M6ilzGJ
M6ilzGJ=function(rjpKFl,YUGQovw,...)if rjpKFl==nil then rjpKFl=sgeP.default end
if
rjpKFl[YUGQovw]then return rjpKFl[YUGQovw](rjpKFl,...)else return
sgeP.default[YUGQovw](sgeP.default,...)end end;local iW6CD
iW6CD=function(XZt7GyF,Zn3SC,D4,crA9EKx)if Zn3SC==nil then Zn3SC="hel"end
if D4 ==nil then D4=XxJ(_,Zn3SC)end;if crA9EKx==nil then crA9EKx=XZt7GyF.name end;if not XZt7GyF then
return false,"'nil' given"end
if not n(D4)then local Wp9xT,P=XPoQB(D4)if not Wp9xT then
return false,"Failed to create '"..
tostring(XxJ(D4,Zn3SC)).."' directory for manifest files: "..tostring(P)end end;local IcsJ,A=io.open(XxJ(D4,crA9EKx),"w")
if IcsJ then
IcsJ:write(wVzn(XZt7GyF))IcsJ:close()return true else return false,
"Failed to open file for writing: "..tostring(A)end end;local wZdg
wZdg=function(o0_XG8FI,jLsxpw,x)if x==nil then x="hel"end
jLsxpw=jLsxpw or XxJ(_,x,o0_XG8FI)
if O(jLsxpw)then local AXNfV,cX=io.open(jLsxpw,"rb")
if AXNfV then
local iyx=Zg(pE(AXNfV:read("*all")))AXNfV:close()return iyx else return false,
"Failed to open manifest for '"..tostring(o0_XG8FI).."' package: "..
tostring(cX)end else return false,
"No manifest found for '"..tostring(o0_XG8FI).."' package"end end;local BaX
BaX=function(bxvn,mWYrzB)if mWYrzB==nil then mWYrzB="hel"end
local O7kX=XxJ(_,mWYrzB,bxvn)
if O(O7kX)then return pX4gCR(O7kX)else return false,
"No manifest found for '"..tostring(bxvn).."' package"end end;local SJsW11k
SJsW11k=function(Q4XSpdY)return
setmetatable({__public=true},{__call=function(fzTyrQ9F,...)return Q4XSpdY(...)end})end;local Ki1HJT
Ki1HJT=function(fAumJ0i,i0)
return
function()local tZliF4,jlmopoj=pcall(fAumJ0i)
if not(tZliF4)then return false,
"Could not download '"..
tostring(i0).."': "..tostring(jlmopoj)else return jlmopoj end end end;local wjim8xCV
wjim8xCV=function(R,uS_N6,o5SLRA)
if uS_N6 ==nil then uS_N6="Could not download '%s': %s"end;if o5SLRA==nil then o5SLRA="Could not download '%s': %s"end
local ztwXaCR,M2WtMgiq,FgfME=E(R)if not(ztwXaCR and M2WtMgiq)then
return false,uS_N6:format(R,FgfME)end;local ylH9o=""for CC4Kfjh,FgfME in Ki1HJT(M2WtMgiq)do
if CC4Kfjh then
ylH9o=ylH9o..CC4Kfjh else return false,o5SLRA:format(R,FgfME)end end;return ylH9o end;local EQLam
EQLam=function()
if not(el.y)then
io.write("Press [ENTER] to continue...")local k=select(3,RSjapQ("key_down"))if k==13 then QJf()return true else
io.write("\n")return false end else return true end end;local qTDt
qTDt=function(eUQ0x)local r0OR=0;local pYHkv={}
if not(Oh(eUQ0x.install))then
local hxZHlgP={"Packages to INSTALL:",table.concat(eUQ0x.install," ")}y06X3k(pYHkv,hxZHlgP)r0OR=r0OR+#eUQ0x.install else
eUQ0x.install={}end
if not(Oh(eUQ0x.reinstall))then
local zct={"Packages to REINSTALL:",table.concat(eUQ0x.reinstall," ")}y06X3k(pYHkv,zct)r0OR=r0OR+#eUQ0x.reinstall else
eUQ0x.reinstall={}end
if not(Oh(eUQ0x.upgrade))then
local WQk6Wkd={"Packages to UPGRADE:",table.concat(eUQ0x.upgrade," ")}y06X3k(pYHkv,WQk6Wkd)r0OR=r0OR+#eUQ0x.upgrade else
eUQ0x.upgrade={}end
if not(Oh(eUQ0x.remove))then
local t={"Packages to REMOVE:",table.concat(eUQ0x.remove," ")}y06X3k(pYHkv,t)r0OR=r0OR+#eUQ0x.remove else
eUQ0x.remove={}end
do
local pRCHPl={tostring(#eUQ0x.install).." to INSTALL, "..
tostring(#eUQ0x.reinstall)..
" to REINSTALL, "..
tostring(#eUQ0x.upgrade).." to UPGRADE, "..tostring(#eUQ0x.remove)..
" to REMOVE."}y06X3k(pYHkv,pRCHPl)end
for sCffg4HK,EyljhkFp in pairs(pYHkv)do for sCffg4HK,uGDn542 in pairs(EyljhkFp)do
if sCffg4HK==1 then mMp.print(uGDn542)else mMp.print(" "..
tostring(uGDn542))end end;if
sCffg4HK~=#pYHkv then mMp.print("")end end
if r0OR>1 then if not(EQLam())then return pfZ3SPy_(7)end end end
do local DQ;local s6Ahlni_={}s6Ahlni_.__index=s6Ahlni_
DQ=setmetatable({__init=function()end,__base=s6Ahlni_,__name="default"},{__index=s6Ahlni_,__call=function(H,...)
local YlzZm=setmetatable({},s6Ahlni_)H.__init(YlzZm,...)return YlzZm end})s6Ahlni_.__class=DQ;local T6dNu=DQ
T6dNu.install=function()return
mMp.fatal("Incorrect source is provided! No default 'install' implementation.")end
T6dNu.remove=function(T6dNu,vj9879b5,cotcYZ1f)if cotcYZ1f==nil then cotcYZ1f="hel"end
if vj9879b5 then
if vj9879b5.files then
for FRcmT,zfl in
pairs(vj9879b5.files)do local itxD=XxJ(zfl.dir,zfl.name)local JPHs7A,yzYgnMtr=pX4gCR(itxD)
if
not(JPHs7A)then return false,"Failed to remove '"..
tostring(itxD).."': "..tostring(yzYgnMtr)end end end;return BaX(vj9879b5.name,cotcYZ1f)else
return false,"Package can't be removed: the manifest is empty."end end
T6dNu.save=function()return
mMp.fatal("Incorrect source is provided! No default 'save' implementation.")end;sgeP.default=DQ end
do local o;local wmkJ=sgeP.default;local I1={}I1.__index=I1
setmetatable(I1,wmkJ.__base)
o=setmetatable({__init=function(R60Ru4bj,...)return o.__parent.__init(R60Ru4bj,...)end,__base=I1,__name="hel",__parent=wmkJ},{__index=function(eQWRf,WT2AX)
local _AvO=rawget(I1,WT2AX)if _AvO==nil then local qEO=rawget(eQWRf,"__parent")
if qEO then return qEO[WT2AX]end else return _AvO end end,__call=function(q,...)
local WUY7=setmetatable({},I1)q.__init(WUY7,...)return WUY7 end})I1.__class=o;local gXu5hG=o;gXu5hG.URL="https://hel-roottree.rhcloud.com/"
gXu5hG.parsePackageJSON=function(gXu5hG,_puepou,DYLeJ)if
DYLeJ==nil then DYLeJ=JtAjijkG.Spec("*")end;local udbF=nil
local dt1={}
for UjlBMb,PKWIJ9 in pairs(_puepou.versions)do local rQYWEt=JtAjijkG.Version(UjlBMb)if not
(rQYWEt)then
mMp.fatal("Could not parse the version in package: "..tostring(rQYWEt))end;dt1[rQYWEt]=PKWIJ9 end
local V7eMEiVW,Co1tUVas=pcall(function()return
DYLeJ:select((function()local nCwsa={}local IPPy=1
for zYGA2q2,I9Mw in pairs(dt1)do nCwsa[IPPy]=zYGA2q2;IPPy=IPPy+1 end;return nCwsa end)())end)if not(V7eMEiVW)then
mMp.fatal("Could not select the best version: "..tostring(Co1tUVas))end
udbF=tostring(Co1tUVas)if not(Co1tUVas)then
mMp.fatal("No candidate for version specification '"..tostring(DYLeJ).."' found!")end
local B={name=_puepou.name,version=udbF,files={},dependencies={}}for e,BUtIET in pairs(dt1[Co1tUVas].files)do local NvAj=BUtIET.dir;local Icg=BUtIET.name
y06X3k(B.files,{url=e,dir=NvAj,name=Icg})end;for PzMsk,axLuO in
pairs(dt1[Co1tUVas].depends)do local j=axLuO.version;local As=axLuO.type
y06X3k(B.dependencies,{name=PzMsk,version=j,type=As})end
return B end
gXu5hG.getPackageSpec=function(gXu5hG,JmCzKm)
mMp.info("Downloading package data for "..tostring(JmCzKm).." ...")
local Mwhc,A6z=E(gXu5hG.URL.."packages/"..JmCzKm)if not(Mwhc)then
mMp.fatal("HTTP request error: "..A6z)end;local _Mk=""for L9 in A6z do _Mk=_Mk..L9 end
local PXrrrSid=UlikV:decode(_Mk)if not(PXrrrSid)then
mMp.fatal("Incorrect JSON format!\n"..tostring(_Mk))end;return PXrrrSid.data end
gXu5hG.rawInstall=function(gXu5hG,_KZPScl,dbTwy,R4f819q)if dbTwy==nil then dbTwy=false end
if R4f819q==nil then R4f819q=false end;local Kj1I
if R4f819q then Kj1I=XxJ(LfEJbh_(),_KZPScl.name)else Kj1I="/"end
if R4f819q and not n(Kj1I)then local nTUMgqomA,Id5sIM=XPoQB(Kj1I)
if not(nTUMgqomA)then
mMp.fatal(
"Failed creating '"..
tostring(Kj1I).."' directory for package '"..tostring(_KZPScl.name)..
"'! \n"..tostring(Id5sIM))end elseif not R4f819q then local gZM2ANLt=wZdg(_KZPScl.name,nil,"hel")
if gZM2ANLt then
if
gZM2ANLt.version==tostring(_KZPScl.version)then
mMp.print("'"..
tostring(_KZPScl.name).."@"..
tostring(gZM2ANLt.version).."' is already installed, skipping...")return gZM2ANLt else
mMp.fatal("'"..
tostring(_KZPScl.name)..
"@"..
tostring(_KZPScl.version)..
"' was attempted to install, however, another version of the same package is already installed: '"..tostring(_KZPScl.name)..
"@"..tostring(gZM2ANLt.version).."'")end end end
for aC72qEnu,B60J in pairs(_KZPScl.files)do
mMp.info("Fetching '"..tostring(B60J.name).."' ...")local Y4=Zg(wjim8xCV(B60J.url))
local f=XxJ(Kj1I,B60J.dir)
if not n(f)then local yeCnvcd6,Iq93c6cA=XPoQB(f)if not(yeCnvcd6)then
mMp.fatal("Failed to create '"..
tostring(f)..
"' directory for '"..
tostring(B60J.name).."'! \n"..tostring(Iq93c6cA))end end
do local nsM0h;B60J,nsM0h=io.open(XxJ(f,B60J.name),"w")if
not(B60J)then
mMp.fatal("Could not open '"..tostring(XxJ(f,B60J.name))..
"' for writing: "..tostring(nsM0h))end
B60J:write(Y4)B60J:close()end end;return
{name=_KZPScl.name,version=tostring(_KZPScl.version),files=_KZPScl.files,dependencies=_KZPScl.dependencies,manual=dbTwy}end
gXu5hG.resolveDependencies=function(gXu5hG,Czi,IlxN,EA_3x01A,m54tY2)if IlxN==nil then IlxN={}end
if EA_3x01A==nil then EA_3x01A={}end;if m54tY2 ==nil then m54tY2={}end
for WJWMdKI=1,#Czi do local AhbP=Czi[WJWMdKI]local QHFgYUN,RoEsr7So
QHFgYUN,RoEsr7So=AhbP.name,AhbP.version;local dX=false;for Rz=1,#IlxN do local j177r=IlxN[Rz]
if j177r.pkg.name==QHFgYUN then dX=true;break end end
if not(dX)then
y06X3k(EA_3x01A,{name=QHFgYUN,version=""})local j=wZdg(QHFgYUN,nil,"hel")
if not j or not
RoEsr7So:match(JtAjijkG.Version(j.version))then
local qCaFw=gXu5hG:getPackageSpec(QHFgYUN)local syvPi=gXu5hG:parsePackageJSON(qCaFw,RoEsr7So)
EA_3x01A[#EA_3x01A].version=syvPi.version;local NrgSK2=syvPi.dependencies
for wIH=1,#NrgSK2 do local TYWkpc=NrgSK2[wIH]dX=false
for k=1,#IlxN do
local J=IlxN[k]if J.pkg.name==TYWkpc.name then dX=true;break end end
if not dX then local gtlO9=nil;for Lun,beUJXhjw in pairs(EA_3x01A)do
if beUJXhjw.name==TYWkpc.name then gtlO9=Lun;break end end
if gtlO9 then
if
EA_3x01A[gtlO9].version==TYWkpc.version then
mMp.fatal("Circular dependencies detected: '"..
tostring(QHFgYUN)..
"@"..
tostring(syvPi.version)..
"' depends on '"..
tostring(TYWkpc.name)..
"@"..
tostring(TYWkpc.version)..
"', and '"..
tostring(EA_3x01A[gtlO9].name)..
"@"..tostring(EA_3x01A[gtlO9].version)..
"' depends on '"..tostring(QHFgYUN).."@"..
tostring(syvPi.version).."'.")else
mMp.fatal("Attempted to install two versions of the same package: '"..
tostring(TYWkpc.name)..
"@"..
tostring(TYWkpc.version)..
"' and '"..
tostring(EA_3x01A[gtlO9].name)..
"@"..
tostring(EA_3x01A[gtlO9].version)..
"' when resolving dependencies for '"..tostring(QHFgYUN).."@"..
tostring(syvPi.version).."'.")end end
gXu5hG:resolveDependencies({{name=TYWkpc.name,version=JtAjijkG.Spec(TYWkpc.version)}},IlxN,EA_3x01A,m54tY2)end end;y06X3k(IlxN,{pkg=syvPi})
y06X3k(m54tY2,{pkg=syvPi})else y06X3k(IlxN,{pkg=j})end;EA_3x01A[#EA_3x01A]=nil end end;return m54tY2 end
gXu5hG.getPackageDependants=function(gXu5hG,zY7adu,Nlvw,K55)if Nlvw==nil then Nlvw={}end;if K55 ==nil then K55={}end
for BJcMTdMi=1,#zY7adu
do local f1MKKJ=zY7adu[BJcMTdMi]local nFf=false
for EIqL41=1,#Nlvw do local iv=Nlvw[EIqL41]if
iv.name==f1MKKJ then nFf=true;break end end
if not(nFf)then y06X3k(K55,{name=f1MKKJ})
local rfmMR4=wZdg(f1MKKJ,nil,"hel")
if rfmMR4 then y06X3k(Nlvw,{name=f1MKKJ,manifest=rfmMR4})
local Tq2I=Zg(d3fMjkg(XxJ(_,"hel")))
for GNo in Tq2I do rfmMR4=Zg(wZdg(GNo,nil,"hel"))
local e5x=rfmMR4.dependencies
for QrONvWGq=1,#e5x do local D94fnZaa=e5x[QrONvWGq]
if D94fnZaa.name==f1MKKJ then nFf=false
for XI=1,#Nlvw do
local FNi=Nlvw[XI]if FNi.name==GNo then nFf=true;break end end
if not nFf then
for pRW2nEmK=1,#K55 do local OR=K55[pRW2nEmK]if OR.name==GNo then
mMp.fatal("Circular dependencies detected: "..
tostring(GNo))end end;gXu5hG:getPackageDependants({GNo},Nlvw,K55)end end end end else
mMp.fatal("Package "..
tostring(f1MKKJ).." is referenced as a dependant of another package, however, this package isn't installed.")end;K55[#K55]=nil end end;return Nlvw end
gXu5hG.install=SJsW11k(function(gXu5hG,...)
if el.l or el["local"]then local f5=JD.resolve(...)
local UAc=Zg(wZdg(f5,XxJ(f5,"manifest")))local Ef=gXu5hG:resolveDependencies(UAc.depends,nil)local P=el.d or
el.onlyDeps;local F4AWvI={}for GYVN=1,#Ef do local DNlB1V=Ef[GYVN]
y06X3k(F4AWvI,
tostring(DNlB1V.pkg.name).."@"..tostring(DNlB1V.pkg.version))end;if not(P)then
y06X3k(F4AWvI,
tostring(UAc.name).."@"..tostring(UAc.version))end;qTDt({install=F4AWvI})
for erb6G_E=1,#
Ef,1 do local QFUU10K=Ef[erb6G_E]
mMp.print("Installing '"..
tostring(QFUU10K.pkg.name).."@"..
tostring(QFUU10K.pkg.version).."'...")UAc=gXu5hG:rawInstall(QFUU10K.pkg,false,false)
local xNPDtul,k8=iW6CD(UAc,"hel")
if xNPDtul then
mMp.info("Saved the manifest of '"..tostring(UAc.name).."'.")else
mMp.fatal("Couldn't save the manifest of '"..tostring(UAc.name)..
"': "..tostring(k8)..".")end end
if not P then
mMp.print("Installing '"..tostring(UAc.name)..
"@"..tostring(UAc.version).."'...")
for fghe,vFXf in pairs(UAc.files)do if not n(XxJ(vFXf.dir,vFXf.name))then
XPoQB(vFXf.dir)end
local CA0uX7n,ze5Vpc3=o5sms(XxJ(f5,vFXf.url),XxJ(vFXf.dir,vFXf.name))if not(CA0uX7n)then
mMp.fatal("Cannot copy file '"..tostring(vFXf.name)..
"': "..tostring(ze5Vpc3))end end;local HmgRk,UuCdpVi=iW6CD(UAc,"hel")
if HmgRk then
mMp.info("Saved the manifest of '"..
tostring(UAc.name).."'.")else
mMp.fatal("Couldn't save the manifest of '"..tostring(UAc.name)..
"': "..tostring(UuCdpVi)..".")end end end;local Arww={}local BYH={...}
for vwK8=1,#BYH do local Sk_SiC=BYH[vwK8]
local X0bgPvA,M9CyqH=Sk_SiC:match("^(.+)@(.+)$"or Sk_SiC)if Oh(M9CyqH)then M9CyqH="*"end
mMp.info("Creating version specification for "..tostring(M9CyqH)..
" ...")
local z0x4qSAN,X0GTupeV=pcall(function()return JtAjijkG.Spec(M9CyqH)end)if not(z0x4qSAN)then
mMp.fatal("Could not parse the version specification: "..tostring(X0GTupeV).."!")end
y06X3k(Arww,{name=X0bgPvA,version=X0GTupeV})end;local o7E8TLH=el.r or el.reinstall;local N5N27Jd=el.s or el.save
local m=gXu5hG:resolveDependencies(Arww)local nK={}local _zr={}
for rQ=1,#m do local k=false
repeat local Oc=m[rQ]
if o7E8TLH then local IHovU=false
for e_wDQjk=1,#Arww do
local ClglY=Arww[e_wDQjk]if ClglY.name==Oc.pkg.name then IHovU=true;break end end;if IHovU then
y06X3k(nK,tostring(Oc.pkg.name).."@"..tostring(Oc.pkg.version))k=true;break end end
y06X3k(_zr,tostring(Oc.pkg.name).."@"..tostring(Oc.pkg.version))k=true until true;if not k then break end end;qTDt({install=_zr,reinstall=nK})
if o7E8TLH then local S
do local NKetZhs={}local EFLZ0N1=1;for gL=1,#
Arww do local m4=Arww[gL]
NKetZhs[EFLZ0N1]=Zg(wZdg(m4.name,nil,"hel"))EFLZ0N1=EFLZ0N1+1 end
S=NKetZhs end;gXu5hG:_remove(S,true,false)end
for rNOL8G=1,#m do local q=m[rNOL8G]
mMp.print("Installing '"..tostring(q.pkg.name).."@"..
tostring(q.pkg.version).."'...")
local lKO=gXu5hG:rawInstall(q.pkg,iPL3B4cr(q.pkg.name,Arww),N5N27Jd)local hcwgu,omgCdqp8=iW6CD(lKO,"hel")
if hcwgu then
mMp.info("Saved the manifest of '"..
tostring(lKO.name).."'.")else
mMp.fatal("Couldn't save the manifest of '"..tostring(lKO.name)..
"': "..tostring(omgCdqp8)..".")end end end)
gXu5hG.remove=SJsW11k(function(gXu5hG,...)local X17eHTx={...}local SGF={}
for myIHU=1,#X17eHTx do local xxNCdF=X17eHTx[myIHU]
local _cl1b=Zg(wZdg(xxNCdF,nil,"hel"))y06X3k(SGF,_cl1b)end;return gXu5hG:_remove(SGF,false)end)
gXu5hG._remove=function(gXu5hG,Xz18nk,P,sTX4)if P==nil then P=false end;if sTX4 ==nil then sTX4=true end;local A0TJx
if not
CM.get("hel",{},true).get("remove_dependants",true)or not sTX4 then
do local Nqdkw={}
local t=1;for QbMO=1,#Xz18nk do local wYZ=Xz18nk[QbMO]
Nqdkw[t]={name=wYZ.name,manifest=wYZ}t=t+1 end;A0TJx=Nqdkw end else
A0TJx=gXu5hG:getPackageDependants((function()local aMd={}local o0pf=1;for tx1LD=1,#Xz18nk do local N3ROeR=Xz18nk[tx1LD]
aMd[o0pf]=N3ROeR.name;o0pf=o0pf+1 end;return aMd end)())end
if not(P)then
qTDt({remove=(function()local I1oQVnUd={}local oTX=1
for WZlF4=1,#A0TJx do local IxqPDOWH=A0TJx[WZlF4]
I1oQVnUd[oTX]="hel:"..
tostring(IxqPDOWH.manifest.name).."@"..tostring(IxqPDOWH.manifest.version)oTX=oTX+1 end;return I1oQVnUd end)()})end
for GZqV=1,#A0TJx do local OVubrDw_=A0TJx[GZqV]
mMp.print("Removing '"..
tostring(OVubrDw_.manifest.name)..
"@"..tostring(OVubrDw_.manifest.version).."' ...")
Zg(o.__parent.remove(gXu5hG,OVubrDw_.manifest,"hel"))end;return true end
gXu5hG.upgrade=SJsW11k(function(gXu5hG)local G2_TeR8={}
for QnNOl in Zg(d3fMjkg(XxJ(_,"hel")))do if not
(u(XxJ(_,"hel",QnNOl)))then
y06X3k(G2_TeR8,Zg(wZdg(QnNOl,nil,"hel")))end end;local yk={}
for aQs=1,#G2_TeR8 do local uow_0tb=G2_TeR8[aQs]
local tykg=gXu5hG:getPackageSpec(uow_0tb.name)local C_pPyW=gXu5hG:parsePackageJSON(tykg)
uow_0tb.latest={spec=tykg,data=C_pPyW}
if JtAjijkG.Version(uow_0tb.latest.data.version)>
JtAjijkG.Version(uow_0tb.version)then y06X3k(yk,uow_0tb)end end
gXu5hG:resolveDependencies((function()local mgb4b={}local LOBqxO=1
for m8=1,#yk do local mcoAHO=yk[m8]
mgb4b[LOBqxO]={name=mcoAHO.name,version=JtAjijkG.Spec(mcoAHO.latest.data.version)}LOBqxO=LOBqxO+1 end;return mgb4b end)())local OPSPMfr_
do local d3gFWO={}local D=1
for obodPKnu=1,#yk do local kgdzk=yk[obodPKnu]
d3gFWO[D]=
tostring(kgdzk.name).."@{"..
tostring(kgdzk.version).." => "..
tostring(kgdzk.latest.data.version).."}"D=D+1 end;OPSPMfr_=d3gFWO end;qTDt({upgrade=OPSPMfr_})
for oVSp=1,#yk do local uBJ=yk[oVSp]
gXu5hG:_remove({uBJ},true,false)
mMp.print("Installing '"..
tostring(uBJ.name).."@"..
tostring(uBJ.latest.data.version).."'...")
local A=gXu5hG:rawInstall(uBJ.latest.data,uBJ.manual,false)local MP,jb=iW6CD(A,"hel")
if MP then
mMp.info("Saved the manifest of '"..tostring(A.name).."'.")else
mMp.fatal("Couldn't save the manifest of '"..
tostring(A.name).."': "..tostring(jb)..".")end end end)
gXu5hG.info=SJsW11k(function(gXu5hG,uKSj,YXgXQB)if YXgXQB==nil then YXgXQB="*"end;if Oh(uKSj)then
mMp.fatal("Usage: hpm hel:info <package name> [<version specification>]")end
if Oh(YXgXQB)then YXgXQB="*"end
mMp.print("Creating version specification for "..tostring(YXgXQB).." ...")
local bvL1X4,PPNahh=pcall(function()return JtAjijkG.Spec(YXgXQB)end)if not(bvL1X4)then
mMp.fatal("Could not parse the version specification: "..tostring(PPNahh).."!")end
local z2g=gXu5hG:getPackageSpec(uKSj)local m9JTkVv6=gXu5hG:parsePackageJSON(z2g,PPNahh)local Q={}
y06X3k(Q,
"- Package name: "..tostring(z2g.name))
y06X3k(Q,"- Description:\n"..tostring(z2g.description))
y06X3k(Q,"- Package owners: "..tostring(table.concat(z2g.owners,", ")))
y06X3k(Q,"- Authors:\n"..
tostring(table.concat((function()local bWkP={}local JtFj=1;local PQ3=z2g.authors
for _xCtN=1,#PQ3 do
local JVpe=PQ3[_xCtN]bWkP[JtFj]=" - "..tostring(JVpe)JtFj=JtFj+1 end;return bWkP end)(),"\n")))
y06X3k(Q,"- License: "..tostring(z2g.license))
y06X3k(Q,"- Versions: "..tostring(GI2hz6SK(z2g.versions))..", latest: "..
tostring(m9JTkVv6.version))
y06X3k(Q," - Files: "..tostring(#m9JTkVv6.files))
y06X3k(Q," - Depends: "..
tostring(table.concat((function()local nG36XmZC={}local Vf26=1;local xUGt=m9JTkVv6.dependencies;for _U=1,#xUGt
do local hkI39=xUGt[_U]nG36XmZC[Vf26]=tostring(hkI39.name).."@"..
tostring(hkI39.version)Vf26=
Vf26+1 end
return nG36XmZC end)())))
y06X3k(Q," - Changes:\n"..
tostring(z2g.versions[m9JTkVv6.version].changes))y06X3k(Q,"- Stats:")
y06X3k(Q," - Views: "..tostring(z2g.stats.views))
y06X3k(Q,"- Creation date: "..
tostring(z2g.stats.date.created).." UTC")
y06X3k(Q,"- Last updated: "..tostring(z2g.stats.date["last-updated"])..
" UTC")return mMp.print(table.concat(Q,"\n"))end)if wmkJ.__inherited then wmkJ.__inherited(wmkJ,o)end
sgeP.hel=o end
do local MwwN;local oZ9=sgeP.default;local OXlT0={}OXlT0.__index=OXlT0
setmetatable(OXlT0,oZ9.__base)
MwwN=setmetatable({__init=function(zIYNIXy1,...)return MwwN.__parent.__init(zIYNIXy1,...)end,__base=OXlT0,__name="oppm",__parent=oZ9},{__index=function(c,mReHt4h)
local I7=rawget(OXlT0,mReHt4h)if I7 ==nil then local Upw=rawget(c,"__parent")
if Upw then return Upw[mReHt4h]end else return I7 end end,__call=function(nqBfKL,...)
local gs3a=setmetatable({},OXlT0)nqBfKL.__init(gs3a,...)return gs3a end})OXlT0.__class=MwwN;local V=MwwN
V.REPOS="https://raw.githubusercontent.com/OpenPrograms/openprograms.github.io/master/repos.cfg"V.PACKAGES="https://raw.githubusercontent.com/%s/master/programs.cfg"
V.FILES="https://raw.githubusercontent.com/%s/%s"V.DIRECTORY="https://api.github.com/repos/%s/contents/%s?ref=%s"
V.DEFAULT_CACHE_DIRECTORY="/var/cache/hpm/oppm"
V.cacheDirectory=function(V)
local AkKaBC=CM.get("oppm",{},true).get("cache_directory",V.DEFAULT_CACHE_DIRECTORY)
if not(n(AkKaBC))then local OmRH8,GY=XPoQB(AkKaBC)if not(OmRH8)then
mMp.fatal(
"Could not create the cache directory at "..tostring(AkKaBC)..": "..tostring(GY))end end;return AkKaBC end
V.listCache=function(V)local oukM79R={}local D_j=V:cacheDirectory()
local mZPe4w=Zg(d3fMjkg(D_j))
for OvZ in mZPe4w do
if u(XxJ(D_j,OvZ))then
local cBOpf=Zg(d3fMjkg(XxJ(D_j,OvZ)))
for KZYA5y in cBOpf do
if u(XxJ(D_j,OvZ,KZYA5y))then
local YoCAN7OU=Zg(d3fMjkg(XxJ(D_j,OvZ,KZYA5y)))
for FoP in YoCAN7OU do local jqtWXY=XxJ(D_j,OvZ,KZYA5y,FoP)
if not(u(jqtWXY))then local XgRb
do
local GoP6,cZ_=io.open(jqtWXY,"r")if not GoP6 then
return false,"Could not open '"..
tostring(jqtWXY).."' for reading: "..tostring(cZ_)end
PG=GoP6:read("*all")XgRb=pE(PG)GoP6:close()end;local G3e=XxJ(OvZ,KZYA5y)
y06X3k(oukM79R,{path=jqtWXY,repo=G3e,pkg=FoP,data=XgRb})end end end end end end;return oukM79R end
V.fixCache=function(V)local NYc8=V:cacheDirectory()local Dff8=Zg(d3fMjkg(NYc8))
for lEYwsOG9 in Dff8 do
local M=true;local Vt95q2G=XxJ(NYc8,lEYwsOG9)
if u(Vt95q2G)then
local jsPbwU=Zg(d3fMjkg(Vt95q2G))
for Wvs3rd6o in jsPbwU do local UdVlP=true;local N=XxJ(Vt95q2G,Wvs3rd6o)
if u(N)then
local v9mB_RUi=Zg(d3fMjkg(N))
for hX in v9mB_RUi do local AVU=true;local I=XxJ(N,hX)
if not(u(I))then AVU,UdVlP,M=false,false,false end;if AVU then pX4gCR(I)end end end;if UdVlP then pX4gCR(N)end end end;if M then pX4gCR(Vt95q2G)end end;return true end
V.resolveDirectory=function(V,_x5O1,eFI8dI3,i)
local l6xUetCb=Zg(wjim8xCV(V.DIRECTORY:format(_x5O1,i,eFI8dI3)))l6xUetCb=UlikV:decode(l6xUetCb)
if l6xUetCb.message then
return false,"Could not fetch "..
tostring(_x5O1)..":"..
tostring(eFI8dI3).."/"..tostring(i)..
": "..tostring(l6xUetCb.message)end;local lOb_Sv={}local VspvGB9V=1
for LrFLp5=1,#l6xUetCb do local GfB7=l6xUetCb[LrFLp5]
if GfB7.type=="file"then
lOb_Sv[VspvGB9V]={name=GfB7.name,url=GfB7.download_url,path=GfB7.path}VspvGB9V=VspvGB9V+1 end end;return lOb_Sv end
V.updateCache=function(V)local Iz_w1j=V:cacheDirectory()local G=Zg(V:listCache())
local X7YKzX,od0VOF=wjim8xCV(V.REPOS)
if not(X7YKzX)then return false,"Could not fetch "..
tostring(V.REPOS)..": "..tostring(od0VOF)end;X7YKzX=pE(X7YKzX)local oO6SbZ={}
for kef2zBS,Z in pairs(X7YKzX)do local ze0=false
repeat
if Z.repo then
mMp.info("Fetching '"..
tostring(kef2zBS).."' at '"..tostring(Z.repo).."' ...")local ylW3uC0,N_G1
ylW3uC0,N_G1,od0VOF=E(V.PACKAGES:format(Z.repo))
if not(ylW3uC0 and N_G1)then
mMp.error("Could not fetch '"..tostring(kef2zBS)..
"' at '"..
tostring(Z.repo).."': "..tostring(od0VOF))ze0=true;break end;local wkGNE=""
for ylW3uC0,BV in function()return pcall(N_G1)end do
if not ylW3uC0 then
mMp.error("Could not fetch '"..
tostring(kef2zBS)..
"' at '"..tostring(Z.repo).."': "..tostring(BV))wkGNE=false;break else if not BV then break end;wkGNE=wkGNE..BV end end;if wkGNE==false then ze0=true;break end;if Oh(wkGNE)then
mMp.error("Could not fetch '"..
tostring(kef2zBS).."' at '"..tostring(Z.repo).."'")ze0=true;break end;local ccK
ccK,od0VOF=pE(wkGNE)
if not ccK then
mMp.error("Manifest '"..tostring(kef2zBS)..
"' at '"..tostring(Z.repo).."' is malformed: "..
tostring(od0VOF))ze0=true;break end
for HnLY,cm51CH1n in pairs(ccK)do local iWrSgT=false
repeat
if HnLY:match("[^A-Za-z0-9._-]")then
mMp.error(
"Package name contains illegal characters: "..tostring(kef2zBS)..":"..tostring(HnLY).."!")iWrSgT=true;break end
y06X3k(oO6SbZ,{repo=Z.repo,name=HnLY,data=cm51CH1n})iWrSgT=true until true;if not iWrSgT then break end end end;ze0=true until true;if not ze0 then break end end;local UE_vrsNx={}
for C=1,#oO6SbZ do local YK1=oO6SbZ[C]local t96Qtz,HjKNi,Ub9iqg
t96Qtz,HjKNi,Ub9iqg=YK1.name,YK1.repo,YK1.data;if iPL3B4cr(XxJ(HjKNi,t96Qtz),UE_vrsNx)then
mMp.error("There're multiple packages under the same name: "..
tostring(t96Qtz).."!")end
if not
(n(XxJ(Iz_w1j,HjKNi)))then local wNbC65Ta
wNbC65Ta,od0VOF=XPoQB(XxJ(Iz_w1j,HjKNi))
if not(wNbC65Ta)then return false,
"Could not create directory '"..tostring(XxJ(Iz_w1j,HjKNi)).."': "..
tostring(od0VOF)end end;local r_S8HFRo
r_S8HFRo,od0VOF=io.open(XxJ(Iz_w1j,HjKNi,t96Qtz),"w")
if not(r_S8HFRo)then return false,
"Could not open '"..tostring(XxJ(Iz_w1j,HjKNi,t96Qtz))..
"' for writing: "..tostring(od0VOF)end;do
r_S8HFRo:write(wVzn({name=t96Qtz,repo=HjKNi,data=Ub9iqg}))r_S8HFRo:close()end;local qIF4RFBv
do for xOiPW,Z9j in
pairs(G)do
if Z9j.repo==HjKNi and Z9j.pkg==t96Qtz then qIF4RFBv=xOiPW;break end end end;if qIF4RFBv then table.remove(G,qIF4RFBv)else
y06X3k(UE_vrsNx,XxJ(HjKNi,t96Qtz))end end;mMp.print("Removing old cache files ...")for r=1,#G do local OnJ1=G[r]
local KFU0;KFU0=OnJ1.path;pX4gCR(KFU0)end
mMp.print("Fixing bad cache nodes ...")V:fixCache()
mMp.print("- "..
tostring(#oO6SbZ).." program"..
tostring(N5UjTN(#oO6SbZ)).." cached.")
mMp.print("- "..
tostring(#UE_vrsNx).." package"..
tostring(N5UjTN(#UE_vrsNx)).." "..tostring(tE(
#UE_vrsNx)).." new.")
mMp.print("- "..tostring(#G)..
" package"..tostring(N5UjTN(#G)).." no longer exist"..
tostring(qLH5(#G))..".")return true end
V.parseLocalPath=function(V,Pvuq,lOpDJ)
if lOpDJ:sub(1,2)=="//"then
return XxJ(Pvuq,lOpDJ:sub(3))else return XxJ(Pvuq,"usr",lOpDJ)end end
V.rawInstall=function(V,YLe,lTH,JL,FpU_E)if lTH==nil then lTH="/"end;if JL==nil then JL=false end;if FpU_E==nil then
FpU_E=false end;local JWtwnQ2t=V:listCache()
local uEKPPpj_={filesInstalled=0,packagesInstalled=0}
if FpU_E and not n(lTH)then local hXgSzEI,AUQ=XPoQB(lTH)if not(hXgSzEI)then
mMp.fatal(
"Failed to create '"..tostring(lTH).."' directory for package '"..
tostring(YLe).."'! \n"..tostring(AUQ))end elseif
not FpU_E then local B=wZdg(YLe,nil,"oppm")if B then
mMp.print("'"..
tostring(YLe).."' is already installed, skipping...")return B,uEKPPpj_ end end;local aYO4NN
for J=1,#JWtwnQ2t do local coSiE=JWtwnQ2t[J]local wm,_O,smj,obBu
wm,_O,smj,obBu=coSiE.path,coSiE.pkg,coSiE.repo,coSiE.data;if _O==YLe then aYO4NN=coSiE;break end end;if not(aYO4NN)then
mMp.fatal("No such package: "..tostring(YLe))end;local CtG9nSQL={}local uZtK5yX=aYO4NN.repo
for cbQlG,YZQu1DR4 in
pairs(aYO4NN.data.data.files)do local kza={}
if cbQlG:sub(1,1)==":"then
kza=V:resolveDirectory(uZtK5yX,cbQlG:sub(2,cbQlG:find("/")-1,
nil),cbQlG:sub(cbQlG:find("/")+1))else
kza={{name=JQi1jg.name(cbQlG),path=cbQlG,url=V.FILES:format(uZtK5yX,cbQlG)}}end;local YLe
for CvGDk_2=1,#kza do local EGpun=kza[CvGDk_2]local LNlhK,cnx_1g
YLe,LNlhK,cnx_1g=EGpun.name,EGpun.path,EGpun.url;local eV=Zg(wjim8xCV(cnx_1g))
local DGQnw=V:parseLocalPath(lTH,YZQu1DR4)if not(n(DGQnw))then XPoQB(DGQnw)end
do
local yLgHuF,fpL=io.open(XxJ(DGQnw,YLe),"w")if not yLgHuF then
mMp.fatal("Could not open file for writing: "..tostring(fpL))end;yLgHuF:write(eV)
yLgHuF:close()end;uEKPPpj_.filesInstalled=uEKPPpj_.filesInstalled+1
y06X3k(CtG9nSQL,{name=YLe,url=cnx_1g,dir=DGQnw})end end;local kr2CYaS={}if aYO4NN.data.data.dependencies then
for k6 in
pairs(aYO4NN.data.data.dependencies)do y06X3k(kr2CYaS,{name=k6})end end;uEKPPpj_.packagesInstalled=
uEKPPpj_.packagesInstalled+1;return
{name=YLe,files=CtG9nSQL,dependencies=kr2CYaS,manual=JL},uEKPPpj_ end
V.resolveDependencies=function(V,m,rvNhq6v,gC,QO)if rvNhq6v==nil then rvNhq6v={}end;if gC==nil then gC={}end;if
QO==nil then QO={}end;local VvzMQHj=V:listCache()
for fSYJX=1,#m do local WV=m[fSYJX]local yUho4MXRx=false;for J2=1,#
rvNhq6v do local hgrBfz0w=rvNhq6v[J2]
if hgrBfz0w==WV then yUho4MXRx=true;break end end
if not(yUho4MXRx)then
gC[WV]=true;local Gi=wZdg(WV,nil,"oppm")
if not Gi then local wpv1
for I9IMuWm=1,#VvzMQHj do local a=VvzMQHj[I9IMuWm]
local rZ;rZ=a.pkg;if rZ==WV then wpv1=a;break end end
if not(wpv1)then return false,"Unknown package: "..tostring(WV)end
if wpv1.data.data.dependencies then
for VKTNfzUf in pairs(wpv1.data.data.dependencies)do
yUho4MXRx=false;for Oms4=1,#rvNhq6v do local JfA=rvNhq6v[Oms4]
if JfA==VKTNfzUf then yUho4MXRx=true;break end end
if not(yUho4MXRx)then
if
gC[VKTNfzUf]then
mMp.fatal("Circular dependencies detected: '"..
tostring(WV).."' depends on '"..
tostring(VKTNfzUf).."', and '"..
tostring(VKTNfzUf).."' depends on '"..tostring(WV).."'.")end;V:resolveDependencies({VKTNfzUf},rvNhq6v,gC,QO)end end end;y06X3k(QO,WV)end;y06X3k(rvNhq6v,WV)gC[WV]=nil end end;return QO end
V.getPackageDependants=function(V,CPu1,pfyhF,pglFz82w)if pfyhF==nil then pfyhF={}end
if pglFz82w==nil then pglFz82w={}end
for RkeCL=1,#CPu1 do local LoW_7e=CPu1[RkeCL]local mLgQ=false
for ng=1,#pfyhF do local Pp_NboV=pfyhF[ng]if Pp_NboV.name==
LoW_7e then mLgQ=true;break end end
if not(mLgQ)then y06X3k(pglFz82w,{name=LoW_7e})
local owAp3u2G=wZdg(LoW_7e,nil,"oppm")
if owAp3u2G then
y06X3k(pfyhF,{name=LoW_7e,manifest=owAp3u2G})local OH0C=Zg(d3fMjkg(XxJ(_,"oppm")))
for kmQkm9cr in OH0C do
owAp3u2G=Zg(wZdg(kmQkm9cr,nil,"oppm"))local IE97m=owAp3u2G.dependencies
for wey=1,#IE97m do local hThO6=IE97m[wey]
if
hThO6.name==LoW_7e then mLgQ=false;for zXU=1,#pfyhF do local HmJym2=pfyhF[zXU]
if HmJym2.name==kmQkm9cr then mLgQ=true;break end end
if not mLgQ then
for Jjb7Am5=1,#pglFz82w do
local UwqY7A=pglFz82w[Jjb7Am5]if UwqY7A.name==kmQkm9cr then
mMp.fatal("Circular dependencies detected: "..tostring(kmQkm9cr))end end
V:getPackageDependants({kmQkm9cr},pfyhF,pglFz82w)end end end end else
mMp.fatal("Package "..
tostring(LoW_7e).." is referenced as a dependant of another package, however, this package isn't installed.")end;pglFz82w[#pglFz82w]=nil end end;return pfyhF end
V.whatDependsOn=function(V,k)local d7gPKcw=Zg(wZdg(k,nil,"oppm"))local naeNp={}
local gA=Zg(d3fMjkg(XxJ(_,"oppm")))
for r in gA do d7gPKcw=Zg(wZdg(r,nil,"oppm"))
local LWe=d7gPKcw.dependencies;for _3Tq=1,#LWe do local Rq1hByv=LWe[_3Tq]
if Rq1hByv.name==k then y06X3k(naeNp,r)end end end;return naeNp end
V.install=SJsW11k(function(V,...)local iFk={...}local sEFtmNgB=el.r or el.reinstall
local qxiez0Cn=el.s or el.save;local Ck_H=Zg(V:resolveDependencies(iFk))
qTDt({install=(function()local _QFw_It={}
local WLqHf=1;for vN=1,#Ck_H do local BIwW6_=Ck_H[vN]
if
not sEFtmNgB or not iPL3B4cr(BIwW6_,iFk)then _QFw_It[WLqHf]=BIwW6_;WLqHf=WLqHf+1 end end
return _QFw_It end)(),reinstall=
sEFtmNgB and
(function()local Vdfc3={}local CzM7PG=1
for RKf6s5=1,#Ck_H do local tP9E_=Ck_H[RKf6s5]if iPL3B4cr(tP9E_,iFk)then
Vdfc3[CzM7PG]=tP9E_;CzM7PG=CzM7PG+1 end end;return Vdfc3 end)()or nil})local Sc={filesInstalled=0,packagesInstalled=0}
if sEFtmNgB then local Y1WX
do local G06Z2={}local K=1
for tQx9TV=1,#iFk do
local FL7g2o=iFk[tQx9TV]G06Z2[K]=Zg(wZdg(FL7g2o,nil,"oppm"))K=K+1 end;Y1WX=G06Z2 end;V:_remove(Y1WX,true,false)end
for dkh7Tt9=1,#Ck_H do local XiNd_H=Ck_H[dkh7Tt9]
mMp.print("Installing '"..tostring(XiNd_H).."'...")local Q_c4px86;if qxiez0Cn then
Q_c4px86="./"..tostring(XiNd_H).."/"else Q_c4px86="/"end
local _F6VYt,ITv3PH1i=V:rawInstall(XiNd_H,Q_c4px86,iPL3B4cr(XiNd_H,iFk),qxiez0Cn)
Sc.filesInstalled=Sc.filesInstalled+ITv3PH1i.filesInstalled
Sc.packagesInstalled=Sc.packagesInstalled+ITv3PH1i.packagesInstalled
if Sc.packagesInstalled~=0 then local _5fF,OUQqQp=iW6CD(_F6VYt,"oppm")
if _5fF then
mMp.info(
"Saved the manifest of '"..tostring(_F6VYt.name).."'.")else
mMp.fatal("Couldn't save the manifest of '"..tostring(_F6VYt.name)..
"': "..tostring(OUQqQp)..".")end end end
mMp.print("- "..
tostring(Sc.packagesInstalled).." package"..
tostring(N5UjTN(Sc.packagesInstalled)).." installed.")return
mMp.print("- "..
tostring(Sc.filesInstalled).." file"..
tostring(N5UjTN(Sc.filesInstalled)).." installed.")end)
V.remove=SJsW11k(function(V,...)local OyOfzTWn={...}local rx={}for ijvSrZA1=1,#OyOfzTWn do local STNuSN6=OyOfzTWn[ijvSrZA1]local PYOeGnAZ=Zg(wZdg(STNuSN6,
nil,"oppm"))
y06X3k(rx,PYOeGnAZ)end;return
V:_remove(rx,false)end)
V._remove=function(V,s10ar5XH,YoKhvIs,I2ipE)if YoKhvIs==nil then YoKhvIs=false end
if I2ipE==nil then I2ipE=true end;local qS730I
if not
CM.get("oppm",{},true).get("remove_dependants",true)or not I2ipE then
do
local PYEbnua={}local Um4ZYiT=1
for AF=1,#s10ar5XH do local shIHW=s10ar5XH[AF]
PYEbnua[Um4ZYiT]={name=shIHW.name,manifest=shIHW}Um4ZYiT=Um4ZYiT+1 end;qS730I=PYEbnua end else
qS730I=V:getPackageDependants((function()local H5={}local HYY=1;for C3=1,#s10ar5XH do local SkCMMH=s10ar5XH[C3]
H5[HYY]=SkCMMH.name;HYY=HYY+1 end;return H5 end)())end
if not(YoKhvIs)then
qTDt({remove=(function()local kvvs={}local _yTx3S94=1;for Mm=1,#qS730I do local g524=qS730I[Mm]
kvvs[_yTx3S94]=tostring(g524.name)_yTx3S94=_yTx3S94+1 end
return kvvs end)()})end
for WUdVeYc=1,#qS730I do local lHep6wo=qS730I[WUdVeYc]
mMp.print("Removing '"..
tostring(lHep6wo.manifest.name).."' ...")
Zg(MwwN.__parent.remove(V,lHep6wo.manifest,"oppm"))end;return true end
V.cache=SJsW11k(function(V,BKZsJ,...)local Sw=BKZsJ
if"update"==Sw then
mMp.print("Updating OpenPrograms program cache ...")Zg(V:updateCache())return mMp.print("Done.")elseif"fix"==Sw then
mMp.print("Fixing OpenPrograms program cache ...")Zg(V:fixCache())return mMp.print("Done.")else
mMp.error("Unknown command.")return mMp.print("Usage: hpm oppm:cache {update|fix}")end end)
V.autoremove=SJsW11k(function(V)local W67mm9p6={}local oBxdTi6u={}
local T7hLe5j=Zg(d3fMjkg(XxJ(_,"oppm")))
for I_ in T7hLe5j do local J2Jin=Zg(wZdg(I_,nil,"oppm"))if not(J2Jin.manual)then
local Rvg=V:getPackageDependants(I_)
if#Rvg==1 then y06X3k(W67mm9p6,I_)y06X3k(oBxdTi6u,I_)end end end
while true do local HpdA=false;T7hLe5j=Zg(d3fMjkg(XxJ(_,"oppm")))
for DsAJbW in
T7hLe5j do
if not(iPL3B4cr(DsAJbW,W67mm9p6))then
local AXfX=Zg(wZdg(DsAJbW,nil,"oppm"))
if not(AXfX.manual)then local btcUUhB=V:getPackageDependants(DsAJbW)
table.remove(btcUUhB,1)
if
PG((function()local iw0S={}local Tjg=1;for n2srE7H=1,#btcUUhB do local Rf=btcUUhB[n2srE7H]
iw0S[Tjg]=iPL3B4cr(Rf.name,W67mm9p6)Tjg=Tjg+1 end;return iw0S end)())then
for X9ZjrTz=1,#btcUUhB do local tYFIuD=btcUUhB[X9ZjrTz]
local Ht5Ge,l=iPL3B4cr(tYFIuD.name,oBxdTi6u)if l then table.remove(oBxdTi6u,l)end end;y06X3k(W67mm9p6,DsAJbW)y06X3k(oBxdTi6u,DsAJbW)HpdA=true end end end end;if not(HpdA)then break end end
qTDt({remove=(function()
if#W67mm9p6 >0 then local IO={}local YDJY=1
for t=1,#W67mm9p6 do local Rdi8NIft=W67mm9p6[t]IO[YDJY]="oppm:"..
tostring(Rdi8NIft)YDJY=YDJY+1 end;return IO else return nil end end)()})for J0uTkQ9=1,#oBxdTi6u do local sd6k=oBxdTi6u[J0uTkQ9]
V:_remove({Zg(wZdg(sd6k,nil,"oppm"))},false)end
mMp.print("Done.")return true end)if oZ9.__inherited then oZ9.__inherited(oZ9,MwwN)end
sgeP.oppm=MwwN end;local v
v=function()local a=Zg(d3fMjkg(_))Oh=true
for lK7 in a do local KWMxs7a=JQi1jg.name(lK7)
if
u(XxJ(_,KWMxs7a))then local T=Zg(d3fMjkg(XxJ(_,KWMxs7a)))
for LBIp4 in T do
if not
(u(XxJ(_,KWMxs7a,LBIp4)))then local A5=Zg(wZdg(LBIp4,nil,KWMxs7a))
mMp.print(
KWMxs7a..":"..LBIp4 ..
(A5.version and" @ "..A5.version or""))Oh=false end end end end
if Oh then return mMp.print("No packages installed.")end end;local Ta
Ta=function(...)Wu_uIt,el=YAtG_LV3(...)if#Wu_uIt<1 then return z()end end;local unArcvQl
unArcvQl=function()local PV168s0f=Wu_uIt[1]
if"list"==PV168s0f then return v()elseif"help"==PV168s0f then return z()else
do
local bjK=y(Wu_uIt[1])
if bjK then
return
bjK(ivnJjrA((function()local Us1Xh={}local rs59=1;for R=2,#Wu_uIt do local rGa2MaGH=Wu_uIt[R]Us1Xh[rs59]=rGa2MaGH;rs59=
rs59+1 end;return Us1Xh end)()))end end end end;Ta(...)Zg(gad4ZcL())OO()unArcvQl()return RkGFh6;
local s=load([===[
local rA5U=20160728.17
local Uc06="-[ JSON.lua package by Jeffrey Friedl (http://regex.info/blog/lua/json) version 20160728.17 ]-"local lcBL={VERSION=rA5U,AUTHOR_NOTE=Uc06}local DHPxI=" "
local dx={pretty=true,align_keys=false,indent=DHPxI}
local RRuSHnxf={__tostring=function()return"JSON array"end}RRuSHnxf.__index=RRuSHnxf
local mcYOuT={__tostring=function()return"JSON object"end}mcYOuT.__index=mcYOuT;function lcBL:newArray(iXxD6s)
return setmetatable(iXxD6s or{},RRuSHnxf)end;function lcBL:newObject(oiY)return
setmetatable(oiY or{},mcYOuT)end;local function Rr(FsYIVlkf)
return
type(FsYIVlkf)=='number'and FsYIVlkf or FsYIVlkf.N end
local scRP0={__index=isNumber,__tostring=function(HLXS0Q_)return HLXS0Q_.S end,__unm=function(Kw)return
Rr(Kw)end,__concat=function(nvaIsNv7,vDnoL55)
return tostring(nvaIsNv7)..tostring(vDnoL55)end,__add=function(xlAK,zr1y)return Rr(xlAK)+Rr(zr1y)end,__sub=function(Hs,jk)return
Rr(Hs)-Rr(jk)end,__mul=function(qzSFyIO,Z65)
return Rr(qzSFyIO)*Rr(Z65)end,__div=function(umyCNfj,FT)return Rr(umyCNfj)/Rr(FT)end,__mod=function(YVLXYq,bJfct)return
Rr(YVLXYq)%Rr(bJfct)end,__pow=function(OhuFpq_N,Dzg)return
Rr(OhuFpq_N)^Rr(Dzg)end,__lt=function(_4O,C)return Rr(_4O)<Rr(C)end,__eq=function(fLI2zRe,_Fr2YU)return
Rr(fLI2zRe)==Rr(_Fr2YU)end,__le=function(Xfn,U)return
Rr(Xfn)<=Rr(U)end}
function lcBL:asNumber(Ebsw)
if getmetatable(Ebsw)==scRP0 then return Ebsw elseif
type(Ebsw)=='table'and
type(Ebsw.S)=='string'and type(Ebsw.N)=='number'then return setmetatable(Ebsw,scRP0)else
local UlikV={S=tostring(Ebsw),N=tonumber(Ebsw)}return setmetatable(UlikV,scRP0)end end
local function AI0R2TQ6(JtAjijkG)
if JtAjijkG<=127 then return string.char(JtAjijkG)elseif JtAjijkG<=2047 then
local s=math.floor(JtAjijkG/0x40)local YAtG_LV3=JtAjijkG- (0x40*s)return
string.char(0xC0+s,0x80+YAtG_LV3)elseif JtAjijkG<=65535 then
local LfEJbh_=math.floor(JtAjijkG/0x1000)local JD=JtAjijkG-0x1000*LfEJbh_
local u=math.floor(JD/0x40)local pzDMZwG=JD-0x40*u;LfEJbh_=0xE0+LfEJbh_;u=0x80+u
pzDMZwG=0x80+pzDMZwG
if
(LfEJbh_==0xE0 and u<0xA0)or
(LfEJbh_==0xED and u>0x9F)or(LfEJbh_==0xF0 and u<0x90)or(LfEJbh_==0xF4 and u>0x8F)then return"?"else return string.char(LfEJbh_,u,pzDMZwG)end else local XPoQB=math.floor(JtAjijkG/0x40000)
local XxJ=JtAjijkG-0x40000*XPoQB;local o5sms=math.floor(XxJ/0x1000)
XxJ=XxJ-0x1000*o5sms;local JQi1jg=math.floor(XxJ/0x40)local wVzn=XxJ-0x40*JQi1jg
return string.char(
0xF0+XPoQB,0x80+o5sms,0x80+JQi1jg,0x80+wVzn)end end
function lcBL:onDecodeError(pE,RSjapQ,QJf,zC)if RSjapQ then
if QJf then
pE=string.format("%s at char %d of: %s",pE,QJf,RSjapQ)else pE=string.format("%s: %s",pE,RSjapQ)end end
if zC~=nil then pE=pE.." ("..
lcBL:encode(zC)..")"end
if self.assert then self.assert(false,pE)else assert(false,pE)end end;lcBL.onDecodeOfNilError=lcBL.onDecodeError
lcBL.onDecodeOfHTMLError=lcBL.onDecodeError
function lcBL:onEncodeError(pfZ3SPy_,pDNa2ox6)
if pDNa2ox6 ~=nil then pfZ3SPy_=pfZ3SPy_..
" ("..lcBL:encode(pDNa2ox6)..")"end;if self.assert then self.assert(false,pfZ3SPy_)else
assert(false,pfZ3SPy_)end end
local function yA(Do6yo7nm,y06X3k,ivnJjrA,d3fMjkg)
local el=y06X3k:match('^-?[1-9]%d*',ivnJjrA)or y06X3k:match("^-?0",ivnJjrA)if not el then
Do6yo7nm:onDecodeError("expected number",y06X3k,ivnJjrA,d3fMjkg.etc)end
local Wu_uIt=ivnJjrA+el:len()local w=y06X3k:match('^%.%d+',Wu_uIt)or""Wu_uIt=Wu_uIt+
w:len()
local sgeP=y06X3k:match('^[eE][-+]?%d+',Wu_uIt)or""Wu_uIt=Wu_uIt+sgeP:len()local CM=el..w..sgeP;if
d3fMjkg.decodeNumbersAsObjects then return lcBL:asNumber(CM),Wu_uIt end
if
(
d3fMjkg.decodeIntegerStringificationLength and(el:len()>=d3fMjkg.decodeIntegerStringificationLength or
sgeP:len()>0))or
(d3fMjkg.decodeDecimalStringificationLength and
(
w:len()>=d3fMjkg.decodeDecimalStringificationLength or sgeP:len()>0))then return CM,Wu_uIt end;local Qlmlet=tonumber(CM)if not Qlmlet then
Do6yo7nm:onDecodeError("bad number",y06X3k,ivnJjrA,d3fMjkg.etc)end;return Qlmlet,Wu_uIt end
local function XmVolesU(_,RkGFh6,hw18,nvCiFt7r)if RkGFh6:sub(hw18,hw18)~='"'then
_:onDecodeError("expected string's opening quote",RkGFh6,hw18,nvCiFt7r.etc)end;local xSebv5Jc=hw18+1
local mMp=RkGFh6:len()local rDtVf=""
while xSebv5Jc<=mMp do local vj=RkGFh6:sub(xSebv5Jc,xSebv5Jc)if
vj=='"'then return rDtVf,xSebv5Jc+1 end
if vj~='\\'then rDtVf=rDtVf..vj;xSebv5Jc=
xSebv5Jc+1 elseif RkGFh6:match('^\\b',xSebv5Jc)then rDtVf=rDtVf.."\b"xSebv5Jc=
xSebv5Jc+2 elseif RkGFh6:match('^\\f',xSebv5Jc)then rDtVf=rDtVf.."\f"xSebv5Jc=
xSebv5Jc+2 elseif RkGFh6:match('^\\n',xSebv5Jc)then rDtVf=rDtVf.."\n"xSebv5Jc=
xSebv5Jc+2 elseif RkGFh6:match('^\\r',xSebv5Jc)then rDtVf=rDtVf.."\r"xSebv5Jc=
xSebv5Jc+2 elseif RkGFh6:match('^\\t',xSebv5Jc)then rDtVf=rDtVf.."\t"xSebv5Jc=
xSebv5Jc+2 else
local z=RkGFh6:match('^\\u([0123456789aAbBcCdDeEfF][0123456789aAbBcCdDeEfF][0123456789aAbBcCdDeEfF][0123456789aAbBcCdDeEfF])',xSebv5Jc)
if z then xSebv5Jc=xSebv5Jc+6;local Zg=tonumber(z,16)
if
Zg>=0xD800 and Zg<=0xDBFF then
local ykRppH=RkGFh6:match('^\\u([dD][cdefCDEF][0123456789aAbBcCdDeEfF][0123456789aAbBcCdDeEfF])',xSebv5Jc)
if ykRppH then xSebv5Jc=xSebv5Jc+6;Zg=0x2400+ (Zg-0xD800)*0x400+
tonumber(ykRppH,16)else end end;rDtVf=rDtVf..AI0R2TQ6(Zg)else rDtVf=rDtVf..
RkGFh6:match('^\\(.)',xSebv5Jc)xSebv5Jc=xSebv5Jc+2 end end end
_:onDecodeError("unclosed string",RkGFh6,hw18,nvCiFt7r.etc)end
local function eZ0l3ch(WQ6,y36Aetn)local iPL3B4cr,GI2hz6SK=WQ6:find("^[ \n\r\t]+",y36Aetn)if GI2hz6SK then
return GI2hz6SK+1 else return y36Aetn end end;local W_63_9
local function h9dyA_4T(Oh,PG,n,O)if PG:sub(n,n)~='{'then
Oh:onDecodeError("expected '{'",PG,n,O.etc)end;local N5UjTN=eZ0l3ch(PG,n+1)local qLH5=Oh.strictTypes and
Oh:newObject{}or{}if
PG:sub(N5UjTN,N5UjTN)=='}'then return qLH5,N5UjTN+1 end
local tE=PG:len()
while N5UjTN<=tE do local VcV0EuD,pX4gCR=XmVolesU(Oh,PG,N5UjTN,O)
N5UjTN=eZ0l3ch(PG,pX4gCR)if PG:sub(N5UjTN,N5UjTN)~=':'then
Oh:onDecodeError("expected colon",PG,N5UjTN,O.etc)end
N5UjTN=eZ0l3ch(PG,N5UjTN+1)local gad4ZcL,pX4gCR=W_63_9(Oh,PG,N5UjTN,O)qLH5[VcV0EuD]=gad4ZcL
N5UjTN=eZ0l3ch(PG,pX4gCR)local dk=PG:sub(N5UjTN,N5UjTN)
if dk=='}'then return qLH5,N5UjTN+1 end;if PG:sub(N5UjTN,N5UjTN)~=','then
Oh:onDecodeError("expected comma or '}'",PG,N5UjTN,O.etc)end
N5UjTN=eZ0l3ch(PG,N5UjTN+1)end;Oh:onDecodeError("unclosed '{'",PG,n,O.etc)end
local function oh(E,OO,y,cR6rJlAl)if OO:sub(y,y)~='['then
E:onDecodeError("expected '['",OO,y,cR6rJlAl.etc)end;local M6ilzGJ=eZ0l3ch(OO,y+1)local iW6CD=E.strictTypes and
E:newArray{}or{}if
OO:sub(M6ilzGJ,M6ilzGJ)==']'then return iW6CD,M6ilzGJ+1 end
local wZdg=1;local BaX=OO:len()
while M6ilzGJ<=BaX do
local SJsW11k,Ki1HJT=W_63_9(E,OO,M6ilzGJ,cR6rJlAl)iW6CD[wZdg]=SJsW11k;wZdg=wZdg+1;M6ilzGJ=eZ0l3ch(OO,Ki1HJT)
local wjim8xCV=OO:sub(M6ilzGJ,M6ilzGJ)if wjim8xCV==']'then return iW6CD,M6ilzGJ+1 end;if
OO:sub(M6ilzGJ,M6ilzGJ)~=','then
E:onDecodeError("expected comma or '['",OO,M6ilzGJ,cR6rJlAl.etc)end
M6ilzGJ=eZ0l3ch(OO,M6ilzGJ+1)end
E:onDecodeError("unclosed '['",OO,y,cR6rJlAl.etc)end
W_63_9=function(E,QLam,qTDt,v)qTDt=eZ0l3ch(QLam,qTDt)
if qTDt>QLam:len()then E:onDecodeError("unexpected end of string",QLam,
nil,v.etc)end
if QLam:find('^"',qTDt)then return XmVolesU(E,QLam,qTDt,v.etc)elseif
QLam:find('^[-0123456789 ]',qTDt)then return yA(E,QLam,qTDt,v)elseif QLam:find('^%{',qTDt)then
return h9dyA_4T(E,QLam,qTDt,v)elseif QLam:find('^%[',qTDt)then return oh(E,QLam,qTDt,v)elseif QLam:find('^true',qTDt)then return true,
qTDt+4 elseif QLam:find('^false',qTDt)then return false,qTDt+5 elseif
QLam:find('^null',qTDt)then return nil,qTDt+4 else
E:onDecodeError("can't parse JSON",QLam,qTDt,v.etc)end end
function lcBL:decode(Ta,u,nArcvQl)if type(nArcvQl)~='table'then nArcvQl={}end;if u~=nil then
nArcvQl.etc=u end;if
type(self)~='table'or self.__index~=lcBL then
lcBL:onDecodeError("JSON:decode must be called in method format",nil,nil,nArcvQl.etc)end
if Ta==nil then
self:onDecodeOfNilError(string.format("nil passed to JSON:decode()"),
nil,nil,nArcvQl.etc)elseif type(Ta)~='string'then
self:onDecodeError(string.format("expected string argument to JSON:decode(), got %s",type(Ta)),
nil,nil,nArcvQl.etc)end;if Ta:match('^%s*$')then return nil end;if Ta:match('^%s*<')then
self:onDecodeOfHTMLError(string.format("html passed to JSON:decode()"),Ta,
nil,nArcvQl.etc)end
if
Ta:sub(1,1):byte()==0 or
(Ta:len()>=2 and Ta:sub(2,2):byte()==0)then
self:onDecodeError("JSON package groks only UTF-8, sorry",Ta,nil,nArcvQl.etc)end;if nArcvQl.decodeNumbersAsObjects==nil then
nArcvQl.decodeNumbersAsObjects=self.decodeNumbersAsObjects end;if
nArcvQl.decodeIntegerStringificationLength==nil then
nArcvQl.decodeIntegerStringificationLength=self.decodeIntegerStringificationLength end;if
nArcvQl.decodeDecimalStringificationLength==nil then
nArcvQl.decodeDecimalStringificationLength=self.decodeDecimalStringificationLength end
local h6Ub7U,Gm=pcall(W_63_9,self,Ta,1,nArcvQl)if h6Ub7U then return Gm else
if self.assert then self.assert(false,Gm)else assert(false,Gm)end;return nil,Gm end end
local function DZXGTh(YKA7cU)
if YKA7cU=="\n"then return"\\n"elseif YKA7cU=="\r"then return"\\r"elseif YKA7cU=="\t"then return"\\t"elseif YKA7cU=="\b"then
return"\\b"elseif YKA7cU=="\f"then return"\\f"elseif YKA7cU=='"'then return'\\"'elseif YKA7cU=='\\'then return'\\\\'else return
string.format("\\u%04x",YKA7cU:byte())end end
local Su9Koz='['..'"'..
'%\\'..'%z'..'\001'..'-'..'\031'..']'local Uk7e=AI0R2TQ6(0x2028)local KwQCk_G=AI0R2TQ6(0x2029)
local function ptZa(mCsewfX,yY)
local Xf=mCsewfX:gsub(Su9Koz,DZXGTh)if yY.stringsAreUtf8 then
Xf=Xf:gsub(Uk7e,'\\u2028'):gsub(KwQCk_G,'\\u2029')end;return'"'..Xf..'"'end
local function PEqsd(UlFdiZ7v,U,wFeA)local JQgI={}local N={}local fs52REi=false;local PUNkgaiM
for X in pairs(U)do
if type(X)=='string'then
table.insert(JQgI,X)elseif type(X)=='number'then table.insert(N,X)
if X<=0 or X>=math.huge then
fs52REi=true elseif not PUNkgaiM or X>PUNkgaiM then PUNkgaiM=X end else
UlFdiZ7v:onEncodeError("can't encode table with a key of type "..type(X),wFeA)end end
if#JQgI==0 and not fs52REi then
if#N>0 then return nil,PUNkgaiM elseif
tostring(U)=="JSON array"then return nil elseif tostring(U)=="JSON object"then return{}else return nil end end;table.sort(JQgI)local s6FbB
if#N>0 then if UlFdiZ7v.noKeyConversion then
UlFdiZ7v:onEncodeError("a table with both numeric and string keys could be an object or array; aborting",wFeA)end
s6FbB={}for dc61,aguhyl in pairs(U)do s6FbB[dc61]=aguhyl end
table.sort(N)
for p,gOPDv in ipairs(N)do local aSdZU3=tostring(gOPDv)
if s6FbB[aSdZU3]==nil then
table.insert(JQgI,aSdZU3)s6FbB[aSdZU3]=U[gOPDv]else
UlFdiZ7v:onEncodeError(
"conflict converting table with mixed-type keys into a JSON object: key "..gOPDv.." exists both as a string and a number.",wFeA)end end end;return JQgI,nil,s6FbB end;local iSj
function iSj(YKDL,oFyb6OLp,oGdh_mv,WjvvK,TASVwBgU,KjUncMB,XkT)
if oFyb6OLp==nil or
(not XkT and TASVwBgU and TASVwBgU.null and oFyb6OLp==
TASVwBgU.null)then return'null'elseif
type(oFyb6OLp)=='string'then return ptZa(oFyb6OLp,TASVwBgU)elseif type(oFyb6OLp)=='number'then
if
oFyb6OLp~=oFyb6OLp then return"null"elseif oFyb6OLp>=math.huge then return"1e+9999"elseif oFyb6OLp<=-math.huge then
return"-1e+9999"else return tostring(oFyb6OLp)end elseif type(oFyb6OLp)=='boolean'then return tostring(oFyb6OLp)elseif type(oFyb6OLp)~=
'table'then
YKDL:onEncodeError("can't convert "..type(oFyb6OLp).." to JSON",WjvvK)elseif getmetatable(oFyb6OLp)==scRP0 then return tostring(oFyb6OLp)else
local c3dr=oFyb6OLp;if type(TASVwBgU)~='table'then TASVwBgU={}end;if type(KjUncMB)~=
'string'then KjUncMB=""end
if oGdh_mv[c3dr]then
YKDL:onEncodeError("table "..
tostring(c3dr).." is a child of itself",WjvvK)else oGdh_mv[c3dr]=true end;local NGH;local tIc,MD2O,HQ=PEqsd(YKDL,c3dr,WjvvK)
if MD2O then local cng={}for lE=1,MD2O do
table.insert(cng,iSj(YKDL,c3dr[lE],oGdh_mv,WjvvK,TASVwBgU,KjUncMB))end
if TASVwBgU.pretty then NGH="[ "..
table.concat(cng,", ").." ]"else NGH="["..
table.concat(cng,",").."]"end elseif tIc then local nI2F0id=HQ or c3dr
if TASVwBgU.pretty then local N4aMD_P={}local pCi=0
for lNOqUk8,YAnZNei in ipairs(tIc)do
local h8YWR44E=iSj(YKDL,tostring(YAnZNei),oGdh_mv,WjvvK,TASVwBgU,KjUncMB,true)
if TASVwBgU.align_keys then pCi=math.max(pCi,#h8YWR44E)end;table.insert(N4aMD_P,h8YWR44E)end
local NzeoQJ=KjUncMB..tostring(TASVwBgU.indent or"")
local AwGfFV=NzeoQJ..string.rep(" ",pCi)..
(TASVwBgU.align_keys and" "or"")
local wCRY="%s%"..string.format("%d",pCi).."s: %s"local d0uKSVw1={}
for VF,fTrMe in ipairs(tIc)do
local ypDndT8=iSj(YKDL,nI2F0id[fTrMe],oGdh_mv,WjvvK,TASVwBgU,AwGfFV)
table.insert(d0uKSVw1,string.format(wCRY,NzeoQJ,N4aMD_P[VF],ypDndT8))end;NGH="{\n"..
table.concat(d0uKSVw1,",\n").."\n"..KjUncMB.."}"else local MV65={}
for Y3D66Ym9,q in
ipairs(tIc)do
local PhJ=iSj(YKDL,nI2F0id[q],oGdh_mv,WjvvK,TASVwBgU,KjUncMB)
local h=iSj(YKDL,tostring(q),oGdh_mv,WjvvK,TASVwBgU,KjUncMB,true)
table.insert(MV65,string.format("%s:%s",h,PhJ))end;NGH="{"..table.concat(MV65,",").."}"end else NGH="[]"end;oGdh_mv[c3dr]=false;return NGH end end
function lcBL:encode(j2K,r8hgwQ,_6U)if type(self)~='table'or self.__index~=lcBL then
lcBL:onEncodeError("JSON:encode must be called in method format",r8hgwQ)end;if
type(_6U)~='table'then _6U={}end;return iSj(self,j2K,{},r8hgwQ,_6U)end
function lcBL:encode_pretty(GLSzBQs,c,xg)if type(self)~='table'or self.__index~=lcBL then
lcBL:onEncodeError("JSON:encode_pretty must be called in method format",c)end;if
type(xg)~='table'then xg=dx end;return iSj(self,GLSzBQs,{},c,xg)end;function lcBL.__tostring()return"JSON encode/decode package"end
lcBL.__index=lcBL
function lcBL:new(Id2KoP_G)local Y2or={}if Id2KoP_G then
for zN8ASHV5,iju in pairs(Id2KoP_G)do Y2or[zN8ASHV5]=iju end end
return setmetatable(Y2or,lcBL)end;return lcBL:new()
]===])()
local YAtG_LV3=(function()
local yY=[[ Copyright (c) The python-semanticversion project
All rights reserved.
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are met:
1. Redistributions of source code must retain the above copyright notice, this
list of conditions and the following disclaimer.
2. Redistributions in binary form must reproduce the above copyright notice,
this list of conditions and the following disclaimer in the documentation
and/or other materials provided with the distribution.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR
ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
]]
yY=[[ The use of the library is similar to the original one,
check the documentation here: https://python-semanticversion.readthedocs.io/en/latest/
]]local Xf,UlFdiZ7v,U;do local aSdZU3=table
Xf,UlFdiZ7v,U=aSdZU3.concat,aSdZU3.insert,aSdZU3.unpack end;local wFeA
wFeA=function(YKDL)
do local oFyb6OLp=tonumber(YKDL)if
oFyb6OLp then return oFyb6OLp,true else return YKDL,false end end end;local JQgI
JQgI=function(oGdh_mv)return oGdh_mv and oGdh_mv[1]=='0'and
tonumber(oGdh_mv and oGdh_mv~='0')end;local N
N=function(WjvvK,TASVwBgU)if WjvvK==TASVwBgU then return 0 end
if WjvvK>TASVwBgU then return 1 end;if WjvvK<TASVwBgU then return-1 end end;local fs52REi
fs52REi=function(KjUncMB,XkT)local c3dr,NGH=wFeA(KjUncMB)local tIc,MD2O=wFeA(XkT)
if NGH and MD2O then
return N(c3dr,tIc)elseif NGH then return-1 elseif MD2O then return 1 else return N(c3dr,tIc)end end;local PUNkgaiM
PUNkgaiM=function(HQ,cng)local lE;do local nI2F0id={}for N4aMD_P=1,#HQ do if cng[N4aMD_P]then
nI2F0id[HQ[N4aMD_P]]=cng[N4aMD_P]end end
lE=nI2F0id end
for pCi,NzeoQJ in pairs(lE)do
local AwGfFV=fs52REi(pCi,NzeoQJ)if AwGfFV~=0 then return AwGfFV end end;return N(#HQ,#cng)end;local s6FbB
do local wCRY
local d0uKSVw1={_coerce=function(YAnZNei,h8YWR44E,VF)if VF==nil then VF=false end
if h8YWR44E==nil and VF then return h8YWR44E end;return tonumber(h8YWR44E)end,next_major=function(fTrMe)
if
fTrMe.prerelease and fTrMe.minor==0 and fTrMe.patch==0 then
return
s6FbB(Xf((function()local ypDndT8={}local MV65=1
local Y3D66Ym9={fTrMe.major,fTrMe.minor,fTrMe.patch}for q=1,#Y3D66Ym9 do local PhJ=Y3D66Ym9[q]ypDndT8[MV65]=tostring(PhJ)
MV65=MV65+1 end;return ypDndT8 end)(),'.'))else
return
s6FbB(Xf((function()local h={}local j2K=1;local r8hgwQ={fTrMe.major+1,0,0}
for _6U=1,#r8hgwQ do
local GLSzBQs=r8hgwQ[_6U]h[j2K]=tostring(GLSzBQs)j2K=j2K+1 end;return h end)(),'.'))end end,next_minor=function(c)if
not(c.minor)then
error("Partial version doesn't contain the minor component!")end
if c.prerelease and c.patch==0 then
return
s6FbB(Xf((function()
local xg={}local Id2KoP_G=1;local Y2or={c.major,c.minor,c.patch}
for zN8ASHV5=1,#Y2or do
local iju=Y2or[zN8ASHV5]xg[Id2KoP_G]=tostring(iju)Id2KoP_G=Id2KoP_G+1 end;return xg end)(),'.'))else
return
s6FbB(Xf((function()local XsWgh={}local l4Hdz=1;local NSXCgSH={c.major,c.minor+1,0}
for Wq=1,#NSXCgSH do
local SbOQ=NSXCgSH[Wq]XsWgh[l4Hdz]=tostring(SbOQ)l4Hdz=l4Hdz+1 end;return XsWgh end)(),'.'))end end,next_patch=function(IiuHGo)if
not(IiuHGo.patch)then
error("Partial version doesn't contain the patch component!")end
if IiuHGo.prerelease then
return
s6FbB(Xf((function()local cGqxtYr={}
local bgJFKeeZ=1;local yu9fg0nN={IiuHGo.major,IiuHGo.minor,IiuHGo.patch}
for wgx=1,#
yu9fg0nN do local zlU7X=yu9fg0nN[wgx]
cGqxtYr[bgJFKeeZ]=tostring(zlU7X)bgJFKeeZ=bgJFKeeZ+1 end;return cGqxtYr end)(),'.'))else
return
s6FbB(Xf((function()local t={}local f6qbO=1
local kk={IiuHGo.major,IiuHGo.minor,IiuHGo.patch+1}
for QrubIAv=1,#kk do local bLHDW=kk[QrubIAv]t[f6qbO]=tostring(bLHDW)f6qbO=f6qbO+1 end;return t end)(),'.'))end end,coerce=function(YjFd7b,jZgPYb,zN2)if
zN2 ==nil then zN2=false end;local IN69pa5
IN69pa5=function(OVx_mN)
local lB,byE=OVx_mN:match('^(%d+)(.*)$')if not(lB)then return nil end;local bITCI=lB
local K,F5dtVpnN=byE:match('^%.(%d+)(.*)$')if K then byE=F5dtVpnN;bITCI=bITCI.. ('.'..K)end;local kxeBp
kxeBp,F5dtVpnN=byE:match('^%.(%d+)(.*)$')
if kxeBp then byE=F5dtVpnN;bITCI=bITCI.. ('.'..kxeBp)end;return OVx_mN,bITCI end;local UOWJ,WtalJw=IN69pa5(jZgPYb)if not(UOWJ)then
error("Version string lacks a numerical component: "..
tostring(jZgPYb))end
local JYrf2=jZgPYb:sub(1,#WtalJw)
if not zN2 then while({JYrf2:gsub('.','')})[2]<2 do JYrf2=
JYrf2 ..'.0'end end;if#WtalJw==#jZgPYb then return s6FbB(JYrf2,zN2)end;local KHDOUlRY=jZgPYb:sub(
#WtalJw+1)
KHDOUlRY=KHDOUlRY:gsub('[^a-zA-Z0-9+.-]','-')local I0JvPpn,Ce4ZE=nil,nil
if KHDOUlRY:sub(1,1)=='+'then I0JvPpn=''
Ce4ZE=KHDOUlRY:sub(2)elseif KHDOUlRY:sub(1,1)=='.'then I0JvPpn=''Ce4ZE=KHDOUlRY:sub(2)elseif
KHDOUlRY:sub(1,1)=='-'then KHDOUlRY=KHDOUlRY:sub(2)
do
local a=KHDOUlRY:find('+')if a then
I0JvPpn,Ce4ZE=KHDOUlRY:sub(1,a-1),KHDOUlRY:sub(a+1,-1)else I0JvPpn,Ce4ZE=KHDOUlRY,''end end else do local kQ=KHDOUlRY:find('+')
if kQ then I0JvPpn,Ce4ZE=KHDOUlRY:sub(1,kQ-1),KHDOUlRY:sub(
kQ+1,-1)else I0JvPpn,Ce4ZE=KHDOUlRY,''end end end;Ce4ZE=Ce4ZE:gsub('+','.')if I0JvPpn and I0JvPpn~=''then JYrf2=JYrf2 ..
('-'..I0JvPpn)end;if
Ce4ZE and Ce4ZE~=''then JYrf2=JYrf2 .. ('+'..Ce4ZE)end;return
YjFd7b.__class(JYrf2,zN2)end,parse=function(EE9LAE,iVx,eg,AQviNt)if
eg==nil then eg=false end;if AQviNt==nil then AQviNt=false end;if not iVx or
type(iVx)~='string'or iVx==''then
error("Invalid empty version string: "..
tostring(tostring(iVx)))end;local T6
if eg then
T6=EE9LAE.__class.partialVersionRe else T6=EE9LAE.__class.versionRe end;local NviN0i,BlMQce,o,dpRE,fEiXwWq=T6(EE9LAE.__class,iVx)if not NviN0i then
error(
"Invalid version string: "..tostring(iVx))end;if JQgI(NviN0i)then
error("Invalid leading zero in major: "..
tostring(iVx))end;if JQgI(BlMQce)then
error("Invalid leading zero in minor: "..
tostring(iVx))end;if JQgI(o)then
error("Invalid leading zero in patch: "..
tostring(iVx))end;NviN0i=tonumber(NviN0i)
BlMQce=EE9LAE:_coerce(BlMQce,eg)o=EE9LAE:_coerce(o,eg)
if dpRE==nil then if eg and fEiXwWq==nil then return
{NviN0i,BlMQce,o,nil,nil}else dpRE={}end elseif dpRE==''then dpRE={}else
do
local r3JzMga6={}local Tuyw=1
for FYLcr2nu in dpRE:gmatch('[^.]+')do r3JzMga6[Tuyw]=FYLcr2nu;Tuyw=Tuyw+1 end;dpRE=r3JzMga6 end;EE9LAE:_validateIdentifiers(dpRE,false)end
if fEiXwWq==nil then if eg then fEiXwWq=nil else fEiXwWq={}end elseif fEiXwWq==''then fEiXwWq={}else do
local ioS69={}local AiP=1
for S2jwpoi in fEiXwWq:gmatch('[^.]+')do ioS69[AiP]=S2jwpoi;AiP=AiP+1 end;fEiXwWq=ioS69 end
EE9LAE:_validateIdentifiers(fEiXwWq,true)end;return{NviN0i,BlMQce,o,dpRE,fEiXwWq}end,_validateIdentifiers=function(_WX9u,u0riyU,UH)if
UH==nil then UH=false end
for WNph=1,#u0riyU do local ytF=u0riyU[WNph]if not ytF then
error(
"Invalid empty identifier "..
tostring(ytF).." in "..tostring(Xf(u0riyU,'.')))end;if
ytF:sub(1,1)=='0'and
tonumber(ytF)and ytF~='0'and not UH then
error("Invalid leading zero in identifier "..tostring(ytF))end end end,__pairs=function(d)return
pairs({d.major,d.minor,d.patch,d.prerelease,d.build})end,__ipairs=function(gRm)return
ipairs({gRm.major,gRm.minor,gRm.patch,gRm.prerelease,gRm.build})end,__tostring=function(LPX0)
local g=tostring(LPX0.major)
if LPX0.minor~=nil then g=g.. ('.'..LPX0.minor)end
if LPX0.patch~=nil then g=g.. ('.'..LPX0.patch)end
if LPX0.prerelease and#LPX0.prerelease>0 or
LPX0.partial and LPX0.prerelease and#LPX0.prerelease==0 and LPX0.build==nil then g=g.. ('-'..
Xf(LPX0.prerelease,'.'))end
if
LPX0.build and#LPX0.build>0 or LPX0.partial and LPX0.build and#
LPX0.build==0 then g=g.. ('+'..Xf(LPX0.build,'.'))end;return g end,_comparsionFunctions=function(_l,qao)if
qao==nil then qao=false end;local ipUPIzc
ipUPIzc=function(J7nsK,dXbd)
if J7nsK and dXbd then
return PUNkgaiM(J7nsK,dXbd)elseif J7nsK then return-1 elseif dXbd then return 1 else return 0 end end;local N8
N8=function(vQj,sVBxyy)if vQj==sVBxyy then return 0 else return'not implemented'end end;local Gzk
Gzk=function(N9d)local S7
S7=function(bJtvRSR,aBhZK5)if bJtvRSR==nil or aBhZK5 ==nil then return 0 else
return N9d(bJtvRSR,aBhZK5)end end;return S7 end;if qao then return{N,Gzk(N),Gzk(N),Gzk(ipUPIzc),Gzk(N8)}else return
{N,N,N,ipUPIzc,N8}end end,__compare=function(Jz8JUscj,OtGmbAgE)
local oU_r=Jz8JUscj:_comparsionFunctions(
Jz8JUscj.partial or OtGmbAgE.partial)
local n_lv={{oU_r[1],Jz8JUscj.major,OtGmbAgE.major},{oU_r[2],Jz8JUscj.minor,OtGmbAgE.minor},{oU_r[3],Jz8JUscj.patch,OtGmbAgE.patch},{oU_r[4],Jz8JUscj.prerelease,OtGmbAgE.prerelease},{oU_r[5],Jz8JUscj.build,OtGmbAgE.build}}
for UYQF=1,#n_lv do local WXx=n_lv[UYQF]local W4EuxJXi,BlYNd61h,XDPndG=U(WXx)
local sJYFQIP4=W4EuxJXi(BlYNd61h,XDPndG)if sJYFQIP4 ~=0 then return sJYFQIP4 end end;return 0 end,__compareHelper=function(Ogq0S2,n8Cw3SR,GJqd7gt,slE5aDm2)
local aL_g=Ogq0S2:__compare(n8Cw3SR)if aL_g=='not implemented'then return slE5aDm2 end
return GJqd7gt(aL_g)end,__eq=function(IMUI10L,vPA)
local pUXZ6G4;pUXZ6G4=function(mk)return mk==0 end;return
IMUI10L:__compareHelper(vPA,pUXZ6G4,false)end,__lt=function(OeQex1U4,i0cV9)
local EGD;EGD=function(VWiGCreH)return VWiGCreH<0 end;return
OeQex1U4:__compareHelper(i0cV9,EGD,false)end,__le=function(B_kkL,uEO6Y)
local i_053JPY;i_053JPY=function(l)return l<=0 end;return
B_kkL:__compareHelper(uEO6Y,i_053JPY,false)end}d0uKSVw1.__index=d0uKSVw1
wCRY=setmetatable({__init=function(UK,NzaICo,k1X83nYm)
if k1X83nYm==nil then k1X83nYm=false end;local xxzxfj,_ad1m4I,H1QsS,rIMx,TiA=U(UK:parse(NzaICo,k1X83nYm))
UK.major,UK.minor,UK.patch,UK.prerelease,UK.build,UK.partial=xxzxfj,_ad1m4I,H1QsS,rIMx,TiA,k1X83nYm end,__base=d0uKSVw1,__name="Version"},{__index=d0uKSVw1,__call=function(Y51P,...)
local ichL=setmetatable({},d0uKSVw1)Y51P.__init(ichL,...)return ichL end})d0uKSVw1.__class=wCRY;local lNOqUk8=wCRY
lNOqUk8.versionRe=function(lNOqUk8,NOK)
local Alv,YeLO2,CkrmO,ooovsSJe=NOK:match('^(%d+)%.(%d+)%.(%d+)(.*)$')if not(Alv)then return nil end
local s5IsD,KvYEVoXt=ooovsSJe:match('^%-([0-9a-zA-z.-]+)(.*)$')if s5IsD then ooovsSJe=KvYEVoXt end;local VWWD_P
VWWD_P,KvYEVoXt=ooovsSJe:match('^%+([0-9a-zA-Z.-]+)(.*)$')if VWWD_P then ooovsSJe=KvYEVoXt end;if#ooovsSJe>0 then return nil end;return
Alv,YeLO2,CkrmO,s5IsD,VWWD_P end
lNOqUk8.partialVersionRe=function(lNOqUk8,zsMuNkv)local aXxi,Q18a7QTy=zsMuNkv:match('^(%d+)(.*)$')if
not(aXxi)then return nil end
local K5Rp6,GTIA=Q18a7QTy:match('^%.(%d+)(.*)$')if K5Rp6 then Q18a7QTy=GTIA end;local gdPUe
gdPUe,GTIA=Q18a7QTy:match('^%.(%d+)(.*)$')if gdPUe then Q18a7QTy=GTIA end;local _bxEn
_bxEn,GTIA=Q18a7QTy:match('^%-([0-9a-zA-Z.-]*)(.*)$')if _bxEn then Q18a7QTy=GTIA end;local pcN_ceXY
pcN_ceXY,GTIA=Q18a7QTy:match('^%+([0-9a-zA-Z.-]*)(.*)$')if pcN_ceXY then Q18a7QTy=GTIA end;if#Q18a7QTy>0 then return nil end;return aXxi,
K5Rp6,gdPUe,_bxEn,pcN_ceXY end;s6FbB=wCRY end;local X
do local _P
local rq={parse=function(I,RAAJAsR)if
not RAAJAsR or type(RAAJAsR)~='string'or RAAJAsR==''then
error("Invalid empty requirement specification: "..tostring(tostring(RAAJAsR)))end;if RAAJAsR==
'*'then return{I.__class.KIND_ANY,''}end
local c1pjj7,BMv=I.__class:reSpec(RAAJAsR)if not c1pjj7 then
error("Invalid requirement specification: "..tostring(RAAJAsR))end;c1pjj7=
I.__class.KIND_ALIASES[c1pjj7]or c1pjj7;local NQh8=s6FbB(BMv,true)
if
NQh8.build~=nil and c1pjj7 ~=I.__class.KIND_EQUAL and c1pjj7 ~=
I.__class.KIND_NEQ then
error(
"Invalid requirement specification "..tostring(RAAJAsR)..": build numbers have no ordering")end;return{c1pjj7,NQh8}end,match=function(P,bkTe)
local ohmPbyDd=P.kind
if P.__class.KIND_ANY==ohmPbyDd then return true elseif P.__class.KIND_LT==ohmPbyDd then return bkTe<
P.spec elseif P.__class.KIND_LTE==ohmPbyDd then return bkTe<=P.spec elseif
P.__class.KIND_EQUAL==ohmPbyDd then return bkTe==P.spec elseif P.__class.KIND_GTE==ohmPbyDd then return bkTe>=
P.spec elseif P.__class.KIND_GT==ohmPbyDd then return bkTe>P.spec elseif
P.__class.KIND_NEQ==ohmPbyDd then return bkTe~=P.spec elseif P.__class.KIND_CARET==ohmPbyDd then
return
P.spec<=bkTe and bkTe<P.spec:next_major()elseif P.__class.KIND_TILDE==ohmPbyDd then return P.spec<=bkTe and
bkTe<P.spec:next_minor()else return
error("Unexpected match kind: "..tostring(P.kind))end end,__tostring=function(D)return
tostring(D.kind)..tostring(D.spec)end,__eq=function(DfDLWkT,MTU8HP4d)return
DfDLWkT.kind==MTU8HP4d.kind and DfDLWkT.spec==MTU8HP4d.spec end}rq.__index=rq
_P=setmetatable({__init=function(hIM_cG0i,jD)
hIM_cG0i.kind,hIM_cG0i.spec=U(hIM_cG0i:parse(jD))end,__base=rq,__name="SpecItem"},{__index=rq,__call=function(me,...)
local sgU5HAMG=setmetatable({},rq)me.__init(sgU5HAMG,...)return sgU5HAMG end})rq.__class=_P;local mo=_P;mo.KIND_ANY='*'mo.KIND_LT='<'mo.KIND_LTE='<='
mo.KIND_EQUAL='=='mo.KIND_SHORTEQ='='mo.KIND_EMPTY=''mo.KIND_GTE='>='mo.KIND_GT='>'
mo.KIND_NEQ='!='mo.KIND_CARET='^'mo.KIND_TILDE='~'
mo.KIND_ALIASES={[mo.__class.KIND_SHORTEQ]=mo.__class.KIND_EQUAL,[mo.__class.KIND_EMPTY]=mo.__class.KIND_EQUAL}
mo.reSpec=function(mo,FDydY)local PEZ_,c=FDydY:match('^(.-)(%d.*)$')
if not
(
PEZ_=='<'or PEZ_=='<='or PEZ_==''or PEZ_=='='or PEZ_=='=='or PEZ_=='>='or PEZ_=='>'or PEZ_=='!='or PEZ_=='^'or PEZ_=='~')then return nil else
return PEZ_,c end end;X=_P end;local dc61
do local ElbTbcZG
local r3={parse=function(pUiVYRok,jvPsY9)local tEBmuypm={}local hW=1;for iOcgdUx in jvPsY9:gmatch('[^,]+')do
tEBmuypm[hW]=X(iOcgdUx)hW=hW+1 end;return tEBmuypm end,match=function(kCwLIk,_l)
local rjQ=kCwLIk.specs
for Euo0=1,#rjQ do local LIV=rjQ[Euo0]if not LIV:match(_l)then return false end end;return true end,filter=function(vydlAbZ3,BXxv5z)
local mKLU=0
return function()
while true do mKLU=mKLU+1;local Him=BXxv5z[mKLU]if not(Him)then return nil end;if
vydlAbZ3:match(Him)then return Him end end end end,select=function(cPDhu,UQnOS)
local tRWU
do local X2Zy_nb={}local ITtw3N7E=1;for yozOp in cPDhu:filter(UQnOS)do X2Zy_nb[ITtw3N7E]=yozOp;ITtw3N7E=
ITtw3N7E+1 end;tRWU=X2Zy_nb end
if#tRWU>0 then local wxU=tRWU[1]for kOmS5sy=1,#tRWU do local CLSdD=tRWU[kOmS5sy]
if wxU<CLSdD then wxU=CLSdD end end;return wxU else return nil end end,__index=function(Fh,IlAPA)if
Fh:match(IlAPA)then return true else return nil end end,__pairs=function(jLKMpQuK)return
pairs(jLKMpQuK.specs)end,__ipairs=function(sUQpby)return ipairs(sUQpby.specs)end,__tostring=function(mbA)
return
Xf((function()
local _qPhpaFx={}local zex=1;local pPGcdu=mbA.specs;for rjp=1,#pPGcdu do local cT2z=pPGcdu[rjp]
_qPhpaFx[zex]=tostring(cT2z)zex=zex+1 end;return _qPhpaFx end)(),',')end,__eq=function(zke1tWps,gRFA)
local jX9a0tJX=zke1tWps.specs
for YFy4TGc=1,#jX9a0tJX do local YjpbYkCb=jX9a0tJX[YFy4TGc]local L1p7luJ=false;local eH=gRFA.specs
for WpOZ=1,#eH do
local fD2289=eH[WpOZ]if YjpbYkCb==fD2289 then L1p7luJ=true;break end end;if not L1p7luJ then return false end end;return true end}r3.__index=r3
ElbTbcZG=setmetatable({__init=function(folfO,vtsK)
if type(vtsK)=='string'then vtsK={vtsK}end;local E1p4Mv
do local IHap={}local rDvV=1;for RX1L2q=1,#vtsK do local bCBtWguf=vtsK[RX1L2q]
IHap[rDvV]=folfO:parse(bCBtWguf)rDvV=rDvV+1 end;E1p4Mv=IHap end;folfO.specs={}
for q=1,#E1p4Mv do local e1sXUN4f=E1p4Mv[q]for x=1,#e1sXUN4f do local VP=e1sXUN4f[x]
UlFdiZ7v(folfO.specs,VP)end end end,__base=r3,__name="Spec"},{__index=r3,__call=function(IQwqq,...)
local Xcc4=setmetatable({},r3)IQwqq.__init(Xcc4,...)return Xcc4 end})r3.__class=ElbTbcZG;dc61=ElbTbcZG end;local aguhyl
aguhyl=function(fqw5,qnVfOeRE)return N(s6FbB(fqw5,s6FbB(qnVfOeRE)))end;local p
p=function(YIiSKsxK,Ua)return dc61(YIiSKsxK):match(s6FbB(Ua))end;local gOPDv;gOPDv=function(qeJtG)
return({s6FbB:parse(qeJtG)})[1]end;return
{Spec=dc61,SpecItem=X,Version=s6FbB,compare=aguhyl,match=p,validate=gOPDv}end)()local LfEJbh_;LfEJbh_=require("component").isAvailable;local JD,u
do
local pdpNgBcZ=require("shell")JD,u=pdpNgBcZ.parse,pdpNgBcZ.getWorkingDirectory end;local pzDMZwG=require("shell")local XPoQB,XxJ,o5sms,JQi1jg,wVzn;do
local wV=require("filesystem")
XPoQB,XxJ,o5sms,JQi1jg,wVzn=wV.isDirectory,wV.exists,wV.makeDirectory,wV.concat,wV.copy end
local pE=require("filesystem")local RSjapQ,QJf;do local rLd=require("serialization")
RSjapQ,QJf=rLd.serialize,rLd.unserialize end;local zC
zC=require("event").pull;local pfZ3SPy_,pDNa2ox6,Do6yo7nm;do local z8oF=require("term")
pfZ3SPy_,pDNa2ox6,Do6yo7nm=z8oF.clearLine,z8oF.getCursor,z8oF.clear end;local y06X3k;y06X3k=os.exit
local ivnJjrA,d3fMjkg
do local DB6A7N=io;ivnJjrA,d3fMjkg=DB6A7N.write,DB6A7N.stderr end;local el,Wu_uIt
do local VhYX=table;el,Wu_uIt=VhYX.insert,VhYX.unpack end;local w=pE.list;local sgeP,CM={},{}local Qlmlet=nil;local _={}local RkGFh6={}local hw18={}
local nvCiFt7r="/etc/hpm/module/"local xSebv5Jc="/var/lib/hpm/dist/"local mMp=0;local rDtVf="/etc/hpm/hpm.cfg"
local vj=[[Usage: hpm OPTIONS COMMAND
See `man hpm` for more info.]]
local z=[[-- << Global settings >> -------------------------------------------------------
-- A directory where package manifests will be placed.
-- It will be created if it doesn't exist.
dist = "/var/lib/hpm/dist"
-- A place where to search for custom hpm modules.
-- It will be created if it doesn't exist.
modules = "/etc/hpm/module"
-- << Settings related to the hel module >> ------------------------------------
hel = {}
-- If set to `false`, hpm will *only* remove a package that hpm is told to
-- remove. Otherwise, all of its dependants will be also removed.
hel.remove_dependants = true
-- << Settings related to the oppm module >> -----------------------------------
oppm = {}
-- A cache file where package manifests will be stored for faster access.
oppm.cache_file = "/var/cache/hpm/oppm"
-- See hel.remove_dependants above.
oppm.remove_dependants = true]]
local Zg={info=function(...)
if sgeP.v then
return
print(table.concat((function(...)local Ha7ErH={}local rjU95v=1;local sxBl={...}for m=1,#sxBl do local nD4LhX6z=sxBl[m]
Ha7ErH[rjU95v]=tostring(nD4LhX6z)rjU95v=rjU95v+1 end;return Ha7ErH end)(...),"\t"))end end,print=function(...)
if
not(sgeP.q)then
return
print(table.concat((function(...)local iN={}local Lq=1;local s9tW={...}for R61K=1,#s9tW do local Jf4os=s9tW[R61K]
iN[Lq]=tostring(Jf4os)Lq=Lq+1 end;return iN end)(...),"\t"))end end,error=function(...)
if
not(sgeP.q)then
return
d3fMjkg:write(
table.concat((function(...)local a4xc={}local e=1;local la5={...}for i=1,#la5 do local R=la5[i]
a4xc[e]=tostring(R)e=e+1 end;return a4xc end)(...),"\t")..'\n')end end,fatal=function(...)
if
not(sgeP.q)then
d3fMjkg:write(
table.concat((function(...)local xWVu={}local Yw8Yxix=1;local i={...}
for VoXG=1,#i do
local JL0I04c=i[VoXG]xWVu[Yw8Yxix]=tostring(JL0I04c)Yw8Yxix=Yw8Yxix+1 end;return xWVu end)(...),"\t")..'\n')end;return y06X3k(1)end}local ykRppH
ykRppH=function(En6r_K97,T4AA)if not(En6r_K97)then return Zg.fatal(T4AA)end end;local WQ6
WQ6=function(VnuCKTdu)return
Zg.fatal((tostring(VnuCKTdu))..": Not implemented yet!")end;local y36Aetn
y36Aetn=function()ivnJjrA(vj)return y06X3k(0)end;local iPL3B4cr
iPL3B4cr=function(XnNgn,H1JD)if not(XnNgn)then Zg.fatal(H1JD)end;return XnNgn end;local GI2hz6SK
GI2hz6SK=function(gEEa9I,ULLLDUm,e4F3)
if not(type(gEEa9I==ULLLDUm))then
Zg.fatal("Value '"..
tostring(gEEa9I)..
"' is "..tostring(type(e4F3))..
", however, a "..tostring(ULLLDUm).." is expected.")end;return e4F3 end;local Oh;Oh=function(GsfNt7)
return GI2hz6SK(GsfNt7,"number",tonumber(GsfNt7))end;local PG
PG=function(fF0)return
GI2hz6SK(fF0,"string",tostring(fF0))end;local n
n=function(YWPfQKb2,r)
for OS0Zp3i,BK in pairs(r)do if BK==YWPfQKb2 then return true,OS0Zp3i end end;return false end;local O
O=function(Idjbe70)local B=0;for nDjt,NVWt in pairs(Idjbe70)do B=B+1 end;return B end;local N5UjTN
N5UjTN=function(efuUGMh)
if type(efuUGMh)=="nil"then return true elseif type(efuUGMh)=="string"then return
not efuUGMh or#efuUGMh<1 elseif type(efuUGMh)=="table"then return
not efuUGMh or O(efuUGMh)<1 else return true end end;local qLH5
qLH5=function(p4nNp)
for VW=1,#p4nNp do local Zt=p4nNp[VW]if not Zt then return false end end;return true end;local tE
tE=function(V)return XxJ(V)and XPoQB(V)end;local VcV0EuD
VcV0EuD=function(mzeTI)return XxJ(mzeTI)and not XPoQB(mzeTI)end;local pX4gCR
pX4gCR=function(sy4J)return sy4J==1 and""or"s"end;local gad4ZcL
gad4ZcL=function(ztJhP_u8)return ztJhP_u8 ~=1 and""or"s"end;local dk
dk=function(D)return D==1 and"is"or"are"end;local E
E=function(XIcl)return XIcl:match("^([^:]-):?([^:@]+)@?([^:@]*)$")end;local OO
OO=function(ys)
if
pE.get(pzDMZwG.resolve(ys)).isReadOnly()then return false,"the path is readonly!"elseif not XxJ(ys)then
return false,"the filesystem node doesn't exist."else
if not(XPoQB(ys)or pE.isLink(ys))then
return pE.remove(ys)else
for rMQ1um8 in iPL3B4cr(w(ys))do OO(JQi1jg(ys,rMQ1um8))end;return pE.remove(ys)end end end;local y
y=function()local U2=sgeP.c or sgeP.config or rDtVf
if
not VcV0EuD(U2)then local Z=pE.path(U2)
if not tE(Z)then local B58,PYVzrNl=o5sms(Z)if not B58 then
return false,"Failed to create '"..
tostring(Z).."' directory for the config file: "..tostring(PYVzrNl)end end;local ZDICnKE,L=io.open(U2,"w")if ZDICnKE then ZDICnKE:write(z)
ZDICnKE:close()else
return false,"Failed to open config file for writing: "..tostring(L)end end;local X,zLtWO09=io.open(U2,"r")
if X then local KTVmRC=X:read("*all")X:close()
local Pa={};(load(KTVmRC,"config","t",Pa))()
local bmK
bmK=function(OJPc3R)if OJPc3R==nil then OJPc3R={}end
return
setmetatable(OJPc3R,{__index={get=function(j,vMgKnGj,M9K)if
type(OJPc3R[j])~="nil"then
if type(OJPc3R[j])=="table"then return bmK(OJPc3R[j])end;return OJPc3R[j]end
Zg.error(
"Attempt to access undeclared config field '"..tostring(j).."'!")if not M9K then return vMgKnGj else return bmK(vMgKnGj)end end}})end;RkGFh6=bmK(Pa)nvCiFt7r=RkGFh6.get("modules",nvCiFt7r)