mirror of
https://github.com/Doodle3D/doodle3d-firmware.git
synced 2024-12-22 11:03:48 +01:00
Ask confirmation before syncing files to server.
Use doodle3d feed path to load updater module.
This commit is contained in:
parent
d71d96b9ba
commit
b6862c17cc
@ -11,15 +11,10 @@ if not ok then
|
|||||||
os.exit(2)
|
os.exit(2)
|
||||||
end
|
end
|
||||||
pl = pl()
|
pl = pl()
|
||||||
|
local um --- update manager module, will be loaded later through @{loadUpdateManager}
|
||||||
|
|
||||||
local lfs = require('lfs') -- assume this exists since it's required by penlight as well
|
local lfs = require('lfs') -- assume this exists since it's required by penlight as well
|
||||||
|
|
||||||
local argStash = arg
|
|
||||||
arg = nil
|
|
||||||
local um = require('d3d-update-mgr') -- arg must be nil for the update manager to load as module
|
|
||||||
arg = argStash
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
-----------------------------
|
-----------------------------
|
||||||
-- CONSTANTS AND VARIABLES --
|
-- CONSTANTS AND VARIABLES --
|
||||||
@ -48,6 +43,14 @@ local paths = {}
|
|||||||
-- UTILITY FUNCTIONS --
|
-- UTILITY FUNCTIONS --
|
||||||
-----------------------
|
-----------------------
|
||||||
|
|
||||||
|
local function loadUpdateManager()
|
||||||
|
package.path = package.path .. ';' .. pl.path.join(paths.firmware, 'updater-ng') .. '/?.lua'
|
||||||
|
local argStash = arg
|
||||||
|
arg = nil
|
||||||
|
um = require('d3d-update-mgr') -- arg must be nil for the update manager to load as module
|
||||||
|
arg = argStash
|
||||||
|
end
|
||||||
|
|
||||||
local function quit(ev)
|
local function quit(ev)
|
||||||
if lock then lock:free() end
|
if lock then lock:free() end
|
||||||
os.exit(ev or 0)
|
os.exit(ev or 0)
|
||||||
@ -59,6 +62,17 @@ local function md5sum(file)
|
|||||||
return rv and sum:sub(1, -2) or nil
|
return rv and sum:sub(1, -2) or nil
|
||||||
end
|
end
|
||||||
|
|
||||||
|
local function getYesNo(question)
|
||||||
|
local answer
|
||||||
|
repeat
|
||||||
|
io.write(question)
|
||||||
|
io.flush()
|
||||||
|
answer = io.stdin:read('*line'):lower()
|
||||||
|
until answer == 'yes' or answer == 'no' or answer == 'n'
|
||||||
|
|
||||||
|
return (answer == 'yes') and true or false
|
||||||
|
end
|
||||||
|
|
||||||
local function detectRootPrivileges()
|
local function detectRootPrivileges()
|
||||||
local rv,_,userId = pl.utils.executeex('id -u')
|
local rv,_,userId = pl.utils.executeex('id -u')
|
||||||
if not rv then return nil end
|
if not rv then return nil end
|
||||||
@ -116,7 +130,7 @@ end
|
|||||||
--end
|
--end
|
||||||
|
|
||||||
local function runAction(actMsg, errMsg, ev, func)
|
local function runAction(actMsg, errMsg, ev, func)
|
||||||
io.stdout:write(actMsg .. "...")
|
io.stdout:write("* " .. actMsg .. "...")
|
||||||
local rv,err = func()
|
local rv,err = func()
|
||||||
if not rv then
|
if not rv then
|
||||||
print("Error: " .. errMsg .. " (" .. err .. ")")
|
print("Error: " .. errMsg .. " (" .. err .. ")")
|
||||||
@ -160,7 +174,7 @@ end
|
|||||||
local function prepare()
|
local function prepare()
|
||||||
local msg = nil
|
local msg = nil
|
||||||
|
|
||||||
io.stdout:write("Checking if working directory is the OpenWrt root... ")
|
io.stdout:write("* Checking if working directory is the OpenWrt root... ")
|
||||||
local isOpenWrtRoot = detectOpenWrtRoot()
|
local isOpenWrtRoot = detectOpenWrtRoot()
|
||||||
if isOpenWrtRoot then
|
if isOpenWrtRoot then
|
||||||
paths.wrt = pl.path.currentdir()
|
paths.wrt = pl.path.currentdir()
|
||||||
@ -170,7 +184,7 @@ local function prepare()
|
|||||||
return nil
|
return nil
|
||||||
end
|
end
|
||||||
|
|
||||||
io.stdout:write("Looking for Doodle3D feed path... ")
|
io.stdout:write("* Looking for Doodle3D feed path... ")
|
||||||
local d3dFeed,msg = getWifiboxFeedRoot('feeds.conf')
|
local d3dFeed,msg = getWifiboxFeedRoot('feeds.conf')
|
||||||
if d3dFeed then
|
if d3dFeed then
|
||||||
print("found " .. d3dFeed)
|
print("found " .. d3dFeed)
|
||||||
@ -187,13 +201,15 @@ local function prepare()
|
|||||||
if not paths.cache or paths.cache == '' then
|
if not paths.cache or paths.cache == '' then
|
||||||
paths.cache = '/tmp/d3d-release-dir'
|
paths.cache = '/tmp/d3d-release-dir'
|
||||||
end
|
end
|
||||||
io.stdout:write("Attempting to use " .. paths.cache .. " as cache dir... ")
|
io.stdout:write("* Attempting to use " .. paths.cache .. " as cache dir... ")
|
||||||
local rv,msg = pl.dir.makepath(paths.cache)
|
local rv,msg = pl.dir.makepath(paths.cache)
|
||||||
if not rv then
|
if not rv then
|
||||||
print("could not create path (" .. msg .. ").")
|
print("could not create path (" .. msg .. ").")
|
||||||
return nil
|
return nil
|
||||||
end
|
end
|
||||||
|
|
||||||
|
loadUpdateManager()
|
||||||
|
|
||||||
local rv,msg = pl.dir.makepath(imageCachePath())
|
local rv,msg = pl.dir.makepath(imageCachePath())
|
||||||
if not rv then
|
if not rv then
|
||||||
print("could not create images dir (" .. msg .. ").")
|
print("could not create images dir (" .. msg .. ").")
|
||||||
@ -318,7 +334,7 @@ local function uploadFiles()
|
|||||||
end
|
end
|
||||||
|
|
||||||
local function main()
|
local function main()
|
||||||
print("Doodle3D release script")
|
print("\nDoodle3D release script")
|
||||||
if detectRootPrivileges() then
|
if detectRootPrivileges() then
|
||||||
print("Error: refusing to run script as root.")
|
print("Error: refusing to run script as root.")
|
||||||
quit(99)
|
quit(99)
|
||||||
@ -343,15 +359,15 @@ local function main()
|
|||||||
quit(3)
|
quit(3)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
local isStable = (newVersion.version.suffix == nil)
|
||||||
|
print("\nRolling release for firmware version " .. um.formatVersion(newVersion.version) .. " (type: " .. (isStable and "stable" or "beta") .. ").")
|
||||||
|
|
||||||
local stables,betas = fetchVersionInfo()
|
local stables,betas = fetchVersionInfo()
|
||||||
if not stables then
|
if not stables then
|
||||||
print("Error: could not get version information (" .. betas .. ")")
|
print("Error: could not get version information (" .. betas .. ")")
|
||||||
quit(1)
|
quit(1)
|
||||||
end
|
end
|
||||||
|
|
||||||
local isStable = (newVersion.version.suffix == nil)
|
|
||||||
print("Rolling release for firmware version " .. um.formatVersion(newVersion.version) .. " (type: " .. (isStable and "stable" or "beta") .. ").")
|
|
||||||
|
|
||||||
if um.findVersion(newVersion.version, stables) or um.findVersion(newVersion.version, betas) then
|
if um.findVersion(newVersion.version, stables) or um.findVersion(newVersion.version, betas) then
|
||||||
print("Error: firmware version " .. um.formatVersion(newVersion.version) .. " already exists")
|
print("Error: firmware version " .. um.formatVersion(newVersion.version) .. " already exists")
|
||||||
quit(3)
|
quit(3)
|
||||||
@ -377,15 +393,21 @@ local function main()
|
|||||||
|
|
||||||
runAction("Copying release notes", "failed", 4, copyReleaseNotes)
|
runAction("Copying release notes", "failed", 4, copyReleaseNotes)
|
||||||
|
|
||||||
io.stdout:write("Building package feed directory...")
|
io.stdout:write("* Building package feed directory...")
|
||||||
print("skipped - not implemented")
|
print("skipped - not implemented")
|
||||||
-- runAction("Building package feed directory", "failed", 4, buildFeedDir)
|
-- runAction("Building package feed directory", "failed", 4, buildFeedDir)
|
||||||
|
|
||||||
|
|
||||||
|
local answer = getYesNo("? Local updates directory will be synced to remote server, proceed? (y/n) ")
|
||||||
|
if answer ~= true then
|
||||||
|
print("Did not get green light, quitting.")
|
||||||
|
quit(5)
|
||||||
|
end
|
||||||
|
|
||||||
runAction("About to sync files to server", "could not upload files", 5, uploadFiles)
|
runAction("About to sync files to server", "could not upload files", 5, uploadFiles)
|
||||||
|
|
||||||
print("Done.")
|
print("Done.")
|
||||||
quit()
|
quit()
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
main()
|
main()
|
||||||
|
Loading…
Reference in New Issue
Block a user