]> git.e2factory.org Git - e2factory.git/commitdiff
cleanup: fix global tools to work with modularized libraries
authorGordon Hecker <gh@emlix.com>
Fri, 22 Jan 2010 09:40:47 +0000 (10:40 +0100)
committerGordon Hecker <gh@emlix.com>
Fri, 12 Feb 2010 09:52:01 +0000 (10:52 +0100)
Signed-off-by: Gordon Hecker <gh@emlix.com>
Makefile
generic/cache.lua
generic/e2lib.lua
generic/e2option.lua
generic/luafile.lua
global/Makefile
global/e2-create-project.lua.in
global/e2-fetch-project.lua.in
global/e2-install-e2.lua.in
global/e2.lua.in

index 7f5267fc2dc089e5c6ca6e56ad8675a066107ce1..21fa5d972c5e8a77beccc245ca88ffea2aa37f00 100644 (file)
--- a/Makefile
+++ b/Makefile
@@ -72,16 +72,9 @@ all: e2commit buildconfig.lua
        $(MAKE) -C extensions all
 
 install: all
-       mkdir -p $(DESTDIR)$(BINDIR)
-       mkdir -p $(DESTDIR)$(LIBDIR)
-       mkdir -p $(DESTDIR)$(LIBEXECDIR)
-       mkdir -p $(DESTDIR)$(INCDIR)
-       mkdir -p $(DESTDIR)$(MANDIR)
-       mkdir -p $(DESTDIR)$(TOOLDIR)
-       install -m 644 buildconfig.lua $(DESTDIR)$(LIBDIR)
+       $(MAKE) -C global install
        $(MAKE) -C lua install
        $(MAKE) -C generic install
-       $(MAKE) -C global install
        $(MAKE) -C local install
        $(MAKE) -C doc/man install
        $(MAKE) -C templates install
index 52fac51d1c9eed3b53c55199b39a93f6ba63b7d3..c8041a450833855a8076bb1380ea1bacece26020 100644 (file)
@@ -26,6 +26,9 @@
 ]]
 
 module("cache", package.seeall)
+require("e2lib")
+require("transport")
+require("url")
 
 --- cache
 -- @class table
index 0108e548ad2a8f8bb4bbffc9d5d0b4ca374284b2..7aede66d109b6489cfe0613fed0a61735fd1cb47 100644 (file)
 module("e2lib", package.seeall)
 require("strict")
 require("buildconfig")
+require("lock")
+require("err")
+require("plugin")
+require("tools")
+require("cache")
+require("luafile")
 
 _version = "e2factory, the emlix embedded build system, version " .. 
                                                        buildconfig.VERSION
@@ -92,6 +98,8 @@ globals = {
   global_interface_version_file = ".e2/global-version",
   lock = nil,
   logrotate = 5,   -- configurable via config.log.logrotate
+  _version = _version,
+  _licence = _licence,
 }
 
 -- Interrupt handling
@@ -233,7 +241,7 @@ function warnf(category, format, ...)
   end
   if globals.warn_category[category] == true then
     local prefix = "Warning: "
-    if log_debug then
+    if globals.log_debug then
       prefix = string.format("Warning [%s]: ", category)
     end
     log(1, prefix .. string.format(format, ...))
@@ -332,7 +340,7 @@ function getlogflags()
   if getlog(4) then
     logflags = logflags .. " --v4"
   end
-  if log_debug then
+  if globals.log_debug then
     logflags = logflags .. " --log-debug"
   end
   return " " .. logflags
index 5c836cbea7dc8982d0468cd4d334ec1b07a6e22d..bdbf51410e102272873ada89d090d3ef17979794 100644 (file)
@@ -216,7 +216,7 @@ function parse(args)
                  category)
     flag("log-debug", "enable logging of debugging output",
                  function()
-                   e2lib.log_debug = true
+                   e2lib.globals.log_debug = true
                    return true
                  end,
                  category)
@@ -241,9 +241,9 @@ function parse(args)
                  category)
     flag("licence", "show licence information",
                  function()
-                   print(_version)
+                   print(e2lib.globals._version)
                    print()
-                   print(_licence)
+                   print(e2lib.globals._licence)
                    e2lib.finish(0)
                  end,
                  category)
@@ -357,7 +357,7 @@ end
 -- @param rc number: return code, passed to e2lib.finish()
 -- @return nil
 function usage(rc)
-  print(_version)
+  print(e2lib.globals._version)
   print([[
 Copyright (C) 2007-2009 by Gordon Hecker and Oskar Schirmer, emlix GmbH
 Copyright (C) 2007-2008 by Felix Winkelmann, emlix GmbH
index cc0f63bc2bb9d9475ce3ce4f810597727b9dd6e4..92247a31fe2d981ba670cb0ebf56590b6cc41dba 100644 (file)
@@ -27,6 +27,7 @@
 
 
 module("luafile", package.seeall)
+require("luafile_ll")
 
 function new()
   local f = {}
index 6e575bd357dd6eb76b74f2eb9dd3ca75a73daca3..03a66c5aaa32d54ee553100342f8d0af0009553a 100644 (file)
@@ -29,22 +29,38 @@ TOPLEVEL = ..
 
 include $(TOPLEVEL)/make.vars
 
-VPATH = .:$(TOPLEVEL)/generic
+VPATH = .:$(TOPLEVEL)/generic:$(TOPLEVEL)
 
 SCRIPTS =
 GLOBALLUATOOLS = e2-create-project e2-fetch-project e2-install-e2 e2-root
 GLOBALSHTOOLS = e2-locate-project-root e2ssh
 GLOBALTOOLS = $(GLOBALLUATOOLS) $(GLOBALSHTOOLS)
 CLEAN_FILES = *~ $(GLOBALTOOLS) *.lc e2 $(SCRIPTS) *.lua e2-su *.sh e2.conf
-
+LUA_LIBS = strict.lua collection.lua loader.lua plugin.lua e2lib.lua
+LUA_LIBS += e2option.lua hash.lua tools.lua transport.lua cache.lua url.lua
+LUA_LIBS += generic_git.lua luafile.lua lua-version-map.lua err.lua lock.lua
+LUA_LIBS += buildconfig.lua
 
 .PHONY: all install uninstall clean
 
 all: e2 e2-root $(SCRIPTS) e2-su $(GLOBALLUATOOLS:=.lc) \
-       $(GLOBALSHTOOLS:=.sh) e2.conf e2generic.lc sha1.so e2-su-2.2 \
+       $(GLOBALSHTOOLS:=.sh) e2.conf sha1.so e2-su-2.2 \
        luafile_ll.so e2util.so
 
-install: all
+install-dirs:
+       install -d $(DESTDIR)$(BINDIR)
+       install -d $(DESTDIR)$(LIBDIR)
+       install -d $(DESTDIR)$(LIBEXECDIR)
+       install -d $(DESTDIR)$(INCDIR)
+       install -d $(DESTDIR)$(MANDIR)
+       install -d $(DESTDIR)$(TOOLDIR)
+       install -d $(DESTDIR)$(SYSCONFDIR)
+       install -d -m 2775 -g $(E2_GROUP) $(DESTDIR)$(LOCALSTATEDIR)
+
+install-lua: $(LUA_LIBS)
+       install -m 644 $^ $(DESTDIR)$(LIBDIR)
+
+install: all install-dirs install-lua
        for i in $(GLOBALLUATOOLS) ; do \
                install -m 755 $$i.lc $(DESTDIR)$(TOOLDIR)/$$i ; \
                ln -sf e2 $(DESTDIR)$(BINDIR)/$$i ; \
@@ -55,13 +71,10 @@ 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 -d $(DESTDIR)$(SYSCONFDIR)
        if [ ! -f "$(DESTDIR)$(SYSCONFDIR)/e2.conf" ] ; then \
                install -m 644 e2.conf $(DESTDIR)$(SYSCONFDIR)/e2.conf ; \
        fi
        install -m 644 e2.conf $(DESTDIR)$(SYSCONFDIR)/e2.conf.sample
-       install -d -m 2775 -g $(E2_GROUP) $(DESTDIR)$(LOCALSTATEDIR)
-       install -m 644 e2generic.lc $(DESTDIR)$(LIBDIR)
        install -m 755 sha1.so $(DESTDIR)$(LIBDIR)
        install -m 755 luafile_ll.so $(DESTDIR)$(LIBDIR)
        install -m 755 e2util.so $(DESTDIR)$(LIBDIR)
@@ -76,7 +89,6 @@ uninstall:
                rm -f $(DESTDIR)$(BINDIR)/$$i ; \
        done
        rm -f $(DESTDIR)$(BINDIR)/e2-su-2.2
-       rm -f $(DESTDIR)$(LIBDIR)/e2generic.lc
        rm -f $(DESTDIR)$(LIBDIR)/luafile_ll.so
        rm -f $(DESTDIR)$(LIBDIR)/e2util.so
        rm -f $(DESTDIR)$(TOOLDIR)/e2-root
@@ -119,14 +131,6 @@ e2-root: e2-root.lc
 e2.conf: e2.conf.in
        $(TOPLEVEL)/scripts/genscript.sh $< $@
 
-e2generic.lc: strict.lua collection.lua loader.lua \
-               plugin.lua \
-               e2lib.lua e2option.lua hash.lua tools.lua \
-               transport.lua cache.lua url.lua generic_git.lua \
-               luafile.lua lua-version-map.lua \
-               error.lua lock.lua
-       $(BUILD_LUAC) -o $@ $^
-
 sha1.so: sha1.o lsha1.o
 
 luafile_ll.so: luafile_ll.o
index eb33720d57e0b7ea8923bd19febd67a96707d371..bc77977d1fa27097e4787e17b8e41aa3d1b7ef10 100755 (executable)
@@ -26,7 +26,9 @@
 ]]
 
 require("buildconfig")
-require("e2generic")
+require("e2lib")
+require("e2option")
+require("generic_git")
 
 e2lib.init()
 
@@ -36,7 +38,8 @@ usage: e2-create-project [<option> ...] [<server>:]<location>
 Create a new project and store it on <server> in <location>.
 <server> defaults to '%s'.
 ]]
