and will be replaced by plugin support soon.
Signed-off-by: Gordon Hecker <gh@emlix.com>
e2-build-numbers.1
MANPAGES5 = e2rc.5 e2config.5
-MANPAGES7 = e2global.7 e2hooks.7 e2intro.7 e2workflow.7
+MANPAGES7 = e2global.7 e2intro.7 e2workflow.7
MANPAGES = $(MANPAGES1) $(MANPAGES5) $(MANPAGES7)
MANPAGES_HTML = $(MANPAGES:=.html)
Depending on the intended outcome, different versions of the source
files to use may be retrieved for the build process.
See \fBe2config\fR for a description of the source config file format.
-Invokes the hooks "pre-build" and "post-build".
.SH RETURN VALUE
Normally, exit status is 0. On error, it is non-zero.
.BR e2-ls-project (1),
.BR e2-playground (1),
.BR e2config (5),
-.BR e2hooks (7),
.BR e2-sync-results (1),
.BR e2-runbuild (1).
for f in {proj/chroot,
proj/env,
proj/init/*,
- proj/hooks/*,
res/result/build-script,
res/result/config:files
} sha1sum(f),
The project name will be the basename of <location>.
The usual project location convention is
\fBprojects:<customer>/<projectname>\fR.
-e2-create-project invokes the "create-project" hook.
.SH RETURN VALUE
Normally, exit status is 0. On error, it is non-zero.
.BR e2-fetch-sources(1)
.BR e2-ls-project(1)
.BR e2config(5)
-.BR e2hooks(7)
.SH AUTHORS
Gordon Hecker, Oskar Schirmer and Felix Winkelmann
\fBe2-fetch-project\fR clones a project repository designated by "PATH",
which should be the absolute path to a \fBe2(7)\fR project. The usual
project path convention is \fB/<server-project-dir>/<customer>/<projectname>\fR.
-Invokes the "fetch-project" hook.
.SH RETURN VALUE
Normally, exit status is 0. On error, it is non-zero.
.BR e2-fetch-sources(1)
.BR e2-ls-project(1)
.BR e2config(5)
-.BR e2hooks(7)
.SH AUTHORS
Gordon Hecker, Oskar Schirmer and Felix Winkelmann
\fBe2-fetch-sources\fR retrieves sources for project results. Sources can be
either specified through the source- or result names. For sources stored
in version-controlled repositories, the associated repositories will be
-cloned and a project-local working copy created. Invokes the
-"fetch-sources" hook.
+cloned and a project-local working copy created.
Note, that sources of type \fIfiles\fR are not fetched.
.BR e2intro (7),
.BR e2-ls-project (1),
.BR e2config (5),
-.BR e2hooks (7).
.SH AUTHORS
Gordon Hecker, Oskar Schirmer and Felix Winkelmann
\fBe2-playground\fR enters a \fBchroot\fR(1) environment previously
created by running \fBe2-build\fR with the "--playground" option, or
one that is left over from a previous (possibly failed) build.
-Calls the "enter-playground" hook.
.SH RETURN VALUE
Normally, exit status is 0. On error, it is non-zero.
.BR e2-ls-project (1),
.BR e2-build (1),
.BR e2config (5),
-.BR e2hooks (7).
.SH AUTHORS
Gordon Hecker, Oskar Schirmer and Felix Winkelmann
| |-- chroot required chroot tarballs
| |-- default-results main final results of the project
| |-- init initialization scripts run inside chroot
-| |-- hooks hook scripts for customization (optional)
| |-- licences list of licences used by sources (optional)
| |-- name project name
| |-- result-storage where to store shared build-results
+++ /dev/null
-.\" Man page for e2 hooks
-.\"
-.\" (c)2007 emlix GmbH
-.\"
-.TH e2hook 7 "Aug 2, 2007" "0.1"
-
-.SH NAME
-e2hooks \- Hooks available in the e2 build system
-
-.SH DESCRIPTION
-During execution of \fBe2\fR commands a number of "hook" scripts are
-called, if available, to perform any site-specific customization of
-the build process. Hook scripts are located in the "hooks"
-subdirectory of the project and will be loaded and evaluated as Lua
-code. Global tools do not nocessarily execute in a project directory
-and will load and evaluate hooks in the \fB$HOME/.e2/hooks\fR
-directory, if it exists. Hook-specific arguments are passed as a table
-in the global "e2hook" table under the key "arguments". The project
-info structure (not necessarily complete) is stored under the key
-"info" in the "e2hook" table. Finally, the name of the currently
-invoked tool can be found under "toolname" in the said table.
-
-Note, that hooks are not intended to add functionality changing the
-build process itself. It is an error to let a hook do anything that
-changes the outcome of the build process. Instead, hooks may be used
-to trigger actions in the environment of the build process.
-
-.SH HOOKS
-
-.TP
-.BR tool\-start
-Called when a local tool executes (after command-line processing, but
-before the actual operations begin). Note that the \fBe2hook.info\fR
-entry may be \fBnil\fR if this hook is triggered in a global tool.
-
-.TP
-.BR tool\-finish
-Called after a local tool executed without an error. If an error
-occurred, this hook will not run. Note that the \fBe2hook.info\fR
-entry may be \fBnil\fR if this hook is triggered in a global tool.
-
-.TP
-.BR pre\-build
-Called before an \fBe2-build(1)\fR command commences. Arguments are
-given in a table with the following keys:
-
-.nf
- info = <project info structure>
- result = <table of results>
- tags = <bool>
- heads = <bool>
- playground = <resultname or false>
-.fi
-
-.TP
-.BR post\-build
-Called after \fBe2-build(1)\fR finishes, with the same arguments as
-"pre-build".
-
-.TP
-.BR build\-setup\-chroot
-Called after the chroot(1) environment has been set up for building a
-single result. The argument is a build configuration table.
-
-.TP
-.BR build\-pre\-runbuild
-Called before starting the actual build-script inside the chroot(1)
-environment for a single result. The argument is the build configuration table.
-
-.TP
-.BR build\-post\-runbuild
-Called after the build-script of a single result has completed. Argument
-is the build configuration table.
-
-.TP
-.BR build\-remove\-chroot
-Called before the chroot(1) environment for a single result is removed.
-Argument is the build configuration table.
-
-.TP
-.BR build\-pre\-sources
-Called before the sources are applied into the chroot(1) environment for
-a single result. Argument is the build configuration table.
-
-.TP
-.BR build\-post\-sources
-Called after the sources have been applied into the chroot(1) environment.
-
-.TP
-.BR build\-failure
-Called when the build script of a result fails. Argument is the build
-configuration table.
-
-.TP
-.BR files\-prepare\-source
-Called once after preparing each single source file for files sources.
-The argument table carries the entries \fBsource\fR (source name),
-\fBfile\fR (file name) and \fBpath\fR (build path).
-
-.TP
-.BR build\-pre\-result
-Called before a single result is build. Argument is the build configuration
-table.
-
-.TP
-.BR build\-post\-result
-Called after a single result is build. Argument is the build configuration
-table.
-
-.TP
-.BR create\-project
-Called after a base project has been cloned by \fBe2-create-project(1)\fR
-and before it is stored on the project server.
-The argument is the root path of the project. The "info" entry in
-the "e2hook" table is incomplete for this hook.
-
-.TP
-.BR fetch\-project
-Called after fetching a project with \fBe2-fetch-project(1)\fR. The argument
-is the root path of the project. The "info" entry in
-the "e2hook" table is incomplete for this hook.
-
-.TP
-.BR fetch\-sources
-Called after fetching sources with \fBe2-fetch-sources(1)\fR. The argument
-is a table containing the requested sources.
-
-.TP
-.BR enter\-playground
-Called before entering a chroot(1) environment via \fBe2-playground(1)\fR.
-The argument is the path where the chroot environment is located.
-
-.TP
-.BR use\-source
-Called after a new source is inserted into an existing project by
-\fBe2-use-source(1)\fR. The argument is a table with the following entries:
-
-.nf
- type = <source type string>
- server = <server name>
- remote = <server path>
- working = <working directory>
- branch = <branch name>
- tag = <tag name>
-.fi
-
-.SH "HOOK ORDER"
-Build-related hooks are run in the following order:
-
-.nf
- pre-build
- build-pre-result (once for each result)
- build-setup-chroot
- build-pre-sources
- build-post-sources
- build-pre-runbuild
- build-post-runbuild
- build-post-result
- build-remove-chroot
- post-build
-.fi
-
-.SH BUGS
-
-When \fBe2-new-source\fR is invoked without the \fB--source\fR option,
-then the \fBtool-start\fR and \fBtool-finish\fR hooks will not execute.
-
-Doubtless there are many others.
-
-.SH "SEE ALSO"
-.BR e2intro(7)
-.BR e2-build(1)
-.BR e2-create-project(1)
-.BR e2-fetch-project(1)
-.BR e2-fetch-sources(1)
-.BR e2-playground(1)
-.BR e2-use-source(1)
-
-.SH AUTHORS
-Gordon Hecker, Oskar Schirmer and Felix Winkelmann
-
-.SH COPYRIGHT
-(c)2007 emlix GmbH
.BR e2-new-source(1)
.BR e2-create-project(1)
.BR e2config(5)
-.BR e2hooks(7)
.BR e2-sync-results(1)
.BR e2global(1)
.BR e2-install-e2(1)
rm -f $(CLEAN_FILES)
e2generic_global.lc: strict.lua collection.lua e2lib_global_prefix.lua \
- e2lib.lua e2hook.lua e2option.lua sha1.lua \
+ e2lib.lua e2option.lua sha1.lua \
transport.lua cache.lua url.lua scm.git.lua \
convenience.lua luafile.lua lua-version-map.lua \
error.lua
$(BUILD_LUAC) -o $@ $^
e2generic_local.lc: strict.lua collection.lua e2lib_local_prefix.lua \
- e2lib.lua e2hook.lua e2option.lua sha1.lua \
+ e2lib.lua e2option.lua sha1.lua \
transport.lua cache.lua url.lua scm.git.lua \
convenience.lua luafile.lua lua-version-map.lua
$(LUAC) -o $@ $^
+++ /dev/null
---[[
- e2factory, the emlix embedded build system
-
- Copyright (C) 2007-2009 Gordon Hecker <gh@emlix.com>, emlix GmbH
- Copyright (C) 2007-2009 Oskar Schirmer <os@emlix.com>, emlix GmbH
- Copyright (C) 2007-2008 Felix Winkelmann, emlix GmbH
-
- For more information have a look at http://www.e2factory.org
-
- e2factory is a registered trademark by emlix GmbH.
-
- This file is part of e2factory, the emlix embedded build system.
-
- e2factory is free software: you can redistribute it and/or modify
- it under the terms of the GNU General Public License as published by
- the Free Software Foundation, either version 3 of the License, or
- (at your option) any later version.
-
- This program is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- GNU General Public License for more details.
-
- You should have received a copy of the GNU General Public License
- along with this program. If not, see <http://www.gnu.org/licenses/>.
-]]
-
-e2hook = e2lib.module("e2hook")
-
-e2hook.hooks = {}
-
-local hooks = {
- "tool-start",
- "tool-finish",
- "pre-build",
- "post-build",
- "create-project",
- "fetch-project",
- "fetch-sources",
- "enter-playground",
- "use-source",
- "build-setup-chroot",
- "build-pre-runbuild",
- "build-post-runbuild",
- "build-remove-chroot",
- "build-pre-sources",
- "build-post-sources",
- "build-pre-result",
- "build-post-result",
- "files-prepare-source",
- "build-failure",
-}
-
-for _, k in pairs(hooks) do
- e2hook.hooks[ k ] = true
-end
-
-e2hook.info = nil
-e2hook.arguments = nil
-
-function e2hook.log(msg)
- e2lib.log(3, "[hook: " .. e2hook.hookname .. "] " .. msg)
-end
-
-function e2hook.run_hook(info, hookname, arguments, toolname)
- if not e2hook.hooks[ hookname ] then
- e2lib.bomb("invalid hook: ", hookname)
- end
- local hfile
- if info then
- hfile = info.root .. "/proj/hooks/" .. hookname
- else
- hfile = buildconfig.PREFIX .. "/share/e2/hooks/" .. hookname
- end
- if e2util.exists(hfile) then
- e2lib.log(3, "running hook `" .. hookname .. "' ...")
- e2hook.arguments = arguments
- e2hook.hookname = hookname
- e2hook.info = info or {}
- e2hook.toolname = toolname
- dofile(hfile)
- end
-end
termwidth = 72,
env = {},
last_output = false,
- abort_hook = false,
tmpdirs = {},
tmpfiles = {},
enable_invocation_log = false,
local t = { ... }
local e = t[1]
if e and e.print then
- if e2lib.abort_hook then
- e2lib.abort_hook("no message")
- end
e:print()
else
local msg = table.concat(t)
if msg:len() == 0 then
e2lib.bomb("calling e2lib.abort() with zero length message")
end
- if e2lib.abort_hook then
- e2lib.abort_hook(msg)
- end
e2lib.log(1, "Error: " .. msg)
end
e2lib.rmtempdirs()
-- standard global tool setup finished
---e2hook.run_hook(nil, "tool-start", nil, "e2-create-project")
-
if e2lib.osenv["E2_LOCAL_TAG"] and e2lib.osenv["E2_LOCAL_BRANCH"] then
e2lib.local_e2_branch = e2lib.osenv["E2_LOCAL_BRANCH"]
e2lib.local_e2_tag = e2lib.osenv["E2_LOCAL_TAG"]
-- standard global tool setup finished
---e2hook.run_hook(nil, "tool-start", nil, "e2-fetch-project")
-
if #opts.arguments < 1 then
e2lib.abort("specify path to a project to fetch")
end
-- standard global tool setup finished
---e2hook.run_hook(nil, "tool-start", nil, "e2-install-e2")
-
if #opts.arguments > 0 then
e2option.usage(1)
end
$(TOPLEVEL)/generic/url.lua \
$(TOPLEVEL)/generic/collection.lua \
$(TOPLEVEL)/generic/e2lib.lua \
- $(TOPLEVEL)/generic/e2hook.lua \
e2tool.lua e2scm.lua git.lua svn.lua cvs.lua files.lua \
$(TOPLEVEL)/generic/e2option.lua \
$(TOPLEVEL)/generic/convenience.lua \
end
e2lib.log_invocation(info, arg)
-e2hook.run_hook(info, "tool-start", nil, "e2-buildnumbers")
-- read build numbers,
-- merge to results,
end
e2lib.log_invocation(info, arg)
-e2hook.run_hook(info, "tool-start", nil, "e2-build")
-- get build mode from the command line
local build_mode = policy.handle_commandline_options(opts, true)
if opts.release and not e2tool.e2_has_fixed_tag(info) then
e2lib.abort("Failure: e2 is on pseudo tag while building in release mode.")
end
--- XXX e2hook.run_hook(info, "pre-build", a, "e2-build")
if opts["buildnumber"] then
e2lib.logf(1, "setting up build numbers")
if not rc then
e2lib.abort(re)
end
--- XXX e2hook.run_hook(info, "post-build", a, "e2-build")
-e2hook.run_hook(info, "tool-finish", nil, "e2-build")
e2lib.finish()
end
e2lib.log_invocation(info, arg)
-e2hook.run_hook(info, "tool-start", nil, "e2-dlist")
if not info.results[ result ] then
e2lib.abort("no such result: ", result)
for i = 1, #dep do print(dep[i]) end
end
-e2hook.run_hook(info, "tool-finish", nil, "e2-dlist")
e2lib.finish()
end
e2lib.log_invocation(info, arg)
-e2hook.run_hook(info, "tool-start", nil, "e2-dsort")
local d = e2tool.dsort(info)
if d then
for i = 1, #d do print(d[i]) end
end
-e2hook.run_hook(info, "tool-finish", nil, "e2-dsort")
e2lib.finish()
e2tool.reset_umask(info)
out:close()
if rc ~= 0 then
- -- XXX e2hook.run_hook(c.info, "build-failure", c, "e2-build")
e = new_error("build script for %s failed with exit status %d", r, rc)
e:append("see %s for more information", res.build_config.buildlog)
return false, e
end
- -- XXX e2hook.run_hook(c.info, "build-post-runbuild", c, "e2-build")
return true, nil
end
end
local steps = {
- --XXX e2hook.run_hook(c.info, "build-pre-sources", c, "e2-build")
install_directory_structure,
install_build_script,
install_env,
install_build_driver,
install_build_time_dependencies,
install_sources,
- --XXX e2hook.run_hook(c.info, "build-post-sources", c, "e2-build")
}
for _,f in ipairs(steps) do
local rflags = {}
if not rc then
return false, e:cat(re)
end
- -- do not set this metatable here, as we want to allow changing
- -- the environment in a hook...
- --setmetatable(info.env, { __newindex = invalid_access })
end
-- read project configuration
hc:hash_line(hash) -- the file content
end
end
- for f in e2lib.directory(info.root .. "/proj/hooks", false, true) do
- if not e2lib.is_backup_file(f) then
- local location = string.format("proj/hooks/%s",
- e2lib.basename(f))
- local hash, e = e2tool.hash_file(info,
- info.root_server_name, location)
- if not hash then
- e2lib.abort(e)
- end
- hc:hash_line(location) -- the file location
- hc:hash_line(hash) -- the file content
- end
- end
hc:hash_line(info.release_id)
hc:hash_line(info.project.chroot_arch)
hc:hash_line(buildconfig.VERSION)
end
e2lib.log_invocation(info, arg)
-e2hook.run_hook(info, "tool-start", nil, "e2-fetch-sources")
if not (opts.fetch or opts.update) then
opts.fetch = true
end
end
---e2hook.run_hook(info, "fetch-sources", srcs)
---e2hook.run_hook(info, "tool-finish", nil, "e2-fetch-sources")
-
if e:getcount() > 0 then
e2lib.abort(e)
end
file.location, file.server))
end
end
- e2hook.run_hook(info, "files-prepare-source",
- {source=sourcename, file=file.base, path=buildpath},
- "e2-build")
end
return true, nil
end
end
e2lib.log_invocation(info, arg)
-e2hook.run_hook(info, "tool-start", nil, "e2-lookup-server")
local server, islocal = e2tool.lookup_server(info, opts.arguments[1])
if not server then e2options.usage(1) end
print(server)
-e2hook.run_hook(info, "tool-finish", nil, "e2-lookup-server")
e2lib.finish()
end
--e2lib.log_invocation(info, arg)
-e2hook.run_hook(info, "tool-start", nil, "e2-ls-project")
local function pempty(s1, s2, s3)
print(string.format(" %s %s %s", s1, s2, s3))
end
print("}")
e2lib.finish()
- e2hook.run_hook(info, "tool-finish", nil, "e2-ls-project")
end
--------------- project name
end
end
-e2hook.run_hook(info, "tool-finish", nil, "e2-ls-project")
e2lib.finish()
end
e2lib.log_invocation(info, arg)
-e2hook.run_hook(info, "tool-start", nil, "e2-new-source")
if opts.git then
if #opts.arguments ~= 1 then
"sources in your project")
end
-e2hook.run_hook(info, "tool-finish", nil, "e2-new-source")
e2lib.finish(0)
end
e2lib.log_invocation(info, arg)
-e2hook.run_hook(info, "tool-start", nil, "e2-playground")
if #opts.arguments ~= 1 then
e2option.usage(1)
r = opts.arguments[1]
---e2hook.run_hook(info, "enter-playground", c.c "e2-playground")
-- get build mode from the command line
local build_mode = policy.handle_commandline_options(opts, true)
if not build_mode then
if not rc then
e2lib.abort(re)
end
---e2hook.run_hook(info, "tool-finish", nil, "e2-playground")
e2lib.finish()
"remove_logfile",
"chroot_cleanup_if_exists",
"setup_chroot",
- -- XXX run build-setup-chroot hook here
"sources",
"collect_project",
- -- XXX run build-pre-runbuild hook here
-- XXX to be done: e2build.playground: stop if playgrund requested
"fix_permissions",
"playground",
"runbuild",
- -- XXX how to handle the build failure hook?
- -- XXX run build-post-runbuild hook here
"store_result",
"linklast",
"chroot_cleanup",
- -- XXX run build-remove-chroot hook here?
}
policy = {}