mirror of
https://github.com/motioneye-project/motioneyeos.git
synced 2025-07-28 21:56:31 +00:00
package/luarocks: refactor Buildroot addon with new argparse module
The wellknown module `argparse` is now used by LuaRocks 3.2.0, instead of a homemade argument parsing. Signed-off-by: Francois Perrad <francois.perrad@gadz.org> Signed-off-by: Thomas Petazzoni <thomas.petazzoni@bootlin.com>
This commit is contained in:
parent
f947d52b39
commit
a766aa818b
@ -10,15 +10,20 @@ local search = require("luarocks.search")
|
|||||||
local download = require("luarocks.download")
|
local download = require("luarocks.download")
|
||||||
local fetch = require("luarocks.fetch")
|
local fetch = require("luarocks.fetch")
|
||||||
|
|
||||||
buildroot.help_summary = "generate buildroot package files of a rock."
|
function buildroot.add_to_parser(parser)
|
||||||
buildroot.help_arguments = "rockname [brname]"
|
local cmd = parser:command("buildroot", [[
|
||||||
buildroot.help = [[
|
|
||||||
This addon generates Buildroot package files of a rock.
|
This addon generates Buildroot package files of a rock.
|
||||||
First argument is the name of a rock, the second argument is optional
|
First argument is the name of a rock, the second argument is optional
|
||||||
and needed when Buildroot uses another name (usually prefixed by lua-).
|
and needed when Buildroot uses another name (usually prefixed by lua-).
|
||||||
Files are generated with the source content of the rock and more
|
Files are generated with the source content of the rock and more
|
||||||
especially the rockspec. So, the rock is downloaded and unpacked.
|
especially the rockspec. So, the rock is downloaded and unpacked.
|
||||||
]]
|
]], util.see_also())
|
||||||
|
:summary("generate buildroot package files of a rock.")
|
||||||
|
|
||||||
|
cmd:argument("rockname", "the name of a rock to be fetched and unpacked.")
|
||||||
|
cmd:argument("brname", "the name used by Buildroot.")
|
||||||
|
:args("?")
|
||||||
|
end
|
||||||
|
|
||||||
local function brname (name)
|
local function brname (name)
|
||||||
return name:upper():gsub('-', '_')
|
return name:upper():gsub('-', '_')
|
||||||
@ -309,15 +314,10 @@ local function generate_test (rockspec, lcname)
|
|||||||
end
|
end
|
||||||
|
|
||||||
--- Driver function for the "buildroot" command.
|
--- Driver function for the "buildroot" command.
|
||||||
-- @param rockname string: the name of a rock to be fetched and unpacked.
|
|
||||||
-- @param brname string: the name used by Buildroot (optional)
|
|
||||||
-- @return boolean: true if successful
|
-- @return boolean: true if successful
|
||||||
function buildroot.command(flags, rockname, fsname)
|
function buildroot.command(args)
|
||||||
if type(rockname) ~= 'string' then
|
local rockname = assert(args.rockname)
|
||||||
return nil, "Argument missing. "..util.see_help('buildroot')
|
local fsname = args.brname or rockname
|
||||||
end
|
|
||||||
fsname = fsname or rockname
|
|
||||||
assert(type(fsname) == 'string')
|
|
||||||
|
|
||||||
local query = queries.new(rockname:lower(), nil, false, 'src')
|
local query = queries.new(rockname:lower(), nil, false, 'src')
|
||||||
local url, err = search.find_suitable_rock(query)
|
local url, err = search.find_suitable_rock(query)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user