local err = require("err")
local hash = require("hash")
local licence = require("licence")
-local scm = require("scm")
+local result = require("result")
local source = require("source")
local strict = require("strict")
local tools = require("tools")
local url = require("url")
-plugin_descriptor = {
- description = "CVS SCM Plugin",
- init = function (ctx)
- local rc, re
-
- rc, re = source.register_source_class("cvs", cvs.cvs_source)
- if not rc then
- return false, re
- end
-
- rc, re = scm.register("cvs", cvs)
- if not rc then
- return false, re
- end
-
- if e2tool.current_tool() == "fetch-sources" then
- e2option.flag("cvs", "select cvs sources")
- end
-
- return true
- end,
- exit = function (ctx) return true end,
-}
-
--------------------------------------------------------------------------------
--- Build the cvsroot string.
--------------------------------------------------------------------------------
-function cvs.toresult(info, sourcename, sourceset, directory)
- -- <directory>/source/<sourcename>.tar.gz
- -- <directory>/makefile
- -- <directory>/licences
+--- Convert cvs source to result.
+local function cvs_to_result(src, sourceset, directory)
local rc, re, out
- local e = err.new("converting result")
- local src = source.sources[sourcename]
+ local e = err.new("converting %s to result", src:get_name())
rc, re = src:working_copy_available()
if not rc then
local makefile = "Makefile"
local source = "source"
local sourcedir = string.format("%s/%s", directory, source)
- local archive = string.format("%s.tar.gz", sourcename)
+ local archive = string.format("%s.tar.gz", src:get_name())
local fname = string.format("%s/%s", directory, makefile)
rc, re = e2lib.mkdir_recursive(sourcedir)
if not rc then
-- create a tarball in the final location
local archive = string.format("%s.tar.gz", src:get_name())
rc, re = e2lib.tar({ "-C", tmpdir ,"-czf", sourcedir .. "/" .. archive,
- sourcename })
+ src:get_name() })
if not rc then
return false, e:cat(re)
end
return true, nil
end
+--------------------------------------------------------------------------------
+
+plugin_descriptor = {
+ description = "CVS SCM Plugin",
+ init = function (ctx)
+ local rc, re
+
+ rc, re = source.register_source_class("cvs", cvs.cvs_source)
+ if not rc then
+ return false, re
+ end
+
+ for typ, theclass in result.iterate_result_classes() do
+ if typ == "collect_project" then
+ theclass:add_source_to_result_fn("cvs", cvs_to_result)
+ break
+ end
+ end
+
+ if e2tool.current_tool() == "fetch-sources" then
+ e2option.flag("cvs", "select cvs sources")
+ end
+
+ return true
+ end,
+ exit = function (ctx) return true end,
+ depends = {
+ "collect_project.lua"
+ }
+}
+
+
strict.lock(cvs)
-- vim:sw=4:sts=4:et:
local err = require("err")
local hash = require("hash")
local licence = require("licence")
-local scm = require("scm")
+local result = require("result")
local sl = require("sl")
local source = require("source")
local strict = require("strict")
local tools = require("tools")
-plugin_descriptor = {
- description = "Files SCM Plugin",
- init = function (ctx)
- local rc, re
-
- rc, re = source.register_source_class("files", files.files_source)
- if not rc then
- return false, re
- end
-
- rc, re = scm.register("files", files)
- if not rc then
- return false, re
- end
-
- if e2tool.current_tool() == "fetch-sources" then
- e2option.flag("files", "select files sources")
- end
-
- return true
- end,
- exit = function (ctx) return true end,
-}
-
--------------------------------------------------------------------------------
--- Generates the command to unpack an archive file.
return true, nil
end
-
--------------------------------------------------------------------------------
--- Create a source result containing the generated Makefile and files
-- belonging to the source, for use with collect_project.
-- Result refers to a collection of files to recreate an e2source for
-- collect_project in this context.
--- @param info The info table.
--- @param sourcename Source name (string).
+-- @param src Source object.
-- @param sourceset Unused.
-- @param directory Name of the source directory (string).
-- @return Boolean, true on success.
-- @return An error object on failure.
-function files.toresult(info, sourcename, sourceset, directory)
+local function files_to_result(src, sourceset, directory)
local rc, re, out
local e = err.new("converting result failed")
- local src = source.sources[sourcename]
local source = "source" -- directory to store source files in
local makefile = e2lib.join(directory, "Makefile")
if e2lib.stat(e2lib.join(destdir, destname)) then
return false,
e:cat("can not convert source %q due to multiple files named %q",
- sourcename, destname)
+ src:get_name(), destname)
end
rc, re = cache.fetch_file(cache.cache(), file:server(), file:location(),
end
table.insert(out, "\n")
- if file:unpack() ~= sourcename then
+ if file:unpack() ~= src:get_name() then
table.insert(out, string.format("\tln -s %s $(BUILD)/%s\n",
- file:unpack(), sourcename))
+ file:unpack(), src:get_name()))
end
end
if file:copy() then
from = e2lib.shquote(
e2lib.join(source, e2lib.basename(file:location())))
- local destdir, destname = gen_dest_dir_name("/", sourcename,
+ local destdir, destname = gen_dest_dir_name("/", src:get_name(),
file:copy(), file:location(), "isdir")
--
-- is a directory?
--
-- not a directory
--
- destdir, destname = gen_dest_dir_name("/", sourcename, file:copy(),
+ destdir, destname = gen_dest_dir_name("/", src:get_name(), file:copy(),
file:location(), "no")
to = string.format('"$(BUILD)"%s', e2lib.shquote(destdir))
if file:patch() then
table.insert(out, string.format(
"\tpatch -p%s -d \"$(BUILD)/%s\" -i \"$(shell pwd)/%s/%s\"\n",
- file:patch(), sourcename, source, e2lib.basename(file:location())))
+ file:patch(), src:get_name(), source, e2lib.basename(file:location())))
end
-- write licences
local destdir = string.format("%s/licences", directory)
return true
end
+--------------------------------------------------------------------------------
+
+plugin_descriptor = {
+ description = "Files SCM Plugin",
+ init = function (ctx)
+ local rc, re
+
+ rc, re = source.register_source_class("files", files.files_source)
+ if not rc then
+ return false, re
+ end
+
+ if e2tool.current_tool() == "fetch-sources" then
+ e2option.flag("files", "select files sources")
+ end
+
+ for typ, theclass in result.iterate_result_classes() do
+ if typ == "collect_project" then
+ theclass:add_source_to_result_fn("files", files_to_result)
+ break
+ end
+ end
+
+ return true
+ end,
+ exit = function (ctx) return true end,
+ depends = {
+ "collect_project.lua",
+ }
+}
+
+
strict.lock(files)
-- vim:sw=4:sts=4:et:
local generic_git = require("generic_git")
local hash = require("hash")
local licence = require("licence")
-local scm = require("scm")
+local result = require("result")
local source = require("source")
local strict = require("strict")
local tools = require("tools")
local url = require("url")
---- Initialize git plugin.
--- @param ctx Plugin context. See plugin module.
--- @return True on success, false on error.
--- @return Error object on failure.
-local function git_plugin_init(ctx)
- local rc, re
-
- rc, re = source.register_source_class("git", git.git_source)
- if not rc then
- return false, re
- end
-
- rc, re = scm.register("git", git)
- if not rc then
- return false, re
- end
-
- if e2tool.current_tool() == "fetch-sources" then
- e2option.flag("git", "select git sources")
- end
-
- return true
-end
-
-plugin_descriptor = {
- description = "Git SCM Plugin",
- init = git_plugin_init,
- exit = function (ctx) return true end,
-}
-
---------------------------------------------------------------------------------
-
git.git_source = class("git_source", source.basic_source)
function git.git_source.static:is_scm_source_class()
--------------------------------------------------------------------------------
-function git.toresult(info, sourcename, sourceset, directory)
+local function git_to_result(src, sourceset, directory)
local rc, re, argv
- local e = err.new("converting result")
- local src = source.sources[sourcename]
+ local e = err.new("converting %s to result", src:get_name())
rc, re = src:working_copy_available()
if not rc then
argv = generic_git.git_new_argv(nil, e2lib.join(e2tool.root(), src:get_working()))
table.insert(argv, "archive")
table.insert(argv, "--format=tar") -- older versions don't have "tar.gz"
- table.insert(argv, string.format("--prefix=%s/", sourcename))
+ table.insert(argv, string.format("--prefix=%s/", src:get_name()))
table.insert(argv, "-o")
table.insert(argv, tmpfn)
table.insert(argv, ref)
elseif sourceset == "working-copy" then
argv = {
"-C", e2lib.join(e2tool.root(), src:get_working()),
- string.format("--transform=s,^./,./%s/,", sourcename),
+ string.format("--transform=s,^./,./%s/,", src:get_name()),
"--exclude=.git",
"-czf",
e2lib.join(sourcedir, archive),
return true, nil
end
+--------------------------------------------------------------------------------
+
+--- Initialize git plugin.
+-- @param ctx Plugin context. See plugin module.
+-- @return True on success, false on error.
+-- @return Error object on failure.
+local function git_plugin_init(ctx)
+ local rc, re
+
+ rc, re = source.register_source_class("git", git.git_source)
+ if not rc then
+ return false, re
+ end
+
+ for typ, theclass in result.iterate_result_classes() do
+ if typ == "collect_project" then
+ theclass:add_source_to_result_fn("git", git_to_result)
+ break
+ end
+ end
+
+ if e2tool.current_tool() == "fetch-sources" then
+ e2option.flag("git", "select git sources")
+ end
+
+ return true
+end
+
+plugin_descriptor = {
+ description = "Git SCM Plugin",
+ init = git_plugin_init,
+ exit = function (ctx) return true end,
+ depends = {
+ "collect_project.lua"
+ }
+}
+
+
strict.lock(git)
-- vim:sw=4:sts=4:et:
local generic_git = require("generic_git")
local hash = require("hash")
local licence = require("licence")
-local scm = require("scm")
+local result = require("result")
local source = require("source")
local strict = require("strict")
local url = require("url")
--------------------------------------------------------------------------------
--- Archives the source and prepares the necessary files outside the archive
--- @param info the info structure
--- @param sourcename string
+-- @param src source object
-- @param sourceset string, should be "tag" "branch" or "working copy", in order for it to work
-- @param the directory where the sources are and where the archive is to be created
-- @return True on success, false on error.
-- @return Error object on failure
-function gitrepo.toresult(info, sourcename, sourceset, directory)
- assertIsTable(info)
- assertIsStringN(sourcename)
+local function gitrepo_to_result(src, sourceset, directory)
+ assertIsTable(src)
assertIsStringN(sourceset)
assertIsStringN(directory)
local rc, re, e
- local src, srcdir, sourcedir, archive
+ local srcdir, sourcedir, archive
local argv
- e = err.new("converting source %q failed", sourcename)
- src = source.sources[sourcename]
+ e = err.new("converting source %q failed", src:get_name())
rc, re = src:working_copy_available()
if not rc then
srcdir = "source"
sourcedir = e2lib.join(directory, srcdir)
- archive = string.format("%s.tar.gz", sourcename)
+ archive = string.format("%s.tar.gz", src:get_name())
rc, re = e2lib.mkdir(sourcedir)
if not rc then
if sourceset == "tag" or sourceset == "branch" then
local tmpdir = e2lib.mktempdir()
local worktree = e2lib.join(e2tool.root(), src:get_working())
- local destdir = e2lib.join(tmpdir, sourcename, ".git")
+ local destdir = e2lib.join(tmpdir, src:get_name(), ".git")
rc, re = e2lib.mkdir_recursive(destdir)
if not rc then
end
rc, rc = e2lib.tar({"-czf", e2lib.join(sourcedir, archive),
- "-C", tmpdir, sourcename})
+ "-C", tmpdir, src:get_name()})
if not rc then
return false, e:cat(re)
end
elseif sourceset == "working-copy" then
rc, rc = e2lib.tar({"-czf", e2lib.join(sourcedir, archive),
- "-C", e2lib.join(e2tool.root(), src:get_working(), ".."), sourcename})
+ "-C", e2lib.join(e2tool.root(), src:get_working(), ".."),
+ src:get_name()})
if not rc then
return false, e:cat(re)
end
return false, e:cat("build mode %s not supported", source_set)
end
- local builddir = e2lib.join("$(BUILD)", sourcename)
+ local builddir = e2lib.join("$(BUILD)", src:get_name())
local makefile = e2lib.join(directory, "Makefile")
if sourceset == "tag" then
rc, re = eio.file_write(makefile, string.format(
return false, re
end
- rc, re = scm.register("gitrepo", gitrepo)
- if not rc then
- return false, re
+ for typ, theclass in result.iterate_result_classes() do
+ if typ == "collect_project" then
+ theclass:add_source_to_result_fn("gitrepo", gitrepo_to_result)
+ break
+ end
end
if e2tool.current_tool() == "fetch-sources" then
description = "Provides Git repository as source",
init = gitrepo_plugin_init,
exit = function(ctx) return true end,
+ depends = {
+ "collect_project.lua"
+ }
}
--------------------------------------------------------------------------------
local err = require("err")
local hash = require("hash")
local licence = require("licence")
-local scm = require("scm")
+local result = require("result")
local source = require("source")
local strict = require("strict")
local tools = require("tools")
local url = require("url")
-plugin_descriptor = {
- description = "SVN SCM Plugin",
- init = function (ctx)
- local rc, re
-
- rc, re = source.register_source_class("svn", svn.svn_source)
- if not rc then
- return false, re
- end
-
- rc, re = scm.register("svn", svn)
- if not rc then
- return false, re
- end
-
- if e2tool.current_tool() == "fetch-sources" then
- e2option.flag("svn", "select svn sources")
- end
-
- return true
- end,
- exit = function (ctx) return true end,
-}
-
svn.svn_source = class("svn_source", source.basic_source)
function svn.svn_source.static:is_scm_source_class()
--------------------------------------------------------------------------------
-function svn.toresult(info, sourcename, sourceset, directory)
+local function svn_to_result(src, sourceset, directory)
-- <directory>/source/<sourcename>.tar.gz
-- <directory>/makefile
-- <directory>/licences
local rc, re
- local e = err.new("converting result")
- local src = source.sources[sourcename]
+ local e = err.new("converting %s to result", src:get_name())
+ local src = source.sources[src:get_name()]
rc, re = src:working_copy_available()
if not rc then
local makefile = "Makefile"
local source = "source"
local sourcedir = e2lib.join(directory, source)
- local archive = string.format("%s.tar.gz", sourcename)
+ local archive = string.format("%s.tar.gz", src:get_name())
local fname = e2lib.join(directory, makefile)
rc, re = e2lib.mkdir_recursive(sourcedir)
if not rc then
-- create a tarball in the final location
local archive = string.format("%s.tar.gz", src:get_name())
rc, re = e2lib.tar({ "-C", tmpdir ,"-czf", sourcedir .. "/" .. archive,
- sourcename })
+ src:get_name() })
if not rc then
return false, e:cat(re)
end
return true, nil
end
+--------------------------------------------------------------------------------
+
+plugin_descriptor = {
+ description = "SVN SCM Plugin",
+ init = function (ctx)
+ local rc, re
+
+ rc, re = source.register_source_class("svn", svn.svn_source)
+ if not rc then
+ return false, re
+ end
+
+ for typ, theclass in result.iterate_result_classes() do
+ if typ == "collect_project" then
+ theclass:add_source_to_result_fn("svn", svn_to_result)
+ break
+ end
+ end
+
+ if e2tool.current_tool() == "fetch-sources" then
+ e2option.flag("svn", "select svn sources")
+ end
+
+ return true
+ end,
+ exit = function (ctx) return true end,
+ depends = {
+ "collect_project.lua"
+ }
+}
+
+
strict.lock(svn)
-- vim:sw=4:sts=4:et: