]> git.e2factory.org Git - e2factory.git/commitdiff
move build time configuration to buildconfig.lua
authorGordon Hecker <gh@emlix.com>
Mon, 11 May 2009 18:15:19 +0000 (20:15 +0200)
committerGordon Hecker <gh@emlix.com>
Tue, 12 May 2009 13:24:51 +0000 (15:24 +0200)
Signed-off-by: Gordon Hecker <gh@emlix.com>
16 files changed:
Makefile
generic/e2hook.lua
generic/e2lib.lua
generic/lua-version-map.lua.in
generic/transport.lua
global/Makefile
global/config.lua.in [deleted file]
global/e2-create-project.lua.in
global/e2-fetch-project.lua.in
global/e2-install-e2.lua.in
global/e2.lua.in
global/e2global.lua.in [deleted file]
local/Makefile
local/config.lua.in [deleted file]
local/e2tool.lua
make.vars

index 99bb0ebd745bf2d0c2ec8ba6f880fa22a11d50f6..6fbe57d0e356007855cc68b7ec825752eb0f4616 100644 (file)
--- a/Makefile
+++ b/Makefile
@@ -31,7 +31,7 @@ TOPLEVEL    = .
 
 include $(TOPLEVEL)/make.vars
 
-CLEAN_FILES = *~ E2_COMMIT
+CLEAN_FILES = *~ E2_COMMIT buildconfig.lua
 
 
 .PHONY: all e2commit install install-local clean local localdist uninstall \
@@ -40,7 +40,19 @@ CLEAN_FILES = *~ E2_COMMIT
 help:
        @cat INSTALL
 
-all: e2commit
+buildconfig.lua: Makefile
+       echo 'module ("buildconfig")' > $@
+       echo 'PREFIX="$(PREFIX)"' >>$@
+       echo 'BINDIR="$(BINDIR)"' >>$@
+       echo 'LIBDIR="$(LIBDIR)"' >>$@
+       echo 'TOOLDIR="$(TOOLDIR)"' >>$@
+       echo 'E2="$(E2)"' >>$@
+       echo 'LUA="$(LUA)"' >>$@
+       echo 'E2_VERSION="$(E2_VERSION)"' >>$@
+       echo 'E2_COMMIT="$(E2_COMMIT)"' >>$@
+       echo 'E2_SYNTAX="$(E2_SYNTAX)"' >>$@
+
+all: e2commit buildconfig.lua
        $(MAKE) -C lua
        $(MAKE) -C generic
        $(MAKE) -C global
@@ -65,6 +77,7 @@ install: all
        mkdir -p $(DESTDIR)$(INCDIR)
        mkdir -p $(DESTDIR)$(MANDIR)
        mkdir -p $(DESTDIR)$(TOOLDIR)
+       install -m 644 buildconfig.lua $(DESTDIR)$(LIBDIR)
        $(MAKE) -C lua install
        $(MAKE) -C generic install
        $(MAKE) -C global install
@@ -80,7 +93,7 @@ uninstall:
        $(MAKE) -C templates uninstall
        $(MAKE) -C local uninstall
 
-local: e2commit
+local: e2commit buildconfig.lua
        $(MAKE) -C generic local
        $(MAKE) -C local
        $(MAKE) -C templates local
@@ -90,6 +103,7 @@ install-local:
        $(MAKE) -C generic install-local
        $(MAKE) -C local install-local
        $(MAKE) -C templates install-local
+       install -m 644 buildconfig.lua $(LOCALLIBDIR)
 
 doc:
        for s in $(SUBDIRS) ; do \
index 6d7321f6680d65bafaff778acfee17311ff19b01..9928bce872e6cab30b0f5d6717170b18d6b2afd0 100644 (file)
@@ -70,7 +70,7 @@ function e2hook.run_hook(info, hookname, arguments, toolname)
   if info then
     hfile = info.root .. "/proj/hooks/" .. hookname
   else