-e2option.documentation = string.format(doc, e2lib.default_projects_server)
+e2option.documentation = string.format(doc,
+                               e2lib.globals.default_projects_server)
 
 local opts = e2option.parse(arg)
 local rc, e = e2lib.read_global_config()
@@ -59,18 +62,18 @@ e2lib.log_invocation(nil, arg)
 
 -- standard global tool setup finished
 
-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"]
-elseif e2lib.osenv["E2_LOCAL_TAG"] then
-  e2lib.local_e2_branch = "-"
-  e2lib.local_e2_tag = e2lib.osenv["E2_LOCAL_TAG"]
-elseif e2lib.osenv["E2_LOCAL_BRANCH"] then
-  e2lib.local_e2_branch = e2lib.osenv["E2_LOCAL_BRANCH"]
-  e2lib.local_e2_tag = "^"
+if e2lib.globals.osenv["E2_LOCAL_TAG"] and e2lib.globals.osenv["E2_LOCAL_BRANCH"] then
+  e2lib.globals.local_e2_branch = e2lib.globals.osenv["E2_LOCAL_BRANCH"]
+  e2lib.globals.local_e2_tag = e2lib.globals.osenv["E2_LOCAL_TAG"]
+elseif e2lib.globals.osenv["E2_LOCAL_TAG"] then
+  e2lib.globals.local_e2_branch = "-"
+  e2lib.globals.local_e2_tag = e2lib.globals.osenv["E2_LOCAL_TAG"]
+elseif e2lib.globals.osenv["E2_LOCAL_BRANCH"] then
+  e2lib.globals.local_e2_branch = e2lib.globals.osenv["E2_LOCAL_BRANCH"]
+  e2lib.globals.local_e2_tag = "^"
 else
-  e2lib.local_e2_branch = config.site.e2_branch
-  e2lib.local_e2_tag =  config.site.e2_tag
+  e2lib.globals.local_e2_branch = config.site.e2_branch
+  e2lib.globals.local_e2_tag =  config.site.e2_tag
 end
 
 if #opts.arguments ~= 1 then
@@ -78,15 +81,15 @@ if #opts.arguments ~= 1 then
 end
 
 local sl, re = e2lib.parse_server_location(opts.arguments[1],
-                                               e2lib.default_projects_server)
+                                       e2lib.globals.default_projects_server)
 if not sl then
   e2lib.abort(e:cat(re))
 end
 
 local p = {}
 p.version = buildconfig.GLOBAL_INTERFACE_VERSION[1] -- the project version
