Skip to content

Commit

Permalink
Moved lots of code into a subproject
Browse files Browse the repository at this point in the history
I think stuff like zip and github installing belong in a repository
dedicated to installing from github. Moved these libraries into a new
project called grin (Github Release INstaller)
  • Loading branch information
ElvishJerricco committed Sep 30, 2014
1 parent 7a6a8e0 commit b7b7b12
Show file tree
Hide file tree
Showing 9 changed files with 26 additions and 1,629 deletions.
3 changes: 3 additions & 0 deletions .gitmodules
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
[submodule "lasm"]
path = lasm
url = https://github.com/Yevano/LuaAssemblyTools.git
[submodule "grin"]
path = grin
url = https://github.com/ElvishJerricco/Grin.git
6 changes: 6 additions & 0 deletions bin/jvml
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,12 @@ for i,v in ipairs(fs.list(libDir)) do
os.loadAPI(fs.combine(libDir, v))
end
end
local grinLibDir = fs.combine(jcd, "grin/lib")
for i,v in ipairs(fs.list(grinLibDir)) do
if not v:find("^%.") and not _G[v] then
os.loadAPI(fs.combine(grinLibDir, v))
end
end

---------------------------------------------------------------------------------------------------------------
-- Parse arguments
Expand Down
25 changes: 12 additions & 13 deletions build.xml
Original file line number Diff line number Diff line change
@@ -1,13 +1,4 @@
<project name="JVML_JIT_RELEASE" default="main">
<loadresource property="zip.contents">
<file file="lib/zip"/>
</loadresource>
<loadresource property="json.contents">
<file file="lib/json"/>
</loadresource>
<loadresource property="base64.contents">
<file file="lib/base64"/>
</loadresource>
<property name="release.contents" value="release/jvml" />
<condition property="is_windows">
<os family="windows"/>
Expand Down Expand Up @@ -38,6 +29,9 @@
<copy todir="${release.contents}/lib">
<fileset dir="lib" />
</copy>
<copy todir="${release.contents}/grin/lib">
<fileset dir="grin/lib" />
</copy>
<copy todir="${release.contents}/jvml_data">
<fileset dir="jvml_data" />
</copy>
Expand Down Expand Up @@ -70,13 +64,18 @@
</exec>
</target>

<target name="create_installer" depends="if_unix, if_windows">
<target name="grin">
<ant dir="grin" target="main" />
</target>

<target name="create_installer" depends="grin, if_unix, if_windows">
<loadresource property="grin.text">
<file file="grin/build/installer.lua"/>
</loadresource>
<copy file="installer.lua" tofile="release/installer.lua" overwrite="true">
<filterchain>
<replacetokens>
<token key="ZIP" value="${zip.contents}"/>
<token key="JSON" value="${json.contents}"/>
<token key="BASE64" value="${base64.contents}"/>
<token key="GRIN" value="${grin.text}"/>
</replacetokens>
</filterchain>
</copy>
Expand Down
1 change: 1 addition & 0 deletions grin
Submodule grin added at df17bf
94 changes: 4 additions & 90 deletions installer.lua
Original file line number Diff line number Diff line change
@@ -1,93 +1,7 @@
-- use build.xml to import the zip and json libraries directly

local zip = setmetatable({}, {__index=getfenv()})
local json = setmetatable({}, {__index=getfenv()})
local base64 = setmetatable({}, {__index=getfenv()})

do
local function zip_api_make()
@ZIP@
end
setfenv(zip_api_make, zip)
zip_api_make()

local function json_api_make()
@JSON@
end
setfenv(json_api_make, json)
json_api_make()

local function base64_api_make()
@BASE64@
end
setfenv(base64_api_make, base64)
base64_api_make()
end

local oldTime = os.time()
local function sleepCheckin()
local newTime = os.time()
if newTime - oldTime >= (0.020 * 1.5) then
oldTime = newTime
sleep(0)
end
local function grin(...)
@GRIN@
end

local function combine(path, ...)
if not path then
return ""
end
return fs.combine(path, combine(...))
end

-- Begin installation

local githubApiResponse = assert(http.get("https://api.github.com/repos/Yevano/JVML-JIT/releases"))
assert(githubApiResponse.getResponseCode() == 200, "Failed github response")
print("Got github response")
local githubApiJSON = json.decode(githubApiResponse.readAll())
assert(githubApiJSON and
githubApiJSON[1] and
githubApiJSON[1].assets and
githubApiJSON[1].assets[1] and
githubApiJSON[1].assets[1].url,
"Malformed response")
print("Got JSON")
local zipResponse = assert(http.get(githubApiJSON[1].assets[1].url, {["Accept"]="application/octet-stream"}))
assert(zipResponse.getResponseCode() == 200 or zipResponse.getResponseCode() == 302, "Failed zip response")
local base64Str = zipResponse.readAll()
print("Decoding base64")
sleep(0)
local zipTbl = assert(base64.decode(base64Str), "Failed to decode base 64")
print("Zip scanned. Unarchiving...")
sleep(0)

local i = 0
local zfs = zip.open({read=function()
sleepCheckin()
i = i + 1
return zipTbl[i]
end})

local function copyFilesFromDir(dir)
for i,v in ipairs(zfs.list(dir)) do
sleepCheckin()
local fullPath = fs.combine(dir, v)
if zfs.isDir(fullPath) then
copyFilesFromDir(fullPath)
else
print("Copying file: " .. fullPath)
local fh = fs.open(combine(shell.dir(), "jvml", fullPath), "wb")
local zfh = zfs.open(fullPath, "rb")
for b in zfh.read do
sleepCheckin()
fh.write(b)
end
fh.close()
zfh.close()
end
end
end
grin("-u", "Yevano", "-r", "JVML-JIT")

copyFilesFromDir("")
print("Installation complete. It is recommended that you add jvml/bin to your shell's path at startup")
print("It is recommended that you add jvml/bin to your shell's path.")
163 changes: 0 additions & 163 deletions lib/argparse

This file was deleted.

38 changes: 0 additions & 38 deletions lib/base64

This file was deleted.

Loading

0 comments on commit b7b7b12

Please sign in to comment.