-    hfile = E2_PREFIX .. "/share/e2/hooks/" .. hookname
+    hfile = buildconfig.PREFIX .. "/share/e2/hooks/" .. hookname
   end
   if e2util.exists(hfile) then
     e2lib.log(3, "running hook `" .. hookname .. "' ...")
index 77637ff3e2caabf56cacd492eae8c68a8bd75fd5..5cddca011bc3c2a73df0290321a3e91913195ed7 100644 (file)
@@ -26,7 +26,7 @@
 ]]
 
 _version = "e2factory, the emlix embedded build system, version " .. 
-                                                               E2_VERSION
+                                                       buildconfig.E2_VERSION
 
 _licence = [[
 e2factory is free software: you can redistribute it and/or modify
@@ -79,7 +79,7 @@ e2lib = {
   default_e2 = {
     local_branch = "master",
     local_tag = "^",
-    local_syntax = E2_SYNTAX,
+    local_syntax = buildconfig.E2_SYNTAX,
   },
   local_e2_branch = nil,
   local_e2_tag = nil,
@@ -449,8 +449,8 @@ function e2lib.log_invocation(info, args)
   end
   local logstring = string.format(
        "%s %s %s/%s %s \"%s %s\"\n",
-       pname, os.date(), E2_VERSION, E2_COMMIT, e2lib.username, 
-       arg[0], table.concat(args, " "))
+       pname, os.date(), buildconfig.E2_VERSION, buildconfig.E2_COMMIT,
+       e2lib.username, arg[0], table.concat(args, " "))
 
   -- always log to the user logfile
   local ulogdir = string.format("%s/.e2", e2lib.homedir)
index 8630fd721a5bab77639806fd231c363a8d294107..2356682ef86d79d871f40561526eb0978fcd0d47 100644 (file)
@@ -35,7 +35,7 @@ lua_versions = {
 }
 
 function lua_versions.get_version(e2_version)
-  local v = e2_version or E2_VERSION
+  local v = e2_version or buildconfig.E2_VERSION
   local lv = lua_versions[ v ]
   return lv or lua_versions.latest
 end
index 659e83d933914f0c1dba5a27bcb77a85212c7f9b..037d396bb2e11ced84f46ca68ace77937c3e6096 100644 (file)
@@ -25,6 +25,8 @@
    along with this program.  If not, see <http://www.gnu.org/licenses/>.
 ]]
 