-p.e2version = string.format("%s %s", e2lib.local_e2_branch,
-                                                       e2lib.local_e2_tag)
+p.e2version = string.format("%s %s", e2lib.globals.local_e2_branch,
+                                               e2lib.globals.local_e2_tag)
 p.server = sl.server                           -- the server
 p.location = sl.location                       -- the project location
 p.name = e2lib.basename(sl.location)           -- the project basename
@@ -215,7 +218,7 @@ rc, re = e2lib.write_extension_config(config.site.default_extensions)
 if not rc then
        e2lib.abort(e:cat(re))
 end
-rc, re = e2lib.git(nil, "add", e2lib.extension_config)
+rc, re = e2lib.git(nil, "add", e2lib.globals.extension_config)
 if not rc then
        e2lib.abort(e:cat(re))
 end
index 585a369c60cc3d8f3127cb5d9ae425bb2eea500c..6b5acac0ca3924b8b9089dabba73833feca65ac7 100755 (executable)
@@ -26,7 +26,9 @@
 ]]
 
 require("buildconfig")
-require("e2generic")
+require("e2lib")
+require("e2option")
+require("generic_git")
 
 e2lib.init()
 local e = new_error("fetching project failed")
@@ -37,7 +39,8 @@ fetch the project located in server:location to a directory given in
 <destination>.
 <server> defaults to '%s'.
 ]]
-e2option.documentation = string.format(doc, e2lib.default_projects_server)
+e2option.documentation = string.format(doc,
+                               e2lib.globals.default_projects_server)
 
 e2option.flag("binary", "install binary local tools [broken]")
 e2option.option("branch", "retrieve a specific project branch")
@@ -71,7 +74,7 @@ if #opts.arguments > 2 then
 end
 
 local sl, re = e2lib.parse_server_location(opts.arguments[1],
-                                               e2lib.default_projects_server)
+                                       e2lib.globals.default_projects_server)
 if not sl then
   e2lib.abort(e:cat(re))
 end
@@ -175,7 +178,8 @@ if not rc then
 end
 
 -- write version file
-local rc, re = e2lib.write_file(e2lib.global_interface_version_file, string.format("%d\n", v))
+local rc, re = e2lib.write_file(e2lib.globals.global_interface_version_file,
+                                               string.format("%d\n", v))
 
 -- call e2-install-e2
 e2_install_e2 = string.format("'%s' '%s/e2-install-e2'", 
index 683c9c97b2edc2c584cc3a425fb0c3c0c1c4233b..8da07bee4944fc4b37e3ba1b2822b0655ddc3cf7 100755 (executable)
@@ -26,7 +26,9 @@
 ]]
 
 require("buildconfig")
-require("e2generic")
+require("e2lib")
+require("e2option")
+require("generic_git")
 
 install_prefix = buildconfig.PREFIX
 
@@ -81,7 +83,7 @@ if not rc then
 end
 
 -- read the version from the first line
-local line, re = e2lib.read_line(e2lib.global_interface_version_file)
+local line, re = e2lib.read_line(e2lib.globals.global_interface_version_file)
 if not line then
        e2lib.abort(e:cat(re))
 end
@@ -102,7 +104,7 @@ end
 e2lib.logf(2, "installing local tools")
 
 local extensions
-if e2util.exists(e2lib.extension_config) then
+if e2util.exists(e2lib.globals.extension_config) then
   extensions, re = e2lib.read_extension_config()
   if not extensions then
     e2lib.abort(e:cat(re))
index 9fb6e0ac0dfab6a64366d25c5fc76375a5f8c4e4..8e180ac2188b883b68f1103b9793cb90ba6bef9c 100755 (executable)
@@ -29,7 +29,10 @@ package.path  = "@LIBDIR@/?.lc;@LIBDIR@/?.lua"
 package.cpath = "@LIBDIR@/?.so"
 
 require("buildconfig")
-require("e2generic")
+require("e2lib")
+require("e2option")
+require("e2util")
+
 e2lib.init()
 
 e2option.documentation = [[