Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
branch: master
Fetching contributors…

Cannot retrieve contributors at this time

executable file 133 lines (104 sloc) 3.685 kb
#!/usr/local/bin/lua52
--[[
Copyright (c) 2012 J. Lievisse Adriaanse <jasper@humppa.nl>
Permission to use, copy, modify, and distribute this software for any
purpose with or without fee is hereby granted, provided that the above
copyright notice and this permission notice appear in all copies.
THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
--]]
posix = require "posix"
templates = {"p5", "node", "gnome" };
opts = {}
template_Makefile = [[
# $OpenBSD$
COMMENT =
__DISTNAME__
CATEGORIES =
HOMEPAGE =
# XXX: License
PERMIT_PACKAGE_CDROM= Yes
PERMIT_PACKAGE_FTP= Yes
PERMIT_DISTFILES_CDROM= Yes
PERMIT_DISTFILES_FTP= Yes
__MASTER_SITES__
__MODULES__
__CONFIGURE_STYLE__
__EXTRA__
.include <bsd.port.mk>
]]
-- Tables containing a mapping of certain variables needed in these ports.
modules_template = {
p5 = { MODULES = "MODULES = cpan",
DISTNAME = "DISTNAME =",
EXTRA = "CPAN_AUTHOR ="},
node = { MODULES = "MODULES = lang/node",
DISTNAME = "NPM_VERSION =\nNPM_NAME =",
CONFIGURE_STYLE = "CONFIGURE_STYLE = npm #ext expresso"},
gnome = { MODULES = "MODULES =\tdevel/gettext\n\t\tx11/gnome",
DISTNAME = "GNOME_PROJECT=\nGNOME_VERSION=",
EXTRA = "MODGNOME_TOOLS =\tgoi # gtk-doc vala yelp\n" ..
"MODGNOME_DESKTOP_FILE =\tYes"}
}
function create_port (portname, makefile)
posix.mkdir(portname)
posix.chdir(portname)
local f = io.open("Makefile", "w")
f:write(makefile)
f:close()
posix.mkdir("pkg")
end
function usage ()
print("Usage: " .. arg[0] .. " portname [template]\n")
io.write("Optional [template] can be one of: ")
for i,v in pairs(templates) do
io.write(v .. " ")
end
print()
os.exit(1)
end
function compose_Makefile (p, t)
-- Now compose the Makefile based on the template
if (t == nil) then
makefile = template_Makefile:gsub("__DISTNAME__", "DISTNAME =\t" .. p .. "-")
makefile = makefile:gsub("__MASTER_SITES__", "MASTER_SITES =\thttp://")
makefile = makefile:gsub("__MODULES__", "#MODULES = \tdevel/gettext")
makefile = makefile:gsub("__CONFIGURE_STYLE__", "CONFIGURE_STYLE =\tgnu")
makefile = makefile:gsub("__EXTRA__", "")
else
makefile = template_Makefile:gsub("__DISTNAME__", modules_template[t].DISTNAME)
makefile = makefile:gsub("__MASTER_SITES__", "")
makefile = makefile:gsub("__CONFIGURE_STYLE__", "")
makefile = makefile:gsub("__MODULES__", modules_template[t].MODULES)
makefile = makefile:gsub("__EXTRA__", modules_template[t].EXTRA or "")
end
return makefile
end
function parse_args ()
if (#arg == 0 or #arg > 2) then
usage()
elseif (#arg == 2) then
local _found = false;
for i,v in pairs(templates) do
if (arg[2] == v) then
_found = true
end
end
if (not _found) then
print("No valid template given: " .. arg[2])
usage()
end
end
return { portname = arg[1], template = arg[2] }
end
--if (posix.stat(portname).type == 'directory') then
-- print(portname .. " already exists!");
-- os.exit(1)
--end
opts = parse_args()
create_port(opts.portname, compose_Makefile(opts.portname, opts.template))
Jump to Line
Something went wrong with that request. Please try again.