+require("buildconfig")
+
 local tools = {
        which = { name = "which", flags = "", optional = false },
        curl = { name = "curl", flags = "", optional = false },
@@ -49,10 +51,10 @@ local tools = {
        touch = { name = "touch", flags = "", optional = false },
        uname = { name = "uname", flags = "", optional = false },
        patch = { name = "patch", flags = "", optional = false },
-        ["e2-su"] = { name = E2_PREFIX .. "/bin/e2-su", flags = "",
-                                                       optional = false },
-       ["e2-su-2.2"] = { name = E2_PREFIX .. "/bin/e2-su-2.2", flags = "",
+        ["e2-su"] = { name = buildconfig.PREFIX .. "/bin/e2-su", flags = "",
                                                        optional = false },
+       ["e2-su-2.2"] = { name = buildconfig.PREFIX .. "/bin/e2-su-2.2",
+                                               flags = "", optional = false },
 }
 
 
index ee7f339cf4118d0db76073014a9d6a0dd82abf18..ee2365700ec819001acb44f3ff37d916b1a8d5c2 100644 (file)
@@ -38,7 +38,7 @@ CLEAN_FILES = *~ $(GLOBALTOOLS) *.lc e2 $(SCRIPTS) *.lua e2-su *.sh e2.conf
 
 .PHONY: all install uninstall clean
 
-all: e2 e2-root e2global.lc $(SCRIPTS) e2-su $(GLOBALLUATOOLS:=.lc) \
+all: e2 e2-root $(SCRIPTS) e2-su $(GLOBALLUATOOLS:=.lc) \
        $(GLOBALSHTOOLS:=.sh) e2.conf
 
 install: all
@@ -52,7 +52,6 @@ install: all
        install -m 755 e2-root $(DESTDIR)$(TOOLDIR)/
        install -m 4754 -o root -g $(E2_GROUP) e2-su $(DESTDIR)$(BINDIR)/
        install -m 755 e2 $(DESTDIR)$(BINDIR)/
-       install -m 644 e2global.lc $(DESTDIR)$(LIBDIR)/
        install -d $(DESTDIR)$(SYSCONFDIR)
        if [ ! -f "$(DESTDIR)$(SYSCONFDIR)/e2.conf" ] ; then \
                install -m 644 e2.conf $(DESTDIR)$(SYSCONFDIR)/e2.conf ; \
@@ -71,7 +70,6 @@ uninstall:
        rm -f $(DESTDIR)$(TOOLDIR)/e2-root
        rm -f $(DESTDIR)$(BINDIR)/e2-su
        rm -f $(DESTDIR)$(BINDIR)/e2
-       rm -f $(DESTDIR)$(LIBDIR)/e2global.lc
 
 doc:
        for s in $(SUBDIRS) ; do \
@@ -86,9 +84,6 @@ install-doc:
 clean:
        rm -f $(CLEAN_FILES)
 
-e2global.lc: config.lua e2global.lua
-       $(BUILD_LUAC) -o $@ $^
-
 %.lua: %.lua.in
        $(TOPLEVEL)/scripts/genscript.sh $< $@
 
diff --git a/global/config.lua.in b/global/config.lua.in
deleted file mode 100644 (file)
index feef1e9..0000000
+++ /dev/null
@@ -1,60 +0,0 @@
---[[
-   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/>.
-]]
-
---[[
-   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/>.
-]]
-
--- Program configuration
-
-E2_VERSION = "@E2_VERSION@"
-E2_COMMIT = "@E2_COMMIT@"
-E2_PREFIX = "@E2_PREFIX@"
-E2_SYNTAX = "@E2_SYNTAX@"
index 802623a915a798e0b1030d61e8873491230c1713..0e10a7c3f11c89d66d88c9e49d641fc86b625d5b 100755 (executable)
@@ -25,7 +25,9 @@
    along with this program.  If not, see <http://www.gnu.org/licenses/>.
 ]]
 
-require("e2global")
+require("buildconfig")
+require("e2generic_global")
+
 e2lib.init()
 
 local doc = [[
index 56c9534a039fbd72eedb3462f0013a9caa80249b..4f24f1c118463903d9a570467e15f613a11b8bd7 100755 (executable)
@@ -25,7 +25,8 @@
    along with this program.  If not, see <http://www.gnu.org/licenses/>.
 ]]
 
-require("e2global")
+require("buildconfig")
+require("e2generic_global")
 
 e2lib.init()
 local e = new_error("fetching project failed")
@@ -180,7 +181,7 @@ end
 
 -- call e2-install-e2
 e2_install_e2 = string.format("'%s' '%s/e2-install-e2'", 
-                       getinstallpath("LUA"), getinstallpath("TOOLDIR"))
+                       buildconfig.LUA, buildconfig.TOOLDIR)
 rc, re = e2lib.callcmd_log(e2_install_e2)
 if not rc then
        e:append("installing local e2 failed")
index 66e2fc3e5b47237066675ed6eb99d86bf9c18483..4423870955e911be0aab3718b478d5a50999beb9 100755 (executable)
    along with this program.  If not, see <http://www.gnu.org/licenses/>.
 ]]
 
-require("e2global")
+require("buildconfig")
+require("e2generic_global")
 
-install_prefix = getinstallpath("PREFIX")
+install_prefix = buildconfig.PREFIX
 
 e2lib.init()
 
index 40ce7f8a6846a5bbaa19ddec16e997b48e5cf03e..609c6e0e6b53339d7c60525332e4e60d3a2000e9 100755 (executable)
@@ -28,7 +28,8 @@
 package.path  = "@LIBDIR@/?.lc;@LIBDIR@/?.lua"
 package.cpath = "@LIBDIR@/?.so"
 
-require("e2global")
+require("buildconfig")
+require("e2generic_global")
 e2lib.init()
 
 e2option.documentation = [[
@@ -42,7 +43,7 @@ ing on whether the invocation took place inside or outside a project tree.
 
 e2option.flag("prefix", "print installation prefix",
              function()
-               print("@E2_PREFIX@")
+               print(buildconfig.PREFIX)
                os.exit(0)
              end)
 
@@ -71,19 +72,17 @@ else
   e2call.arg_string = quoteargs(table.concat(arg, "' '", 1))
 end
 
--- provide install paths in the environment
-setinstallpaths()
-
-e2call.globaltool = getinstallpath("TOOLDIR") .. "/" .. e2call.toolname
+e2call.globaltool = buildconfig.TOOLDIR .. "/" .. e2call.toolname
 if root then 
   e2call.localtool = root .. "/.e2/bin/" .. e2call.toolname
 end
 
 if e2util.stat(e2call.globaltool) then
   e2call.tool = e2call.globaltool
-  env = "LUA_PATH='@LIBDIR@/?.lc;@LIBDIR@/?.lua'" ..
-        "LUA_CPATH='@LIBDIR@/?.so'"
-  lua = "@LIBEXECDIR@/e2-lua-@LUA_VERSION@"
+  env = string.format("LUA_PATH='%s/?.lc;%s/?.lua' " ..
+        "LUA_CPATH='%s/?.so'", buildconfig.LIBDIR, buildconfig.LIBDIR,
+       buildconfig.LIBDIR)
+  lua = buildconfig.LUA
   cmd = string.format("%s %s %s %s", env, lua, e2call.tool, e2call.arg_string)
 elseif not root then
   e2lib.abort(e2call.toolname .. 
diff --git a/global/e2global.lua.in b/global/e2global.lua.in
deleted file mode 100644 (file)
index 8ec353b..0000000
+++ /dev/null
@@ -1,113 +0,0 @@
---[[
-   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/>.
-]]
-
-package.path="@LIBDIR@/?.lc;@LIBDIR@/?.lua;" .. package.path
-package.cpath="@LIBDIR@/?.so;" .. package.cpath
-
-require("e2generic_global")
-
--- project
---     .name
---     .path
---     .checkout_path
---     .server_versionfile
---     .versionfile
---     .version
---     .e2versionfile
---     .e2version
-
-
-local install = {}
-install [ "PREFIX" ] = "@E2_PREFIX@"
-install [ "BINDIR" ] = "@BINDIR@"
-install [ "LIBDIR" ] = "@LIBDIR@"
-install [ "LIBEXECDIR" ] = "@LIBEXECDIR@"
-install [ "TOOLDIR" ] = "@TOOLDIR@"
-install [ "LUA" ] = "@LIBEXECDIR@/e2-lua-@LUA_VERSION@"
-
--- getinstallpath(var)
---
--- lookup an installation path from the install table.
-
-function getinstallpath(var)
-  if install [ var ] == nil then
-    e2lib.abort("querying non-existent variable in getinstallpath()")
-  end
-  return install[var]
-end
-
--- setinstallpaths()
---
--- set all installation paths in the environment. That enables the local
--- tools to call the correct e2-su global tools.
-
-function setinstallpaths()
-  for var,val in pairs(install) do
-    e2util.setenv(var, val, true)
-  end
-end
-
--- e2generic table: holds functions that must work across all future
---                  e2 versions
-
-e2generic = {}
-
---- get the project version from the server
--- @param a project description table
--- @return string: the project version, or nil
--- @return an error object on failure
-function e2generic.getprojectversionfromserver(project)
-  local e = new_error("getting project version from server failed")
-  local tmpdir = e2lib.mktempdir()
-  local location = string.format("%s/%s", project.location, 
-                                               project.server_versionfile)
-  local rc, re = transport.fetch_file(project.surl, location, tmpdir, nil)
-  if not rc then
-    return nil, e:cat(re)
-  end
-  local vfile = string.format("%s/%s", tmpdir, project.server_versionfile)
-  local v = e2lib.parse_versionfile(vfile)
-  if not v then
-    return nil, e:cat("can't parse version file")
-  end
-  e2lib.rmtempdir(tmpdir)
-  return v, nil
-end
-
-function e2generic.getprojectversionfromproject(project)
-  return e2lib.parse_versionfile("./" .. project.versionfile)
-end
-
-function e2generic.gete2versionfromproject(project)
-  return e2lib.parse_e2versionfile(project.checkout_path .. "/" .. project.e2versionfile)
-end
-
-e2lib.module("e2generic", e2generic)
-
--- V table: holds functions implementing the  global tool interfaces for each version
-
-V = {}
index 8800d3e606f1519349c5e910464ef17ba8324532..cd878d094e26f482432ea996a7343734a9864e27 100644 (file)
@@ -32,7 +32,7 @@ TOPLEVEL = ..
 
 include $(TOPLEVEL)/make.vars
 
-CLEAN_FILES = *~ *.so linux32 config.lua *.lc *.o
+CLEAN_FILES = *~ *.so linux32 *.lc *.o
 CFLAGS += -I. -I$(DESTDIR)$(INCDIR) -I$(DESTDIR)$(INCDIR)/lua-$(LUA_VERSION) \
        -I../lua/lua-$(LUA_VERSION)/src -fPIC
 LDFLAGS += -L. -L../lua/lua-$(LUA_VERSION)/src -Wl,-R$(LIBDIR) 
@@ -107,7 +107,7 @@ clean:
 %.lc: %.lua
        $(LUAC) -o $@ $<
 
-e2local.lc: config.lua $(TOPLEVEL)/generic/strict.lua \
+e2local.lc: $(TOPLEVEL)/generic/strict.lua \
                result.lua \
                loader.lua \
                $(TOPLEVEL)/generic/scm.git.lua \
diff --git a/local/config.lua.in b/local/config.lua.in
deleted file mode 100644 (file)
index 060f9ee..0000000
+++ /dev/null
@@ -1,37 +0,0 @@
---[[
-   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/>.
-]]
-
--- config.lua          -*- lua -*-
---
--- Program configuration
-
-E2_VERSION = "@E2_VERSION@"
-E2_COMMIT = "@E2_COMMIT@"
-E2_PREFIX = "@E2_PREFIX@"
-E2_SYNTAX = "@E2_SYNTAX@"
-
-require("e2util_local")
index 6b51a64bddd5a644c79ab802ed995e0cddcedb1c..d977009edd3d001e6ba00d2e0b647de3eddd5bb6 100644 (file)
@@ -36,7 +36,7 @@ e2tool = e2lib.module("e2tool")
 -- first, to maintain correct error messages
 
 local config_syntax_compat = {
-       E2_SYNTAX,      -- keep this one, it holds the current syntax.
+       buildconfig.E2_SYNTAX,  -- keep this one, it holds the current syntax.
        "2_2_0",
 }
 
@@ -1066,7 +1066,7 @@ function e2tool.projid(info)
        end
        hc:hash_line(info.release_id)
        hc:hash_line(info.project.chroot_arch)
-       hc:hash_line(E2_VERSION)
+       hc:hash_line(buildconfig.E2_VERSION)
        info.projid = hc:hash_finish()
        return info.projid
 end
index 641610c5a0ca522841073f9ee7a850c88fefb24a..45482314fd36437664fe9f375575ce8b65260627 100644 (file)
--- a/make.vars
+++ b/make.vars
@@ -32,6 +32,7 @@ export LOCALPREFIX LOCALBINDIR LOCALLIBDIR LOCALMAKDIR
 ARCH             = $(shell uname -m)
 LUA_VERSION       = 5.1.3
 LUA_ALL_VERSIONS  = 5.1.2 5.1.3
+LUA               = $(LIBEXECDIR)/e2-lua-$(LUA_VERSION)
 LUAC              = $(LIBEXECDIR)/e2-luac-$(LUA_VERSION)
 ifdef LUA_UNPACK_PATH
 BUILD_LUAC        = $(LUA_UNPACK_PATH)/lua-$(LUA_VERSION)/src/luac